extension-develop 4.0.21 → 4.0.22-canary.1785348713.017c274a

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 (30) hide show
  1. package/dist/0~dev-server.mjs +2 -1
  2. package/dist/0~rspack-config.mjs +137 -189
  3. package/dist/0~stats-handler.mjs +74 -10
  4. package/dist/101.mjs +98 -107
  5. package/dist/266.mjs +41 -9
  6. package/dist/839.mjs +68 -17
  7. package/dist/845.mjs +25 -29
  8. package/dist/dev-server/compiler-hooks.d.ts +1 -0
  9. package/dist/dev-server/messages.d.ts +1 -1
  10. package/dist/extension-js-devtools/chrome/content_scripts/content-0.js +2 -2
  11. package/dist/extension-js-devtools/chrome/pages/centralized-logger.js +4 -4
  12. package/dist/extension-js-devtools/chrome/pages/welcome.js +1 -1
  13. package/dist/extension-js-devtools/chromium/content_scripts/content-0.js +2 -2
  14. package/dist/extension-js-devtools/chromium/pages/centralized-logger.js +4 -4
  15. package/dist/extension-js-devtools/chromium/pages/welcome.js +1 -1
  16. package/dist/extension-js-devtools/edge/content_scripts/content-0.js +2 -2
  17. package/dist/extension-js-devtools/edge/pages/centralized-logger.js +4 -4
  18. package/dist/extension-js-devtools/edge/pages/welcome.js +1 -1
  19. package/dist/extension-js-devtools/firefox/content_scripts/content-0.js +2 -2
  20. package/dist/extension-js-devtools/firefox/pages/centralized-logger.js +4 -4
  21. package/dist/extension-js-devtools/firefox/pages/welcome.js +1 -1
  22. package/dist/lib/messages.d.ts +6 -8
  23. package/dist/lib/stats-handler.d.ts +13 -0
  24. package/dist/plugin-compilation/boring.d.ts +1 -1
  25. package/dist/plugin-compilation/compilation-lib/messages.d.ts +0 -2
  26. package/dist/plugin-compilation/index.d.ts +2 -0
  27. package/dist/plugin-compilation/zip-artifacts.d.ts +7 -0
  28. package/package.json +1 -1
  29. package/dist/0~branding.mjs +0 -26
  30. package/dist/plugin-compilation/compilation-lib/shared-state.d.ts +0 -7
package/dist/839.mjs CHANGED
@@ -2,10 +2,10 @@ import { createRequire as __extjsCreateRequire } from "node:module"; const requi
2
2
  import { createRequire } from "node:module";
3
3
  import { execFileSync, spawn, spawnSync as external_node_child_process_spawnSync } from "node:child_process";
4
4
  import { buildExecEnv, detectPackageManagerFromLockfile } from "prefers-yarn";
5
- import pintor from "pintor";
5
+ import "pintor";
6
6
  import { EventEmitter } from "node:events";
7
7
  import { browserRowValue, isDebug, CODES, ENVELOPE, prefix as messaging_prefix, claimCardKey, card } from "./349.mjs";
8
- import { package_namespaceObject, buildWarningsDetails, sanitize, getDirs, projectInstallFallbackToNpm, assertNoManagedDependencyConflicts, debugDirs, browserLaunchFailed, buildSuccess, extensionLoadRecovered, writingTypeDefinitionsError, extensionLoadStillRefused, projectInstallScriptsDisabled, authorInstallNotice, getSpecialFoldersDataForProjectRoot, buildSuccessWithWarnings, loadCommandConfig, needsInstall, buildCommandFailed, writingTypeDefinitions, buildWebpack, normalizeBrowser, debugBrowser, debugOutputPath, loadCustomConfig, devCommandFailed, getProjectStructure, getDistPath, resolveCompanionExtensionsConfig, loadBrowserConfig } from "./101.mjs";
8
+ import { package_namespaceObject, buildWarningsDetails, sanitize, buildFailed, getDirs, zipArtifactReady, projectInstallFallbackToNpm, assertNoManagedDependencyConflicts, debugDirs, browserLaunchFailed, extensionLoadRecovered, extensionLoadStillRefused, writingTypeDefinitionsError, projectInstallScriptsDisabled, authorInstallNotice, getSpecialFoldersDataForProjectRoot, buildAssetsTree, loadCommandConfig, needsInstall, buildCommandFailed, writingTypeDefinitions, buildComplete, normalizeBrowser, debugBrowser, debugOutputPath, loadCustomConfig, devCommandFailed, getProjectStructure, getDistPath, resolveCompanionExtensionsConfig, loadBrowserConfig } from "./101.mjs";
9
9
  import { stripBom, parseJsonSafe } from "./23.mjs";
