extension-develop 3.2.0-next.8 → 3.2.0-next.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/547.js CHANGED
@@ -6527,7 +6527,6 @@ Set background.noDynamicEntryWarning to true to disable this warning.
6527
6527
  this.browser = options.browser || 'chrome';
6528
6528
  }
6529
6529
  }
6530
- var external_chokidar_ = __webpack_require__("chokidar");
6531
6530
  function serverRestartRequiredFromSpecialFolderMessageOnly(addingOrRemoving, folder, typeOfAsset) {
6532
6531
  return `${external_pintor_default().red('ERROR')} in ${external_pintor_default().yellow('manifest.json')} entrypoint: ${addingOrRemoving} ${external_pintor_default().yellow(typeOfAsset)} in ${external_pintor_default().underline(folder + '/')} requires a dev server restart to apply changes.`;
6533
6532
  }
@@ -6537,6 +6536,16 @@ Set background.noDynamicEntryWarning to true to disable this warning.
6537
6536
  function specialFolderChangeDetected(action, folder, relativePath) {
6538
6537
  return `Special folders change — ${action} in ${folder}/: ${relativePath}`;
6539
6538
  }
6539
+ function warn_upon_folder_changes_define_property(obj, key, value) {
6540
+ if (key in obj) Object.defineProperty(obj, key, {
6541
+ value: value,
6542
+ enumerable: true,
6543
+ configurable: true,
6544
+ writable: true
6545
+ });
6546
+ else obj[key] = value;
6547
+ return obj;
6548
+ }
6540
6549
  class WarnUponFolderChanges {
6541
6550
  throwCompilationError(compilation, folder, filePath, isAddition) {
6542
6551
  const addingOrRemoving = isAddition ? 'Adding' : 'Removing';
@@ -6556,58 +6565,57 @@ Set background.noDynamicEntryWarning to true to disable this warning.
6556
6565
  err.details = `Removing from ${folder}/ breaks current build. Restart the dev server to recompile.`;
6557
6566
  compilation.errors?.push(err);
6558
6567
  }
6568
+ trackChange(projectPath, folder, change, filePath) {
6569
+ if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(specialFolderChangeDetected('add' === change ? 'add' : 'remove', folder, external_path_.relative(projectPath, filePath)));
6570
+ this.pendingChanges.push({
6571
+ type: change,
6572
+ folder,
6573
+ filePath
6574
+ });
6575
+ }
6576
+ collectChanges(compiler) {
6577
+ const projectPath = compiler.options.context || process.cwd();
6578
+ const pagesPath = external_path_.join(projectPath, 'pages') + external_path_.sep;
6579
+ const scriptsPath = external_path_.join(projectPath, "scripts") + external_path_.sep;
6580
+ const extensionsSupported = compiler.options.resolve?.extensions;
6581
+ const supportedScripts = new Set((extensionsSupported || []).map((e)=>e.toLowerCase()));
6582
+ const modifiedFiles = compiler.modifiedFiles || new Set();
6583
+ const removedFiles = compiler.removedFiles || new Set();
6584
+ for (const filePath of modifiedFiles){
6585
+ if (filePath.startsWith(pagesPath) && filePath.endsWith('.html')) this.trackChange(projectPath, 'pages', 'add', filePath);
6586
+ if (filePath.startsWith(scriptsPath)) {
6587
+ const ext = external_path_.extname(filePath).toLowerCase();
6588
+ if (supportedScripts.has(ext)) this.trackChange(projectPath, "scripts", 'add', filePath);
6589
+ }
6590
+ }
6591
+ for (const filePath of removedFiles){
6592
+ if (filePath.startsWith(pagesPath) && filePath.endsWith('.html')) this.trackChange(projectPath, 'pages', 'remove', filePath);
6593
+ if (filePath.startsWith(scriptsPath)) {
6594
+ const ext = external_path_.extname(filePath).toLowerCase();
6595
+ if (supportedScripts.has(ext)) this.trackChange(projectPath, "scripts", 'remove', filePath);
6596
+ }
6597
+ }
6598
+ }
6599
+ applyPendingChanges(compilation) {
6600
+ for (const change of this.pendingChanges)this.throwCompilationError(compilation, change.folder, change.filePath, 'add' === change.type);
6601
+ this.pendingChanges = [];
6602
+ }
6559
6603
  apply(compiler) {
6604
+ compiler.hooks.watchRun.tap('special-folders:warn-upon-folder-changes', ()=>{
6605
+ this.collectChanges(compiler);
6606
+ });
6560
6607
  compiler.hooks.thisCompilation.tap('special-folders:warn-upon-folder-changes', (compilation)=>{
6561
6608
  const projectPath = compiler.options.context || process.cwd();
6562
6609
  const pagesPath = external_path_.join(projectPath, 'pages');
6563
6610
  const scriptsPath = external_path_.join(projectPath, "scripts");
6564
- const pagesWatcher = external_chokidar_.watch(pagesPath, {
6565
- ignoreInitial: true
6566
- });
6567
- const scriptsWatcher = external_chokidar_.watch(scriptsPath, {
6568
- ignoreInitial: true
6569
- });
6570
- const extensionsSupported = compiler.options.resolve?.extensions;
6571
- pagesWatcher.on('add', (filePath)=>{
6572
- const ext = external_path_.extname(filePath).toLowerCase();
6573
- const isHtml = '.html' === ext;
6574
- if (isHtml) {
6575
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(specialFolderChangeDetected('add', 'pages', external_path_.relative(projectPath, filePath)));
6576
- this.throwCompilationError(compilation, 'pages', filePath, true);
6577
- }
6578
- });
6579
- pagesWatcher.on('unlink', (filePath)=>{
6580
- const ext = external_path_.extname(filePath).toLowerCase();
6581
- const isHtml = '.html' === ext;
6582
- if (isHtml) {
6583
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(specialFolderChangeDetected('remove', 'pages', external_path_.relative(projectPath, filePath)));
6584
- this.throwCompilationError(compilation, 'pages', filePath);
6585
- }
6586
- });
6587
- scriptsWatcher.on('add', (filePath)=>{
6588
- const ext = external_path_.extname(filePath).toLowerCase();
6589
- const supported = new Set((extensionsSupported || []).map((e)=>e.toLowerCase()));
6590
- const isScript = supported.has(ext);
6591
- if (isScript) {
6592
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(specialFolderChangeDetected('add', "scripts", external_path_.relative(projectPath, filePath)));
6593
- this.throwCompilationError(compilation, "scripts", filePath, true);
6594
- }
6595
- });
6596
- scriptsWatcher.on('unlink', (filePath)=>{
6597
- const ext = external_path_.extname(filePath).toLowerCase();
6598
- const supported = new Set((extensionsSupported || []).map((e)=>e.toLowerCase()));
6599
- const isScript = supported.has(ext);
6600
- if (isScript) {
6601
- if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(specialFolderChangeDetected('remove', "scripts", external_path_.relative(projectPath, filePath)));
6602
- this.throwCompilationError(compilation, "scripts", filePath);
6603
- }
6604
- });
6605
- compiler.hooks.watchClose.tap('WarnUponFolderChanges', ()=>{
6606
- pagesWatcher.close().catch(()=>{});
6607
- scriptsWatcher.close().catch(()=>{});
6608
- });
6611
+ compilation.contextDependencies?.add(pagesPath);
6612
+ compilation.contextDependencies?.add(scriptsPath);
6613
+ this.applyPendingChanges(compilation);
6609
6614
  });
6610
6615
  }
6616
+ constructor(){
6617
+ warn_upon_folder_changes_define_property(this, "pendingChanges", []);
6618
+ }
6611
6619
  }
