extension-develop 4.1.5 → 4.1.7

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.
Files changed (53) hide show
  1. package/dist/0~rspack-config.mjs +163 -84
  2. package/dist/101.mjs +21 -2
  3. package/dist/494.mjs +18 -0
  4. package/dist/839.mjs +7 -3
  5. package/dist/86.mjs +36 -0
  6. package/dist/bridge.mjs +3 -1
  7. package/dist/dead-css-url-loader.mjs +34 -0
  8. package/dist/extension-js-devtools/chrome/content_scripts/content-0.js +2 -2
  9. package/dist/extension-js-devtools/chrome/manifest.json +1 -1
  10. package/dist/extension-js-devtools/chrome/pages/centralized-logger.css +1 -1
  11. package/dist/extension-js-devtools/chrome/pages/welcome.css +1 -1
  12. package/dist/extension-js-devtools/chrome/pages/welcome.js +4 -8
  13. package/dist/extension-js-devtools/chrome/scripts/logger-client.js +1 -0
  14. package/dist/extension-js-devtools/chromium/content_scripts/content-0.js +2 -2
  15. package/dist/extension-js-devtools/chromium/manifest.json +1 -1
  16. package/dist/extension-js-devtools/chromium/pages/centralized-logger.css +1 -1
  17. package/dist/extension-js-devtools/chromium/pages/welcome.css +1 -1
  18. package/dist/extension-js-devtools/chromium/pages/welcome.js +4 -8
  19. package/dist/extension-js-devtools/chromium/scripts/logger-client.js +1 -0
  20. package/dist/extension-js-devtools/edge/content_scripts/content-0.js +2 -2
  21. package/dist/extension-js-devtools/edge/manifest.json +1 -1
  22. package/dist/extension-js-devtools/edge/pages/centralized-logger.css +1 -1
  23. package/dist/extension-js-devtools/edge/pages/welcome.css +1 -1
  24. package/dist/extension-js-devtools/edge/pages/welcome.js +4 -8
  25. package/dist/extension-js-devtools/edge/scripts/logger-client.js +1 -0
  26. package/dist/extension-js-devtools/firefox/content_scripts/content-0.js +2 -2
  27. package/dist/extension-js-devtools/firefox/pages/centralized-logger.css +1 -1
  28. package/dist/extension-js-devtools/firefox/pages/welcome.css +1 -1
  29. package/dist/extension-js-devtools/firefox/pages/welcome.js +4 -8
  30. package/dist/extension-js-devtools/firefox/scripts/logger-client.js +1 -0
  31. package/dist/feature-scripts-classic-concat-loader.js +85 -13
  32. package/dist/feature-scripts-classic-concat-loader.mjs +85 -13
  33. package/dist/plugin-css/css-lib/build-css-rules.d.ts +1 -0
  34. package/dist/plugin-css/css-lib/dead-url-refs.d.ts +9 -0
  35. package/dist/plugin-css/dead-css-url-loader.d.ts +16 -0
  36. package/dist/plugin-reload/index.d.ts +1 -0
  37. package/dist/plugin-reload/steps/setup-chunk-loading-target.d.ts +21 -0
  38. package/dist/plugin-reload/steps/setup-reload-strategy/index.d.ts +13 -2
  39. package/dist/plugin-web-extension/feature-scripts/steps/add-content-script-wrapper/classic-concat-loader.d.ts +17 -1
  40. package/dist/plugin-web-extension/feature-scripts/steps/{validate-content-script-syntax.d.ts → validate-emitted-script-syntax.d.ts} +1 -1
  41. package/package.json +1 -1
  42. package/dist/extension-js-devtools/chrome/assets/developer-mode-off.f9a94937.jpeg +0 -0
  43. package/dist/extension-js-devtools/chrome/assets/developer-mode-on.ede80e5b.jpeg +0 -0
  44. package/dist/extension-js-devtools/chrome/assets/local-network-permission.4fae40a7.png +0 -0
  45. package/dist/extension-js-devtools/chromium/assets/developer-mode-off.f9a94937.jpeg +0 -0
  46. package/dist/extension-js-devtools/chromium/assets/developer-mode-on.ede80e5b.jpeg +0 -0
  47. package/dist/extension-js-devtools/chromium/assets/local-network-permission.4fae40a7.png +0 -0
  48. package/dist/extension-js-devtools/edge/assets/developer-mode-off.f9a94937.jpeg +0 -0
  49. package/dist/extension-js-devtools/edge/assets/developer-mode-on.ede80e5b.jpeg +0 -0
  50. package/dist/extension-js-devtools/edge/assets/local-network-permission.4fae40a7.png +0 -0
  51. package/dist/extension-js-devtools/firefox/assets/developer-mode-off.f9a94937.jpeg +0 -0
  52. package/dist/extension-js-devtools/firefox/assets/developer-mode-on.ede80e5b.jpeg +0 -0
  53. package/dist/extension-js-devtools/firefox/assets/local-network-permission.4fae40a7.png +0 -0
