extension-develop 4.1.11 → 4.1.13

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 (110) hide show
  1. package/dist/0~dev-server.mjs +147 -81
  2. package/dist/0~rspack-config.mjs +1096 -694
  3. package/dist/0~zip.mjs +1 -1
  4. package/dist/101.mjs +185 -895
  5. package/dist/129.mjs +89 -0
  6. package/dist/278.mjs +52 -0
  7. package/dist/292.mjs +61 -0
  8. package/dist/372.mjs +87 -0
  9. package/dist/518.mjs +434 -0
  10. package/dist/77.mjs +928 -0
  11. package/dist/839.mjs +178 -40
  12. package/dist/845.mjs +10 -1
  13. package/dist/887.mjs +1 -1
  14. package/dist/bridge-entry.d.ts +2 -1
  15. package/dist/bridge.mjs +56 -7
  16. package/dist/css-parse-guard-loader.mjs +3 -0
  17. package/dist/dead-css-url-loader.mjs +51 -24
  18. package/dist/dev-server/cleanup.d.ts +2 -1
  19. package/dist/dev-server/control-bridge/broker.d.ts +1 -0
  20. package/dist/dev-server/control-bridge/contracts.d.ts +2 -0
  21. package/dist/dev-server/control-bridge/logs-query.d.ts +12 -1
  22. package/dist/dev-server/control-bridge/producer-runtime.d.ts +1 -1
  23. package/dist/dev-server/messages.d.ts +8 -0
  24. package/dist/dev-server/session-restart.d.ts +29 -0
  25. package/dist/ensure-hmr-for-scripts.js +37 -20
  26. package/dist/ensure-hmr-for-scripts.mjs +37 -20
  27. package/dist/extension-js-devtools/chrome/content_scripts/content-0.js +2 -2
  28. package/dist/extension-js-devtools/chrome/scripts/logger-client.js +1 -1
  29. package/dist/extension-js-devtools/chromium/content_scripts/content-0.js +2 -2
  30. package/dist/extension-js-devtools/chromium/scripts/logger-client.js +1 -1
  31. package/dist/extension-js-devtools/edge/content_scripts/content-0.js +2 -2
  32. package/dist/extension-js-devtools/edge/scripts/logger-client.js +1 -1
  33. package/dist/extension-js-devtools/firefox/content_scripts/content-0.js +2 -2
  34. package/dist/extension-js-devtools/firefox/scripts/logger-client.js +1 -1
  35. package/dist/feature-scripts-classic-concat-loader.js +58 -5
  36. package/dist/feature-scripts-classic-concat-loader.mjs +58 -5
  37. package/dist/feature-scripts-content-script-wrapper.js +14 -17
  38. package/dist/feature-scripts-content-script-wrapper.mjs +14 -17
  39. package/dist/feature-scripts-native-geturl-import-loader.mjs +10 -3
  40. package/dist/lib/asset-source-maps.d.ts +7 -0
  41. package/dist/lib/config-loader.d.ts +7 -34
  42. package/dist/lib/loader-source-maps.d.ts +17 -0
  43. package/dist/lib/messages.d.ts +1 -0
  44. package/dist/lib/msg-placeholders.d.ts +2 -0
  45. package/dist/lib/paths.d.ts +2 -0
  46. package/dist/lib/project.d.ts +3 -0
  47. package/dist/lib/session-project-root.d.ts +1 -0
  48. package/dist/minimum-script-file.js +41 -1
  49. package/dist/minimum-script-file.mjs +41 -1
  50. package/dist/module.d.ts +1 -1
  51. package/dist/module.mjs +1 -1
  52. package/dist/plugin-css/css-lib/dead-url-refs.d.ts +5 -0
  53. package/dist/plugin-css/css-lib/inline-content-script-css.d.ts +32 -0
  54. package/dist/plugin-css/css-lib/messages.d.ts +3 -0
  55. package/dist/plugin-css/css-lib/verbatim-css.d.ts +9 -0
  56. package/dist/plugin-css/css-parse-guard-loader.d.ts +3 -0
  57. package/dist/plugin-css/css-tools/postcss.d.ts +1 -0
  58. package/dist/plugin-css/dead-css-url-loader.d.ts +8 -4
  59. package/dist/plugin-css/index.d.ts +1 -0
  60. package/dist/plugin-js-frameworks/js-frameworks-lib/jsx-transform.d.ts +10 -0
  61. package/dist/plugin-js-frameworks/js-tools/solid-jsx-runtime.d.ts +8 -0
  62. package/dist/plugin-js-frameworks/js-tools/solid.d.ts +3 -0
  63. package/dist/plugin-js-frameworks/swc-targets.d.ts +3 -0
  64. package/dist/plugin-reload/classify-reload.d.ts +6 -0
  65. package/dist/plugin-reload/index.d.ts +2 -1
  66. package/dist/plugin-reload/reload-dispatch.d.ts +1 -0
  67. package/dist/plugin-special-folders/folder-extensions/resolve-dirs.d.ts +1 -0
  68. package/dist/plugin-special-folders/folder-extensions/utils.d.ts +3 -0
  69. package/dist/plugin-special-folders/messages.d.ts +2 -0
  70. package/dist/plugin-special-folders/resolve-public-folder.d.ts +13 -0
  71. package/dist/plugin-web-extension/feature-html/html-lib/assets.d.ts +1 -1
  72. package/dist/plugin-web-extension/feature-html/html-lib/base-href.d.ts +11 -0
  73. package/dist/plugin-web-extension/feature-html/html-lib/patch-html.d.ts +2 -2
  74. package/dist/plugin-web-extension/feature-html/html-lib/utils.d.ts +13 -0
  75. package/dist/plugin-web-extension/feature-html/index.d.ts +1 -0
  76. package/dist/plugin-web-extension/feature-html/steps/ensure-hmr-for-scripts.d.ts +1 -1
  77. package/dist/plugin-web-extension/feature-icons/extract-action-theme-icons.d.ts +2 -0
  78. package/dist/plugin-web-extension/feature-icons/omnibox-fields.d.ts +2 -0
  79. package/dist/plugin-web-extension/feature-icons/theme-image-fields.d.ts +2 -0
  80. package/dist/plugin-web-extension/feature-json/json-validation.d.ts +1 -0
  81. package/dist/plugin-web-extension/feature-manifest/index.d.ts +1 -0
  82. package/dist/plugin-web-extension/feature-manifest/manifest-lib/manifest.d.ts +1 -1
  83. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/index.d.ts +1 -1
  84. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/sandbox.d.ts +1 -1
  85. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/storage.d.ts +1 -1
  86. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/theme.d.ts +1 -1
  87. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/index.d.ts +1 -1
  88. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv2/chrome_settings_overrides.d.ts +1 -1
  89. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv2/index.d.ts +1 -1
  90. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv2/theme_experiment.d.ts +1 -1
  91. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/action.d.ts +2 -1
  92. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/declarative_net_request.d.ts +1 -1
  93. package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/index.d.ts +1 -1
  94. package/dist/plugin-web-extension/feature-manifest/messages.d.ts +2 -0
  95. package/dist/plugin-web-extension/feature-manifest/normalize-manifest-path.d.ts +4 -0
  96. package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/patch-csp.d.ts +1 -1
  97. package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults.d.ts +1 -0
  98. package/dist/plugin-web-extension/feature-scripts/steps/native-geturl-import-loader.d.ts +7 -2
  99. package/dist/plugin-web-extension/feature-web-resources/collect-entry-imports.d.ts +1 -0
  100. package/dist/plugin-web-extension/index.d.ts +1 -0
  101. package/dist/plugin-web-extension/shared/html-surfaces.d.ts +19 -0
  102. package/dist/plugin-web-extension/shared/manifest-fields-change-detector.d.ts +1 -0
  103. package/dist/plugin-web-extension/shared/manifest-fields.d.ts +18 -0
  104. package/dist/plugin-web-extension/shared/manifest-path-assets.d.ts +4 -0
  105. package/dist/plugin-web-extension/shared/paths.d.ts +1 -0
  106. package/dist/solid-jsx-runtime.mjs +15 -0
  107. package/dist/types.d.ts +20 -7
  108. package/package.json +1 -1
  109. package/dist/494.mjs +0 -89
  110. package/dist/86.mjs +0 -36