10
10
  import { hasProjectDependency, findNearestProjectManifestDirSync } from "./80.mjs";
11
11
  import { buildSummaryPath, ensureSessionArtifactsIgnoreFile } from "./494.mjs";
@@ -14,6 +14,7 @@ import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
14
14
  import { dirname as __rspack_dirname } from "node:path";
15
15
  var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
16
16
  import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
17
+ import * as __rspack_external_node_os_74b4b876 from "node:os";
17
18
  import * as __rspack_external_node_path_c5b9b54f from "node:path";
18
19
  import * as __rspack_external_node_fs_promises_153e37e0 from "node:fs/promises";
19
20
  const MAX_OUTPUT_CHARS = 2000;
@@ -804,7 +805,7 @@ function isUsingIntegration(name) {
804
805
  return `integration use=${name}`;
805
806
  }
806
807
  function creatingTSConfig() {
807
- return `${messaging_prefix('info')} Create a default tsconfig.json.`;
808
+ return `${messaging_prefix('info')} Creating a default tsconfig.json…`;
808
809
  }
809
810
  function isUsingCustomLoader(loaderPath) {
810
811
  return `${messaging_prefix('debug')} loader custom=${loaderPath}`;
@@ -918,6 +919,32 @@ function writeTsConfig(projectPath) {
918
919
  mode: 'development'
919
920
  }), null, 2));
920
921
  }
922
+ const ARTIFACTS_KEY = '__extensionJsZipArtifacts';
923
+ function recordZipArtifact(carrier, artifact) {
924
+ if (!carrier || 'object' != typeof carrier) return;
925
+ const host = carrier;
926
+ if (!Array.isArray(host[ARTIFACTS_KEY])) host[ARTIFACTS_KEY] = [];
927
+ host[ARTIFACTS_KEY].push(artifact);
928
+ }
929
+ function getZipArtifacts(carrier) {
930
+ if (!carrier || 'object' != typeof carrier) return [];
931
+ const host = carrier;
932
+ return Array.isArray(host[ARTIFACTS_KEY]) ? host[ARTIFACTS_KEY] : [];
933
+ }
934
+ function collapseHomeDir(value) {
935
+ const home = __rspack_external_node_os_74b4b876.homedir();
936
+ if (!home || !value.startsWith(home)) return value;
937
+ const rest = value.slice(home.length);
938
+ if ('' === rest) return '~';
939
+ if (rest.startsWith(__rspack_external_node_path_c5b9b54f.sep) || rest.startsWith('/')) return `~${rest}`;
940
+ return value;
941
+ }
942
+ function relativeToCwd(target) {
943
+ const relative = __rspack_external_node_path_c5b9b54f.relative(process.cwd(), target);
944
+ if (relative && !relative.startsWith('..') && !__rspack_external_node_path_c5b9b54f.isAbsolute(relative)) return relative;
945
+ return null;
946
+ }
947
+ const reportedBuildFailures = new WeakSet();
921
948
  function printBuildCard(manifestPath, browser, distPath) {
922
949
  if (!claimCardKey(`${browser}::${__rspack_external_node_path_c5b9b54f.resolve(distPath)}`)) return;
923
950
  let extensionLabel = '';
@@ -945,7 +972,7 @@ function printBuildCard(manifestPath, browser, distPath) {
945
972
  },
946
973
  {
947
974
  label: 'Output',
948
- value: distPath
975
+ value: collapseHomeDir(distPath)
949
976
  }
950
977
  ]
951
978
  }));
@@ -960,7 +987,6 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
960
987
  const { manifestDir, packageJsonDir } = getDirs(projectStructure);
961
988
  const distPath = getDistPath(packageJsonDir, browser);
962
989
  const isAuthor = isDebug();
