extension-develop 4.1.4 → 4.1.6

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 (50) hide show
  1. package/dist/0~rspack-config.mjs +69 -27
  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-web-extension/feature-scripts/steps/add-content-script-wrapper/classic-concat-loader.d.ts +17 -1
  37. package/dist/plugin-web-extension/feature-scripts/steps/{validate-content-script-syntax.d.ts → validate-emitted-script-syntax.d.ts} +1 -1
  38. package/package.json +1 -1
  39. package/dist/extension-js-devtools/chrome/assets/developer-mode-off.f9a94937.jpeg +0 -0
  40. package/dist/extension-js-devtools/chrome/assets/developer-mode-on.ede80e5b.jpeg +0 -0
  41. package/dist/extension-js-devtools/chrome/assets/local-network-permission.4fae40a7.png +0 -0
  42. package/dist/extension-js-devtools/chromium/assets/developer-mode-off.f9a94937.jpeg +0 -0
  43. package/dist/extension-js-devtools/chromium/assets/developer-mode-on.ede80e5b.jpeg +0 -0
  44. package/dist/extension-js-devtools/chromium/assets/local-network-permission.4fae40a7.png +0 -0
  45. package/dist/extension-js-devtools/edge/assets/developer-mode-off.f9a94937.jpeg +0 -0
  46. package/dist/extension-js-devtools/edge/assets/developer-mode-on.ede80e5b.jpeg +0 -0
  47. package/dist/extension-js-devtools/edge/assets/local-network-permission.4fae40a7.png +0 -0
  48. package/dist/extension-js-devtools/firefox/assets/developer-mode-off.f9a94937.jpeg +0 -0
  49. package/dist/extension-js-devtools/firefox/assets/developer-mode-on.ede80e5b.jpeg +0 -0
  50. 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;
@@ -12670,44 +12680,76 @@ class KeepGetURLImportsNative {
12670
12680
  });
12671
12681
  }
12672
12682
  }
12673
- class ValidateContentScriptSyntax {
12683
+ const requireModule = createRequire(import.meta.url);
12684
+ class ValidateEmittedScriptSyntax {
12674
12685
  apply(compiler) {
12675
12686
  if (!compiler?.hooks?.thisCompilation?.tap) return;
12676
- compiler.hooks.thisCompilation.tap("scripts:validate-content-script-syntax", (compilation)=>{
12687
+ compiler.hooks.thisCompilation.tap("scripts:validate-emitted-script-syntax", (compilation)=>{
12677
12688
  compilation.hooks.processAssets.tap({
12678
- name: "scripts:validate-content-script-syntax",
12689
+ name: "scripts:validate-emitted-script-syntax",
12679
12690
  stage: core_Compilation.PROCESS_ASSETS_STAGE_REPORT
12680
12691
  }, ()=>{
12681
12692
  const assets = 'function' == typeof compilation.getAssets ? compilation.getAssets() : [];
12682
12693
  for (const asset of assets){
12683
12694
  const name = asset?.name || '';
12684
- if (!isCanonicalContentScriptAsset(name)) continue;
12685
- if (!name.endsWith('.js')) continue;
12695
+ if (!/\.[cm]?js$/i.test(name)) continue;
12686
12696
  let source = '';
12687
12697
  try {
12688
12698
  source = asset.source?.source?.().toString() || '';
12689
12699
  } catch {
12690
12700
  continue;
12691
12701
  }
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
- }
12702
+ if (!source) continue;
12703
+ const error = findSyntaxError(source);
12704
+ if (!error) continue;
12705
+ const err = new core_WebpackError([
12706
+ `${name} is not valid JavaScript: ${error.message}.`,
12707
+ ...describeSlot(name)
12708
+ ].join('\n'));
12709
+ err.file = name;
12710
+ compilation.errors.push(err);
12706
12711
  }
12707
12712
  });
12708
12713
  });
12709
12714
  }
12710
12715
  }
12716
+ function describeSlot(name) {
12717
+ if (isCanonicalContentScriptAsset(name)) return [
12718
+ "The browser will silently skip an unparsable content script:",
12719
+ 'it never injects and reports no error anywhere. Fix the syntax',
12720
+ "error in the source file(s) this content_scripts entry bundles."
12721
+ ];
12722
+ return [
12723
+ 'The browser refuses to run a file it cannot parse, so the surface this',
12724
+ 'backs is dead on arrival. Fix the syntax error in the source file(s)',
12725
+ 'this entry bundles.'
12726
+ ];
12727
+ }
12728
+ function findSyntaxError(source) {
12729
+ try {
12730
+ new Function(source);
12731
+ return;
12732
+ } catch (caught) {
12733
+ const error = caught;
12734
+ if (error?.name !== 'SyntaxError') return;
12735
+ if (parsesAsModule(source)) return;
12736
+ return error;
12737
+ }
12738
+ }
12739
+ function parsesAsModule(source) {
12740
+ try {
12741
+ const acorn = requireModule('acorn');
12742
+ acorn.parse(source, {
12743
+ ecmaVersion: 'latest',
12744
+ sourceType: 'module',
12745
+ allowAwaitOutsideFunction: true,
12746
+ allowHashBang: true
12747
+ });
12748
+ return true;
12749
+ } catch {
12750
+ return false;
12751
+ }
12752
+ }
12711
12753
  class ScriptsPlugin {
12712
12754
  manifestPath;
12713
12755
  includeList;
@@ -12736,7 +12778,7 @@ class ScriptsPlugin {
12736
12778
  browser: this.browser
12737
12779
  }).apply(compiler);
12738
12780
  if ('production' === compiler.options.mode) new AddPublicPathRuntimeModule().apply(compiler);
12739
- new ValidateContentScriptSyntax().apply(compiler);
12781
+ new ValidateEmittedScriptSyntax().apply(compiler);
12740
12782
  }
12741
12783
  }
12742
12784
  class CollectContentEntryImports {
@@ -13306,8 +13348,8 @@ function webpackConfig(projectStructure, devOptions) {
13306
13348
  ...transpilePackageDirs.length > 0 ? [] : [
13307
13349
  '**/node_modules/**'
13308
13350
  ],
13309
- `${toPosixPath(primaryExtensionOutputDir)}/**`,
13310
- `${toPosixPath(__rspack_external_node_path_c5b9b54f.join(packageJsonDir, 'dist'))}/**`,
13351
+ `${paths_toPosixPath(primaryExtensionOutputDir)}/**`,
13352
+ `${paths_toPosixPath(__rspack_external_node_path_c5b9b54f.join(packageJsonDir, 'dist'))}/**`,
13311
13353
  '**/extension-js/profiles/**'
13312
13354
  ],
13313
13355
  ...'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.4","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.6","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;