package/dist/839.mjs CHANGED
@@ -5,10 +5,11 @@ import { buildExecEnv, detectPackageManagerFromLockfile } from "prefers-yarn";
5
5
  import "pintor";
6
6
  import { EventEmitter } from "node:events";
7
7
  import { browserRowValue, ENVELOPE, CODES, prefix as messaging_prefix, card, isDebug, claimCardKey, isMachineOutput } from "./349.mjs";
8
- import { package_namespaceObject, buildWarningsDetails, DEV_COMMAND_DEFAULTS, buildFailed, getDirs, stampReadyDistExtensionId, zipArtifactReady, stampReadyKnownExtensionId, projectInstallFallbackToNpm, assertNoManagedDependencyConflicts, debugDirs, browserLaunchFailed, START_BUILD_DEFAULTS, extensionLoadRecovered, extensionLoadStillRefused, writingTypeDefinitionsError, projectInstallScriptsDisabled, authorInstallNotice, getSpecialFoldersDataForProjectRoot, buildAssetsTree, loadCommandConfig, needsInstall, mergeOptionLayers, buildCommandFailed, writingTypeDefinitions, buildComplete, normalizeBrowser, debugBrowser, debugOutputPath, loadCustomConfig, devCommandFailed, getProjectStructure, getDistPath, resolveCompanionExtensionsConfig, buildShareHint, loadBrowserConfig, BUILD_COMMAND_DEFAULTS, withDarkMode } from "./101.mjs";
8
+ import { package_namespaceObject, loadCommandConfig, DEV_COMMAND_DEFAULTS, stampReadyDistExtensionId, loadProjectConfigDefaults, mergeOptionLayers, stampReadyKnownExtensionId, assertNoManagedDependencyConflicts, loadCustomConfig, START_BUILD_DEFAULTS, loadBrowserConfig, resolveCompanionExtensionsConfig, BUILD_COMMAND_DEFAULTS, getSpecialFoldersDataForProjectRoot, withDarkMode } from "./101.mjs";
9
9
  import { stripBom, parseJsonSafe } from "./23.mjs";
10
+ import { buildAssetsTree, buildWarningsDetails, getProjectStructure, buildFailed, needsInstall, getDirs, buildCommandFailed, writingTypeDefinitions, buildComplete, zipArtifactReady, ensureSessionStateInProjectGitignore, projectInstallFallbackToNpm, ensureSessionArtifactsIgnoreFile, normalizeBrowser, debugDirs, debugBrowser, debugOutputPath, browserLaunchFailed, buildSummaryPath, extensionLoadRecovered, extensionLoadStillRefused, getDistPath, buildShareHint, writingTypeDefinitionsError, devCommandFailed, projectInstallScriptsDisabled, authorInstallNotice, configBrowserOrThrow } from "./77.mjs";
10
11
  import { hasProjectDependency, findNearestProjectManifestDirSync } from "./80.mjs";
11
- import { buildSummaryPath, ensureSessionArtifactsIgnoreFile, ensureSessionStateInProjectGitignore } from "./494.mjs";
12
+ import { publicRootsFor } from "./278.mjs";
12
13
  import { getCanonicalContentScriptEntryName } from "./291.mjs";
13
14
  import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
14
15
  import { dirname as __rspack_dirname } from "node:path";
@@ -808,10 +809,67 @@ async function ensureDevelopArtifacts() {
808
809
  stdio
809
810
  });
810
811
  }
