extension-develop 4.1.3 → 4.1.4

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.
@@ -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, PlaywrightPlugin, isGeckoBasedBrowser, spacerLine, isWebkitBasedBrowser, messages_ready, CHROMIUM_FAMILY_ALIASES, treeWithSourceAndDistFiles, computeExtensionsToLoad, noCompanionExtensionsResolved, treeWithSourceFiles, bundlerFatalError, bundlerRecompiling, noEntrypointsDetected, GECKO_FAMILY_ALIASES, packagingSourceFiles, debugBrowser, debugOutputPath, manifestInvalidJson, isChromiumBasedBrowser, getSpecialFoldersDataForCompiler } from "./101.mjs";
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";
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";
@@ -1223,10 +1223,12 @@ class EnvPlugin {
1223
1223
  }
1224
1224
  const envVars = envPath ? __rspack_external_dotenv.parse(__rspack_external_node_fs_5ea92f0c.readFileSync(envPath)) : {};
1225
1225
  const defaultsVars = __rspack_external_node_fs_5ea92f0c.existsSync(defaultsPath) ? __rspack_external_dotenv.parse(__rspack_external_node_fs_5ea92f0c.readFileSync(defaultsPath)) : {};
1226
+ const preloadedKeys = getPreloadedEnvKeys();
1227
+ const systemEnv = Object.fromEntries(Object.entries(process.env).filter(([key])=>!preloadedKeys.has(key)));
1226
1228
  const combinedVars = {
1227
1229
  ...defaultsVars,
1228
1230
  ...envVars,
1229
- ...process.env
1231
+ ...systemEnv
1230
1232
  };