963
- printBuildCard(projectStructure.manifestPath, browser, distPath);
964
990
  try {
965
991
  await ensureDevelopArtifacts();
966
992
  if (buildOptions?.install !== false) await ensureUserProjectDependencies(packageJsonDir);
@@ -969,7 +995,7 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
969
995
  const [{ rspack }, { merge }, { handleStatsErrors }, { default: webpackConfig }] = await Promise.all([
970
996
  import("@rspack/core"),
971
997
  import("webpack-merge"),
972
- import("./0~stats-handler.mjs"),
998
+ import("./0~stats-handler.mjs").then((m)=>m.stats_handler_namespaceObject),
973
999
  import("./0~rspack-config.mjs").then((m)=>m.rspack_config_namespaceObject)
974
1000
  ]);
975
1001
  const debug = isAuthor;
@@ -1033,12 +1059,29 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
1033
1059
  return reject(err);
1034
1060
  }
1035
1061
  if (!stats || 'function' != typeof stats.hasErrors) return reject(new Error('Build failed: bundler returned invalid stats output (no reliable compilation result).'));
1036
- if (!buildOptions?.silent && stats) try {
1037
- humanLine(buildWebpack(manifestDir, stats, browser));
1062
+ try {
1063
+ printBuildCard(projectStructure.manifestPath, browser, distPath);
1064
+ if (!buildOptions?.silent) {
1065
+ const assetsTree = buildAssetsTree(stats);
1066
+ if (assetsTree) humanLine(assetsTree);
1067
+ }
1038
1068
  } catch {}
1039
1069
  if (stats.hasErrors()) {
1040
1070
  handleStatsErrors(stats);
1041
- if (!shouldExitOnError) return reject(new Error('Build failed with errors'));
1071
+ let errorCount = 1;
1072
+ try {
1073
+ const info = stats.toJson({
1074
+ all: false,
1075
+ errors: true
1076
+ });
1077
+ errorCount = Math.max(1, info?.errors?.length || 1);
1078
+ } catch {}
1079
+ console.error(buildFailed(errorCount));
1080
+ if (!shouldExitOnError) {
1081
+ const failure = new Error('Build failed with errors');
1082
+ reportedBuildFailures.add(failure);
1083
+ return reject(failure);
1084
+ }
1042
1085
  process.exit(1);
1043
1086
  } else {
1044
1087
  const info = stats?.toJson({
@@ -1057,10 +1100,15 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
1057
1100
  __rspack_external_node_fs_5ea92f0c.writeFileSync(summaryFile, JSON.stringify(summary));
1058
1101
  } catch {}
1059
1102
  if (summary.warnings_count > 0) {
1060
- humanLine(buildSuccessWithWarnings(summary.warnings_count));
1061
1103
  const warningDetails = buildWarningsDetails(info?.warnings || []);
1062
- if (warningDetails) humanLine(`\n${warningDetails}`);
1063
- } else humanLine(buildSuccess());
1104
+ if (warningDetails) humanLine(warningDetails);
1105
+ }
1106
+ const distDisplay = relativeToCwd(distPath) || collapseHomeDir(distPath);
1107
+ humanLine(buildComplete(browser, distDisplay, summary.total_bytes));
1108
+ for (const artifact of getZipArtifacts(stats.compilation)){
1109
+ const zipDisplay = relativeToCwd(artifact.path) || artifact.path;
1110
+ humanLine(zipArtifactReady(zipDisplay, artifact.size));
1111
+ }
1064
1112
  resolve();
1065
1113
  }
1066
1114
  });
@@ -1086,9 +1134,12 @@ async function extensionBuild(pathOrRemoteUrl, buildOptions) {
1086
1134
  }
1087
1135
  return summary;
1088
1136
  } catch (error) {
1089
- const isAuthor = isDebug();
1090
- if (isAuthor) console.error(error);
1091
- else console.error(buildCommandFailed(error));
1137
+ const alreadyReported = error instanceof Error && reportedBuildFailures.has(error);
1138
+ if (!alreadyReported) {
1139
+ if (isDebug()) console.error(error);
1140
+ else console.error(buildCommandFailed(error));
1141
+ console.error(buildFailed(1));
1142
+ }
1092
1143
  if (!shouldExitOnError) throw error;
1093
1144
  process.exit(1);
1094
1145
  }
@@ -1102,7 +1153,7 @@ function viaBroker(broker, instruction) {
1102
1153
  });