811
- async function generateExtensionTypes(manifestDir, packageJsonDir) {
812
- const extensionEnvFile = __rspack_external_node_path_c5b9b54f.join(packageJsonDir, 'extension-env.d.ts');
813
- const typePath = 'extension';
814
- const fileContent = `\
812
+ const EXTENSION_ENV_TYPES_PACKAGE = 'extension';
813
+ const STYLE_TYPE = 'Readonly<Record<string, string>>';
814
+ const EXTENSION_ENV_WILDCARD_MODULES = Object.freeze([
815
+ {
816
+ pattern: '*.css',
817
+ type: STYLE_TYPE
818
+ },
819
+ {
820
+ pattern: '*.module.css',
821
+ type: STYLE_TYPE
822
+ },
823
+ {
824
+ pattern: '*.module.scss',
825
+ type: STYLE_TYPE
826
+ },
827
+ {
828
+ pattern: '*.module.sass',
829
+ type: STYLE_TYPE
830
+ },
831
+ {
832
+ pattern: '*.png',
833
+ type: 'string'
834
+ },
835
+ {
836
+ pattern: '*.jpg',
837
+ type: 'string'
838
+ },
839
+ {
840
+ pattern: '*.jpeg',
841
+ type: 'string'
842
+ },
843
+ {
844
+ pattern: '*.gif',
845
+ type: 'string'
846
+ },
847
+ {
848
+ pattern: '*.webp',
849
+ type: 'string'
850
+ },
851
+ {
852
+ pattern: '*.avif',
853
+ type: 'string'
854
+ },
855
+ {
856
+ pattern: '*.ico',
857
+ type: 'string'
858
+ },
859
+ {
860
+ pattern: '*.bmp',
861
+ type: 'string'
862
+ },
863
+ {
864
+ pattern: '*.svg',
865
+ type: 'any'
866
+ }
867
+ ]);
868
+ function renderWildcardModuleDeclarations(modules = EXTENSION_ENV_WILDCARD_MODULES) {
869
+ return modules.map(({ pattern, type })=>`declare module '${pattern}' {\n const content: ${type}\n export default content\n}\n`).join('');
870
+ }
871
+ function renderExtensionEnvTypes(typePath = EXTENSION_ENV_TYPES_PACKAGE) {
872
+ return `\
815
873
  // Required Extension.js types for TypeScript projects.
816
874
  // This file is auto-generated and should not be excluded.
817
875
  // If you need additional types, consider creating a new *.d.ts file and
@@ -821,7 +879,15 @@ async function generateExtensionTypes(manifestDir, packageJsonDir) {
821
879
 
822
880
  // Polyfill types for browser.* APIs
823
881
  /// <reference types="${typePath}/types/polyfill" />
824
- `;
882
+
883
+ // Asset and stylesheet imports. These wildcard declarations also live in
884
+ // ${typePath}/types, but TypeScript 7 native does not apply them through the
885
+ // reference above, so they are emitted here as well.
886
+ ${renderWildcardModuleDeclarations()}`;
887
+ }
888
+ async function generateExtensionTypes(manifestDir, packageJsonDir) {
889
+ const extensionEnvFile = __rspack_external_node_path_c5b9b54f.join(packageJsonDir, 'extension-env.d.ts');
890
+ const fileContent = renderExtensionEnvTypes();
825
891
  try {
826
892
  await __rspack_external_node_fs_promises_153e37e0.access(extensionEnvFile);
827
893
  const existingContent = await __rspack_external_node_fs_promises_153e37e0.readFile(extensionEnvFile, 'utf8');
@@ -1041,8 +1107,10 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
1041
1107
  const projectStructure = await getProjectStructure(pathOrRemoteUrl);
1042
1108
  const isVitest = 'true' === process.env.VITEST;
1043
1109
  const shouldExitOnError = (buildOptions?.exitOnError ?? false) && !isVitest;
1044
- const browser = normalizeBrowser(buildOptions?.browser || 'chrome', buildOptions?.chromiumBinary, buildOptions?.geckoBinary || buildOptions?.firefoxBinary, buildOptions?.safariBinary);
1045
1110
  const { manifestDir, packageJsonDir } = getDirs(projectStructure);
1111
+ const commandKey = buildOptions?.metadataCommand === 'start' ? 'start' : 'build';
1112
+ const configBrowser = buildOptions?.browser ? void 0 : configBrowserOrThrow((await loadCommandConfig(packageJsonDir, commandKey)).browser, commandKey);
1113
+ const browser = normalizeBrowser(buildOptions?.browser || configBrowser || 'chrome', buildOptions?.chromiumBinary, buildOptions?.geckoBinary || buildOptions?.firefoxBinary, buildOptions?.safariBinary);
1046
1114
  const distPath = getDistPath(packageJsonDir, browser);
1047
1115
  const stagingDistPath = stagingDistPathFor(distPath);
1048
1116
  const isAuthor = isDebug();
@@ -1060,11 +1128,11 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
1060
1128
  const debug = isAuthor;
1061
1129
  const userManifestPath = projectStructure.packageJsonPath || projectStructure.denoJsonPath;
1062
1130
  if (userManifestPath) assertNoManagedDependencyConflicts(userManifestPath, manifestDir);
1063
- const commandKey = buildOptions?.metadataCommand === 'start' ? 'start' : 'build';
1131
+ const projectConfig = await loadProjectConfigDefaults(packageJsonDir);
1064
1132
  const commandConfig = await loadCommandConfig(packageJsonDir, commandKey);
1065
1133
  const browserConfig = await loadBrowserConfig(packageJsonDir, browser);
1066
1134
  const specialFoldersData = getSpecialFoldersDataForProjectRoot(packageJsonDir);
1067
- const mergedBuildOptions = mergeOptionLayers('start' === commandKey ? START_BUILD_DEFAULTS : BUILD_COMMAND_DEFAULTS, browserConfig, commandConfig, buildOptions);
1135
+ const mergedBuildOptions = mergeOptionLayers('start' === commandKey ? START_BUILD_DEFAULTS : BUILD_COMMAND_DEFAULTS, projectConfig, browserConfig, commandConfig, buildOptions);
1068
1136
  const silent = Boolean(mergedBuildOptions.silent);
1069
1137
  removeStaleStagingDirs(distPath);
1070
1138
  if (debug) {
@@ -1072,7 +1140,7 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
1072
1140
  console.log(debugBrowser(browser, buildOptions?.chromiumBinary, buildOptions?.geckoBinary || buildOptions?.firefoxBinary));
1073
1141
  console.log(debugOutputPath(distPath));
1074
1142
  }
1075
- const mergedExtensionsConfig = buildOptions?.extensions ?? commandConfig.extensions ?? browserConfig.extensions ?? specialFoldersData.extensions;
1143
+ const mergedExtensionsConfig = buildOptions?.extensions ?? commandConfig.extensions ?? browserConfig.extensions ?? projectConfig.extensions ?? specialFoldersData.extensions;
1076
1144
  const resolvedExtensionsConfig = await resolveCompanionExtensionsConfig({
1077
1145
  projectRoot: packageJsonDir,
1078
1146
  browser,
@@ -1100,7 +1168,8 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
1100
1168
  });
1101
1169
  const compilerConfig = merge(userConfig);
1102
1170
  compilerConfig.stats = false;
1103
- const mergedOutputPath = 'string' == typeof compilerConfig.output?.path ? __rspack_external_node_path_c5b9b54f.resolve(compilerConfig.output.path) : '';
1171
+ const compileContext = 'string' == typeof compilerConfig.context && compilerConfig.context ? __rspack_external_node_path_c5b9b54f.resolve(compilerConfig.context) : packageJsonDir;
1172
+ const mergedOutputPath = 'string' == typeof compilerConfig.output?.path ? __rspack_external_node_path_c5b9b54f.resolve(compileContext, compilerConfig.output.path) : '';
1104
1173
  const useStagingSwap = mergedOutputPath === __rspack_external_node_path_c5b9b54f.resolve(stagingDistPath);
1105
1174
  const displayDistPath = useStagingSwap || !mergedOutputPath ? distPath : mergedOutputPath;
1106
1175
  if (!useStagingSwap && mergedOutputPath) try {
@@ -1171,7 +1240,7 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
1171
1240
  warnings: true,
1172
1241
  errors: true
1173
1242
  });
1174
- summary = getBuildSummary(browser, info, distPath);
1243
+ summary = getBuildSummary(browser, info, displayDistPath);
1175
1244
  try {
1176
1245
  const summaryFile = buildSummaryPath(packageJsonDir, browser);
1177
1246
  __rspack_external_node_fs_5ea92f0c.mkdirSync(__rspack_external_node_path_c5b9b54f.dirname(summaryFile), {
@@ -1192,7 +1261,8 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
1192
1261
  const zipDisplay = relativeToCwd(artifactPath) || artifactPath;
1193
1262
  humanLine(zipArtifactReady(zipDisplay, artifact.size));
1194
1263
  }
1195
- humanLine(buildShareHint());
1264
+ const shareHint = buildShareHint();
1265
+ if (shareHint) humanLine(shareHint);
1196
1266
  resolve();
1197
1267
  }
1198
1268
  });
@@ -1236,7 +1306,10 @@ function viaBroker(broker, instruction) {
1236
1306
  type: instruction.type,
1237
1307
  changedContentScriptEntries: instruction.changedContentScriptEntries,
1238
1308
  label: instruction.label,
1239
- changedFiles: instruction.changedAssets
1309
+ changedFiles: instruction.changedAssets,
1310
+ ...instruction.changedScriptFiles?.length ? {
1311
+ changedScriptFiles: instruction.changedScriptFiles
1312
+ } : {}
1240
1313
  });