6612
6620
  function checkManifestInPublic(compilation, publicDir) {
6613
6621
  try {
package/dist/module.js CHANGED
@@ -132514,10 +132514,6 @@ var __webpack_modules__ = {
132514
132514
  "use strict";
132515
132515
  module.exports = require("child_process");
132516
132516
  },
132517
- chokidar (module) {
132518
- "use strict";
132519
- module.exports = require("chokidar");
132520
- },
132521
132517
  "chrome-location2" (module) {
132522
132518
  "use strict";
132523
132519
  module.exports = require("chrome-location2");
@@ -132620,7 +132616,7 @@ var __webpack_modules__ = {
132620
132616
  },
132621
132617
  "./package.json" (module) {
132622
132618
  "use strict";
132623
- module.exports = JSON.parse('{"rE":"3.2.0-next.8","El":{"@rspack/core":"^1.7.2","@rspack/dev-server":"^1.1.5","@swc/core":"^1.15.8","@swc/helpers":"^0.5.18","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.1","case-sensitive-paths-webpack-plugin":"^2.4.0","chokidar":"^5.0.0","chrome-location2":"4.0.0","chromium-location":"2.0.0","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^17.2.3","edge-location":"2.2.0","firefox-location2":"3.0.0","go-git-it":"^5.0.3","ignore":"^7.0.5","loader-utils":"^3.3.1","magic-string":"^0.30.21","parse5":"^8.0.0","parse5-utilities":"^1.0.0","pintor":"0.3.0","schema-utils":"^4.3.3","tiny-glob":"^0.2.9","unique-names-generator":"^4.7.1","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.19.0"}}');
132619
+ module.exports = JSON.parse('{"rE":"3.2.0-next.9","El":{"@rspack/core":"^1.7.2","@rspack/dev-server":"^1.1.5","@swc/core":"^1.15.8","@swc/helpers":"^0.5.18","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.1","case-sensitive-paths-webpack-plugin":"^2.4.0","chrome-location2":"4.0.0","chromium-location":"2.0.0","content-security-policy-parser":"^0.6.0","cross-spawn":"^7.0.6","dotenv":"^17.2.3","edge-location":"2.2.0","firefox-location2":"3.0.0","go-git-it":"^5.0.3","ignore":"^7.0.5","loader-utils":"^3.3.1","magic-string":"^0.30.21","parse5":"^8.0.0","parse5-utilities":"^1.0.0","pintor":"0.3.0","schema-utils":"^4.3.3","tiny-glob":"^0.2.9","unique-names-generator":"^4.7.1","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.19.0"}}');
132624
132620
  }
132625
132621
  };
132626
132622
  var __webpack_module_cache__ = {};
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "dist"
23
23
  ],
24
24
  "name": "extension-develop",
25
- "version": "3.2.0-next.8",
25
+ "version": "3.2.0-next.9",
26
26
  "description": "Develop, build, preview, and package Extension.js projects.",
27
27
  "author": {
28
28
  "name": "Cezar Augusto",
@@ -77,7 +77,6 @@
77
77
  "adm-zip": "^0.5.16",
78
78
  "browser-extension-manifest-fields": "^2.2.1",
79
79
  "case-sensitive-paths-webpack-plugin": "^2.4.0",
80
- "chokidar": "^5.0.0",
81
80
  "chrome-location2": "4.0.0",
82
81
  "chromium-location": "2.0.0",
83
82
  "content-security-policy-parser": "^0.6.0",