1103
1154
  }
1104
1155
  function formatReloadingLine(label) {
1105
- return `Reloading ${pintor.brightBlue(label)}…`;
1156
+ return `${messaging_prefix('info')} Reloading ${label}…`;
1106
1157
  }
1107
1158
  async function dispatchReload(instruction, executor) {
1108
1159
  if (!instruction) return;
@@ -1612,4 +1663,4 @@ async function extensionDev(pathOrRemoteUrl, devOptions) {
1612
1663
  process.exit(1);
1613
1664
  }
1614
1665
  }
1615
- export { BuildEmitter, attachLifecycleStream, buildSourceFeatureIndex, classifyReloadFromSources, createChangedSourcesTracker, createLifecycleStream, dispatchReload, ensureTypeScriptConfig, extensionBuild, extensionDev, getUserTypeScriptConfigFile, hasDependency, humanLine, isUsingCustomLoader, isUsingIntegration, isUsingTypeScript, jsFrameworksConfigsDetected, jsFrameworksHmrSummary, jsFrameworksIntegrationsEnabled, readContentScriptCount, resolveDevelopDistFile, resolveDevelopInstallRoot, resolvePackageManager };
1666
+ export { BuildEmitter, attachLifecycleStream, buildSourceFeatureIndex, classifyReloadFromSources, createChangedSourcesTracker, createLifecycleStream, dispatchReload, ensureTypeScriptConfig, extensionBuild, extensionDev, getUserTypeScriptConfigFile, hasDependency, humanLine, isUsingCustomLoader, isUsingIntegration, isUsingTypeScript, jsFrameworksConfigsDetected, jsFrameworksHmrSummary, jsFrameworksIntegrationsEnabled, readContentScriptCount, recordZipArtifact, resolveDevelopDistFile, resolveDevelopInstallRoot, resolvePackageManager };
package/dist/845.mjs CHANGED
@@ -15,56 +15,52 @@ function isUsingIntegration(name) {
15
15
  function missingSassDependency() {
16
16
  return [
17
17
  `${messaging_prefix('error')} Couldn't compile the Sass styles.`,
18
- `The ${pintor.brightBlue('"sass"')} package is not installed in your project.`,
19
- '',
20
- "Add it to your devDependencies, for example:",
21
- ` ${pintor.gray('npm install --save-dev sass')}`,
22
- ` ${pintor.gray('pnpm add -D sass')}`,
23
- '',
24
- 'Sample package.json:',
25
- ' {',
26
- ' "devDependencies": {',
27
- ` "sass": ${pintor.yellow('"<version>"')}`,
28
- ' }',
29
- ' }'
18
+ `The ${pintor.blue('sass')} package isn't installed in your project.`,
19
+ "Add it to your devDependencies:",
20
+ `- ${pintor.blue('npm install --save-dev sass')}`,
21
+ `- ${pintor.blue('pnpm add -D sass')}`
30
22
  ].join('\n');
31
23
  }
32
24
  function postCssPluginNotResolved(pluginName, projectPath) {
33
25
  return [
34
- `${messaging_prefix('warn')} PostCSS plugin ${pintor.brightBlue(`"${pluginName}"`)} could not be resolved from ${pintor.underline(projectPath)}.`,
26
+ `${messaging_prefix('warn')} Couldn't resolve the PostCSS plugin ${pintor.blue(pluginName)}.`,
35
27
  'The plugin was skipped so the build can continue.',
36
28
  'Styles it would generate are missing from the output.',
37
- `Install it in your project to re-enable it, for example: ${pintor.gray(`npm install --save-dev ${pluginName}`)}`
29
+ `${pintor.gray('PATH')} ${pintor.underline(projectPath)}`,
30
+ `Install it in your project to re-enable it: ${pintor.blue(`npm install --save-dev ${pluginName}`)}`
38
31
  ].join('\n');
39
32
  }
40
33
  function cssParseErrorShippedVerbatim(resourcePath, error) {
41
34
  const errObj = error;
42
35
  const reason = error && 'object' == typeof error && 'reason' in error ? String(errObj?.reason) : String(errObj?.message || error);
43
36
  return [
44
- `${messaging_prefix('warn')} Invalid CSS in ${pintor.underline(resourcePath)}.`,
45
- `Reason: ${reason}.`,
46
- 'Browsers skip invalid rules, so the stylesheet was copied as-is instead of failing the build.',
47
- 'PostCSS/Tailwind processing was NOT applied to this file.',
48
- 'Fix the CSS to re-enable it.'
37
+ `${messaging_prefix('warn')} The CSS in this file doesn't parse, so it was copied as-is.`,
38
+ `${pintor.gray('PATH')} ${pintor.underline(resourcePath)}`,
39
+ `${pintor.gray('REASON')} ${reason}`,
40
+ "Browsers skip rules they can't parse, so the build kept going.",
41
+ "PostCSS and Tailwind processing wasn't applied to this file.",
42
+ 'Fix the CSS to re-enable processing.'
49
43
  ].join('\n');
50
44
  }
51
45
  function preprocessorShippedUncompiled(resourcePath, tool) {
52
46
  const pkg = 'sass' === tool ? 'sass' : 'less';
47
+ const language = 'sass' === tool ? 'Sass/SCSS' : 'Less';
53
48
  return [
54
- `${messaging_prefix('warn')} ${pintor.underline(resourcePath)} shipped UNCOMPILED.`,
55
- `The ${pintor.brightBlue(`"${pkg}"`)} package is not installed in this project.`,
56
- `The raw ${'sass' === tool ? 'Sass/SCSS' : 'Less'} source was copied as-is into the output .css, which browsers will treat as broken CSS (unstyled surfaces).`,
57
- `Install it to compile this file, for example: ${pintor.gray(`npm install --save-dev ${pkg}`)}`
49
+ `${messaging_prefix('warn')} This ${language} file shipped uncompiled.`,
50
+ `${pintor.gray('PATH')} ${pintor.underline(resourcePath)}`,
51
+ `The ${pintor.blue(pkg)} package isn't installed in this project.`,
52
+ `The raw ${language} source was copied as-is into the output .css.`,
53
+ "Browsers treat it as broken CSS, so those surfaces render unstyled.",
54
+ `Install it to compile this file: ${pintor.blue(`npm install --save-dev ${pkg}`)}`
58
55
  ].join('\n');
59
56
  }
60
57
  function deadCssUrlRef(issuerPath, request) {
61
58
  return [
62
- `Missing file in ${pintor.underline(issuerPath)}.`,
63
- `The ${pintor.yellow(`url(${request})`)} reference points to a file that exists nowhere in the project.`,
64
- "Chrome applies the rest of the stylesheet and 404s this reference silently, so it is likely dead code.",
65
- `Set ${pintor.yellow('EXTENSION_STRICT_REFS=true')} to make this a build error.`,
66
- '',
67
- `${pintor.red('NOT FOUND')} ${pintor.underline(request)}`
59
+ `A ${pintor.blue(`url(${request})`)} reference points to a file that exists nowhere in the project.`,
60
+ `${pintor.gray('PATH')} ${pintor.underline(issuerPath)}`,
61
+ `${pintor.gray('NOT FOUND')} ${pintor.underline(request)}`,
62
+ "Chrome applies the rest of the stylesheet and 404s this reference silently, so it's likely dead code.",
63
+ `Set ${pintor.blue('EXTENSION_STRICT_REFS=true')} to make this a build error.`
68
64
  ].join('\n');
69
65
  }
70
66
  export { cssConfigsDetected, cssIntegrationsEnabled, cssParseErrorShippedVerbatim, deadCssUrlRef, isUsingIntegration, missingSassDependency, postCssPluginNotResolved, preprocessorShippedUncompiled };
@@ -5,5 +5,6 @@ export declare function setupNoBrowserBannerOnFirstDone(opts: {
5
5
  browser: string;
6
6
  manifestPath: string;
7
7
  readyPath: string;
8
+ distPath?: string;
8
9
  }): void;
9
10
  export declare function setupCompilerDoneDiagnostics(compiler: Compiler, port?: number): void;
@@ -3,7 +3,7 @@ export declare function browserRunnerDisabled(args: {
3
3
  browser: string;
4
4
  manifestPath: string;
5
5
  readyPath: string;
6
- browserModeLabel?: string;
6
+ distPath?: string;
7
7
  }): string;
8
8
  export declare function portInUse(requestedPort: number, newPort: number): string;
9
9
  export declare function extensionJsRunnerError(error: unknown): string;