1231
1233
  const filteredEnvVars = Object.keys(combinedVars).filter((key)=>key.startsWith('EXTENSION_PUBLIC_')).reduce((obj, key)=>{
1232
1234
  obj[`process.env.${key}`] = JSON.stringify(combinedVars[key]);
@@ -7420,15 +7422,6 @@ function emitRootAbsoluteRefs(compilation, context, publicDir) {
7420
7422
  if (0 === emitted) return;
7421
7423
  }
7422
7424
  }
7423
- function serverRestartRequiredFromSpecialFolderMessageOnly(addingOrRemoving, folder, typeOfAsset) {
7424
- return `${messaging_prefix('warn')} ${addingOrRemoving} ${pintor.yellow(typeOfAsset)} in ${pintor.underline(`${folder}/`)} changes the extension entrypoints.\nRestart the dev server to apply the change.`;
7425
- }
7426
- function specialFoldersSetupSummary(hasPublic, copyEnabled, ignoredCount) {
7427
- return `${messaging_prefix('debug')} folders setup public=${String(hasPublic)} copy=${String(copyEnabled)} ignored=${String(ignoredCount)}`;
7428
- }
7429
- function specialFolderChangeDetected(action, folder, relativePath) {
7430
- return `${messaging_prefix('debug')} folders change=${action} scope=${folder} path=${relativePath}`;
7431
- }
7432
7425
  class WarnUponFolderChanges {
7433
7426
  pendingChanges = [];
7434
7427
  knownFolderFiles = new Set();
package/dist/101.mjs CHANGED
@@ -422,6 +422,15 @@ function managedDependencyConflict(duplicates, userPackageJsonPath) {
422
422
  const list = duplicates.map((d)=>`- ${pintor.yellow(d)}`).join('\n');
423
423
  return `${getLoggingPrefix('error')} Your project declares dependencies that Extension.js already manages, so the build was aborted.\n${pintor.red('Duplicate declarations can cause version conflicts and break the build.')}\n\n${pintor.gray('Remove these from your package.json:')}\n${list}\n\n${pintor.gray('PATH')} ${pintor.underline(userPackageJsonPath)}\nIf you need a different version, open an issue so we can consider bundling it safely.`;
424
424
  }
425
+ const preloadedEnvKeys = new Set();
426
+ function getPreloadedEnvKeys() {
427
+ return preloadedEnvKeys;
428
+ }
429
+ function recordPreloadedKeys(filePath) {
430
+ try {
431
+ for (const key of Object.keys(dotenv.parse(__rspack_external_node_fs_5ea92f0c.readFileSync(filePath))))if (!(key in process.env)) preloadedEnvKeys.add(key);
432
+ } catch {}
433
+ }
425
434
  function loadCommonJsConfigWithStableDirname(absolutePath) {
426
435
  const code = __rspack_external_node_fs_5ea92f0c.readFileSync(absolutePath, 'utf-8');
427
436
  const dirname = __rspack_external_node_path_c5b9b54f.dirname(absolutePath);
@@ -451,6 +460,7 @@ function preloadEnvFilesFromDir(envDir, options) {
451
460
  try {
452
461
  const defaultsPath = __rspack_external_node_path_c5b9b54f.join(envDir, '.env.defaults');
453
462
  if (__rspack_external_node_fs_5ea92f0c.existsSync(defaultsPath)) {
463
+ recordPreloadedKeys(defaultsPath);
454
464
  dotenv.config({
455
465
  path: defaultsPath,
456
466
  override: Boolean(options?.override),
@@ -466,6 +476,7 @@ function preloadEnvFilesFromDir(envDir, options) {
466
476
  for (const filename of envCandidates){
467
477
  const filePath = __rspack_external_node_path_c5b9b54f.join(envDir, filename);
468
478
  if (__rspack_external_node_fs_5ea92f0c.existsSync(filePath)) {
479
+ recordPreloadedKeys(filePath);
469
480
  dotenv.config({
470
481
  path: filePath,
471
482
  override: Boolean(options?.override),
@@ -688,7 +699,7 @@ async function config_loader_isUsingExperimentalConfig(projectPath) {
688
699
  }
689
700
  return false;
690
701
  }
691
- var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.1.3","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.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"}}');
692
703
  function asAbsolute(p) {
693
704
  return __rspack_external_node_path_c5b9b54f.isAbsolute(p) ? p : __rspack_external_node_path_c5b9b54f.resolve(p);
694
705
  }
@@ -1857,6 +1868,19 @@ async function resolveCompanionExtensionsConfig(opts) {
1857
1868
  if (resolvedPaths.length > 0) output.paths = resolvedPaths;
1858
1869
  return output;
1859
1870
  }
1871
+ function serverRestartRequiredFromSpecialFolderMessageOnly(addingOrRemoving, folder, typeOfAsset) {
1872
+ return `${messaging_prefix('warn')} ${addingOrRemoving} ${pintor.yellow(typeOfAsset)} in ${pintor.underline(`${folder}/`)} changes the extension entrypoints.\nRestart the dev server to apply the change.`;
1873
+ }
1874
+ function specialFoldersSetupSummary(hasPublic, copyEnabled, ignoredCount) {
1875
+ return `${messaging_prefix('debug')} folders setup public=${String(hasPublic)} copy=${String(copyEnabled)} ignored=${String(ignoredCount)}`;
1876
+ }
1877
+ function specialFolderChangeDetected(action, folder, relativePath) {
1878
+ return `${messaging_prefix('debug')} folders change=${action} scope=${folder} path=${relativePath}`;
1879
+ }
1880
+ function unreferencedScriptDropped(relativePaths) {
1881
+ const list = relativePaths.map((entry)=>` ${pintor.yellow(entry)}`).join('\n');
1882
+ return `${messaging_prefix('warn')} Dropped ${relativePaths.length} unreferenced ${1 === relativePaths.length ? 'entry' : 'entries'} from ${pintor.yellow("scripts/")}:\n${list}\nNothing in this project mentions ${1 === relativePaths.length ? 'that path' : 'those paths'}, so ${1 === relativePaths.length ? 'it was' : 'they were'} treated as dead code. Reference the path where you inject it (for example in the ${pintor.yellow("chrome.scripting.executeScript")} call) to keep ${1 === relativePaths.length ? 'it' : 'them'} in the build.`;
1883
+ }
1860
1884
  const NODE_BUILTINS = new Set([
1861
1885
  'assert',
1862
1886
  'buffer',
@@ -2034,6 +2058,7 @@ function collectReferenceCorpus(projectRoot) {
2034
2058
  walk(projectRoot);
2035
2059
  return 0 === files ? '' : parts.join('\n');
2036
2060
  }
2061
+ const warnedDroppedScripts = new Set();
2037
2062
  function filterUnreferencedScripts(list, projectRoot) {
2038
2063
  const entries = Object.entries(list || {});
2039
2064
  if (0 === entries.length) return list || {};
@@ -2046,13 +2071,26 @@ function filterUnreferencedScripts(list, projectRoot) {
2046
2071
  return corpus.includes(rel);
2047
2072
  };
2048
2073
  const next = {};
2074
+ const dropped = [];
2049
2075
  for (const [key, value] of entries){
2050
2076
  const paths = Array.isArray(value) ? value : value ? [
2051
2077
  value
2052
2078
  ] : [];
2053
2079
  const kept = paths.filter(isReferenced);
2080
+ for (const entry of paths){
2081
+ if (kept.includes(entry)) continue;
2082
+ const abs = String(entry);
2083
+ dropped.push(node_path.isAbsolute(abs) ? node_path.relative(projectRoot, abs).split(node_path.sep).join('/') : abs);
2084
+ }
2054
2085
  if (0 !== kept.length) next[key] = Array.isArray(value) ? kept : kept[0];
2055
2086
  }
2087
+ if (dropped.length > 0) {
2088
+ const signature = dropped.slice().sort().join('|');
2089
+ if (!warnedDroppedScripts.has(signature)) {
2090
+ warnedDroppedScripts.add(signature);
2091
+ humanWarn(unreferencedScriptDropped(dropped));
2092
+ }
2093
+ }
2056
2094
  return next;
2057
2095
  }
2058
2096
  function isUnderPublicDir(entry, projectRoot, publicDir) {
@@ -2541,4 +2579,4 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
2541
2579
  await browserLauncher(resolvedOpts);
2542
2580
  metadata.writeReady();
2543
2581
  }
2544
- export { BUILD_COMMAND_DEFAULTS, CHROMIUM_FAMILY_ALIASES, DEV_COMMAND_DEFAULTS, GECKO_FAMILY_ALIASES, PlaywrightPlugin, START_BUILD_DEFAULTS, asAbsolute, assertNoManagedDependencyConflicts, authorInstallNotice, autoExitForceKill, autoExitModeEnabled, autoExitTriggered, browserLaunchFailed, browserRunnerDisabled, buildAssetsTree, buildCommandFailed, buildComplete, buildFailed, buildShareHint, buildWarningsDetails, bundlerFatalError, bundlerRecompiling, computeExtensionsToLoad, createPlaywrightMetadataWriter, debugBrowser, debugContextPath, debugDirs, debugExtensionsToLoad, debugOutputPath, devCommandFailed, devServerStartTimeout, downloadingText, extensionJsRunnerError, extensionLoadRecovered, extensionLoadStillRefused, extensionPreview, failedToDownloadOrExtractZIPFileError, getDirs, getDistPath, getProjectStructure, getSessionRunId, getSpecialFoldersDataForCompiler, getSpecialFoldersDataForProjectRoot, invalidRemoteZip, isChromiumBasedBrowser, isGeckoBasedBrowser, isWebkitBasedBrowser, loadBrowserConfig, loadCommandConfig, loadCustomConfig, localZipNotFound, manifestInvalidJson, mergeOptionLayers, messages_ready, needsInstall, noCompanionExtensionsResolved, noEntrypointsDetected, normalizeBrowser, notAZipArchive, package_namespaceObject, packagingDistributionFiles, packagingSourceFiles, portInUse, projectInstallFallbackToNpm, projectInstallScriptsDisabled, resolveCompanionExtensionDirs, resolveCompanionExtensionsConfig, sanitize, shouldWarnPortConflict, spacerLine, stampReadyDistExtensionId, stampReadyKnownExtensionId, toPosixPath, treeWithDistFilesBrowser, treeWithSourceAndDistFiles, treeWithSourceFiles, unpackagedSuccessfully, unpackagingExtension, withDarkMode, writingTypeDefinitions, writingTypeDefinitionsError, zipArtifactReady };
2582
+ export { BUILD_COMMAND_DEFAULTS, CHROMIUM_FAMILY_ALIASES, DEV_COMMAND_DEFAULTS, GECKO_FAMILY_ALIASES, PlaywrightPlugin, START_BUILD_DEFAULTS, asAbsolute, assertNoManagedDependencyConflicts, authorInstallNotice, autoExitForceKill, autoExitModeEnabled, autoExitTriggered, browserLaunchFailed, browserRunnerDisabled, buildAssetsTree, buildCommandFailed, buildComplete, buildFailed, buildShareHint, buildWarningsDetails, bundlerFatalError, bundlerRecompiling, computeExtensionsToLoad, createPlaywrightMetadataWriter, debugBrowser, debugContextPath, debugDirs, debugExtensionsToLoad, debugOutputPath, devCommandFailed, devServerStartTimeout, downloadingText, extensionJsRunnerError, extensionLoadRecovered, extensionLoadStillRefused, extensionPreview, failedToDownloadOrExtractZIPFileError, getDirs, getDistPath, getPreloadedEnvKeys, getProjectStructure, getSessionRunId, getSpecialFoldersDataForCompiler, getSpecialFoldersDataForProjectRoot, invalidRemoteZip, isChromiumBasedBrowser, isGeckoBasedBrowser, isWebkitBasedBrowser, loadBrowserConfig, loadCommandConfig, loadCustomConfig, localZipNotFound, manifestInvalidJson, mergeOptionLayers, messages_ready, needsInstall, noCompanionExtensionsResolved, noEntrypointsDetected, normalizeBrowser, notAZipArchive, package_namespaceObject, packagingDistributionFiles, packagingSourceFiles, portInUse, projectInstallFallbackToNpm, projectInstallScriptsDisabled, resolveCompanionExtensionDirs, resolveCompanionExtensionsConfig, sanitize, serverRestartRequiredFromSpecialFolderMessageOnly, shouldWarnPortConflict, spacerLine, specialFolderChangeDetected, specialFoldersSetupSummary, stampReadyDistExtensionId, stampReadyKnownExtensionId, toPosixPath, treeWithDistFilesBrowser, treeWithSourceAndDistFiles, treeWithSourceFiles, unpackagedSuccessfully, unpackagingExtension, withDarkMode, writingTypeDefinitions, writingTypeDefinitionsError, zipArtifactReady };
@@ -1,5 +1,6 @@
1
1
  import type { Configuration } from '@rspack/core';
2
2
  import type { BrowserConfig, DevOptions } from '../types';
3
+ export declare function getPreloadedEnvKeys(): ReadonlySet<string>;
3
4
  export declare function loadCustomConfig(projectPath: string): Promise<(config: Configuration) => Configuration>;
4
5
  export declare function loadCommandConfig(projectPath: string, command: 'dev' | 'build' | 'start' | 'preview'): Promise<{
5
6
  extensions: import("../module").CompanionExtensionsConfig;
@@ -1,3 +1,4 @@
1
1
  export declare function serverRestartRequiredFromSpecialFolderMessageOnly(addingOrRemoving: string, folder: string, typeOfAsset: string): string;
2
2
  export declare function specialFoldersSetupSummary(hasPublic: boolean, copyEnabled: boolean, ignoredCount: number): string;
3
3
  export declare function specialFolderChangeDetected(action: 'add' | 'remove', folder: 'pages' | 'scripts', relativePath: string): string;
4
+ export declare function unreferencedScriptDropped(relativePaths: string[]): string;
package/package.json CHANGED
@@ -43,7 +43,7 @@
43
43
  "runtime"
44
44
  ],
45
45
  "name": "extension-develop",
46
- "version": "4.1.3",
46
+ "version": "4.1.4",
47
47
  "description": "Develop, build, preview, and package Extension.js projects.",
48
48
  "author": {
49
49
  "name": "Cezar Augusto",