1241
1314
  }
1242
1315
  function formatReloadingLine(label) {
@@ -1261,9 +1334,17 @@ function isForcedFullPath(normalized) {
1261
1334
  function isHotAsset(normalized) {
1262
1335
  return normalized.startsWith('hot/') || normalized.includes('.hot-update.');
1263
1336
  }
1337
+ function isDirectory(absolute) {
1338
+ try {
1339
+ return __rspack_external_node_fs_5ea92f0c.statSync(absolute).isDirectory();
1340
+ } catch {
1341
+ return false;
1342
+ }
1343
+ }
1264
1344
  function normalizeChangedPath(file, contextDir) {
1265
1345
  const raw = String(file || '');
1266
1346
  if (!raw) return;
1347
+ if (__rspack_external_node_path_c5b9b54f.isAbsolute(raw) && isDirectory(raw)) return;
1267
1348
  const normalized = __rspack_external_node_path_c5b9b54f.isAbsolute(raw) ? __rspack_external_node_path_c5b9b54f.relative(contextDir, raw).replace(/\\/g, '/') : raw.replace(/\\/g, '/');
1268
1349
  if (!normalized) return;
1269
1350
  return normalized;
@@ -1366,6 +1447,22 @@ function pageContextFromSources(changedSources) {
1366
1447
  for (const rel of changedSources)for (const [re, name] of rules)if (re.test(rel)) return name;
1367
1448
  return 'page';
1368
1449
  }
1450
+ function publicOutputPath(rel, publicRoots) {
1451
+ for (const root of publicRoots || []){
1452
+ const prefix = root.replace(/\/+$/, '');
1453
+ if (prefix) {
1454
+ if (rel.startsWith(`${prefix}/`)) return rel.slice(prefix.length + 1);
1455
+ }
1456
+ }
1457
+ }
1458
+ function relativePublicRoots(compilation, contextDir) {
1459
+ const out = [];
1460
+ for (const root of publicRootsFor(compilation?.compiler)){
1461
+ const rel = __rspack_external_node_path_c5b9b54f.relative(contextDir, root).replace(/\\/g, '/');
1462
+ if (rel && !rel.startsWith('..') && !__rspack_external_node_path_c5b9b54f.isAbsolute(rel)) out.push(rel);
1463
+ }
1464
+ return out;
1465
+ }
1369
1466
  function moduleResourcesFromIdentifier(identifier, contextDir) {
1370
1467
  const afterLoaders = identifier.slice(identifier.lastIndexOf('!') + 1);
1371
1468
  const noLayer = afterLoaders.split('|')[0];
@@ -1386,10 +1483,13 @@ function moduleResourcesFromIdentifier(identifier, contextDir) {
1386
1483
  return out;
1387
1484
  }
1388
1485
  function buildSourceFeatureIndex(compilation, contextDir) {
1486
+ const scriptFilesBySource = new Map();
1389
1487
  const index = {
1390
1488
  swSources: new Set(),
1391
1489
  contentEntriesBySource: new Map(),
1392
- pageSources: new Set()
1490
+ pageSources: new Set(),
1491
+ scriptFilesBySource,
1492
+ publicRoots: relativePublicRoots(compilation, contextDir)
1393
1493
  };
1394
1494
  const chunkGraph = compilation.chunkGraph;
1395
1495
  for (const chunk of compilation.chunks || []){
@@ -1397,6 +1497,7 @@ function buildSourceFeatureIndex(compilation, contextDir) {
1397
1497
  if (!name) continue;
1398
1498
  const isBackground = /^background\//.test(name);
1399
1499
  const isContent = /^content_scripts\//.test(name);
1500
+ const scriptFiles = /^scripts\//.test(name) ? emittedScriptFiles(chunk, name) : [];
1400
1501
  for (const module of chunkGraph.getChunkModulesIterable(chunk)){
1401
1502
  let identifier = '';
1402
1503
  try {
@@ -1404,19 +1505,48 @@ function buildSourceFeatureIndex(compilation, contextDir) {
1404
1505
  } catch {
1405
1506
  continue;
1406
1507
  }
1407
- for (const rel of moduleResourcesFromIdentifier(identifier, contextDir))if (isBackground) index.swSources.add(rel);
1408
- else if (isContent) {
1409
- let entries = index.contentEntriesBySource.get(rel);
1410
- if (!entries) {
1411
- entries = new Set();
1412
- index.contentEntriesBySource.set(rel, entries);
1508
+ for (const rel of moduleResourcesFromIdentifier(identifier, contextDir)){
1509
+ if (isBackground) index.swSources.add(rel);
1510
+ else if (isContent) {
1511
+ let entries = index.contentEntriesBySource.get(rel);
1512
+ if (!entries) {
1513
+ entries = new Set();
1514
+ index.contentEntriesBySource.set(rel, entries);
1515
+ }
1516
+ entries.add(name);
1517
+ } else index.pageSources.add(rel);
1518
+ if (scriptFiles.length > 0) {
1519
+ let files = scriptFilesBySource.get(rel);
1520
+ if (!files) {
1521
+ files = new Set();
1522
+ scriptFilesBySource.set(rel, files);
1523
+ }
1524
+ for (const file of scriptFiles)files.add(file);
1413
1525
  }
1414
- entries.add(name);
1415
- } else index.pageSources.add(rel);
1526
+ }
1416
1527
  }
1417
1528
  }
1418
1529
  return index;
1419
1530
  }
1531
+ function emittedScriptFiles(chunk, name) {
1532
+ const files = chunk?.files ? [
1533
+ ...chunk.files
1534
+ ] : [];
1535
+ const js = files.filter((file)=>/\.js$/i.test(file));
1536
+ return js.length > 0 ? js : [
1537
+ `${name}.js`
1538
+ ];
1539
+ }
1540
+ function changedScriptFilesFor(changedSources, index) {
1541
+ const out = new Set();
1542
+ for (const rel of changedSources){
1543
+ const files = index?.scriptFilesBySource?.get(rel);
1544
+ if (files) for (const file of files)out.add(file);
1545
+ }
1546
+ return [
1547
+ ...out
1548
+ ].sort();
1549
+ }
1420
1550
  function classifyReloadFromSources(opts) {
1421
1551
  const { changedSources, forcedFull, getContentScriptCount, getSourceFeatureIndex, outputPath } = opts;
1422
1552
  if (0 === changedSources.length) return;
@@ -1431,6 +1561,11 @@ function classifyReloadFromSources(opts) {
1431
1561
  } catch {
1432
1562
  index = null;
1433
1563
  }
1564
+ const scriptFiles = changedScriptFilesFor(changedSources, index);
1565
+ const withScripts = (instruction)=>scriptFiles.length > 0 ? {
1566
+ ...instruction,
1567
+ changedScriptFiles: scriptFiles
1568
+ } : instruction;
1434
1569
  const swChanged = [];
1435
1570
  const contentEntries = new Set();
1436
1571
  const contentChanged = [];
@@ -1453,14 +1588,16 @@ function classifyReloadFromSources(opts) {
1453
1588
  }
1454
1589
  if (!known) unknown.push(rel);
1455
1590
  }
1456
- const staticAssetChanged = outputPath && unknown.some((rel)=>{
1591
+ const publicRoots = index?.publicRoots;
1592
+ const publicAssetChanged = changedSources.some((rel)=>void 0 !== publicOutputPath(rel, publicRoots));
1593
+ const staticAssetChanged = publicAssetChanged || outputPath && unknown.some((rel)=>{
1457
1594
  try {
1458
1595
  return __rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(outputPath, rel));
1459
1596
  } catch {
1460
1597
  return false;
1461
1598
  }
1462
1599
  });
1463
- if (swChanged.length > 0) return {
1600
+ if (swChanged.length > 0) return withScripts({
1464
1601
  type: 'service-worker',
1465
1602
  ...contentEntries.size > 0 ? {
1466
1603
  changedContentScriptEntries: [
@@ -1469,47 +1606,47 @@ function classifyReloadFromSources(opts) {
1469
1606
  } : {},
1470
1607
  changedAssets: changedSources,
1471
1608
  label: formatReloadContextLabel(contentEntries.size > 0 ? "service_worker + content_script" : 'service_worker', swChanged)
1472
- };
1473
- if (staticAssetChanged) return {
1609
+ });
1610
+ if (staticAssetChanged) return withScripts({
1474
1611
  type: 'full',
1475
1612
  changedAssets: changedSources,
1476
1613
  label: formatReloadContextLabel('extension', changedSources)
1477
- };
1478
- if (contentChanged.length > 0) return {
1614
+ });
1615
+ if (contentChanged.length > 0) return withScripts({
1479
1616
  type: "content-scripts",
1480
1617
  changedContentScriptEntries: [
1481
1618
  ...contentEntries
1482
1619
  ].sort(),
1483
1620
  changedAssets: changedSources,
1484
1621
  label: formatReloadContextLabel("content_script", contentChanged)
1485
- };
1486
- if (pageChanged.length > 0 && 0 === unknown.length) return {
1622
+ });
1623
+ if (pageChanged.length > 0 && 0 === unknown.length) return withScripts({
1487
1624
  type: 'page',
1488
1625
  changedAssets: changedSources,
1489
1626
  label: formatReloadContextLabel(pageContextFromSources(pageChanged), pageChanged)
1490
- };
1627
+ });
1491
1628
  const isServiceWorkerSource = (rel)=>/(^|\/)background(\.|\/)/i.test(rel) || /service[-_.]?worker/i.test(rel);
1492
- if (unknown.some(isServiceWorkerSource)) return {
1629
+ if (unknown.some(isServiceWorkerSource)) return withScripts({
1493
1630
  type: 'service-worker',
1494
1631
  changedAssets: changedSources,
1495
1632
  label: formatReloadContextLabel('service_worker', changedSources)
1496
- };
1633
+ });
1497
1634
  const contentScriptCount = getContentScriptCount();
1498
1635
  if (contentScriptCount > 0) {
1499
1636
  const entries = [];
1500
1637
  for(let i = 0; i < contentScriptCount; i++)entries.push(getCanonicalContentScriptEntryName(i));
1501
- return {
1638
+ return withScripts({
1502
1639
  type: "content-scripts",
1503
1640
  changedContentScriptEntries: entries,
1504
1641
  changedAssets: changedSources,
1505
1642
  label: formatReloadContextLabel("content_script", changedSources)
1506
- };
1643
+ });
1507
1644
  }
1508
- return {
1645
+ return withScripts({
1509
1646
  type: 'page',
1510
1647
  changedAssets: changedSources,
1511
1648
  label: formatReloadContextLabel(pageContextFromSources(changedSources), changedSources)
1512
- };
1649
+ });
1513
1650
  }
1514
1651
  function readContentScriptCount(compilation, outputPath) {
1515
1652
  try {
@@ -1738,9 +1875,10 @@ async function extensionDev(pathOrRemoteUrl, devOptions) {
1738
1875
  console.log(debugDirs(manifestDir, packageJsonDir));
1739
1876
  console.log(debugBrowser(browser, devOptions.chromiumBinary, geckoBinary));
1740
1877
  }
1878
+ const projectConfig = await loadProjectConfigDefaults(packageJsonDir);
1741
1879
  const browserConfig = await loadBrowserConfig(packageJsonDir, browser);
1742
1880
  const merged = withDarkMode({
1743
- ...mergeOptionLayers(DEV_COMMAND_DEFAULTS, browserConfig, commandConfig, devOptions),
1881
+ ...mergeOptionLayers(DEV_COMMAND_DEFAULTS, projectConfig, browserConfig, commandConfig, devOptions),
1744
1882
  browser
1745
1883
  });
1746
1884
  if (('safari' === browser || 'webkit-based' === browser) && !devOptions.noBrowser && devOptions.safariPackager) {
package/dist/845.mjs CHANGED
@@ -72,4 +72,13 @@ function lateCssImportIgnored(issuerPath, line) {
72
72
  `Move the ${pintor.blue('@import')} above every other rule to make it load.`
73
73
  ].join('\n');
74
74
  }
75
- export { cssConfigsDetected, cssIntegrationsEnabled, cssParseErrorShippedVerbatim, deadCssUrlRef, isUsingIntegration, lateCssImportIgnored, missingSassDependency, postCssPluginNotResolved, preprocessorShippedUncompiled };
75
+ function postCssConfigUnreadable(configPath, error) {
76
+ return `${messaging_prefix('warn')} Could not load the PostCSS config at ${pintor.gray(configPath)}.\n${String(error?.message || error)}\nThe build continues without it. Fix the file or remove it.`;
77
+ }
78
+ function postCssConfigPluginsShape(configPath, found) {
79
+ return `${messaging_prefix('warn')} The PostCSS config at ${pintor.gray(configPath)} lists plugins as ${found}.\nPostCSS expects an array or an object keyed by plugin name. The build continues without this config.`;
80
+ }
81
+ function cssMinifierDroppedRules(assetName, tokens) {
82
+ return `${messaging_prefix('warn')} The CSS minimizer dropped ${tokens.join(', ')} from ${pintor.gray(assetName)}.\nShipped that stylesheet unminified so production keeps every rule development keeps.`;
83
+ }
84
+ export { cssConfigsDetected, cssIntegrationsEnabled, cssMinifierDroppedRules, cssParseErrorShippedVerbatim, deadCssUrlRef, isUsingIntegration, lateCssImportIgnored, missingSassDependency, postCssConfigPluginsShape, postCssConfigUnreadable, postCssPluginNotResolved, preprocessorShippedUncompiled };
package/dist/887.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
- import { controlTokenPath, legacyControlTokenPath } from "./494.mjs";
2
+ import { controlTokenPath, legacyControlTokenPath } from "./77.mjs";
3
3
  import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
4
4
  import * as __rspack_external_node_path_c5b9b54f from "node:path";
5
5
  import * as __rspack_external_node_crypto_9ba42079 from "node:crypto";
@@ -3,7 +3,8 @@ export type { BridgeRefusalCode, BridgeTarget, CommandOp, GapFrame, LogContext,
3
3
  export { CLOSE_BAD_HELLO, CLOSE_BAD_INSTANCE, CLOSE_CONTROL_UNAVAILABLE, CLOSE_SLOW_CONSUMER, CONTROL_ENVELOPE_VERSION, CONTROL_WS_PATH, LOG_EVENT_VERSION, REFUSAL_API_UNAVAILABLE, REFUSAL_NEEDS_HEADED_WINDOW, REFUSAL_NEEDS_USER_GESTURE, REFUSAL_SURFACE_NOT_OPEN } from './dev-server/control-bridge/contracts';
4
4
  export { controlPortFilePath, readPersistedControlPort } from './dev-server/control-bridge/control-port-store';
5
5
  export { BridgeController, type CommandInput, type ControllerOptions } from './dev-server/control-bridge/controller-client';
6
- export { LOG_LEVEL_ORDER, type LogQuery, logLevelRank, matchesLogQuery, readLogEvents } from './dev-server/control-bridge/logs-query';
6
+ export { isAfterSince, LOG_LEVEL_ORDER, type LogQuery, type LogSince, logLevelRank, matchesLogQuery, parseLogSince, readLogEvents } from './dev-server/control-bridge/logs-query';
7
7
  export { controlTokenPath, readControlToken } from './dev-server/control-bridge/session-token';
8
8
  export { actionsPath, browserArtifactsDir, browserDistDir, browserProfileRootDir, buildSummaryPath, eventsPath, logsPath, readyContractPath, sessionArtifactsRootDir, sessionStateDir } from './lib/session-paths';
9
+ export { resolveSessionProjectRoot } from './lib/session-project-root';
9
10
  export type { PlaywrightAutomationCommand, ReadyMetadata, ReadyStatus } from './plugin-playwright';
package/dist/bridge.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
2
  import { WebSocket } from "ws";
3
- import { readyContractPath, logsPath } from "./494.mjs";
3
+ import { logsPath, resolveProjectStructureSync, readyContractPath, getDirs } from "./77.mjs";
4
4
  import { CONTROL_WS_PATH } from "./887.mjs";
5
5
  import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
6
+ import * as __rspack_external_node_path_c5b9b54f from "node:path";
6
7
  function readReadyContractDocument(projectPath, browser = 'chrome') {
7
8
  const readyPath = readyContractPath(projectPath, browser);
8
9
  try {
@@ -197,8 +198,10 @@ class BridgeController {
197
198
  settled = true;
198
199
  clearTimeout(connectTimer);
199
200
  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}`));
201
+ const detail = 4003 === code ? `control is off in the session that answered, so it accepts no controller. A session turns control on with ${flag}, and one that had the flag and still answers this way needs \`extension doctor\`.` : 4001 === code ? "the session that wrote ready.json has been replaced. Re-read ready.json or restart the dev session." : 4002 === code ? "the session did not understand the hello. Update the CLI and the dev session to the same Extension.js version." : 'the session closed the socket during the handshake.';
202
+ reject(Object.assign(new Error(`control channel refused the controller (code ${code}${reason ? `: ${reason}` : ''}). ${detail}`), {
203
+ closeCode: code
204
+ }));
202
205
  }
203
206
  this.failAllPending(new Error(`control channel closed (code ${code})`));
204
207
  this.socket = null;
@@ -288,6 +291,33 @@ function makeUrlMatcher(pattern) {
288
291
  return candidates.some((candidate)=>expression ? expression.test(candidate) : candidate.includes(pattern));
289
292
  };
290
293
  }
294
+ function parseLogSince(value) {
295
+ if (null == value || '' === value) return null;
296
+ if ('number' == typeof value) return Number.isFinite(value) ? {
297
+ seq: value
298
+ } : void 0;
299
+ const text = String(value).trim();
300
+ if (/^\d+(?:\.\d+)?$/.test(text)) return {
301
+ seq: Number(text)
302
+ };
303
+ const time = Date.parse(text);
304
+ return Number.isFinite(time) ? {
305
+ time
306
+ } : void 0;
307
+ }
308
+ function eventTime(event) {
309
+ if ('number' == typeof event.timestamp) return event.timestamp;
310
+ if ('string' == typeof event.ts) {
311
+ const parsed = Date.parse(event.ts);
312
+ return Number.isFinite(parsed) ? parsed : null;
313
+ }
314
+ return null;
315
+ }
316
+ function isAfterSince(event, since) {
317
+ if ('seq' in since) return !('number' == typeof event.seq && event.seq <= since.seq);
318
+ const time = eventTime(event);
319
+ return null == time || time > since.time;
320
+ }
291
321
  function toFiniteNumber(value) {
292
322
  if (null == value || '' === value) return null;
293
323
  const parsed = 'number' == typeof value ? value : Number(value);
@@ -303,8 +333,8 @@ function matchesLogQuery(event, query) {
303
333
  if ('all' !== minLevel && 'off' !== minLevel) {
304
334
  if (logLevelRank(String(event.level || '')) > logLevelRank(minLevel)) return false;
305
335
  }
306
- const since = toFiniteNumber(query.since);
307
- if (null != since && 'number' == typeof event.seq && event.seq <= since) return false;
336
+ const since = parseLogSince(query.since);
337
+ if (since && !isAfterSince(event, since)) return false;
308
338
  if (query.url && !makeUrlMatcher(query.url)(event)) return false;
309
339
  const tabId = toFiniteNumber(query.tab);
310
340
  if (null != tabId && event.tabId !== tabId) return false;
@@ -330,6 +360,25 @@ function readLogEvents(projectPath, browser = 'chrome', query = {}) {
330
360
  }
331
361
  return events;
332
362
  }
363
+ function isLocalDirectory(candidate) {
364
+ try {
365
+ return __rspack_external_node_fs_5ea92f0c.statSync(candidate).isDirectory();
366
+ } catch {
367
+ return false;
368
+ }
369
+ }
370
+ function resolveSessionProjectRoot(pathArg) {
371
+ const inputPath = __rspack_external_node_path_c5b9b54f.resolve(pathArg || process.cwd());
372
+ if (!isLocalDirectory(inputPath)) return inputPath;
373
+ try {
374
+ const structure = resolveProjectStructureSync(inputPath, {
375
+ quiet: true
376
+ });
377
+ return getDirs(structure).packageJsonDir;
378
+ } catch {
379
+ return inputPath;
380
+ }
381
+ }
333
382
  var bridge_entry_CLOSE_BAD_HELLO = 4002;
334
383
  var bridge_entry_CLOSE_BAD_INSTANCE = 4001;
335
384
  var bridge_entry_CLOSE_CONTROL_UNAVAILABLE = 4003;
@@ -337,5 +386,5 @@ var bridge_entry_CLOSE_SLOW_CONSUMER = 4008;
337
386
  var bridge_entry_CONTROL_ENVELOPE_VERSION = 1;
338
387
  var bridge_entry_LOG_EVENT_VERSION = 1;
339
388
  export { CONTROL_WS_PATH, REFUSAL_API_UNAVAILABLE, REFUSAL_NEEDS_HEADED_WINDOW, REFUSAL_NEEDS_USER_GESTURE, REFUSAL_SURFACE_NOT_OPEN, readControlToken, readPersistedControlPort } from "./887.mjs";
340
- export { actionsPath, browserArtifactsDir, browserDistDir, browserProfileRootDir, buildSummaryPath, controlPortFilePath, controlTokenPath, eventsPath, logsPath, readyContractPath, sessionArtifactsRootDir, sessionStateDir } from "./494.mjs";
341
- export { BridgeConsumer, BridgeController, LOG_LEVEL_ORDER, bridge_entry_CLOSE_BAD_HELLO as CLOSE_BAD_HELLO, bridge_entry_CLOSE_BAD_INSTANCE as CLOSE_BAD_INSTANCE, bridge_entry_CLOSE_CONTROL_UNAVAILABLE as CLOSE_CONTROL_UNAVAILABLE, bridge_entry_CLOSE_SLOW_CONSUMER as CLOSE_SLOW_CONSUMER, bridge_entry_CONTROL_ENVELOPE_VERSION as CONTROL_ENVELOPE_VERSION, bridge_entry_LOG_EVENT_VERSION as LOG_EVENT_VERSION, logLevelRank, matchesLogQuery, readLogEvents, readReadyContract, readReadyContractDocument };
389
+ export { actionsPath, browserArtifactsDir, browserDistDir, browserProfileRootDir, buildSummaryPath, controlPortFilePath, controlTokenPath, eventsPath, logsPath, readyContractPath, sessionArtifactsRootDir, sessionStateDir } from "./77.mjs";
390
+ export { BridgeConsumer, BridgeController, LOG_LEVEL_ORDER, bridge_entry_CLOSE_BAD_HELLO as CLOSE_BAD_HELLO, bridge_entry_CLOSE_BAD_INSTANCE as CLOSE_BAD_INSTANCE, bridge_entry_CLOSE_CONTROL_UNAVAILABLE as CLOSE_CONTROL_UNAVAILABLE, bridge_entry_CLOSE_SLOW_CONSUMER as CLOSE_SLOW_CONSUMER, bridge_entry_CONTROL_ENVELOPE_VERSION as CONTROL_ENVELOPE_VERSION, bridge_entry_LOG_EVENT_VERSION as LOG_EVENT_VERSION, isAfterSince, logLevelRank, matchesLogQuery, parseLogSince, readLogEvents, readReadyContract, readReadyContractDocument, resolveSessionProjectRoot };
@@ -1,6 +1,7 @@
1
1
  import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
2
  import postcss from "postcss";
3
3
  import { cssParseErrorShippedVerbatim } from "./845.mjs";
4
+ import { verbatimCssPlaceholder, registerVerbatimCss } from "./129.mjs";
4
5
  import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
5
6
  function cssParseGuardLoader(source) {
6
7
  return source;
@@ -16,6 +17,8 @@ function pitch() {
16
17
  callback(null);
17
18
  } catch (error) {
18
19
  this.emitWarning(new Error(cssParseErrorShippedVerbatim(this.resourcePath, error)));
20
+ const moduleType = String(this._module?.type || '');
21
+ if (moduleType.startsWith('css')) return void callback(null, verbatimCssPlaceholder(registerVerbatimCss(raw, this.resourcePath)));
19
22
  callback(null, raw);
20
23
  }
21
24
  }).catch(()=>{
@@ -1,34 +1,61 @@
1
1
  import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
2
  import { WebpackError } from "@rspack/core";
3
- import { isDeadCssUrlRef, extractCssUrlRefs, toPosixPath } from "./86.mjs";
3
+ import { publicFolderOrDefault } from "./278.mjs";
4
+ import { canonicalizeDir, canonicalizeResourcePath } from "./93.mjs";
5
+ import { isDeadCssUrlRef, extractCssUrlRefs, toPosixPath } from "./518.mjs";
4
6
  import { deadCssUrlRef } from "./845.mjs";
7
+ import { toRuntimeStylesheetModule, rewriteInlinedCssUrls } from "./372.mjs";
8
+ import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
5
9
  import * as __rspack_external_node_path_c5b9b54f from "node:path";
10
+ function reportDeadRefs(loader, source, manifestDir, publicRoot) {
11
+ const roots = [
12
+ publicRoot,
13
+ manifestDir
14
+ ];
15
+ const resourcePath = canonicalizeResourcePath(loader.resourcePath);
16
+ const issuerDir = __rspack_external_node_path_c5b9b54f.dirname(resourcePath);
17
+ const issuerPath = toPosixPath(__rspack_external_node_path_c5b9b54f.relative(manifestDir, resourcePath) || resourcePath);
18
+ const strict = 'true' === process.env.EXTENSION_STRICT_REFS;
19
+ const compilation = loader._compilation;
20
+ for (const request of extractCssUrlRefs(source)){
21
+ if (!isDeadCssUrlRef(request, {
22
+ issuerDir,
23
+ roots
24
+ })) continue;
25
+ const report = new WebpackError(deadCssUrlRef(issuerPath, request));
26
+ report.file = issuerPath;
27
+ const sink = strict ? compilation?.errors : compilation?.warnings;
28
+ if (sink) sink.push(report);
29
+ else if (strict) loader.emitError(report);
30
+ else loader.emitWarning(report);
31
+ }
32
+ }
33
+ function emitTargets(loader, source, manifestDir, publicRoot, sheet) {
34
+ const { css, targets } = rewriteInlinedCssUrls(source, {
35
+ resourcePath: canonicalizeResourcePath(loader.resourcePath),
36
+ manifestDir,
37
+ publicRoot
38
+ });
39
+ if ('function' != typeof loader.emitFile) return source;
40
+ for (const target of targets){
41
+ if (!target.publicOwned || 'chunk' === sheet) loader.emitFile(target.outputName, __rspack_external_node_fs_5ea92f0c.readFileSync(target.absolutePath));
42
+ loader.addDependency?.(target.absolutePath);
43
+ }
44
+ return css;
45
+ }
6
46
  function deadCssUrlLoader(source) {
47
+ let css = source;
48
+ const options = this.getOptions() || {};
7
49
  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);
50
+ const { manifestPath, projectPath } = options;
51
+ if (manifestPath && projectPath) {
52
+ const manifestDir = canonicalizeDir(__rspack_external_node_path_c5b9b54f.dirname(manifestPath));
53
+ const publicRoot = canonicalizeDir(publicFolderOrDefault(manifestPath, projectPath));
54
+ reportDeadRefs(this, source, manifestDir, publicRoot);
55
+ css = emitTargets(this, source, manifestDir, publicRoot, options.sheet);
30
56
  }
31
57
  } catch {}
32
- return source;
58
+ if ('chunk' === options.sheet) return css;
59
+ return toRuntimeStylesheetModule(css);
33
60
  }
34
61
  export default deadCssUrlLoader;
@@ -1,3 +1,4 @@
1
1
  import type { RspackDevServer } from '@rspack/dev-server';
2
2
  import type { PortManager } from './port-manager';
3
- export declare function setupCleanupHandlers(devServer: RspackDevServer, portManager: PortManager): () => void;
3
+ export type DevServerHandle = RspackDevServer | (() => RspackDevServer | null | undefined);
4
+ export declare function setupCleanupHandlers(devServer: DevServerHandle, portManager: PortManager): () => void;