@@ -12,7 +12,7 @@ import { filterKeysForThisBrowser as external_browser_extension_manifest_fields_
12
12
  import content_security_policy_parser from "content-security-policy-parser";
13
13
  import node_fs from "node:fs";
14
14
  import node_path from "node:path";
15
- import { debugExtensionsToLoad, package_namespaceObject, getDirs, asAbsolute, browserRunnerDisabled, treeWithDistFilesBrowser, packagingDistributionFiles, toPosixPath, resolveCompanionExtensionDirs, debugContextPath, specialFoldersSetupSummary, isGeckoBasedBrowser, spacerLine, isWebkitBasedBrowser, PlaywrightPlugin, messages_ready, CHROMIUM_FAMILY_ALIASES, treeWithSourceAndDistFiles, computeExtensionsToLoad, noCompanionExtensionsResolved, treeWithSourceFiles, bundlerFatalError, bundlerRecompiling, serverRestartRequiredFromSpecialFolderMessageOnly, noEntrypointsDetected, GECKO_FAMILY_ALIASES, packagingSourceFiles, getPreloadedEnvKeys, debugBrowser, debugOutputPath, manifestInvalidJson, specialFolderChangeDetected, isChromiumBasedBrowser, getSpecialFoldersDataForCompiler } from "./101.mjs";
15
+ import { debugExtensionsToLoad, package_namespaceObject, getDirs, asAbsolute, browserRunnerDisabled, treeWithDistFilesBrowser, packagingDistributionFiles, toPosixPath as paths_toPosixPath, resolveCompanionExtensionDirs, debugContextPath, specialFoldersSetupSummary, isGeckoBasedBrowser, spacerLine, isWebkitBasedBrowser, PlaywrightPlugin, messages_ready, CHROMIUM_FAMILY_ALIASES, treeWithSourceAndDistFiles, computeExtensionsToLoad, noCompanionExtensionsResolved, treeWithSourceFiles, bundlerFatalError, bundlerRecompiling, serverRestartRequiredFromSpecialFolderMessageOnly, noEntrypointsDetected, GECKO_FAMILY_ALIASES, packagingSourceFiles, getPreloadedEnvKeys, debugBrowser, debugOutputPath, manifestInvalidJson, specialFolderChangeDetected, isChromiumBasedBrowser, getSpecialFoldersDataForCompiler } from "./101.mjs";
16
16
  import { stripBom, parseJsonSafe } from "./23.mjs";
17
17
  import { isResourceUnderDirs, canonicalizeDir, toResourceKey } from "./93.mjs";
18
18
  import { prefix as messaging_prefix, isDebug } from "./349.mjs";
@@ -21,6 +21,7 @@ import { renderStatsBlocks, makeSanitizedConsole } from "./0~stats-handler.mjs";
21
21
  import { getCanonicalContentScriptEntryName, parseCanonicalContentScriptAsset, EXTENSIONJS_CONTENT_SCRIPT_LAYER, isCanonicalContentScriptAsset, getCanonicalContentScriptJsAssetName, getCanonicalContentScriptCssAssetName } from "./291.mjs";
22
22
  import { hasProjectDependency, findNearestProjectManifestSync, PROJECT_MANIFEST_FILENAMES, readProjectDependencies } from "./80.mjs";
23
23
  import { cssIntegrationsEnabled, cssConfigsDetected, deadCssUrlRef, missingSassDependency, isUsingIntegration, postCssPluginNotResolved } from "./845.mjs";
24
+ import { toPosixPath } from "./86.mjs";
24
25
  import { injectedFileDependencyMissing, importScriptsDependencyMissing, getURLDependencyMissing, staticImportDependencyMissing, fetchedFileDependencyMissing, runtimeSetSurfaceDependencyMissing } from "./266.mjs";
25
26
  import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
26
27
  import { dirname as __rspack_dirname } from "node:path";
@@ -2641,7 +2642,7 @@ async function commonStyleLoaders(projectPath, opts) {
2641
2642
  }
2642
2643
  async function buildCssRules(projectPath, mode, usage, opts) {
2643
2644
  const { useSass = true, useLess = true } = usage;
2644
- const { nonModuleType, issuer } = opts;
2645
+ const { nonModuleType, issuer, manifestPath } = opts;
2645
2646
  const fileTypes = [
2646
2647
  {
2647
2648
  test: /\.module\.css$/,
@@ -2725,6 +2726,13 @@ async function buildCssRules(projectPath, mode, usage, opts) {
2725
2726
  if ('css' === type || 'css/module' === type) use.unshift({
2726
2727
  loader: resolveDevelopDistFile('late-css-import-loader')
2727
2728
  });
2729
+ if ('asset/inline' === type && manifestPath) use.unshift({
2730
+ loader: resolveDevelopDistFile('dead-css-url-loader'),
2731
+ options: {
2732
+ manifestPath,
2733
+ projectPath
2734
+ }
2735
+ });
2728
2736
  return {
2729
2737
  test,
2730
2738
  exclude,
@@ -2768,7 +2776,8 @@ function isContentScriptEntry(absolutePath, manifestPath, projectPath) {
2768
2776
  async function cssInContentScriptLoader(projectPath, manifestPath, mode, usage = {}) {
2769
2777
  return buildCssRules(projectPath, mode, usage, {
2770
2778
  nonModuleType: 'asset/inline',
2771
- issuer: (issuer)=>isContentScriptEntry(issuer, manifestPath, projectPath)
2779
+ issuer: (issuer)=>isContentScriptEntry(issuer, manifestPath, projectPath),
2780
+ manifestPath
2772
2781
  });
2773
2782
  }
2774
2783
  async function cssInHtmlLoader(projectPath, mode, manifestPath, usage = {}) {
@@ -2864,8 +2873,9 @@ class CssPlugin {
2864
2873
  const key = `${issuer}|${req}`;
2865
2874
  if (!warned.has(key) && compilation?.warnings) {
2866
2875
  warned.add(key);
2867
- const warning = new core_WebpackError(deadCssUrlRef(__rspack_external_node_path_c5b9b54f.relative(manifestDir, issuer) || issuer, raw));
2868
- warning.file = __rspack_external_node_path_c5b9b54f.relative(manifestDir, issuer);
2876
+ const issuerPath = toPosixPath(__rspack_external_node_path_c5b9b54f.relative(manifestDir, issuer) || issuer);
2877
+ const warning = new core_WebpackError(deadCssUrlRef(issuerPath, raw));
2878
+ warning.file = issuerPath;
2869
2879
  compilation?.warnings.push(warning);
2870
2880
  }
2871
2881
  return false;
@@ -6607,6 +6617,65 @@ class WebExtensionPlugin {
6607
6617
  }
6608
6618
  }
6609
6619
  const webpack_target_webextension_fork = WebExtensionPlugin;
6620
+ function getBackgroundEntryName(manifest, browser) {
6621
+ if (manifest.background) {
6622
+ if (isGeckoBasedBrowser(String(browser))) return {
6623
+ pageEntry: "background/script",
6624
+ tryCatchWrapper: true,
6625
+ eagerChunkLoading: false
6626
+ };
6627
+ if (3 === manifest.manifest_version) return {
6628
+ serviceWorkerEntry: 'background/service_worker',
6629
+ tryCatchWrapper: true,
6630
+ eagerChunkLoading: false
6631
+ };
6632
+ if (2 === manifest.manifest_version) return {
6633
+ pageEntry: "background/script",
6634
+ tryCatchWrapper: true,
6635
+ eagerChunkLoading: false
6636
+ };
6637
+ }
6638
+ return {
6639
+ pageEntry: 'background',
6640
+ tryCatchWrapper: true,
6641
+ eagerChunkLoading: false
6642
+ };
6643
+ }
6644
+ function buildContentScriptsMeta(patchedManifest) {
6645
+ const contentScriptsMeta = {};
6646
+ try {
6647
+ const csList = Array.isArray(patchedManifest.content_scripts) ? patchedManifest.content_scripts : [];
6648
+ const originalCount = csList.length;
6649
+ let bridgeOrdinal = 0;
6650
+ for(let i = 0; i < csList.length; i++){
6651
+ const cs = csList[i];
6652
+ const bundleId = getCanonicalContentScriptJsAssetName(i);
6653
+ const isMain = cs?.world === 'MAIN';
6654
+ if (isMain) {
6655
+ const bridgeIndex = originalCount + bridgeOrdinal++;
6656
+ const bridgeBundleId = getCanonicalContentScriptJsAssetName(bridgeIndex);
6657
+ contentScriptsMeta[bundleId] = {
6658
+ index: i,
6659
+ bundleId,
6660
+ world: 'main',
6661
+ bridgeBundleId
6662
+ };
6663
+ contentScriptsMeta[bridgeBundleId] = {
6664
+ index: bridgeIndex,
6665
+ bundleId: bridgeBundleId,
6666
+ world: 'extension',
6667
+ role: 'main_world_bridge',
6668
+ mainBundleId: bundleId
6669
+ };
6670
+ } else contentScriptsMeta[bundleId] = {
6671
+ index: i,
6672
+ bundleId,
6673
+ world: 'extension'
6674
+ };
6675
+ }
6676
+ } catch {}
6677
+ return contentScriptsMeta;
6678
+ }
6610
6679
  class SetupReloadStrategy {
6611
6680
  manifestPath;
6612
6681
  browser;
@@ -6614,71 +6683,16 @@ class SetupReloadStrategy {
6614
6683
  this.manifestPath = options.manifestPath;
6615
6684
  this.browser = options.browser || 'chrome';
6616
6685
  }
6617
- getEntryName(manifest) {
6618
- if (manifest.background) {
6619
- if (isGeckoBasedBrowser(String(this.browser))) return {
6620
- pageEntry: "background/script",
6621
- tryCatchWrapper: true,
6622
- eagerChunkLoading: false
6623
- };
6624
- if (3 === manifest.manifest_version) return {
6625
- serviceWorkerEntry: 'background/service_worker',
6626
- tryCatchWrapper: true,
6627
- eagerChunkLoading: false
6628
- };
6629
- if (2 === manifest.manifest_version) return {
6630
- pageEntry: "background/script",
6631
- tryCatchWrapper: true,
6632
- eagerChunkLoading: false
6633
- };
6634
- }
6635
- return {
6636
- pageEntry: 'background',
6637
- tryCatchWrapper: true,
6638
- eagerChunkLoading: false
6639
- };
6640
- }
6641
6686
  apply(compiler) {
6642
6687
  const manifest = JSON.parse(stripBom(__rspack_external_node_fs_5ea92f0c.readFileSync(this.manifestPath, 'utf-8')));
6643
6688
  const patchedManifest = filterKeysForThisBrowser(manifest, this.browser);
6644
- const contentScriptsMeta = {};
6645
- try {
6646
- const csList = Array.isArray(patchedManifest.content_scripts) ? patchedManifest.content_scripts : [];
6647
- const originalCount = csList.length;
6648
- let bridgeOrdinal = 0;
6649
- for(let i = 0; i < csList.length; i++){
6650
- const cs = csList[i];
6651
- const bundleId = getCanonicalContentScriptJsAssetName(i);
6652
- const isMain = cs?.world === 'MAIN';
6653
- if (isMain) {
6654
- const bridgeIndex = originalCount + bridgeOrdinal++;
6655
- const bridgeBundleId = getCanonicalContentScriptJsAssetName(bridgeIndex);
6656
- contentScriptsMeta[bundleId] = {
6657
- index: i,
6658
- bundleId,
6659
- world: 'main',
6660
- bridgeBundleId
6661
- };
6662
- contentScriptsMeta[bridgeBundleId] = {
6663
- index: bridgeIndex,
6664
- bundleId: bridgeBundleId,
6665
- world: 'extension',
6666
- role: 'main_world_bridge',
6667
- mainBundleId: bundleId
6668
- };
6669
- } else contentScriptsMeta[bundleId] = {
6670
- index: i,
6671
- bundleId,
6672
- world: 'extension'
6673
- };
6674
- }
6675
- } catch {}
6689
+ const contentScriptsMeta = buildContentScriptsMeta(patchedManifest);
6676
6690
  new SetupBackgroundEntry({
6677
6691
  manifestPath: this.manifestPath,
6678
6692
  browser: this.browser
6679
6693
  }).apply(compiler);
6680
6694
  new webpack_target_webextension_fork({
6681
- background: this.getEntryName(patchedManifest),
6695
+ background: getBackgroundEntryName(patchedManifest, this.browser),
6682
6696
  hmrConfig: false,
6683
6697
  weakRuntimeCheck: true,
6684
6698
  contentScriptsMeta
@@ -6783,6 +6797,35 @@ class ReloadPlugin {
6783
6797
  new PruneStaleHotUpdates().apply(compiler);
6784
6798
  }
6785
6799
  }
6800
+ class SetupChunkLoadingTarget {
6801
+ manifestPath;
6802
+ browser;
6803
+ constructor(options){
6804
+ this.manifestPath = options.manifestPath;
6805
+ this.browser = options.browser || 'chrome';
6806
+ }
6807
+ apply(compiler) {
6808
+ if ('production' !== compiler.options.mode) return;
6809
+ const hasValidManifest = !!this.manifestPath && __rspack_external_node_fs_5ea92f0c.existsSync(this.manifestPath) && __rspack_external_node_fs_5ea92f0c.lstatSync(this.manifestPath).isFile();
6810
+ if (!hasValidManifest) return;
6811
+ let patchedManifest;
6812
+ try {
6813
+ const manifest = JSON.parse(stripBom(__rspack_external_node_fs_5ea92f0c.readFileSync(this.manifestPath, 'utf-8')));
6814
+ patchedManifest = filterKeysForThisBrowser(manifest, this.browser);
6815
+ } catch {
6816
+ return;
6817
+ }
6818
+ new webpack_target_webextension_fork({
6819
+ background: {
6820
+ ...getBackgroundEntryName(patchedManifest, this.browser),
6821
+ classicLoader: false
6822
+ },
6823
+ hmrConfig: false,
6824
+ weakRuntimeCheck: true,
6825
+ contentScriptsMeta: buildContentScriptsMeta(patchedManifest)
6826
+ }).apply(compiler);
6827
+ }
6828
+ }
6786
6829
  function checkManifestInPublic(compilation, publicDir) {
6787
6830
  try {
6788
6831
  const manifestInPublic = __rspack_external_node_path_c5b9b54f.join(publicDir, 'manifest.json');
@@ -12670,44 +12713,76 @@ class KeepGetURLImportsNative {
12670
12713
  });
12671
12714
  }
12672
12715
  }
12673
- class ValidateContentScriptSyntax {
12716
+ const requireModule = createRequire(import.meta.url);
12717
+ class ValidateEmittedScriptSyntax {
12674
12718
  apply(compiler) {
12675
12719
  if (!compiler?.hooks?.thisCompilation?.tap) return;
12676
- compiler.hooks.thisCompilation.tap("scripts:validate-content-script-syntax", (compilation)=>{
12720
+ compiler.hooks.thisCompilation.tap("scripts:validate-emitted-script-syntax", (compilation)=>{
12677
12721
  compilation.hooks.processAssets.tap({
12678
- name: "scripts:validate-content-script-syntax",
12722
+ name: "scripts:validate-emitted-script-syntax",
12679
12723
  stage: core_Compilation.PROCESS_ASSETS_STAGE_REPORT
12680
12724
  }, ()=>{
12681
12725
  const assets = 'function' == typeof compilation.getAssets ? compilation.getAssets() : [];
12682
12726
  for (const asset of assets){
12683
12727
  const name = asset?.name || '';
12684
- if (!isCanonicalContentScriptAsset(name)) continue;
12685
- if (!name.endsWith('.js')) continue;
12728
+ if (!/\.[cm]?js$/i.test(name)) continue;
12686
12729
  let source = '';
12687
12730
  try {
12688
12731
  source = asset.source?.source?.().toString() || '';
12689
12732
  } catch {
12690
12733
  continue;
12691
12734
  }
12692
- if (source) try {
12693
- new Function(source);
12694
- } catch (caught) {
12695
- const error = caught;
12696
- if (error?.name !== 'SyntaxError') continue;
12697
- const err = new core_WebpackError([
12698
- `${name} is not valid JavaScript: ${error.message}.`,
12699
- "The browser will silently skip an unparsable content script:",
12700
- 'it never injects and reports no error anywhere. Fix the syntax',
12701
- "error in the source file(s) this content_scripts entry bundles."
12702
- ].join('\n'));
12703
- err.file = name;
12704
- compilation.errors.push(err);
12705
- }
12735
+ if (!source) continue;
12736
+ const error = findSyntaxError(source);
12737
+ if (!error) continue;
12738
+ const err = new core_WebpackError([
12739
+ `${name} is not valid JavaScript: ${error.message}.`,
12740
+ ...describeSlot(name)
12741
+ ].join('\n'));
12742
+ err.file = name;
12743
+ compilation.errors.push(err);
12706
12744
  }
12707
12745
  });
12708
12746
  });
12709
12747
  }
12710
12748
  }
12749
+ function describeSlot(name) {
12750
+ if (isCanonicalContentScriptAsset(name)) return [
12751
+ "The browser will silently skip an unparsable content script:",
12752
+ 'it never injects and reports no error anywhere. Fix the syntax',
12753
+ "error in the source file(s) this content_scripts entry bundles."
12754
+ ];
12755
+ return [
12756
+ 'The browser refuses to run a file it cannot parse, so the surface this',
12757
+ 'backs is dead on arrival. Fix the syntax error in the source file(s)',
12758
+ 'this entry bundles.'
12759
+ ];
12760
+ }
12761
+ function findSyntaxError(source) {
12762
+ try {
12763
+ new Function(source);
12764
+ return;
12765
+ } catch (caught) {
12766
+ const error = caught;
12767
+ if (error?.name !== 'SyntaxError') return;
12768
+ if (parsesAsModule(source)) return;
12769
+ return error;
12770
+ }
12771
+ }
12772
+ function parsesAsModule(source) {
12773
+ try {
12774
+ const acorn = requireModule('acorn');
12775
+ acorn.parse(source, {
12776
+ ecmaVersion: 'latest',
12777
+ sourceType: 'module',
12778
+ allowAwaitOutsideFunction: true,
12779
+ allowHashBang: true
12780
+ });
12781
+ return true;
12782
+ } catch {
12783
+ return false;
12784
+ }
12785
+ }
12711
12786
  class ScriptsPlugin {
12712
12787
  manifestPath;
12713
12788
  includeList;
@@ -12736,7 +12811,7 @@ class ScriptsPlugin {
12736
12811
  browser: this.browser
12737
12812
  }).apply(compiler);
12738
12813
  if ('production' === compiler.options.mode) new AddPublicPathRuntimeModule().apply(compiler);
12739
- new ValidateContentScriptSyntax().apply(compiler);
12814
+ new ValidateEmittedScriptSyntax().apply(compiler);
12740
12815
  }
12741
12816
  }
12742
12817
  class CollectContentEntryImports {
@@ -13172,6 +13247,10 @@ function webpackConfig(projectStructure, devOptions) {
13172
13247
  manifestPath,
13173
13248
  browser: devOptions.browser
13174
13249
  }),
13250
+ new SetupChunkLoadingTarget({
13251
+ manifestPath,
13252
+ browser: devOptions.browser
13253
+ }),
13175
13254
  new SpecialFoldersPlugin({
13176
13255
  manifestPath
13177
13256
  }),
@@ -13306,8 +13385,8 @@ function webpackConfig(projectStructure, devOptions) {
13306
13385
  ...transpilePackageDirs.length > 0 ? [] : [
13307
13386
  '**/node_modules/**'
13308
13387
  ],
13309
- `${toPosixPath(primaryExtensionOutputDir)}/**`,
13310
- `${toPosixPath(__rspack_external_node_path_c5b9b54f.join(packageJsonDir, 'dist'))}/**`,
13388
+ `${paths_toPosixPath(primaryExtensionOutputDir)}/**`,
13389
+ `${paths_toPosixPath(__rspack_external_node_path_c5b9b54f.join(packageJsonDir, 'dist'))}/**`,
13311
13390
  '**/extension-js/profiles/**'
13312
13391
  ],
13313
13392
  ...'true' === process.env.EXTENSION_WATCH_POLL ? {
package/dist/101.mjs CHANGED
@@ -699,7 +699,7 @@ async function config_loader_isUsingExperimentalConfig(projectPath) {
699
699
  }
700
700
  return false;
701
701
  }
702
- var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.1.5","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^2.1.1","@rspack/dev-server":"2.1.0","@rspack/plugin-preact-refresh":"2.0.1","@rspack/plugin-react-refresh":"2.0.2","@vue/compiler-sfc":"3.5.26","acorn":"^8.16.0","browser-extension-manifest-fields":"^2.2.9","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","dotenv":"^17.2.3","es-module-lexer":"^2.1.0","extension-from-store":"^0.2.5","fflate":"^0.8.3","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.6.7","less-loader":"13.0.0","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.23","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","prefers-yarn":"2.0.1","react-refresh":"0.18.0","sass-loader":"17.0.0","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","vue":"3.5.26","vue-loader":"17.4.2","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.20.1"}}');
702
+ var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.1.7","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^2.1.1","@rspack/dev-server":"2.1.0","@rspack/plugin-preact-refresh":"2.0.1","@rspack/plugin-react-refresh":"2.0.2","@vue/compiler-sfc":"3.5.26","acorn":"^8.16.0","browser-extension-manifest-fields":"^2.2.9","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","dotenv":"^17.2.3","es-module-lexer":"^2.1.0","extension-from-store":"^0.2.5","fflate":"^0.8.3","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.6.7","less-loader":"13.0.0","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.23","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","prefers-yarn":"2.0.1","react-refresh":"0.18.0","sass-loader":"17.0.0","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","vue":"3.5.26","vue-loader":"17.4.2","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.20.1"}}');
703
703
  function asAbsolute(p) {
704
704
  return __rspack_external_node_path_c5b9b54f.isAbsolute(p) ? p : __rspack_external_node_path_c5b9b54f.resolve(p);
705
705
  }
@@ -2058,6 +2058,25 @@ function collectReferenceCorpus(projectRoot) {
2058
2058
  walk(projectRoot);
2059
2059
  return 0 === files ? '' : parts.join('\n');
2060
2060
  }
2061
+ const COMPILED_TO_JS_EXTS = new Set([
2062
+ '.ts',
2063
+ '.tsx',
2064
+ '.jsx',
2065
+ '.mts',
2066
+ '.cts',
2067
+ '.mjs',
2068
+ '.cjs'
2069
+ ]);
2070
+ function referenceSpellings(relativePath) {
2071
+ const ext = node_path.extname(relativePath).toLowerCase();
2072
+ if (!COMPILED_TO_JS_EXTS.has(ext)) return [
2073
+ relativePath
2074
+ ];
2075
+ return [
2076
+ relativePath,
2077
+ `${relativePath.slice(0, -ext.length)}.js`
2078
+ ];
2079
+ }
2061
2080
  const warnedDroppedScripts = new Set();
2062
2081
  function filterUnreferencedScripts(list, projectRoot) {
2063
2082
  const entries = Object.entries(list || {});
@@ -2068,7 +2087,7 @@ function filterUnreferencedScripts(list, projectRoot) {
2068
2087
  const abs = String(entry);
2069
2088
  if (!node_path.isAbsolute(abs)) return true;
2070
2089
  const rel = node_path.relative(projectRoot, abs).split(node_path.sep).join('/');
2071
- return corpus.includes(rel);
2090
+ return referenceSpellings(rel).some((spelling)=>corpus.includes(spelling));
2072
2091
  };
2073
2092
  const next = {};
2074
2093
  const dropped = [];
package/dist/494.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
+ import { spawnSync } from "node:child_process";
2
3
  import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
3
4
  import * as __rspack_external_node_path_c5b9b54f from "node:path";
4
5
  function sessionStateDir(projectPath) {
@@ -33,6 +34,22 @@ function ensureSessionArtifactsIgnoreFile(projectPath) {
33
34
  __rspack_external_node_fs_5ea92f0c.writeFileSync(ignoreFile, SESSION_ARTIFACTS_IGNORE_CONTENT);
34
35
  } catch {}
35
36
  }
37
+ function isAlreadyIgnoredByGit(projectPath) {
38
+ try {
39
+ const result = spawnSync('git', [
40
+ 'check-ignore',
41
+ '-q',
42
+ '--',
43
+ '.extension-js/'
44
+ ], {
45
+ cwd: projectPath,
46
+ stdio: 'ignore'
47
+ });
48
+ return 0 === result.status;
49
+ } catch {
50
+ return false;
51
+ }
52
+ }
36
53
  function ensureSessionStateInProjectGitignore(projectPath) {
37
54
  try {
38
55
  const gitignorePath = __rspack_external_node_path_c5b9b54f.resolve(projectPath, '.gitignore');
@@ -40,6 +57,7 @@ function ensureSessionStateInProjectGitignore(projectPath) {
40
57
  const content = __rspack_external_node_fs_5ea92f0c.readFileSync(gitignorePath, 'utf8');
41
58
  const lines = content.split(/\r?\n/).map((line)=>line.trim());
42
59
  if (lines.includes('.extension-js') || lines.includes('.extension-js/')) return;
60
+ if (isAlreadyIgnoredByGit(projectPath)) return;
43
61
  const prefix = content.length > 0 && !content.endsWith('\n') ? '\n' : '';
44
62
  __rspack_external_node_fs_5ea92f0c.appendFileSync(gitignorePath, `${prefix}\n# extension.js local session state\n.extension-js\n`);
45
63
  } catch {}
package/dist/839.mjs CHANGED
@@ -973,9 +973,13 @@ function defaultTypeScriptConfig(projectPath, _opts) {
973
973
  };
974
974
  }
975
975
  function getUserTypeScriptConfigFile(projectPath) {
976
- const pkgDir = findNearestPackageJsonDirectory(projectPath);
977
- if (pkgDir) {
978
- const tsconfigPath = __rspack_external_node_path_c5b9b54f.join(pkgDir, 'tsconfig.json');
976
+ const searchDirs = [
977
+ findNearestPackageJsonDirectory(projectPath),
978
+ projectPath
979
+ ];
980
+ for (const dir of searchDirs){
981
+ if (!dir) continue;
982
+ const tsconfigPath = __rspack_external_node_path_c5b9b54f.join(dir, 'tsconfig.json');
979
983
  if (__rspack_external_node_fs_5ea92f0c.existsSync(tsconfigPath)) return tsconfigPath;
980
984
  }
981
985
  }
package/dist/86.mjs ADDED
@@ -0,0 +1,36 @@
1
+ import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
+ import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
3
+ import * as __rspack_external_node_path_c5b9b54f from "node:path";
4
+ const ASSET_EXT = /\.(png|jpe?g|gif|webp|svg|avif|ico|bmp|cur|woff2?|ttf|otf|eot|mp3|mp4|webm|ogg|wav)$/i;
5
+ const URL_REF = /url\(\s*(?:"([^"\n]*)"|'([^'\n]*)'|([^)'"\s]*))\s*\)/g;
6
+ function toPosixPath(value) {
7
+ return String(value).split(__rspack_external_node_path_c5b9b54f.sep).join('/');
8
+ }
9
+ function isDeadCssUrlRef(rawRequest, { issuerDir, roots }) {
10
+ const req = String(rawRequest).split('?')[0].split('#')[0];
11
+ if (!req || req.startsWith('//') || /^[a-z][a-z0-9+.-]*:/i.test(req)) return false;
12
+ if (req.startsWith('~') || req.startsWith('@')) return false;
13
+ const isRootRef = req.startsWith('/');
14
+ const isRelativeRef = req.startsWith('./') || req.startsWith('../');
15
+ const isBareAssetRef = !isRootRef && !isRelativeRef && ASSET_EXT.test(req);
16
+ if (!isRootRef && !isRelativeRef && !isBareAssetRef) return false;
17
+ const candidates = isRootRef ? roots.map((root)=>__rspack_external_node_path_c5b9b54f.join(root, req.slice(1))) : [
18
+ __rspack_external_node_path_c5b9b54f.resolve(issuerDir, req),
19
+ ...isBareAssetRef ? roots.map((root)=>__rspack_external_node_path_c5b9b54f.join(root, req)) : []
20
+ ];
21
+ return !candidates.some((candidate)=>__rspack_external_node_fs_5ea92f0c.existsSync(candidate));
22
+ }
23
+ function extractCssUrlRefs(source) {
24
+ const found = [];
25
+ const seen = new Set();
26
+ URL_REF.lastIndex = 0;
27
+ let match;
28
+ while(null !== (match = URL_REF.exec(source))){
29
+ const request = match[1] ?? match[2] ?? match[3] ?? '';
30
+ if (!request || seen.has(request)) continue;
31
+ seen.add(request);
32
+ found.push(request);
33
+ }
34
+ return found;
35
+ }
36
+ export { extractCssUrlRefs, isDeadCssUrlRef, toPosixPath };
package/dist/bridge.mjs CHANGED
@@ -196,7 +196,9 @@ class BridgeController {
196
196
  if (!settled) {
197
197
  settled = true;
198
198
  clearTimeout(connectTimer);
199
- reject(new Error(`control channel refused the controller (code ${code}${reason ? `: ${reason}` : ''}). Is the session started with ${this.opts.unlockFlag || '--allow-control'}?`));
199
+ const flag = this.opts.unlockFlag || '--allow-control';
200
+ const detail = 4003 === code ? `the session has no control channel. It is opened by a running \`dev\` session started with ${flag}; a session started without it, or already stopped, has none to connect to.` : `is the session started with ${flag}?`;
201
+ reject(new Error(`control channel refused the controller (code ${code}${reason ? `: ${reason}` : ''}). ${detail}`));
200
202
  }
201
203
  this.failAllPending(new Error(`control channel closed (code ${code})`));
202
204
  this.socket = null;
@@ -0,0 +1,34 @@
1
+ import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
+ import { WebpackError } from "@rspack/core";
3
+ import { isDeadCssUrlRef, extractCssUrlRefs, toPosixPath } from "./86.mjs";
4
+ import { deadCssUrlRef } from "./845.mjs";
5
+ import * as __rspack_external_node_path_c5b9b54f from "node:path";
6
+ function deadCssUrlLoader(source) {
7
+ try {
8
+ const { manifestPath, projectPath } = this.getOptions() || {};
9
+ if (!manifestPath || !projectPath) return source;
10
+ const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
11
+ const roots = [
12
+ __rspack_external_node_path_c5b9b54f.join(projectPath, 'public'),
13
+ manifestDir
14
+ ];
15
+ const issuerDir = __rspack_external_node_path_c5b9b54f.dirname(this.resourcePath);
16
+ const issuerPath = toPosixPath(__rspack_external_node_path_c5b9b54f.relative(manifestDir, this.resourcePath) || this.resourcePath);
17
+ const strict = 'true' === process.env.EXTENSION_STRICT_REFS;
18
+ const compilation = this._compilation;
19
+ for (const request of extractCssUrlRefs(source)){
20
+ if (!isDeadCssUrlRef(request, {
21
+ issuerDir,
22
+ roots
23
+ })) continue;
24
+ const report = new WebpackError(deadCssUrlRef(issuerPath, request));
25
+ report.file = issuerPath;
26
+ const sink = strict ? compilation?.errors : compilation?.warnings;
27
+ if (sink) sink.push(report);
28
+ else if (strict) this.emitError(report);
29
+ else this.emitWarning(report);
30
+ }
31
+ } catch {}
32
+ return source;
33
+ }
34
+ export default deadCssUrlLoader;