extension-develop 4.0.34 → 4.1.0

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,
@@ -7642,16 +7645,85 @@ class StaticAssetsPlugin {
7642
7645
  return Boolean(rule && rule.test instanceof RegExp && rule.test.test(sample) && (void 0 !== rule.type || void 0 !== rule.use) && void 0 === rule.resourceQuery);
7643
7646
  };
7644
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);
7645
- 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);
7646
7720
  const hasUrlResourceQueryRule = compiler.options.module.rules.some((thisRule)=>{
7647
7721
  const rule = thisRule;
7648
7722
  const resourceQuery = rule?.resourceQuery;
7649
7723
  if (!(resourceQuery instanceof RegExp)) return false;
7650
7724
  return resourceQuery.test('?url');
7651
7725
  });
7652
- const hasCustomFontsRule = compiler.options.module.rules.some((thisRule)=>isFullCustomRuleFor(thisRule, '.woff'));
7653
7726
  const svgScopedQueries = scopedQueriesFor('.svg');
7654
- const fontsScopedQueries = scopedQueriesFor('.woff');
7655
7727
  const loaders = [
7656
7728
  ...hasCustomSvgRule ? [] : [
7657
7729
  svgScopedQueries.length ? {
@@ -7661,44 +7733,15 @@ class StaticAssetsPlugin {
7661
7733
  }
7662
7734
  } : defaultSvgRule
7663
7735
  ],
7664
- {
7665
- test: /\.(png|jpg|jpeg|gif|webp|avif|ico|bmp)$/i,
7666
- type: 'asset',
7667
- generator: {
7668
- filename: filenamePattern
7669
- },
7670
- parser: {
7671
- dataUrlCondition: {
7672
- maxSize: 2048
7673
- }
7674
- }
7675
- },
7676
- ...hasCustomFontsRule ? [] : [
7677
- {
7678
- test: /\.(woff|woff2|eot|ttf|otf)$/i,
7679
- type: 'asset',
7680
- generator: {
7681
- filename: filenamePattern
7682
- },
7683
- ...fontsScopedQueries.length ? {
7684
- resourceQuery: {
7685
- not: fontsScopedQueries
7686
- }
7687
- } : {}
7688
- }
7689
- ],
7690
- {
7691
- test: /\.(txt|md|csv|tsv|xml|pdf|docx|doc|xls|xlsx|ppt|pptx|zip|gz|gzip|tgz)$/i,
7692
- type: 'asset',
7693
- generator: {
7694
- filename: filenamePattern
7695
- },
7696
- parser: {
7697
- dataUrlCondition: {
7698
- maxSize: 2048
7699
- }
7700
- }
7701
- },
7736
+ ...imagesRule ? [
7737
+ imagesRule
7738
+ ] : [],
7739
+ ...fontsRule ? [
7740
+ fontsRule
7741
+ ] : [],
7742
+ ...filesRule ? [
7743
+ filesRule
7744
+ ] : [],
7702
7745
  ...hasUrlResourceQueryRule ? [] : [
7703
7746
  {
7704
7747
  resourceQuery: /(?:^\?|&)url(?:&|=|$)/,
@@ -7716,11 +7759,10 @@ class StaticAssetsPlugin {
7716
7759
  if (isDebug()) {
7717
7760
  const rulesEnabled = [];
7718
7761
  rulesEnabled.push(hasCustomSvgRule ? 'SVG(custom)' : 'SVG(default)');
7719
- rulesEnabled.push('Images');
7720
- rulesEnabled.push('Fonts');
7721
- rulesEnabled.push('Files');
7762
+ rulesEnabled.push(imagesRule ? 'Images' : 'Images(custom)');
7763
+ rulesEnabled.push(fontsRule ? 'Fonts' : 'Fonts(custom)');
7764
+ rulesEnabled.push(filesRule ? 'Files' : 'Files(custom)');
7722
7765
  console.log(assetsRulesEnabled(rulesEnabled));
7723
- const inlineKB = 2;
7724
7766
  console.log(assetsConfigsDetected(filenamePattern, hasCustomSvgRule ? 'custom' : 'default', hasCustomSvgRule ? void 0 : inlineKB, inlineKB, inlineKB));
7725
7767
  compiler.hooks.afterEmit.tap(StaticAssetsPlugin.name, (compilation)=>{
7726
7768
  try {
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.34","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.1.0","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
  }
@@ -2229,13 +2235,13 @@ function browserRunnerDisabled(args) {
2229
2235
  label: 'Extension',
2230
2236
  value: extensionLabel
2231
2237
  },
2232
- {
2233
- label: 'Output',
2234
- value: collapseHomeDirInCardValue(String(args.distPath || '').trim())
2235
- },
2236
2238
  {
2237
2239
  label: 'Run ID',
2238
2240
  value: runLabel
2241
+ },
2242
+ {
2243
+ label: 'Output',
2244
+ value: collapseHomeDirInCardValue(String(args.distPath || '').trim())
2239
2245
  }
2240
2246
  ]
2241
2247
  });
@@ -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/349.mjs CHANGED
@@ -60,11 +60,12 @@ const fmt = {
60
60
  }
61
61
  };
62
62
  const CARD_LABEL_WIDTH = 15;
63
+ const MAX_CARD_ROWS = 3;
63
64
  function card(input = {}) {
64
65
  const version = String(input.version || '').trim();
65
66
  const suffix = String(input.suffix || '').trim();
66
- const head = ` 🧩 ${pintor.brightBlue('Extension.js')}` + (version ? ` ${pintor.gray(version)}` : '') + (suffix ? ` ${suffix}` : '');
67
- const body = (input.rows || []).filter((row)=>String(row.value || '').trim().length > 0).map((row)=>{
67
+ const head = ` 🧩 Extension.js` + (version ? ` ${pintor.gray(version)}` : '') + (suffix ? ` ${suffix}` : '');
68
+ const body = (input.rows || []).filter((row)=>String(row.value || '').trim().length > 0).slice(0, MAX_CARD_ROWS).map((row)=>{
68
69
  const label = row.label.padEnd(CARD_LABEL_WIDTH);
69
70
  return ` ${label}${pintor.gray(String(row.value).trim())}`;
70
71
  });
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;
@@ -23,6 +23,7 @@ export interface CardInput {
23
23
  suffix?: string;
24
24
  rows?: CardRow[];
25
25
  }
26
+ export declare const MAX_CARD_ROWS = 3;
26
27
  export declare function card(input?: CardInput): string;
27
28
  export declare function browserRowValue(browser: string, versionLine?: string): string;
28
29
  export declare function isCardKeyClaimed(key: string): boolean;
@@ -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.34",
46
+ "version": "4.1.0",
47
47
  "description": "Develop, build, preview, and package Extension.js projects.",
48
48
  "author": {
49
49
  "name": "Cezar Augusto",