extension-develop 4.0.33 → 4.0.35

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.
@@ -2720,6 +2720,9 @@ async function buildCssRules(projectPath, mode, usage, opts) {
2720
2720
  if (missingTool) use.push({
2721
2721
  loader: resolveDevelopDistFile('preprocessor-passthrough-loader')
2722
2722
  });
2723
+ if ('css' === type || 'css/module' === type) use.unshift({
2724
+ loader: resolveDevelopDistFile('late-css-import-loader')
2725
+ });
2723
2726
  return {
2724
2727
  test,
2725
2728
  exclude,
@@ -7103,10 +7106,6 @@ function manifestDeclaredSourcePaths(manifest) {
7103
7106
  add(manifest.side_panel?.default_path);
7104
7107
  add(manifest.sidebar_action?.default_panel);
7105
7108
  for (const page of Object.values(manifest.chrome_url_overrides ?? {}))add(page);
7106
- for (const contentScript of manifest.content_scripts ?? []){
7107
- for (const js of contentScript?.js ?? [])add(js);
7108
- for (const css of contentScript?.css ?? [])add(css);
7109
- }
7110
7109
  return declared;
7111
7110
  }
7112
7111
  function extractGetURLLiterals(source) {
@@ -7646,16 +7645,85 @@ class StaticAssetsPlugin {
7646
7645
  return Boolean(rule && rule.test instanceof RegExp && rule.test.test(sample) && (void 0 !== rule.type || void 0 !== rule.use) && void 0 === rule.resourceQuery);
7647
7646
  };
7648
7647
  const scopedQueriesFor = (sample)=>compiler.options.module.rules.map((thisRule)=>thisRule).filter((rule)=>Boolean(rule && rule.test instanceof RegExp && rule.test.test(sample) && (void 0 !== rule.type || void 0 !== rule.use) && rule.resourceQuery instanceof RegExp)).map((rule)=>rule?.resourceQuery);
7649
- const hasCustomSvgRule = compiler.options.module.rules.some((thisRule)=>isFullCustomRuleFor(thisRule, '.svg'));
7648
+ const IMAGE_EXTENSIONS = [
7649
+ 'png',
7650
+ 'jpg',
7651
+ 'jpeg',
7652
+ 'gif',
7653
+ 'webp',
7654
+ 'avif',
7655
+ 'ico',
7656
+ 'bmp'
7657
+ ];
7658
+ const FONT_EXTENSIONS = [
7659
+ 'woff',
7660
+ 'woff2',
7661
+ 'eot',
7662
+ 'ttf',
7663
+ 'otf'
7664
+ ];
7665
+ const FILE_EXTENSIONS = [
7666
+ 'txt',
7667
+ 'md',
7668
+ 'csv',
7669
+ 'tsv',
7670
+ 'xml',
7671
+ 'pdf',
7672
+ 'docx',
7673
+ 'doc',
7674
+ 'xls',
7675
+ 'xlsx',
7676
+ 'ppt',
7677
+ 'pptx',
7678
+ 'zip',
7679
+ 'gz',
7680
+ 'gzip',
7681
+ 'tgz'
7682
+ ];
7683
+ const unclaimedExtensions = (extensions)=>extensions.filter((ext)=>!compiler.options.module.rules.some((thisRule)=>isFullCustomRuleFor(thisRule, `.${ext}`)));
7684
+ const scopedQueriesForAll = (extensions)=>{
7685
+ const seen = new Set();
7686
+ for (const ext of extensions)for (const query of scopedQueriesFor(`.${ext}`))seen.add(query);
7687
+ return Array.from(seen);
7688
+ };
7689
+ const inlineKB = 2;
7690
+ const defaultRuleFor = (extensions, inline)=>{
7691
+ const remaining = unclaimedExtensions(extensions);
7692
+ if (!remaining.length) return null;
7693
+ const scoped = scopedQueriesForAll(remaining);
7694
+ return {
7695
+ test: new RegExp(`\\.(${remaining.join('|')})$`, 'i'),
7696
+ type: 'asset',
7697
+ generator: {
7698
+ filename: filenamePattern
7699
+ },
7700
+ ...inline ? {
7701
+ parser: {
7702
+ dataUrlCondition: {
7703
+ maxSize: 1024 * inlineKB
7704
+ }
7705
+ }
7706
+ } : {},
7707
+ ...scoped.length ? {
7708
+ resourceQuery: {
7709
+ not: scoped
7710
+ }
7711
+ } : {}
7712
+ };
7713
+ };
7714
+ const hasCustomSvgRule = 0 === unclaimedExtensions([
7715
+ 'svg'
7716
+ ]).length;
7717
+ const imagesRule = defaultRuleFor(IMAGE_EXTENSIONS, true);
7718
+ const fontsRule = defaultRuleFor(FONT_EXTENSIONS, true);
7719
+ const filesRule = defaultRuleFor(FILE_EXTENSIONS, true);
7650
7720
  const hasUrlResourceQueryRule = compiler.options.module.rules.some((thisRule)=>{
7651
7721
  const rule = thisRule;
7652
7722
  const resourceQuery = rule?.resourceQuery;
7653
7723
  if (!(resourceQuery instanceof RegExp)) return false;
7654
7724
  return resourceQuery.test('?url');
7655
7725
  });
7656
- const hasCustomFontsRule = compiler.options.module.rules.some((thisRule)=>isFullCustomRuleFor(thisRule, '.woff'));
7657
7726
  const svgScopedQueries = scopedQueriesFor('.svg');
7658
- const fontsScopedQueries = scopedQueriesFor('.woff');
7659
7727
  const loaders = [
7660
7728
  ...hasCustomSvgRule ? [] : [
7661
7729
  svgScopedQueries.length ? {
@@ -7665,44 +7733,15 @@ class StaticAssetsPlugin {
7665
7733
  }
7666
7734
  } : defaultSvgRule
7667
7735
  ],
7668
- {
7669
- test: /\.(png|jpg|jpeg|gif|webp|avif|ico|bmp)$/i,
7670
- type: 'asset',
7671
- generator: {
7672
- filename: filenamePattern
7673
- },
7674
- parser: {
7675
- dataUrlCondition: {
7676
- maxSize: 2048
7677
- }
7678
- }
7679
- },
7680
- ...hasCustomFontsRule ? [] : [
7681
- {
7682
- test: /\.(woff|woff2|eot|ttf|otf)$/i,
7683
- type: 'asset',
7684
- generator: {
7685
- filename: filenamePattern
7686
- },
7687
- ...fontsScopedQueries.length ? {
7688
- resourceQuery: {
7689
- not: fontsScopedQueries
7690
- }
7691
- } : {}
7692
- }
7693
- ],
7694
- {
7695
- test: /\.(txt|md|csv|tsv|xml|pdf|docx|doc|xls|xlsx|ppt|pptx|zip|gz|gzip|tgz)$/i,
7696
- type: 'asset',
7697
- generator: {
7698
- filename: filenamePattern
7699
- },
7700
- parser: {
7701
- dataUrlCondition: {
7702
- maxSize: 2048
7703
- }
7704
- }
7705
- },
7736
+ ...imagesRule ? [
7737
+ imagesRule
7738
+ ] : [],
7739
+ ...fontsRule ? [
7740
+ fontsRule
7741
+ ] : [],
7742
+ ...filesRule ? [
7743
+ filesRule
7744
+ ] : [],
7706
7745
  ...hasUrlResourceQueryRule ? [] : [
7707
7746
  {
7708
7747
  resourceQuery: /(?:^\?|&)url(?:&|=|$)/,
@@ -7720,11 +7759,10 @@ class StaticAssetsPlugin {
7720
7759
  if (isDebug()) {
7721
7760
  const rulesEnabled = [];
7722
7761
  rulesEnabled.push(hasCustomSvgRule ? 'SVG(custom)' : 'SVG(default)');
7723
- rulesEnabled.push('Images');
7724
- rulesEnabled.push('Fonts');
7725
- rulesEnabled.push('Files');
7762
+ rulesEnabled.push(imagesRule ? 'Images' : 'Images(custom)');
7763
+ rulesEnabled.push(fontsRule ? 'Fonts' : 'Fonts(custom)');
7764
+ rulesEnabled.push(filesRule ? 'Files' : 'Files(custom)');
7726
7765
  console.log(assetsRulesEnabled(rulesEnabled));
7727
- const inlineKB = 2;
7728
7766
  console.log(assetsConfigsDetected(filenamePattern, hasCustomSvgRule ? 'custom' : 'default', hasCustomSvgRule ? void 0 : inlineKB, inlineKB, inlineKB));
7729
7767
  compiler.hooks.afterEmit.tap(StaticAssetsPlugin.name, (compilation)=>{
7730
7768
  try {
@@ -12588,7 +12626,9 @@ class AddScripts {
12588
12626
  createSequentialEntryModule(feature, scriptImports),
12589
12627
  ...cssImports
12590
12628
  ] : entryImports;
12591
- if (finalEntryImports.length) newEntries[feature] = 'background/service_worker' === feature ? {
12629
+ if (!finalEntryImports.length) continue;
12630
+ const runsAsWorker = 'background/service_worker' === feature || isBackgroundScriptsFeature(feature) && 3 === Number(manifestJson.manifest_version) && !isGeckoBasedBrowser(String(this.browser));
12631
+ newEntries[feature] = runsAsWorker ? {
12592
12632
  import: finalEntryImports,
12593
12633
  ...manifestJson.background?.type === 'module' ? {} : {
12594
12634
  chunkLoading: "import-scripts"
package/dist/101.mjs CHANGED
@@ -94,6 +94,9 @@ function manifestNotFoundError(manifestPath, candidates = []) {
94
94
  }).join('\n');
95
95
  return `${base}\n\n${pintor.gray(hint)}\n${pintor.blue(suggestions)}`;
96
96
  }
97
+ function previewingSourceFallback(browser, distDir) {
98
+ return `${getLoggingPrefix('warn')} No production build found at ${distDir}, previewing the source manifest directory instead.\nRun \`extension build --browser ${String(browser)}\` first to preview the built output.`;
99
+ }
97
100
  function previewing(browser, noBrowser) {
98
101
  const suffix = noBrowser ? ' (no-browser mode)' : '';
99
102
  return `${getLoggingPrefix('info')} Previewing on ${capitalizedBrowserName(browser)}${suffix}.`;
@@ -145,16 +148,19 @@ function buildFailed(errorCount) {
145
148
  const noun = 1 === count ? 'error' : 'errors';
146
149
  return `${getLoggingPrefix('error')} Build failed with ${count} ${noun}.`;
147
150
  }
151
+ function stripModuleWarningWrapper(message) {
152
+ return message.replace(/^Module (?:Warning|Error) \(from [^)]*\):\s*/, '');
153
+ }
148
154
  function getWarningMessage(warning) {
149
155
  if (!warning) return '';
150
- if ('string' == typeof warning) return warning.trim();
156
+ if ('string' == typeof warning) return stripModuleWarningWrapper(warning.trim());
151
157
  const candidates = [
152
158
  warning.message,
153
159
  warning.details,
154
160
  warning.reason,
155
161
  warning.description
156
162
  ];
157
- for (const candidate of candidates)if ('string' == typeof candidate && candidate.trim()) return candidate.trim();
163
+ for (const candidate of candidates)if ('string' == typeof candidate && candidate.trim()) return stripModuleWarningWrapper(candidate.trim());
158
164
  return '';
159
165
  }
160
166
  function getWarningSource(warning) {
@@ -682,7 +688,7 @@ async function config_loader_isUsingExperimentalConfig(projectPath) {
682
688
  }
683
689
  return false;
684
690
  }
685
- var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.0.33","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"}}');
691
+ var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.0.35","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"}}');
686
692
  function asAbsolute(p) {
687
693
  return __rspack_external_node_path_c5b9b54f.isAbsolute(p) ? p : __rspack_external_node_path_c5b9b54f.resolve(p);
688
694
  }
@@ -2471,6 +2477,7 @@ async function extensionPreview(pathOrRemoteUrl, previewOptions, browserLauncher
2471
2477
  return;
2472
2478
  }
2473
2479
  humanLine(runningMessage(browser));
2480
+ if (!previewOptions.outputPath && __rspack_external_node_path_c5b9b54f.resolve(outputPath) !== __rspack_external_node_path_c5b9b54f.resolve(distPath)) humanLine(previewingSourceFallback(browser, distPath));
2474
2481
  const safeBrowserConfig = sanitize(browserConfig);
2475
2482
  const safeCommandConfig = sanitize(commandConfig);
2476
2483
  const safePreviewOptions = sanitize(previewOptions);
package/dist/845.mjs CHANGED
@@ -63,4 +63,13 @@ function deadCssUrlRef(issuerPath, request) {
63
63
  `Set ${pintor.blue('EXTENSION_STRICT_REFS=true')} to make this a build error.`
64
64
  ].join('\n');
65
65
  }
66
- export { cssConfigsDetected, cssIntegrationsEnabled, cssParseErrorShippedVerbatim, deadCssUrlRef, isUsingIntegration, missingSassDependency, postCssPluginNotResolved, preprocessorShippedUncompiled };
66
+ function lateCssImportIgnored(issuerPath, line) {
67
+ const where = line ? `${issuerPath}:${line}` : issuerPath;
68
+ return [
69
+ `An ${pintor.blue('@import')} rule comes after other rules, so browsers skip it.`,
70
+ `${pintor.gray('PATH')} ${pintor.underline(where)}`,
71
+ "Chrome applies the rest of the stylesheet and ignores this import, so the build kept going.",
72
+ `Move the ${pintor.blue('@import')} above every other rule to make it load.`
73
+ ].join('\n');
74
+ }
75
+ export { cssConfigsDetected, cssIntegrationsEnabled, cssParseErrorShippedVerbatim, deadCssUrlRef, isUsingIntegration, lateCssImportIgnored, missingSassDependency, postCssPluginNotResolved, preprocessorShippedUncompiled };
@@ -1,5 +1,13 @@
1
1
  import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
2
  const GETURL_ARG = /\bruntime\s*\.\s*getURL\s*\(/;
3
+ const BARE_IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
4
+ function identifierBoundToGetURL(source, name) {
5
+ const id = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
6
+ const rhs = '[^;\\n]*\\bruntime\\s*\\.\\s*getURL\\s*\\(';
7
+ const declared = new RegExp('\\b(?:const|let|var)\\s+' + id + '\\s*=' + rhs);
8
+ const assigned = new RegExp('(?:^|[^\\w$.])' + id + '\\s*=(?!=)' + rhs);
9
+ return declared.test(source) || assigned.test(source);
10
+ }
3
11
  function annotateGetURLDynamicImports(source) {
4
12
  const insertions = [];
5
13
  const n = source.length;
@@ -32,7 +40,11 @@ function annotateGetURLDynamicImports(source) {
32
40
  while(j < n && /\s/.test(source[j]))j++;
33
41
  if ('(' === source[j]) {
34
42
  const args = readBalancedArgs(source, j);
35
- if (null != args && GETURL_ARG.test(args) && !args.includes('webpackIgnore')) insertions.push(j + 1);
43
+ if (null != args && !args.includes('webpackIgnore')) {
44
+ const direct = GETURL_ARG.test(args);
45
+ const name = args.trim();
46
+ if (direct || BARE_IDENTIFIER.test(name) && identifierBoundToGetURL(source, name)) insertions.push(j + 1);
47
+ }
36
48
  }
37
49
  prevSignificant = 't';
38
50
  i += 6;
@@ -0,0 +1,47 @@
1
+ import { createRequire as __extjsCreateRequire } from "node:module"; const require = __extjsCreateRequire(import.meta.url);
2
+ import postcss from "postcss";
3
+ import { lateCssImportIgnored } from "./845.mjs";
4
+ import * as __rspack_external_node_path_c5b9b54f from "node:path";
5
+ function findLateImports(css) {
6
+ let root;
7
+ try {
8
+ root = postcss.parse(css);
9
+ } catch {
10
+ return [];
11
+ }
12
+ const firstBlock = root.nodes.findIndex((node)=>Array.isArray(node.nodes));
13
+ const late = [];
14
+ root.walkAtRules('import', (node)=>{
15
+ const start = node.source?.start?.offset;
16
+ const end = node.source?.end?.offset;
17
+ if ('number' != typeof start || 'number' != typeof end) return;
18
+ const atRoot = node.parent === root;
19
+ const index = atRoot ? root.index(node) : -1;
20
+ const isLate = !atRoot || -1 !== firstBlock && index > firstBlock;
21
+ if (!isLate) return;
22
+ late.push({
23
+ start,
24
+ end,
25
+ line: node.source?.start?.line || 0
26
+ });
27
+ });
28
+ return late.sort((a, b)=>a.start - b.start);
29
+ }
30
+ function blankLateImports(css, late) {
31
+ let out = css;
32
+ for (const { start, end } of late){
33
+ const blanked = out.slice(start, end).replace(/[^\n]/g, ' ');
34
+ out = out.slice(0, start) + blanked + out.slice(end);
35
+ }
36
+ return out;
37
+ }
38
+ function lateCssImportLoader(source, map) {
39
+ const late = findLateImports(source);
40
+ if (0 === late.length) return void this.callback(null, source, map);
41
+ const relative = this.rootContext ? __rspack_external_node_path_c5b9b54f.relative(this.rootContext, this.resourcePath) || this.resourcePath : this.resourcePath;
42
+ const issuer = relative.split(__rspack_external_node_path_c5b9b54f.sep).join('/');
43
+ for (const entry of late)this.emitWarning(new Error(lateCssImportIgnored(issuer, entry.line || void 0)));
44
+ this.callback(null, blankLateImports(source, late), map);
45
+ }
46
+ export default lateCssImportLoader;
47
+ export { blankLateImports, findLateImports };
@@ -7,6 +7,7 @@ export declare function remoteFetchTimedOut(target: string, ms: number): string;
7
7
  export declare function manifestInvalidJson(manifestPath: string, error: unknown): string;
8
8
  export declare function notAnExtensionManifestError(manifestPath: string): string;
9
9
  export declare function manifestNotFoundError(manifestPath: string, candidates?: string[]): string;
10
+ export declare function previewingSourceFallback(browser: DevOptions['browser'], distDir: string): string;
10
11
  export declare function previewing(browser: DevOptions['browser'], noBrowser?: boolean): string;
11
12
  export declare function starting(browser: DevOptions['browser'], noBrowser?: boolean): string;
12
13
  export declare function extensionLoadRecovered(): string;
@@ -7,3 +7,4 @@ export declare function postCssPluginNotResolved(pluginName: string, projectPath
7
7
  export declare function cssParseErrorShippedVerbatim(resourcePath: string, error: unknown): string;
8
8
  export declare function preprocessorShippedUncompiled(resourcePath: string, tool: 'sass' | 'less'): string;
9
9
  export declare function deadCssUrlRef(issuerPath: string, request: string): string;
10
+ export declare function lateCssImportIgnored(issuerPath: string, line?: number): string;
@@ -0,0 +1,15 @@
1
+ interface LateCssImportLoaderContext {
2
+ resourcePath: string;
3
+ rootContext?: string;
4
+ callback(err: Error | null, content?: string, map?: unknown): void;
5
+ emitWarning(warning: Error): void;
6
+ }
7
+ export interface LateImport {
8
+ start: number;
9
+ end: number;
10
+ line: number;
11
+ }
12
+ export declare function findLateImports(css: string): LateImport[];
13
+ export declare function blankLateImports(css: string, late: LateImport[]): string;
14
+ export default function lateCssImportLoader(this: LateCssImportLoaderContext, source: string, map?: unknown): void;
15
+ export {};
package/package.json CHANGED
@@ -43,7 +43,7 @@
43
43
  "runtime"
44
44
  ],
45
45
  "name": "extension-develop",
46
- "version": "4.0.33",
46
+ "version": "4.0.35",
47
47
  "description": "Develop, build, preview, and package Extension.js projects.",
48
48
  "author": {
49
49
  "name": "Cezar Augusto",