extension-develop 4.0.2 → 4.0.3-canary.328.4af5697
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.
- package/dist/0~rspack-config.mjs +97 -108
- package/dist/101.mjs +201 -2
- package/dist/845.mjs +39 -0
- package/dist/css-parse-guard-loader.mjs +26 -0
- package/dist/extension-js-devtools/chrome/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/chrome/manifest.json +2 -2
- package/dist/extension-js-devtools/chromium/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/chromium/manifest.json +2 -2
- package/dist/extension-js-devtools/edge/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/edge/manifest.json +2 -2
- package/dist/extension-js-devtools/extension-js/chrome/events.ndjson +2 -2
- package/dist/extension-js-devtools/extension-js/chrome/ready.json +5 -5
- package/dist/extension-js-devtools/extension-js/chromium/events.ndjson +2 -2
- package/dist/extension-js-devtools/extension-js/chromium/ready.json +5 -5
- package/dist/extension-js-devtools/extension-js/edge/events.ndjson +2 -2
- package/dist/extension-js-devtools/extension-js/edge/ready.json +5 -5
- package/dist/extension-js-devtools/extension-js/firefox/events.ndjson +2 -2
- package/dist/extension-js-devtools/extension-js/firefox/ready.json +4 -4
- package/dist/extension-js-devtools/firefox/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/firefox/manifest.json +2 -2
- package/dist/extension-js-theme/extension-js/chrome/events.ndjson +2 -2
- package/dist/extension-js-theme/extension-js/chrome/ready.json +5 -5
- package/dist/extension-js-theme/extension-js/chromium/events.ndjson +2 -2
- package/dist/extension-js-theme/extension-js/chromium/ready.json +5 -5
- package/dist/extension-js-theme/extension-js/edge/events.ndjson +2 -2
- package/dist/extension-js-theme/extension-js/edge/ready.json +5 -5
- package/dist/extension-js-theme/extension-js/firefox/events.ndjson +6 -4
- package/dist/extension-js-theme/extension-js/firefox/ready.json +5 -5
- package/dist/feature-scripts-classic-concat-loader.js +6 -0
- package/dist/feature-scripts-classic-concat-loader.mjs +6 -0
- package/package.json +1 -1
- package/dist/extension-js-devtools/chrome/scripts/logger-client.js +0 -1
- package/dist/extension-js-devtools/chromium/scripts/logger-client.js +0 -1
- package/dist/extension-js-devtools/edge/scripts/logger-client.js +0 -1
- package/dist/extension-js-devtools/firefox/scripts/logger-client.js +0 -1
- /package/dist/extension-js-devtools/chrome/{icons → images}/logo.png +0 -0
- /package/dist/extension-js-devtools/chromium/{icons → images}/logo.png +0 -0
- /package/dist/extension-js-devtools/edge/{icons → images}/logo.png +0 -0
- /package/dist/extension-js-devtools/firefox/{icons → images}/logo.png +0 -0
package/dist/0~rspack-config.mjs
CHANGED
|
@@ -17,6 +17,7 @@ import { isResourceUnderDirs, findNearestPackageJsonSync, backgroundIsRequiredMe
|
|
|
17
17
|
import { getCanonicalContentScriptEntryName, parseCanonicalContentScriptAsset, getCanonicalContentScriptJsAssetName, getCanonicalContentScriptCssAssetName, EXTENSIONJS_CONTENT_SCRIPT_LAYER } from "./291.mjs";
|
|
18
18
|
import { isUsingTypeScript, jsFrameworksIntegrationsEnabled, ensureTypeScriptConfig, ensureOptionalContractModuleLoaded, resolveDevelopInstallRoot, isUsingCustomLoader, getUserTypeScriptConfigFile, isUsingIntegration as messages_isUsingIntegration, parseJsonSafe, resolveOptionalContractPackageWithoutInstall, jsFrameworksHmrSummary, loadOptionalContractModuleWithoutInstall, jsFrameworksConfigsDetected, hasDependency, resolveDevelopDistFile, optional_deps_resolver_ensureOptionalContractPackageResolved } from "./839.mjs";
|
|
19
19
|
import { scrubBrand, makeSanitizedConsole } from "./0~branding.mjs";
|
|
20
|
+
import { cssIntegrationsEnabled, cssConfigsDetected, missingSassDependency, isUsingIntegration } from "./845.mjs";
|
|
20
21
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
21
22
|
import { dirname as __rspack_dirname } from "node:path";
|
|
22
23
|
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
@@ -406,12 +407,9 @@ function unixify(filePath) {
|
|
|
406
407
|
function background_background(manifest) {
|
|
407
408
|
return manifest.background && manifest.background.scripts && {
|
|
408
409
|
background: {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
...new Set(manifest.background.scripts.map((script)=>getFilename("background/scripts.js", String(script))))
|
|
413
|
-
]
|
|
414
|
-
}
|
|
410
|
+
scripts: [
|
|
411
|
+
...new Set(manifest.background.scripts.map((script)=>getFilename("background/scripts.js", String(script))))
|
|
412
|
+
]
|
|
415
413
|
}
|
|
416
414
|
};
|
|
417
415
|
}
|
|
@@ -423,6 +421,12 @@ function normalizeManifestOutputPath(originalPath) {
|
|
|
423
421
|
if (/^\//.test(unixPath)) return unixPath.replace(/^\//, '');
|
|
424
422
|
return unixPath;
|
|
425
423
|
}
|
|
424
|
+
function iconOutputPath(raw) {
|
|
425
|
+
if (/^(?:\/public\/|(?:\.\/)?public\/)/i.test(raw)) return normalizeManifestOutputPath(raw);
|
|
426
|
+
const normalized = normalizeManifestOutputPath(raw).replace(/^\.\//, '');
|
|
427
|
+
const escapes = !normalized || normalized.split('/').includes('..') || /^[A-Za-z]:/.test(normalized);
|
|
428
|
+
return escapes ? `icons/${normalized.split('/').pop() || ''}` : normalized;
|
|
429
|
+
}
|
|
426
430
|
function browserAction(manifest) {
|
|
427
431
|
return manifest.browser_action && {
|
|
428
432
|
browser_action: {
|
|
@@ -433,16 +437,12 @@ function browserAction(manifest) {
|
|
|
433
437
|
...manifest.browser_action.default_icon && {
|
|
434
438
|
default_icon: 'string' == typeof manifest.browser_action.default_icon ? (()=>{
|
|
435
439
|
const raw = String(manifest.browser_action.default_icon);
|
|
436
|
-
|
|
437
|
-
const target = isPublic ? normalizeManifestOutputPath(raw) : `icons/${__rspack_external_path.basename(raw)}`;
|
|
438
|
-
return getFilename(target, raw);
|
|
440
|
+
return getFilename(iconOutputPath(raw), raw);
|
|
439
441
|
})() : Object.fromEntries(Object.entries(manifest.browser_action.default_icon).map(([size, icon])=>{
|
|
440
442
|
const raw = String(icon);
|
|
441
|
-
const isPublic = /^(?:\/public\/|(?:\.\/)?public\/)/i.test(raw);
|
|
442
|
-
const target = isPublic ? normalizeManifestOutputPath(raw) : `icons/${__rspack_external_path.basename(raw)}`;
|
|
443
443
|
return [
|
|
444
444
|
size,
|
|
445
|
-
getFilename(
|
|
445
|
+
getFilename(iconOutputPath(raw), raw)
|
|
446
446
|
];
|
|
447
447
|
}))
|
|
448
448
|
},
|
|
@@ -504,16 +504,12 @@ function pageAction(manifest) {
|
|
|
504
504
|
...manifest.page_action.default_icon && {
|
|
505
505
|
default_icon: 'string' == typeof manifest.page_action.default_icon ? (()=>{
|
|
506
506
|
const raw = String(manifest.page_action.default_icon);
|
|
507
|
-
|
|
508
|
-
const target = isPublic ? normalizeManifestOutputPath(raw) : `icons/${__rspack_external_path.basename(raw)}`;
|
|
509
|
-
return getFilename(target, raw);
|
|
507
|
+
return getFilename(iconOutputPath(raw), raw);
|
|
510
508
|
})() : Object.fromEntries(Object.entries(manifest.page_action.default_icon).map(([size, icon])=>{
|
|
511
509
|
const raw = String(icon);
|
|
512
|
-
const isPublic = /^(?:\/public\/|(?:\.\/)?public\/)/i.test(raw);
|
|
513
|
-
const target = isPublic ? normalizeManifestOutputPath(raw) : `icons/${__rspack_external_path.basename(raw)}`;
|
|
514
510
|
return [
|
|
515
511
|
size,
|
|
516
|
-
getFilename(
|
|
512
|
+
getFilename(iconOutputPath(raw), raw)
|
|
517
513
|
];
|
|
518
514
|
}))
|
|
519
515
|
}
|
|
@@ -530,16 +526,12 @@ function sidebarAction(manifest) {
|
|
|
530
526
|
...manifest.sidebar_action.default_icon && {
|
|
531
527
|
default_icon: 'string' == typeof manifest.sidebar_action.default_icon ? (()=>{
|
|
532
528
|
const raw = String(manifest.sidebar_action.default_icon);
|
|
533
|
-
|
|
534
|
-
const target = isPublic ? normalizeManifestOutputPath(raw) : `icons/${__rspack_external_path.basename(raw)}`;
|
|
535
|
-
return getFilename(target, raw);
|
|
529
|
+
return getFilename(iconOutputPath(raw), raw);
|
|
536
530
|
})() : Object.fromEntries(Object.entries(manifest.sidebar_action.default_icon).map(([size, icon])=>{
|
|
537
531
|
const raw = String(icon);
|
|
538
|
-
const isPublic = /^(?:\/public\/|(?:\.\/)?public\/)/i.test(raw);
|
|
539
|
-
const target = isPublic ? normalizeManifestOutputPath(raw) : `icons/${__rspack_external_path.basename(raw)}`;
|
|
540
532
|
return [
|
|
541
533
|
size,
|
|
542
|
-
getFilename(
|
|
534
|
+
getFilename(iconOutputPath(raw), raw)
|
|
543
535
|
];
|
|
544
536
|
}))
|
|
545
537
|
}
|
|
@@ -581,16 +573,12 @@ function action_action(manifest) {
|
|
|
581
573
|
...manifest.action.default_icon && {
|
|
582
574
|
default_icon: 'string' == typeof manifest.action.default_icon ? (()=>{
|
|
583
575
|
const raw = String(manifest.action.default_icon);
|
|
584
|
-
|
|
585
|
-
const target = isPublic ? normalizeManifestOutputPath(raw) : `icons/${__rspack_external_path.basename(raw)}`;
|
|
586
|
-
return getFilename(target, raw);
|
|
576
|
+
return getFilename(iconOutputPath(raw), raw);
|
|
587
577
|
})() : Object.fromEntries(Object.entries(manifest.action.default_icon).map(([size, icon])=>{
|
|
588
578
|
const raw = String(icon);
|
|
589
|
-
const isPublic = /^(?:\/public\/|(?:\.\/)?public\/)/i.test(raw);
|
|
590
|
-
const target = isPublic ? normalizeManifestOutputPath(raw) : `icons/${__rspack_external_path.basename(raw)}`;
|
|
591
579
|
return [
|
|
592
580
|
size,
|
|
593
|
-
getFilename(
|
|
581
|
+
getFilename(iconOutputPath(raw), raw)
|
|
594
582
|
];
|
|
595
583
|
}))
|
|
596
584
|
}
|
|
@@ -600,13 +588,10 @@ function action_action(manifest) {
|
|
|
600
588
|
function backgroundServiceWorker(manifest) {
|
|
601
589
|
return manifest.background && manifest.background.service_worker && {
|
|
602
590
|
background: {
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
service_worker
|
|
606
|
-
|
|
607
|
-
return getFilename('background/service_worker.js', raw);
|
|
608
|
-
})()
|
|
609
|
-
}
|
|
591
|
+
service_worker: (()=>{
|
|
592
|
+
const raw = String(manifest.background.service_worker);
|
|
593
|
+
return getFilename('background/service_worker.js', raw);
|
|
594
|
+
})()
|
|
610
595
|
}
|
|
611
596
|
};
|
|
612
597
|
}
|
|
@@ -651,13 +636,10 @@ function manifestV3(manifest) {
|
|
|
651
636
|
function backgroundPage(manifest) {
|
|
652
637
|
return manifest.background && manifest.background.page && {
|
|
653
638
|
background: {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
return getFilename('background/index.html', raw);
|
|
659
|
-
})()
|
|
660
|
-
}
|
|
639
|
+
page: (()=>{
|
|
640
|
+
const raw = String(manifest.background.page);
|
|
641
|
+
return getFilename('background/index.html', raw);
|
|
642
|
+
})()
|
|
661
643
|
}
|
|
662
644
|
};
|
|
663
645
|
}
|
|
@@ -760,11 +742,9 @@ function icons_icons(manifest) {
|
|
|
760
742
|
return manifest.icons && {
|
|
761
743
|
icons: Object.fromEntries(Object.entries(manifest.icons).map(([size, icon])=>{
|
|
762
744
|
const raw = String(icon);
|
|
763
|
-
const isPublic = /^(?:\/public\/|(?:\.\/)?public\/)/i.test(raw);
|
|
764
|
-
const target = isPublic ? normalizeManifestOutputPath(raw) : `icons/${__rspack_external_path.basename(raw)}`;
|
|
765
745
|
return [
|
|
766
746
|
size,
|
|
767
|
-
getFilename(
|
|
747
|
+
getFilename(iconOutputPath(raw), raw)
|
|
768
748
|
];
|
|
769
749
|
}))
|
|
770
750
|
};
|
|
@@ -1092,6 +1072,8 @@ class EnvPlugin {
|
|
|
1092
1072
|
filteredEnvVars['import.meta.env.BROWSER'] = JSON.stringify(this.browser);
|
|
1093
1073
|
filteredEnvVars['process.env.MODE'] = JSON.stringify(mode);
|
|
1094
1074
|
filteredEnvVars['import.meta.env.MODE'] = JSON.stringify(mode);
|
|
1075
|
+
filteredEnvVars['import.meta.dirname'] = 'undefined';
|
|
1076
|
+
filteredEnvVars['import.meta.filename'] = 'undefined';
|
|
1095
1077
|
const injectedCount = Object.keys(filteredEnvVars).filter((k)=>k.startsWith('process.env.EXTENSION_PUBLIC_')).length;
|
|
1096
1078
|
if ('true' === process.env.EXTENSION_AUTHOR_MODE) console.log(envInjectedPublicVars(injectedCount));
|
|
1097
1079
|
const processShim = resolveProcessShim();
|
|
@@ -1508,34 +1490,6 @@ class CompilationPlugin {
|
|
|
1508
1490
|
setupCompilerDoneDiagnostics(compiler, this.port);
|
|
1509
1491
|
}
|
|
1510
1492
|
}
|
|
1511
|
-
function cssIntegrationsEnabled(integrations) {
|
|
1512
|
-
const list = integrations.length > 0 ? integrations.map((n)=>pintor.yellow(n)).join(', ') : pintor.gray('none');
|
|
1513
|
-
return `${pintor.gray('⏵⏵⏵')} CSS: Integrations enabled (${pintor.gray(String(integrations.length))}) ${list}`;
|
|
1514
|
-
}
|
|
1515
|
-
function cssConfigsDetected(postcssConfig, tailwindConfig, browserslistSource) {
|
|
1516
|
-
const fmt = (v)=>v ? pintor.underline(v) : pintor.gray('none');
|
|
1517
|
-
return `${pintor.gray('⏵⏵⏵')} CSS: Configs\n${pintor.gray('POSTCSS')} ${fmt(postcssConfig)}\n${pintor.gray('TAILWIND')} ${fmt(tailwindConfig)}\n${pintor.gray('BROWSERSLIST')} ${fmt(browserslistSource)}`;
|
|
1518
|
-
}
|
|
1519
|
-
function isUsingIntegration(name) {
|
|
1520
|
-
return `${pintor.gray('⏵⏵⏵')} Using ${pintor.brightBlue(name)}...`;
|
|
1521
|
-
}
|
|
1522
|
-
function missingSassDependency() {
|
|
1523
|
-
const prefix = pintor.red('⏵⏵⏵');
|
|
1524
|
-
return [
|
|
1525
|
-
`${prefix} SASS support requires the ${pintor.brightBlue('"sass"')} package to be installed in your project.`,
|
|
1526
|
-
'',
|
|
1527
|
-
"Add it to your devDependencies, for example:",
|
|
1528
|
-
` ${pintor.gray('npm install --save-dev sass')}`,
|
|
1529
|
-
` ${pintor.gray('pnpm add -D sass')}`,
|
|
1530
|
-
'',
|
|
1531
|
-
'Sample package.json:',
|
|
1532
|
-
' {',
|
|
1533
|
-
' "devDependencies": {',
|
|
1534
|
-
` "sass": ${pintor.yellow('"<version>"')}`,
|
|
1535
|
-
' }',
|
|
1536
|
-
' }'
|
|
1537
|
-
].join('\n');
|
|
1538
|
-
}
|
|
1539
1493
|
const sass_cjsRequire = createRequire(import.meta.url);
|
|
1540
1494
|
let userMessageDelivered = false;
|
|
1541
1495
|
function isUsingSass(projectPath) {
|
|
@@ -1978,7 +1932,12 @@ async function commonStyleLoaders(projectPath, opts) {
|
|
|
1978
1932
|
const styleLoaders = [];
|
|
1979
1933
|
if (isUsingPostCss(projectPath) || tailwind_isUsingTailwind(projectPath) || isUsingSass(projectPath) || isUsingLess(projectPath)) {
|
|
1980
1934
|
const maybeInstallPostCss = await maybeUsePostCss(projectPath, opts);
|
|
1981
|
-
if (maybeInstallPostCss.loader)
|
|
1935
|
+
if (maybeInstallPostCss.loader) {
|
|
1936
|
+
styleLoaders.push({
|
|
1937
|
+
loader: resolveDevelopDistFile('css-parse-guard-loader')
|
|
1938
|
+
});
|
|
1939
|
+
styleLoaders.push(maybeInstallPostCss);
|
|
1940
|
+
}
|
|
1982
1941
|
}
|
|
1983
1942
|
if (opts.loader) styleLoaders.push({
|
|
1984
1943
|
loader: opts.loader,
|
|
@@ -2204,7 +2163,7 @@ class StaticAssetsPlugin {
|
|
|
2204
2163
|
const rule = thisRule;
|
|
2205
2164
|
const resourceQuery = rule?.resourceQuery;
|
|
2206
2165
|
if (!(resourceQuery instanceof RegExp)) return false;
|
|
2207
|
-
return resourceQuery.test('url');
|
|
2166
|
+
return resourceQuery.test('?url');
|
|
2208
2167
|
});
|
|
2209
2168
|
const hasCustomFontsRule = compiler.options.module.rules.some((thisRule)=>{
|
|
2210
2169
|
const rule = thisRule;
|
|
@@ -2215,7 +2174,7 @@ class StaticAssetsPlugin {
|
|
|
2215
2174
|
const loaders = [
|
|
2216
2175
|
...hasUrlResourceQueryRule ? [] : [
|
|
2217
2176
|
{
|
|
2218
|
-
resourceQuery: /url/,
|
|
2177
|
+
resourceQuery: /(?:^\?|&)url(?:&|=|$)/,
|
|
2219
2178
|
type: 'asset/resource'
|
|
2220
2179
|
}
|
|
2221
2180
|
],
|
|
@@ -2305,17 +2264,6 @@ function isUsingPreact(projectPath) {
|
|
|
2305
2264
|
}
|
|
2306
2265
|
async function maybeUsePreact(projectPath) {
|
|
2307
2266
|
if (!isUsingPreact(projectPath)) return;
|
|
2308
|
-
await optional_deps_resolver_ensureOptionalContractPackageResolved({
|
|
2309
|
-
contractId: 'preact-refresh',
|
|
2310
|
-
projectPath,
|
|
2311
|
-
dependencyId: '@rspack/plugin-preact-refresh'
|
|
2312
|
-
});
|
|
2313
|
-
const PreactRefreshPlugin = await ensureOptionalContractModuleLoaded({
|
|
2314
|
-
contractId: 'preact-refresh',
|
|
2315
|
-
projectPath,
|
|
2316
|
-
dependencyId: '@rspack/plugin-preact-refresh',
|
|
2317
|
-
moduleAdapter: (mod)=>mod?.PreactRefreshRspackPlugin ?? mod?.default?.PreactRefreshRspackPlugin ?? mod?.default ?? mod
|
|
2318
|
-
});
|
|
2319
2267
|
const requireFromProject = createRequire(__rspack_external_path.join(projectPath, 'package.json'));
|
|
2320
2268
|
const resolveFromProject = (id)=>{
|
|
2321
2269
|
try {
|
|
@@ -2330,11 +2278,6 @@ async function maybeUsePreact(projectPath) {
|
|
|
2330
2278
|
const preactTestUtils = resolveFromProject('preact/test-utils');
|
|
2331
2279
|
const preactJsxRuntime = resolveFromProject('preact/jsx-runtime');
|
|
2332
2280
|
const preactJsxDevRuntime = resolveFromProject('preact/jsx-dev-runtime');
|
|
2333
|
-
const preactPlugins = [
|
|
2334
|
-
new PreactRefreshPlugin(preactDir ? {
|
|
2335
|
-
preactPath: preactDir
|
|
2336
|
-
} : {})
|
|
2337
|
-
];
|
|
2338
2281
|
const alias = {};
|
|
2339
2282
|
if (preactDir) alias.preact = preactDir;
|
|
2340
2283
|
if (preactCompat) {
|
|
@@ -2345,7 +2288,7 @@ async function maybeUsePreact(projectPath) {
|
|
|
2345
2288
|
if (preactJsxRuntime) alias['react/jsx-runtime'] = preactJsxRuntime;
|
|
2346
2289
|
if (preactJsxDevRuntime) alias['react/jsx-dev-runtime'] = preactJsxDevRuntime;
|
|
2347
2290
|
return {
|
|
2348
|
-
plugins:
|
|
2291
|
+
plugins: [],
|
|
2349
2292
|
loaders: void 0,
|
|
2350
2293
|
alias
|
|
2351
2294
|
};
|
|
@@ -2880,6 +2823,9 @@ class JsFrameworksPlugin {
|
|
|
2880
2823
|
issuerLayer: {
|
|
2881
2824
|
not: EXTENSIONJS_CONTENT_SCRIPT_LAYER
|
|
2882
2825
|
},
|
|
2826
|
+
resourceQuery: {
|
|
2827
|
+
not: /__extensionjs_classic_concat__/
|
|
2828
|
+
},
|
|
2883
2829
|
type: "javascript/esm",
|
|
2884
2830
|
exclude: [
|
|
2885
2831
|
...swcRuleBase.exclude,
|
|
@@ -3232,6 +3178,30 @@ function toPublicOutput(possiblePath) {
|
|
|
3232
3178
|
if (/^\//.test(normalizedPath)) return normalizedPath.replace(/^\//, '');
|
|
3233
3179
|
return normalizedPath;
|
|
3234
3180
|
}
|
|
3181
|
+
function emitDirectoryAsAssets(compilation, absDir, baseDir) {
|
|
3182
|
+
const walk = (dir)=>{
|
|
3183
|
+
let entries;
|
|
3184
|
+
try {
|
|
3185
|
+
entries = __rspack_external_fs.readdirSync(dir, {
|
|
3186
|
+
withFileTypes: true
|
|
3187
|
+
});
|
|
3188
|
+
} catch {
|
|
3189
|
+
return;
|
|
3190
|
+
}
|
|
3191
|
+
for (const entry of entries){
|
|
3192
|
+
const full = __rspack_external_path.join(dir, entry.name);
|
|
3193
|
+
if (entry.isDirectory()) {
|
|
3194
|
+
walk(full);
|
|
3195
|
+
continue;
|
|
3196
|
+
}
|
|
3197
|
+
if (!entry.isFile()) continue;
|
|
3198
|
+
const outName = unixify(__rspack_external_path.relative(baseDir, full));
|
|
3199
|
+
if (!compilation.getAsset(outName)) compilation.emitAsset(outName, new core_sources.RawSource(__rspack_external_fs.readFileSync(full)));
|
|
3200
|
+
compilation.fileDependencies.add(full);
|
|
3201
|
+
}
|
|
3202
|
+
};
|
|
3203
|
+
walk(absDir);
|
|
3204
|
+
}
|
|
3235
3205
|
function emitFileAsAsset(compilation, absPath) {
|
|
3236
3206
|
const mode = compilation.options?.mode || 'development';
|
|
3237
3207
|
const filenamePattern = 'production' === mode ? 'assets/[name].[contenthash:8][ext]' : 'assets/[name][ext]';
|
|
@@ -3392,6 +3362,12 @@ function resolveUserDeclaredWAR(compilation, manifestPath, manifest, browser) {
|
|
|
3392
3362
|
compilation.warnings.push(warn);
|
|
3393
3363
|
return;
|
|
3394
3364
|
}
|
|
3365
|
+
if (__rspack_external_fs.statSync(abs).isDirectory()) {
|
|
3366
|
+
emitDirectoryAsAssets(compilation, abs, manifestDir);
|
|
3367
|
+
const dirResource = unixify(res).replace(/\/+$/, '') + '/*';
|
|
3368
|
+
pushResource(matches, dirResource, extra);
|
|
3369
|
+
return;
|
|
3370
|
+
}
|
|
3395
3371
|
const emitted = emitFileAsAsset(compilation, abs);
|
|
3396
3372
|
pushResource(matches, emitted, extra);
|
|
3397
3373
|
};
|
|
@@ -5453,10 +5429,8 @@ const add_scripts_isRemoteUrl = (entry)=>/^([a-z][a-z0-9+.-]*:)?\/\//i.test(entr
|
|
|
5453
5429
|
const isContentScriptFeature = (feature)=>feature.startsWith("content_scripts/");
|
|
5454
5430
|
const isScriptsFolderFeature = (feature)=>feature.startsWith("scripts/");
|
|
5455
5431
|
const isBackgroundScriptsFeature = (feature)=>"background/scripts" === feature;
|
|
5456
|
-
function createSequentialEntryModule(feature,
|
|
5457
|
-
const
|
|
5458
|
-
const jsFiles = entryImports.filter((p)=>!isCss(p));
|
|
5459
|
-
const cssFiles = entryImports.filter(isCss);
|
|
5432
|
+
function createSequentialEntryModule(feature, scriptImports) {
|
|
5433
|
+
const jsFiles = scriptImports;
|
|
5460
5434
|
const isClassic = (p)=>{
|
|
5461
5435
|
try {
|
|
5462
5436
|
const src = __rspack_external_fs.readFileSync(p, 'utf8');
|
|
@@ -5470,13 +5444,13 @@ function createSequentialEntryModule(feature, entryImports) {
|
|
|
5470
5444
|
const queryData = encodeURIComponent(JSON.stringify({
|
|
5471
5445
|
feature,
|
|
5472
5446
|
js: jsFiles,
|
|
5473
|
-
css:
|
|
5447
|
+
css: []
|
|
5474
5448
|
}));
|
|
5475
5449
|
return `${jsFiles[0]}?__extensionjs_classic_concat__=${queryData}`;
|
|
5476
5450
|
}
|
|
5477
5451
|
const source = [
|
|
5478
5452
|
`/* extension.js sequential entry: ${feature} */`,
|
|
5479
|
-
...
|
|
5453
|
+
...jsFiles.map((entryImport)=>`import ${JSON.stringify(String(entryImport))};`)
|
|
5480
5454
|
].join('\n');
|
|
5481
5455
|
return `data:text/javascript;charset=utf-8,${encodeURIComponent(source)}`;
|
|
5482
5456
|
}
|
|
@@ -5538,12 +5512,20 @@ class AddScripts {
|
|
|
5538
5512
|
if (__rspack_external_path.isAbsolute(entry)) return entry;
|
|
5539
5513
|
return __rspack_external_path.join(manifestDir, entry);
|
|
5540
5514
|
};
|
|
5515
|
+
const claimedByContentScript = new Set();
|
|
5516
|
+
for (const [feature, scriptPath] of Object.entries(scriptFields)){
|
|
5517
|
+
if (!isContentScriptFeature(feature)) continue;
|
|
5518
|
+
const rawEntries = Array.isArray(scriptPath) ? scriptPath || [] : scriptPath ? [
|
|
5519
|
+
scriptPath
|
|
5520
|
+
] : [];
|
|
5521
|
+
for (const resolved of getScriptEntries(rawEntries.map(resolveEntryPath)))claimedByContentScript.add(__rspack_external_path.resolve(resolved));
|
|
5522
|
+
}
|
|
5541
5523
|
for (const [feature, scriptPath] of Object.entries(scriptFields)){
|
|
5542
5524
|
const rawEntries = Array.isArray(scriptPath) ? scriptPath || [] : scriptPath ? [
|
|
5543
5525
|
scriptPath
|
|
5544
5526
|
] : [];
|
|
5545
5527
|
const resolvedEntries = rawEntries.map(resolveEntryPath);
|
|
5546
|
-
const scriptImports = getScriptEntries(resolvedEntries);
|
|
5528
|
+
const scriptImports = isScriptsFolderFeature(feature) ? getScriptEntries(resolvedEntries).filter((p)=>!claimedByContentScript.has(__rspack_external_path.resolve(p))) : getScriptEntries(resolvedEntries);
|
|
5547
5529
|
const cssImports = getCssEntries(resolvedEntries);
|
|
5548
5530
|
const entryImports = [
|
|
5549
5531
|
...new Set([
|
|
@@ -5553,7 +5535,8 @@ class AddScripts {
|
|
|
5553
5535
|
];
|
|
5554
5536
|
const shouldUseSequentialEntryModule = (isContentScriptFeature(feature) || isBackgroundScriptsFeature(feature)) && scriptImports.length > 1;
|
|
5555
5537
|
const finalEntryImports = shouldUseSequentialEntryModule ? [
|
|
5556
|
-
createSequentialEntryModule(feature,
|
|
5538
|
+
createSequentialEntryModule(feature, scriptImports),
|
|
5539
|
+
...cssImports
|
|
5557
5540
|
] : entryImports;
|
|
5558
5541
|
if (finalEntryImports.length) newEntries[feature] = 'background/service_worker' === feature ? {
|
|
5559
5542
|
import: finalEntryImports,
|
|
@@ -8382,7 +8365,11 @@ class EmitFile {
|
|
|
8382
8365
|
if (('action' === group || 'browser_action' === group || 'page_action' === group || 'sidebar_action' === group) && 'default_icon' === sub) outputDir = 'icons';
|
|
8383
8366
|
else if ('browser_action' === group && 'theme_icons' === sub) outputDir = 'browser_action';
|
|
8384
8367
|
else if ('theme' === group && 'images' === sub) outputDir = 'theme/images';
|
|
8385
|
-
|
|
8368
|
+
let filename = `${outputDir}/${basename}`;
|
|
8369
|
+
if ('icons' === outputDir) {
|
|
8370
|
+
const relFromManifest = __rspack_external_path.relative(manifestDir, resolved).replace(/\\/g, '/');
|
|
8371
|
+
if (relFromManifest && !relFromManifest.startsWith('..') && !__rspack_external_path.isAbsolute(relFromManifest)) filename = relFromManifest;
|
|
8372
|
+
}
|
|
8386
8373
|
compilation.emitAsset(filename, rawSource);
|
|
8387
8374
|
emittedCount++;
|
|
8388
8375
|
}
|
|
@@ -9187,7 +9174,7 @@ function webpackConfig(projectStructure, devOptions) {
|
|
|
9187
9174
|
externals: [
|
|
9188
9175
|
({ request, dependencyType, context }, callback)=>{
|
|
9189
9176
|
if ('string' != typeof request) return callback();
|
|
9190
|
-
if (/^(chrome|moz)-extension:/i.test(request)) return callback(null, request, 'asset');
|
|
9177
|
+
if (/^(chrome|moz)-extension:|^safari-web-extension:/i.test(request)) return callback(null, request, 'asset');
|
|
9191
9178
|
if ('url' === dependencyType && context && !/^[a-z][\w+.-]*:/i.test(request) && !/^[/#]/.test(request) && !request.startsWith('//')) {
|
|
9192
9179
|
const assetPath = request.split(/[?#]/)[0];
|
|
9193
9180
|
try {
|
|
@@ -9294,9 +9281,11 @@ function webpackConfig(projectStructure, devOptions) {
|
|
|
9294
9281
|
__rspack_external_path.join(packageJsonDir, 'node_modules'),
|
|
9295
9282
|
...(()=>{
|
|
9296
9283
|
const developRoot = resolveDevelopInstallRoot();
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9284
|
+
if (!developRoot) return [];
|
|
9285
|
+
return [
|
|
9286
|
+
__rspack_external_path.join(developRoot, 'node_modules'),
|
|
9287
|
+
__rspack_external_path.dirname(developRoot)
|
|
9288
|
+
];
|
|
9300
9289
|
})()
|
|
9301
9290
|
],
|
|
9302
9291
|
extensions: [
|
package/dist/101.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { createRequire } from "module";
|
|
|
4
4
|
import dotenv from "dotenv";
|
|
5
5
|
import pintor from "pintor";
|
|
6
6
|
import { fetchExtensionFromStore } from "extension-from-store";
|
|
7
|
+
import fs_0 from "fs";
|
|
7
8
|
import path_0 from "path";
|
|
8
9
|
import { getSpecialFoldersData } from "browser-extension-manifest-fields";
|
|
9
10
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
@@ -665,7 +666,7 @@ async function config_loader_isUsingExperimentalConfig(projectPath) {
|
|
|
665
666
|
}
|
|
666
667
|
return false;
|
|
667
668
|
}
|
|
668
|
-
var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.0.
|
|
669
|
+
var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.0.3-canary.328.4af5697","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","adm-zip":"^0.5.16","browser-extension-manifest-fields":"^2.2.8","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.1.1","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.10","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","typescript":"5.9.3","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"}}');
|
|
669
670
|
function asAbsolute(p) {
|
|
670
671
|
return __rspack_external_path.isAbsolute(p) ? p : __rspack_external_path.resolve(p);
|
|
671
672
|
}
|
|
@@ -1290,6 +1291,204 @@ async function resolveCompanionExtensionsConfig(opts) {
|
|
|
1290
1291
|
if (resolvedPaths.length > 0) output.paths = resolvedPaths;
|
|
1291
1292
|
return output;
|
|
1292
1293
|
}
|
|
1294
|
+
const NODE_BUILTINS = new Set([
|
|
1295
|
+
'assert',
|
|
1296
|
+
'buffer',
|
|
1297
|
+
'child_process',
|
|
1298
|
+
'cluster',
|
|
1299
|
+
'console',
|
|
1300
|
+
'constants',
|
|
1301
|
+
'crypto',
|
|
1302
|
+
'dgram',
|
|
1303
|
+
'dns',
|
|
1304
|
+
'domain',
|
|
1305
|
+
'events',
|
|
1306
|
+
'fs',
|
|
1307
|
+
'fs/promises',
|
|
1308
|
+
'http',
|
|
1309
|
+
'http2',
|
|
1310
|
+
'https',
|
|
1311
|
+
'inspector',
|
|
1312
|
+
'module',
|
|
1313
|
+
'net',
|
|
1314
|
+
'os',
|
|
1315
|
+
'path',
|
|
1316
|
+
'perf_hooks',
|
|
1317
|
+
'process',
|
|
1318
|
+
'punycode',
|
|
1319
|
+
'querystring',
|
|
1320
|
+
'readline',
|
|
1321
|
+
'repl',
|
|
1322
|
+
'stream',
|
|
1323
|
+
'string_decoder',
|
|
1324
|
+
'timers',
|
|
1325
|
+
'tls',
|
|
1326
|
+
'trace_events',
|
|
1327
|
+
'tty',
|
|
1328
|
+
'url',
|
|
1329
|
+
'util',
|
|
1330
|
+
'v8',
|
|
1331
|
+
'vm',
|
|
1332
|
+
'worker_threads',
|
|
1333
|
+
'zlib'
|
|
1334
|
+
]);
|
|
1335
|
+
const NODE_BUILD_TOOLS = new Set([
|
|
1336
|
+
'fs-extra',
|
|
1337
|
+
'esbuild',
|
|
1338
|
+
'playwright',
|
|
1339
|
+
'playwright-core',
|
|
1340
|
+
'puppeteer',
|
|
1341
|
+
'puppeteer-core',
|
|
1342
|
+
'webpack',
|
|
1343
|
+
'rollup',
|
|
1344
|
+
'vite',
|
|
1345
|
+
'replace-in-file',
|
|
1346
|
+
'zip-dir',
|
|
1347
|
+
'archiver',
|
|
1348
|
+
'adm-zip',
|
|
1349
|
+
'chokidar',
|
|
1350
|
+
'glob',
|
|
1351
|
+
'fast-glob',
|
|
1352
|
+
'rimraf',
|
|
1353
|
+
'yargs',
|
|
1354
|
+
'execa',
|
|
1355
|
+
'cross-spawn',
|
|
1356
|
+
'shelljs',
|
|
1357
|
+
'web-ext',
|
|
1358
|
+
'dotenv',
|
|
1359
|
+
'node-fetch',
|
|
1360
|
+
'minimist',
|
|
1361
|
+
'ora',
|
|
1362
|
+
'chalk',
|
|
1363
|
+
'gulp',
|
|
1364
|
+
'grunt',
|
|
1365
|
+
'ncp',
|
|
1366
|
+
'del',
|
|
1367
|
+
'cpy',
|
|
1368
|
+
'tsx',
|
|
1369
|
+
'ts-node',
|
|
1370
|
+
'nodemon',
|
|
1371
|
+
'concurrently'
|
|
1372
|
+
]);
|
|
1373
|
+
function importsNodeOnly(specifier) {
|
|
1374
|
+
if (specifier.startsWith('node:')) return true;
|
|
1375
|
+
const bare = specifier.startsWith('@') ? specifier.split('/').slice(0, 2).join('/') : specifier.split('/')[0];
|
|
1376
|
+
return NODE_BUILTINS.has(specifier) || NODE_BUILTINS.has(bare) || NODE_BUILD_TOOLS.has(bare);
|
|
1377
|
+
}
|
|
1378
|
+
function isNodeToolingScript(absPath) {
|
|
1379
|
+
let source;
|
|
1380
|
+
try {
|
|
1381
|
+
source = fs_0.readFileSync(absPath, 'utf8');
|
|
1382
|
+
} catch {
|
|
1383
|
+
return false;
|
|
1384
|
+
}
|
|
1385
|
+
if (/^#!.*\bnode\b/.test(source)) return true;
|
|
1386
|
+
const specifierRe = /(?:require\s*\(\s*|(?:import|export)\b[^'"()]*?\bfrom\s*|import\s*)['"]([^'"]+)['"]/g;
|
|
1387
|
+
let match;
|
|
1388
|
+
while(null !== (match = specifierRe.exec(source)))if (importsNodeOnly(match[1])) return true;
|
|
1389
|
+
return false;
|
|
1390
|
+
}
|
|
1391
|
+
function filterNodeToolingScripts(list) {
|
|
1392
|
+
const next = {};
|
|
1393
|
+
for (const [key, value] of Object.entries(list || {})){
|
|
1394
|
+
const paths = Array.isArray(value) ? value : value ? [
|
|
1395
|
+
value
|
|
1396
|
+
] : [];
|
|
1397
|
+
const kept = paths.filter((entry)=>{
|
|
1398
|
+
const abs = String(entry);
|
|
1399
|
+
if (!path_0.isAbsolute(abs)) return true;
|
|
1400
|
+
return !isNodeToolingScript(abs);
|
|
1401
|
+
});
|
|
1402
|
+
if (0 !== kept.length) next[key] = Array.isArray(value) ? kept : kept[0];
|
|
1403
|
+
}
|
|
1404
|
+
return next;
|
|
1405
|
+
}
|
|
1406
|
+
const REFERENCE_SOURCE_EXTS = new Set([
|
|
1407
|
+
'.html',
|
|
1408
|
+
'.htm',
|
|
1409
|
+
'.js',
|
|
1410
|
+
'.jsx',
|
|
1411
|
+
'.mjs',
|
|
1412
|
+
'.cjs',
|
|
1413
|
+
'.ts',
|
|
1414
|
+
'.tsx',
|
|
1415
|
+
'.mts',
|
|
1416
|
+
'.cts',
|
|
1417
|
+
'.vue',
|
|
1418
|
+
'.svelte'
|
|
1419
|
+
]);
|
|
1420
|
+
const REFERENCE_SKIP_DIRS = new Set([
|
|
1421
|
+
'node_modules',
|
|
1422
|
+
'dist',
|
|
1423
|
+
'build',
|
|
1424
|
+
'out',
|
|
1425
|
+
'.output',
|
|
1426
|
+
'coverage',
|
|
1427
|
+
'.next',
|
|
1428
|
+
'.cache',
|
|
1429
|
+
'.git',
|
|
1430
|
+
'.turbo',
|
|
1431
|
+
"scripts"
|
|
1432
|
+
]);
|
|
1433
|
+
const REFERENCE_MAX_FILES = 4000;
|
|
1434
|
+
const REFERENCE_MAX_BYTES = 12582912;
|
|
1435
|
+
function collectReferenceCorpus(projectRoot) {
|
|
1436
|
+
const parts = [];
|
|
1437
|
+
let files = 0;
|
|
1438
|
+
let bytes = 0;
|
|
1439
|
+
const walk = (dir)=>{
|
|
1440
|
+
if (files >= REFERENCE_MAX_FILES || bytes >= REFERENCE_MAX_BYTES) return;
|
|
1441
|
+
let entries;
|
|
1442
|
+
try {
|
|
1443
|
+
entries = fs_0.readdirSync(dir, {
|
|
1444
|
+
withFileTypes: true
|
|
1445
|
+
});
|
|
1446
|
+
} catch {
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
for (const entry of entries){
|
|
1450
|
+
if (files >= REFERENCE_MAX_FILES || bytes >= REFERENCE_MAX_BYTES) return;
|
|
1451
|
+
const full = path_0.join(dir, entry.name);
|
|
1452
|
+
if (entry.isDirectory()) {
|
|
1453
|
+
if (REFERENCE_SKIP_DIRS.has(entry.name) || entry.name.startsWith('.')) continue;
|
|
1454
|
+
walk(full);
|
|
1455
|
+
continue;
|
|
1456
|
+
}
|
|
1457
|
+
if (!entry.isFile()) continue;
|
|
1458
|
+
const ext = path_0.extname(entry.name).toLowerCase();
|
|
1459
|
+
const isManifest = /^manifest\b.*\.json$/i.test(entry.name);
|
|
1460
|
+
if (isManifest || REFERENCE_SOURCE_EXTS.has(ext)) try {
|
|
1461
|
+
const text = fs_0.readFileSync(full, 'utf8');
|
|
1462
|
+
parts.push(text);
|
|
1463
|
+
files += 1;
|
|
1464
|
+
bytes += text.length;
|
|
1465
|
+
} catch {}
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1468
|
+
walk(projectRoot);
|
|
1469
|
+
return 0 === files ? '' : parts.join('\n');
|
|
1470
|
+
}
|
|
1471
|
+
function filterUnreferencedScripts(list, projectRoot) {
|
|
1472
|
+
const entries = Object.entries(list || {});
|
|
1473
|
+
if (0 === entries.length) return list || {};
|
|
1474
|
+
const corpus = collectReferenceCorpus(projectRoot);
|
|
1475
|
+
if ('' === corpus) return list || {};
|
|
1476
|
+
const isReferenced = (entry)=>{
|
|
1477
|
+
const abs = String(entry);
|
|
1478
|
+
if (!path_0.isAbsolute(abs)) return true;
|
|
1479
|
+
const rel = path_0.relative(projectRoot, abs).split(path_0.sep).join('/');
|
|
1480
|
+
return corpus.includes(rel);
|
|
1481
|
+
};
|
|
1482
|
+
const next = {};
|
|
1483
|
+
for (const [key, value] of entries){
|
|
1484
|
+
const paths = Array.isArray(value) ? value : value ? [
|
|
1485
|
+
value
|
|
1486
|
+
] : [];
|
|
1487
|
+
const kept = paths.filter(isReferenced);
|
|
1488
|
+
if (0 !== kept.length) next[key] = Array.isArray(value) ? kept : kept[0];
|
|
1489
|
+
}
|
|
1490
|
+
return next;
|
|
1491
|
+
}
|
|
1293
1492
|
function isUnderPublicDir(entry, projectRoot, publicDir) {
|
|
1294
1493
|
if (!entry) return false;
|
|
1295
1494
|
const normalizedEntry = String(entry);
|
|
@@ -1331,7 +1530,7 @@ function finalizeSpecialFoldersData(data, projectRoot, publicDir) {
|
|
|
1331
1530
|
return {
|
|
1332
1531
|
...data,
|
|
1333
1532
|
pages: filterPublicEntrypoints(data.pages, projectRoot, publicDir),
|
|
1334
|
-
scripts: filterPublicEntrypoints(data.scripts, projectRoot, publicDir),
|
|
1533
|
+
scripts: filterPublicEntrypoints(filterUnreferencedScripts(filterNodeToolingScripts(data.scripts), projectRoot), projectRoot, publicDir),
|
|
1335
1534
|
extensions: {
|
|
1336
1535
|
dir: './extensions'
|
|
1337
1536
|
}
|