extension-develop 4.1.12 → 4.1.14
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~dev-server.mjs +147 -81
- package/dist/0~rspack-config.mjs +1098 -694
- package/dist/0~zip.mjs +1 -1
- package/dist/101.mjs +190 -900
- package/dist/129.mjs +89 -0
- package/dist/278.mjs +52 -0
- package/dist/292.mjs +61 -0
- package/dist/372.mjs +87 -0
- package/dist/518.mjs +434 -0
- package/dist/77.mjs +933 -0
- package/dist/80.mjs +6 -4
- package/dist/839.mjs +176 -39
- package/dist/845.mjs +10 -1
- package/dist/887.mjs +1 -1
- package/dist/bridge-entry.d.ts +2 -1
- package/dist/bridge.mjs +56 -7
- package/dist/css-parse-guard-loader.mjs +3 -0
- package/dist/dead-css-url-loader.mjs +51 -24
- package/dist/dev-server/cleanup.d.ts +2 -1
- package/dist/dev-server/control-bridge/broker.d.ts +1 -0
- package/dist/dev-server/control-bridge/contracts.d.ts +2 -0
- package/dist/dev-server/control-bridge/logs-query.d.ts +12 -1
- package/dist/dev-server/control-bridge/producer-runtime.d.ts +1 -1
- package/dist/dev-server/messages.d.ts +8 -0
- package/dist/dev-server/session-restart.d.ts +29 -0
- package/dist/ensure-hmr-for-scripts.js +37 -20
- package/dist/ensure-hmr-for-scripts.mjs +37 -20
- package/dist/extension-js-devtools/chrome/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/chrome/scripts/logger-client.js +1 -1
- package/dist/extension-js-devtools/chromium/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/chromium/scripts/logger-client.js +1 -1
- package/dist/extension-js-devtools/edge/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/edge/scripts/logger-client.js +1 -1
- package/dist/extension-js-devtools/firefox/content_scripts/content-0.js +2 -2
- package/dist/extension-js-devtools/firefox/scripts/logger-client.js +1 -1
- package/dist/feature-scripts-classic-concat-loader.js +58 -5
- package/dist/feature-scripts-classic-concat-loader.mjs +58 -5
- package/dist/feature-scripts-content-script-wrapper.js +14 -17
- package/dist/feature-scripts-content-script-wrapper.mjs +14 -17
- package/dist/feature-scripts-native-geturl-import-loader.mjs +10 -3
- package/dist/lib/asset-source-maps.d.ts +7 -0
- package/dist/lib/config-loader.d.ts +7 -34
- package/dist/lib/loader-source-maps.d.ts +17 -0
- package/dist/lib/messages.d.ts +1 -0
- package/dist/lib/msg-placeholders.d.ts +2 -0
- package/dist/lib/paths.d.ts +2 -0
- package/dist/lib/project.d.ts +3 -0
- package/dist/lib/session-project-root.d.ts +1 -0
- package/dist/minimum-script-file.js +41 -1
- package/dist/minimum-script-file.mjs +41 -1
- package/dist/module.d.ts +1 -1
- package/dist/module.mjs +1 -1
- package/dist/plugin-css/css-lib/dead-url-refs.d.ts +5 -0
- package/dist/plugin-css/css-lib/inline-content-script-css.d.ts +32 -0
- package/dist/plugin-css/css-lib/messages.d.ts +3 -0
- package/dist/plugin-css/css-lib/verbatim-css.d.ts +9 -0
- package/dist/plugin-css/css-parse-guard-loader.d.ts +3 -0
- package/dist/plugin-css/css-tools/postcss.d.ts +1 -0
- package/dist/plugin-css/dead-css-url-loader.d.ts +8 -4
- package/dist/plugin-css/index.d.ts +1 -0
- package/dist/plugin-js-frameworks/js-frameworks-lib/jsx-transform.d.ts +10 -0
- package/dist/plugin-js-frameworks/js-tools/solid-jsx-runtime.d.ts +8 -0
- package/dist/plugin-js-frameworks/js-tools/solid.d.ts +3 -0
- package/dist/plugin-js-frameworks/swc-targets.d.ts +3 -0
- package/dist/plugin-reload/classify-reload.d.ts +6 -0
- package/dist/plugin-reload/index.d.ts +2 -1
- package/dist/plugin-reload/reload-dispatch.d.ts +1 -0
- package/dist/plugin-special-folders/folder-extensions/resolve-dirs.d.ts +1 -0
- package/dist/plugin-special-folders/folder-extensions/utils.d.ts +3 -0
- package/dist/plugin-special-folders/messages.d.ts +2 -0
- package/dist/plugin-special-folders/resolve-public-folder.d.ts +13 -0
- package/dist/plugin-web-extension/feature-html/html-lib/assets.d.ts +1 -1
- package/dist/plugin-web-extension/feature-html/html-lib/base-href.d.ts +11 -0
- package/dist/plugin-web-extension/feature-html/html-lib/patch-html.d.ts +2 -2
- package/dist/plugin-web-extension/feature-html/html-lib/utils.d.ts +13 -0
- package/dist/plugin-web-extension/feature-html/index.d.ts +1 -0
- package/dist/plugin-web-extension/feature-html/steps/ensure-hmr-for-scripts.d.ts +1 -1
- package/dist/plugin-web-extension/feature-icons/extract-action-theme-icons.d.ts +2 -0
- package/dist/plugin-web-extension/feature-icons/omnibox-fields.d.ts +2 -0
- package/dist/plugin-web-extension/feature-icons/theme-image-fields.d.ts +2 -0
- package/dist/plugin-web-extension/feature-json/json-validation.d.ts +1 -0
- package/dist/plugin-web-extension/feature-manifest/index.d.ts +1 -0
- package/dist/plugin-web-extension/feature-manifest/manifest-lib/manifest.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/index.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/sandbox.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/storage.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/common/theme.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/index.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv2/chrome_settings_overrides.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv2/index.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv2/theme_experiment.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/action.d.ts +2 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/declarative_net_request.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/manifest-overrides/mv3/index.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/messages.d.ts +2 -0
- package/dist/plugin-web-extension/feature-manifest/normalize-manifest-path.d.ts +4 -0
- package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults-lib/patch-csp.d.ts +1 -1
- package/dist/plugin-web-extension/feature-manifest/steps/apply-dev-defaults.d.ts +1 -0
- package/dist/plugin-web-extension/feature-scripts/steps/native-geturl-import-loader.d.ts +7 -2
- package/dist/plugin-web-extension/feature-web-resources/collect-entry-imports.d.ts +1 -0
- package/dist/plugin-web-extension/index.d.ts +1 -0
- package/dist/plugin-web-extension/shared/html-surfaces.d.ts +19 -0
- package/dist/plugin-web-extension/shared/manifest-fields-change-detector.d.ts +1 -0
- package/dist/plugin-web-extension/shared/manifest-fields.d.ts +18 -0
- package/dist/plugin-web-extension/shared/manifest-path-assets.d.ts +4 -0
- package/dist/plugin-web-extension/shared/paths.d.ts +1 -0
- package/dist/solid-jsx-runtime.mjs +15 -0
- package/dist/types.d.ts +20 -7
- package/package.json +1 -1
- package/dist/494.mjs +0 -89
- package/dist/86.mjs +0 -36
package/dist/0~rspack-config.mjs
CHANGED
|
@@ -12,17 +12,20 @@ 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 {
|
|
15
|
+
import { package_namespaceObject, bundlerFatalError, bundlerRecompiling, browserRunnerDisabled, PlaywrightPlugin, publicFolderShadowed, resolveCompanionExtensionDirs, specialFoldersSetupSummary, noEntrypointsDetected, GECKO_FAMILY_ALIASES, isGeckoBasedBrowser, spacerLine, messages_ready, getPreloadedEnvKeys, isWebkitBasedBrowser, specialFolderChangeDetected, publicMustBeAtProjectRoot, isChromiumBasedBrowser, CHROMIUM_FAMILY_ALIASES, serverRestartRequiredFromSpecialFolderMessageOnly, computeExtensionsToLoad, 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";
|
|
19
19
|
import { jsFrameworksHmrSummary, isUsingTypeScript, resolvePackageManager, humanLine, jsFrameworksIntegrationsEnabled, jsFrameworksConfigsDetected, recordZipArtifact, hasDependency, resolveDevelopInstallRoot, resolveDevelopDistFile, isUsingCustomLoader, ensureTypeScriptConfig, isUsingIntegration as messages_isUsingIntegration, getUserTypeScriptConfigFile } from "./839.mjs";
|
|
20
20
|
import { renderStatsBlocks, makeSanitizedConsole } from "./0~stats-handler.mjs";
|
|
21
|
+
import { utils_isUrl, getBaseNode, manifestJsonOutputTarget, getExtname, getBaseHref, toPosixPath, getAssetsFromHtml, normalizeManifestOutputPath, isFromIncludeList, htmlStaticAssetOutputName, manifestPageOutputTarget, iconOutputPath, isSpecialScheme, resolveStaticAttributeName, getHtmlPageDeclaredAssetPath, themeImageOutputPath, themeIconOutputPath, applyRewrittenStaticUrl, cleanLeading, getFilePath, parseHtml, resolveAbsoluteFsPath, cleanAssetUrl, isHttpLike, resolveHtmlRefPath } from "./518.mjs";
|
|
21
22
|
import { EXTENSIONJS_CONTENT_SCRIPT_LAYER, getCanonicalContentScriptEntryName, parseCanonicalContentScriptAsset, CONTENT_SCRIPT_CSS_PROBE_MARKER_PREFIX, createContentScriptCssProbeMarkerPattern, getCanonicalContentScriptJsAssetName, getCanonicalContentScriptCssAssetName, isCanonicalContentScriptAsset } from "./291.mjs";
|
|
23
|
+
import { packagingSourceFiles, debugBrowser, debugExtensionsToLoad, treeWithSourceFiles, debugOutputPath, manifestInvalidJson, getDirs, asAbsolute, treeWithDistFilesBrowser, packagingDistributionFiles, treeWithSourceAndDistFiles, toPosixPath as paths_toPosixPath, debugContextPath, noCompanionExtensionsResolved } from "./77.mjs";
|
|
22
24
|
import { hasProjectDependency, findNearestProjectManifestSync, PROJECT_MANIFEST_FILENAMES, readProjectDependencies } from "./80.mjs";
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
+
import { cssMinifierDroppedRules, postCssConfigUnreadable, missingSassDependency, deadCssUrlRef, postCssPluginNotResolved, postCssConfigPluginsShape, cssIntegrationsEnabled, cssConfigsDetected, isUsingIntegration } from "./845.mjs";
|
|
26
|
+
import { minifierDroppedTokens, restoreVerbatimCssAssets } from "./129.mjs";
|
|
25
27
|
import { injectedFileDependencyMissing, importScriptsDependencyMissing, getURLDependencyMissing, staticImportDependencyMissing, fetchedFileDependencyMissing, runtimeSetSurfaceDependencyMissing } from "./266.mjs";
|
|
28
|
+
import { inspectPublicFolders, publicResolveRoots, rememberPublicRoots } from "./278.mjs";
|
|
26
29
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
27
30
|
import { dirname as __rspack_dirname } from "node:path";
|
|
28
31
|
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
@@ -497,6 +500,90 @@ function countFilesRecursively(dir) {
|
|
|
497
500
|
return 0;
|
|
498
501
|
}
|
|
499
502
|
}
|
|
503
|
+
const ACTION_HTML_FEATURE = 'action/index';
|
|
504
|
+
const PAGE_ACTION_HTML_FEATURE = 'page_action/index';
|
|
505
|
+
const ACTION_HTML_OUTPUT = 'action/index.html';
|
|
506
|
+
const PAGE_ACTION_HTML_OUTPUT = 'page_action/index.html';
|
|
507
|
+
function readDefaultPopup(value) {
|
|
508
|
+
if (!value || 'object' != typeof value || Array.isArray(value)) return;
|
|
509
|
+
const popup = value.default_popup;
|
|
510
|
+
if ('string' != typeof popup) return;
|
|
511
|
+
const trimmed = popup.trim();
|
|
512
|
+
return trimmed || void 0;
|
|
513
|
+
}
|
|
514
|
+
function normalizePopupRef(ref) {
|
|
515
|
+
return String(ref || '').replace(/\\/g, '/').replace(/^\.\//, '').replace(/^\/+/, '');
|
|
516
|
+
}
|
|
517
|
+
function popupRefsShareSource(a, b) {
|
|
518
|
+
if ('string' != typeof a || 'string' != typeof b) return false;
|
|
519
|
+
const left = normalizePopupRef(a);
|
|
520
|
+
const right = normalizePopupRef(b);
|
|
521
|
+
return Boolean(left) && left === right;
|
|
522
|
+
}
|
|
523
|
+
function resolveManifestHtmlPath(context, relativePath) {
|
|
524
|
+
const unix = relativePath.replace(/\\/g, '/');
|
|
525
|
+
if (/^\/public\//i.test(unix)) return __rspack_external_node_path_c5b9b54f.join(context, 'public', unix.replace(/^\/public\//i, ''));
|
|
526
|
+
if (/^(?:\.\/)?public\//i.test(unix)) return __rspack_external_node_path_c5b9b54f.join(context, 'public', unix.replace(/^(?:\.\/)?public\//i, ''));
|
|
527
|
+
if (/^\//.test(unix)) return __rspack_external_node_path_c5b9b54f.join(context, unix.slice(1));
|
|
528
|
+
return __rspack_external_node_path_c5b9b54f.join(context, unix);
|
|
529
|
+
}
|
|
530
|
+
function actionPopupRef(manifest) {
|
|
531
|
+
if (!manifest) return;
|
|
532
|
+
return readDefaultPopup(manifest.action) || readDefaultPopup(manifest.browser_action);
|
|
533
|
+
}
|
|
534
|
+
function pageActionPopupRef(manifest) {
|
|
535
|
+
if (!manifest) return;
|
|
536
|
+
return readDefaultPopup(manifest.page_action);
|
|
537
|
+
}
|
|
538
|
+
function isPageActionLiveSurface(manifest, browser) {
|
|
539
|
+
if (isGeckoBasedBrowser(String(browser || ''))) return true;
|
|
540
|
+
const version = Number(manifest?.manifest_version);
|
|
541
|
+
return Number.isFinite(version) && version < 3;
|
|
542
|
+
}
|
|
543
|
+
function pageActionDropReason(manifest, browser) {
|
|
544
|
+
if (!manifest || 'object' != typeof manifest) return;
|
|
545
|
+
if (!('page_action' in manifest) || null == manifest.page_action) return;
|
|
546
|
+
if (!isPageActionLiveSurface(manifest, browser)) return 'unsupported';
|
|
547
|
+
if (isChromiumBasedBrowser(String(browser || '')) && null != manifest.browser_action) return 'conflicts';
|
|
548
|
+
}
|
|
549
|
+
function shouldDropPageAction(manifest, browser) {
|
|
550
|
+
return void 0 !== pageActionDropReason(manifest, browser);
|
|
551
|
+
}
|
|
552
|
+
function dropPageAction(manifest) {
|
|
553
|
+
if (!manifest || !('page_action' in manifest)) return manifest;
|
|
554
|
+
const rest = {
|
|
555
|
+
...manifest
|
|
556
|
+
};
|
|
557
|
+
delete rest.page_action;
|
|
558
|
+
return rest;
|
|
559
|
+
}
|
|
560
|
+
function pageActionOutputTarget(manifest) {
|
|
561
|
+
const actionRef = actionPopupRef(manifest);
|
|
562
|
+
const pageRef = pageActionPopupRef(manifest);
|
|
563
|
+
if (actionRef && pageRef && popupRefsShareSource(actionRef, pageRef)) return ACTION_HTML_OUTPUT;
|
|
564
|
+
return PAGE_ACTION_HTML_OUTPUT;
|
|
565
|
+
}
|
|
566
|
+
function applyIndependentHtmlSurfaces(html, manifest, context, browser) {
|
|
567
|
+
const next = {
|
|
568
|
+
...html || {}
|
|
569
|
+
};
|
|
570
|
+
const actionRef = actionPopupRef(manifest);
|
|
571
|
+
const pageRef = pageActionPopupRef(manifest);
|
|
572
|
+
const actionAbs = actionRef ? resolveManifestHtmlPath(context, actionRef) : void 0;
|
|
573
|
+
const pageAbs = pageRef ? resolveManifestHtmlPath(context, pageRef) : void 0;
|
|
574
|
+
if (actionAbs) next[ACTION_HTML_FEATURE] = actionAbs;
|
|
575
|
+
else delete next[ACTION_HTML_FEATURE];
|
|
576
|
+
if (!pageAbs || pageActionDropReason(manifest, browser)) {
|
|
577
|
+
delete next[PAGE_ACTION_HTML_FEATURE];
|
|
578
|
+
return next;
|
|
579
|
+
}
|
|
580
|
+
if (actionAbs && popupRefsShareSource(actionRef, pageRef)) {
|
|
581
|
+
delete next[PAGE_ACTION_HTML_FEATURE];
|
|
582
|
+
return next;
|
|
583
|
+
}
|
|
584
|
+
next[PAGE_ACTION_HTML_FEATURE] = pageAbs;
|
|
585
|
+
return next;
|
|
586
|
+
}
|
|
500
587
|
function isFromFilepathList(filePath, filepathList) {
|
|
501
588
|
return Object.values(filepathList || {}).some((value)=>value === filePath);
|
|
502
589
|
}
|
|
@@ -549,6 +636,11 @@ function collectRootAbsoluteRefs(source) {
|
|
|
549
636
|
while(m = urlRe.exec(source))refs.add(m[1]);
|
|
550
637
|
return refs;
|
|
551
638
|
}
|
|
639
|
+
function isManifestAddress(value) {
|
|
640
|
+
if ('string' != typeof value) return false;
|
|
641
|
+
const trimmed = value.trim();
|
|
642
|
+
return /^[a-z][a-z0-9+.-]+:/i.test(trimmed) || trimmed.startsWith('//');
|
|
643
|
+
}
|
|
552
644
|
function backgroundPage(manifest) {
|
|
553
645
|
return manifest.background?.page && {
|
|
554
646
|
background: {
|
|
@@ -559,35 +651,6 @@ function backgroundPage(manifest) {
|
|
|
559
651
|
}
|
|
560
652
|
};
|
|
561
653
|
}
|
|
562
|
-
function normalizeManifestOutputPath(originalPath) {
|
|
563
|
-
if (!originalPath) return originalPath;
|
|
564
|
-
const unixPath = originalPath.replace(/\\/g, '/');
|
|
565
|
-
if (/^\/public\//i.test(unixPath)) return unixPath.replace(/^\/public\//i, '');
|
|
566
|
-
if (/^(?:\.\/)?public\//i.test(unixPath)) return unixPath.replace(/^(?:\.\/)?public\//i, '');
|
|
567
|
-
if (/^\//.test(unixPath)) return unixPath.replace(/^\//, '');
|
|
568
|
-
return unixPath;
|
|
569
|
-
}
|
|
570
|
-
function manifestPageOutputTarget(raw, compiledTarget, manifestPath) {
|
|
571
|
-
const unixPath = raw.replace(/\\/g, '/');
|
|
572
|
-
if (/^(?:\/public\/|(?:\.\/)?public\/)/i.test(unixPath)) return normalizeManifestOutputPath(unixPath);
|
|
573
|
-
if (/^\//.test(unixPath)) {
|
|
574
|
-
const rest = unixPath.replace(/^\/+/, '');
|
|
575
|
-
if (manifestPath && rest) {
|
|
576
|
-
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
577
|
-
const inPublic = __rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(manifestDir, 'public', rest));
|
|
578
|
-
const inRoot = __rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(manifestDir, rest));
|
|
579
|
-
if (inRoot && !inPublic) return compiledTarget;
|
|
580
|
-
}
|
|
581
|
-
return normalizeManifestOutputPath(unixPath);
|
|
582
|
-
}
|
|
583
|
-
return compiledTarget;
|
|
584
|
-
}
|
|
585
|
-
function iconOutputPath(raw) {
|
|
586
|
-
if (/^(?:\/public\/|(?:\.\/)?public\/)/i.test(raw)) return normalizeManifestOutputPath(raw);
|
|
587
|
-
const normalized = normalizeManifestOutputPath(raw).replace(/^\.\//, '');
|
|
588
|
-
const escapes = !normalized || normalized.split('/').includes('..') || /^[A-Za-z]:/.test(normalized);
|
|
589
|
-
return escapes ? `icons/${normalized.split('/').pop() || ''}` : normalized;
|
|
590
|
-
}
|
|
591
654
|
function chromeUrlOverrides(manifest, manifestPath) {
|
|
592
655
|
return manifest.chrome_url_overrides && {
|
|
593
656
|
chrome_url_overrides: {
|
|
@@ -696,16 +759,15 @@ function icons_icons(manifest) {
|
|
|
696
759
|
}))
|
|
697
760
|
};
|
|
698
761
|
}
|
|
699
|
-
const getBasename = (filepath)=>__rspack_external_node_path_c5b9b54f.basename(filepath);
|
|
700
762
|
function omnibox_omnibox(manifest) {
|
|
701
763
|
const omnibox = manifest.omnibox;
|
|
702
764
|
return omnibox && {
|
|
703
765
|
omnibox: {
|
|
704
766
|
...omnibox,
|
|
705
767
|
...omnibox.default_icon && {
|
|
706
|
-
default_icon: 'string' == typeof omnibox.default_icon ? getFilename(
|
|
768
|
+
default_icon: 'string' == typeof omnibox.default_icon ? getFilename(iconOutputPath(omnibox.default_icon), omnibox.default_icon) : Object.fromEntries(Object.entries(omnibox.default_icon).map(([size, icon])=>[
|
|
707
769
|
size,
|
|
708
|
-
getFilename(
|
|
770
|
+
getFilename(iconOutputPath(icon), icon)
|
|
709
771
|
]))
|
|
710
772
|
}
|
|
711
773
|
}
|
|
@@ -737,38 +799,37 @@ function permissions(manifest) {
|
|
|
737
799
|
permissions: manifest.permissions
|
|
738
800
|
};
|
|
739
801
|
}
|
|
740
|
-
function sandbox(manifest) {
|
|
802
|
+
function sandbox(manifest, manifestPath) {
|
|
741
803
|
return manifest.sandbox && {
|
|
742
804
|
sandbox: {
|
|
743
805
|
...manifest.sandbox,
|
|
744
806
|
...manifest.sandbox.pages && {
|
|
745
|
-
pages: manifest.sandbox.pages.map((page, index)=>getFilename(`sandbox/page-${index}.html`, page))
|
|
807
|
+
pages: manifest.sandbox.pages.map((page, index)=>getFilename(manifestPageOutputTarget(page, `sandbox/page-${index}.html`, manifestPath), page))
|
|
746
808
|
}
|
|
747
809
|
}
|
|
748
810
|
};
|
|
749
811
|
}
|
|
750
|
-
function storage(manifest, manifestPath) {
|
|
812
|
+
function storage(manifest, manifestPath, projectPath) {
|
|
751
813
|
return manifest.storage && {
|
|
752
814
|
storage: {
|
|
753
815
|
...manifest.storage.managed_schema && {
|
|
754
816
|
managed_schema: (()=>{
|
|
755
817
|
const raw = String(manifest.storage.managed_schema);
|
|
756
|
-
return getFilename(
|
|
818
|
+
return getFilename(manifestJsonOutputTarget(raw, 'storage/managed_schema.json', manifestPath, projectPath), raw);
|
|
757
819
|
})()
|
|
758
820
|
}
|
|
759
821
|
}
|
|
760
822
|
};
|
|
761
823
|
}
|
|
762
|
-
const
|
|
763
|
-
|
|
764
|
-
function theme_theme(manifest) {
|
|
824
|
+
const rewriteThemeImage = (value, manifestPath)=>getFilename(manifestPageOutputTarget(value, themeImageOutputPath(value), manifestPath), value);
|
|
825
|
+
function theme_theme(manifest, manifestPath) {
|
|
765
826
|
return manifest.theme && {
|
|
766
827
|
theme: {
|
|
767
828
|
...manifest.theme,
|
|
768
829
|
...manifest.theme.images && {
|
|
769
830
|
images: Object.fromEntries(Object.entries(manifest.theme.images).map(([key, value])=>[
|
|
770
831
|
key,
|
|
771
|
-
Array.isArray(value) ? value.map(rewriteThemeImage) : rewriteThemeImage(value)
|
|
832
|
+
Array.isArray(value) ? value.map((entry)=>rewriteThemeImage(entry, manifestPath)) : rewriteThemeImage(value, manifestPath)
|
|
772
833
|
]))
|
|
773
834
|
}
|
|
774
835
|
}
|
|
@@ -809,7 +870,7 @@ function webAccessibleResources(manifest) {
|
|
|
809
870
|
web_accessible_resources: entries
|
|
810
871
|
};
|
|
811
872
|
}
|
|
812
|
-
function manifestCommon(manifest, manifestPath) {
|
|
873
|
+
function manifestCommon(manifest, manifestPath, projectPath) {
|
|
813
874
|
return {
|
|
814
875
|
...backgroundPage(manifest),
|
|
815
876
|
...chromeUrlOverrides(manifest, manifestPath),
|
|
@@ -820,9 +881,9 @@ function manifestCommon(manifest, manifestPath) {
|
|
|
820
881
|
...permissions(manifest),
|
|
821
882
|
...optionsPage(manifest, manifestPath),
|
|
822
883
|
...optionsUi(manifest, manifestPath),
|
|
823
|
-
...sandbox(manifest),
|
|
824
|
-
...storage(manifest, manifestPath),
|
|
825
|
-
...theme_theme(manifest),
|
|
884
|
+
...sandbox(manifest, manifestPath),
|
|
885
|
+
...storage(manifest, manifestPath, projectPath),
|
|
886
|
+
...theme_theme(manifest, manifestPath),
|
|
826
887
|
...userScripts(manifest),
|
|
827
888
|
...webAccessibleResources(manifest),
|
|
828
889
|
...contentSecurityPolicy(manifest),
|
|
@@ -834,7 +895,7 @@ function pageAction(manifest) {
|
|
|
834
895
|
page_action: {
|
|
835
896
|
...manifest.page_action,
|
|
836
897
|
...manifest.page_action.default_popup && {
|
|
837
|
-
default_popup: getFilename(
|
|
898
|
+
default_popup: getFilename(pageActionOutputTarget(manifest), manifest.page_action.default_popup)
|
|
838
899
|
},
|
|
839
900
|
...manifest.page_action.default_icon && {
|
|
840
901
|
default_icon: 'string' == typeof manifest.page_action.default_icon ? (()=>{
|
|
@@ -905,73 +966,61 @@ function browserAction(manifest) {
|
|
|
905
966
|
theme_icons: manifest.browser_action.theme_icons.map((themeIcon)=>({
|
|
906
967
|
...themeIcon,
|
|
907
968
|
...themeIcon.light && {
|
|
908
|
-
light: (()
|
|
909
|
-
const raw = String(themeIcon.light);
|
|
910
|
-
const isPublic = /^(?:\/public\/|(?:\.\/)?public\/)/i.test(raw);
|
|
911
|
-
const target = isPublic ? normalizeManifestOutputPath(raw) : `browser_action/${__rspack_external_node_path_c5b9b54f.basename(raw)}`;
|
|
912
|
-
return getFilename(target, raw);
|
|
913
|
-
})()
|
|
969
|
+
light: getFilename(themeIconOutputPath(String(themeIcon.light), 'browser_action'), String(themeIcon.light))
|
|
914
970
|
},
|
|
915
971
|
...themeIcon.dark && {
|
|
916
|
-
dark: (()
|
|
917
|
-
const raw = String(themeIcon.dark);
|
|
918
|
-
const isPublic = /^(?:\/public\/|(?:\.\/)?public\/)/i.test(raw);
|
|
919
|
-
const target = isPublic ? normalizeManifestOutputPath(raw) : `browser_action/${__rspack_external_node_path_c5b9b54f.basename(raw)}`;
|
|
920
|
-
return getFilename(target, raw);
|
|
921
|
-
})()
|
|
972
|
+
dark: getFilename(themeIconOutputPath(String(themeIcon.dark), 'browser_action'), String(themeIcon.dark))
|
|
922
973
|
}
|
|
923
974
|
}))
|
|
924
975
|
}
|
|
925
976
|
}
|
|
926
977
|
};
|
|
927
978
|
}
|
|
928
|
-
function chromeSettingsOverrides(manifest) {
|
|
929
|
-
|
|
979
|
+
function chromeSettingsOverrides(manifest, manifestPath) {
|
|
980
|
+
const overrides = manifest.chrome_settings_overrides;
|
|
981
|
+
return overrides && {
|
|
930
982
|
chrome_settings_overrides: {
|
|
931
|
-
...
|
|
932
|
-
homepage:
|
|
983
|
+
...overrides.homepage && {
|
|
984
|
+
homepage: overrides.homepage
|
|
933
985
|
},
|
|
934
|
-
...
|
|
986
|
+
...overrides.search_provider && {
|
|
935
987
|
search_provider: {
|
|
936
|
-
...
|
|
937
|
-
...
|
|
988
|
+
...overrides.search_provider,
|
|
989
|
+
...overrides.search_provider.favicon_url && {
|
|
938
990
|
favicon_url: (()=>{
|
|
939
|
-
const fav =
|
|
940
|
-
|
|
941
|
-
return
|
|
991
|
+
const fav = String(overrides.search_provider.favicon_url);
|
|
992
|
+
if (isManifestAddress(fav)) return fav;
|
|
993
|
+
return getFilename(manifestPageOutputTarget(fav, `chrome_settings_overrides/${__rspack_external_node_path_c5b9b54f.basename(fav)}`, manifestPath), fav);
|
|
942
994
|
})()
|
|
943
995
|
}
|
|
944
996
|
}
|
|
945
997
|
},
|
|
946
|
-
...
|
|
947
|
-
startup_pages:
|
|
998
|
+
...overrides.startup_pages && {
|
|
999
|
+
startup_pages: overrides.startup_pages.map((page, index)=>isManifestAddress(page) ? page : getFilename(manifestPageOutputTarget(page, `chrome_settings_overrides/startup-${index}.html`, manifestPath), page))
|
|
948
1000
|
}
|
|
949
1001
|
}
|
|
950
1002
|
};
|
|
951
1003
|
}
|
|
952
|
-
const
|
|
953
|
-
function themeExperiment(manifest) {
|
|
1004
|
+
const getBasename = (filepath)=>__rspack_external_node_path_c5b9b54f.basename(filepath);
|
|
1005
|
+
function themeExperiment(manifest, manifestPath) {
|
|
954
1006
|
const te = manifest.theme_experiment;
|
|
955
1007
|
return te && {
|
|
956
1008
|
theme_experiment: {
|
|
957
1009
|
...te,
|
|
958
1010
|
...'string' == typeof te.stylesheet && {
|
|
959
|
-
stylesheet: getFilename(`theme_experiment/${
|
|
960
|
-
},
|
|
961
|
-
...Array.isArray(te.stylesheets) && {
|
|
962
|
-
stylesheets: te.stylesheets.map((s, i)=>getFilename(`theme_experiment/stylesheet-${i}.css`, s))
|
|
1011
|
+
stylesheet: getFilename(manifestPageOutputTarget(te.stylesheet, `theme_experiment/${getBasename(te.stylesheet)}`, manifestPath), te.stylesheet)
|
|
963
1012
|
}
|
|
964
1013
|
}
|
|
965
1014
|
};
|
|
966
1015
|
}
|
|
967
|
-
function manifestV2(manifest) {
|
|
1016
|
+
function manifestV2(manifest, manifestPath) {
|
|
968
1017
|
return {
|
|
969
1018
|
...background_background(manifest),
|
|
970
1019
|
...browserAction(manifest),
|
|
971
1020
|
...pageAction(manifest),
|
|
972
1021
|
...sidebarAction(manifest),
|
|
973
|
-
...chromeSettingsOverrides(manifest),
|
|
974
|
-
...themeExperiment(manifest)
|
|
1022
|
+
...chromeSettingsOverrides(manifest, manifestPath),
|
|
1023
|
+
...themeExperiment(manifest, manifestPath)
|
|
975
1024
|
};
|
|
976
1025
|
}
|
|
977
1026
|
function action_action(manifest) {
|
|
@@ -992,6 +1041,17 @@ function action_action(manifest) {
|
|
|
992
1041
|
getFilename(iconOutputPath(raw), raw)
|
|
993
1042
|
];
|
|
994
1043
|
}))
|
|
1044
|
+
},
|
|
1045
|
+
...manifest.action.theme_icons && {
|
|
1046
|
+
theme_icons: manifest.action.theme_icons.map((themeIcon)=>({
|
|
1047
|
+
...themeIcon,
|
|
1048
|
+
...themeIcon.light && {
|
|
1049
|
+
light: getFilename(themeIconOutputPath(String(themeIcon.light), 'action'), String(themeIcon.light))
|
|
1050
|
+
},
|
|
1051
|
+
...themeIcon.dark && {
|
|
1052
|
+
dark: getFilename(themeIconOutputPath(String(themeIcon.dark), 'action'), String(themeIcon.dark))
|
|
1053
|
+
}
|
|
1054
|
+
}))
|
|
995
1055
|
}
|
|
996
1056
|
}
|
|
997
1057
|
};
|
|
@@ -1006,14 +1066,14 @@ function backgroundServiceWorker(manifest) {
|
|
|
1006
1066
|
}
|
|
1007
1067
|
};
|
|
1008
1068
|
}
|
|
1009
|
-
function declarativeNetRequest(manifest, manifestPath) {
|
|
1069
|
+
function declarativeNetRequest(manifest, manifestPath, projectPath) {
|
|
1010
1070
|
return manifest.declarative_net_request && {
|
|
1011
1071
|
declarative_net_request: {
|
|
1012
1072
|
...manifest.declarative_net_request,
|
|
1013
1073
|
...Array.isArray(manifest.declarative_net_request.rule_resources) && {
|
|
1014
1074
|
rule_resources: manifest.declarative_net_request.rule_resources.map((resourceObj)=>({
|
|
1015
1075
|
...resourceObj,
|
|
1016
|
-
path: resourceObj.path && getFilename(
|
|
1076
|
+
path: resourceObj.path && getFilename(manifestJsonOutputTarget(resourceObj.path, `declarative_net_request/${resourceObj.id}.json`, manifestPath, projectPath), resourceObj.path)
|
|
1017
1077
|
}))
|
|
1018
1078
|
}
|
|
1019
1079
|
}
|
|
@@ -1037,16 +1097,17 @@ function sidePanel(manifest) {
|
|
|
1037
1097
|
}
|
|
1038
1098
|
};
|
|
1039
1099
|
}
|
|
1040
|
-
function manifestV3(manifest, manifestPath) {
|
|
1100
|
+
function manifestV3(manifest, manifestPath, projectPath) {
|
|
1041
1101
|
return {
|
|
1042
1102
|
...action_action(manifest),
|
|
1103
|
+
...pageAction(manifest),
|
|
1043
1104
|
...backgroundServiceWorker(manifest),
|
|
1044
|
-
...declarativeNetRequest(manifest, manifestPath),
|
|
1105
|
+
...declarativeNetRequest(manifest, manifestPath, projectPath),
|
|
1045
1106
|
...hostPermissions(manifest),
|
|
1046
1107
|
...sidePanel(manifest)
|
|
1047
1108
|
};
|
|
1048
1109
|
}
|
|
1049
|
-
function getManifestOverrides(manifestPath, manifest) {
|
|
1110
|
+
function getManifestOverrides(manifestPath, manifest, projectPath) {
|
|
1050
1111
|
const manifestContent = manifest || JSON.parse(stripBom(__rspack_external_node_fs_5ea92f0c.readFileSync(manifestPath, 'utf8')));
|
|
1051
1112
|
const omit = (obj, key)=>{
|
|
1052
1113
|
if (!obj) return {};
|
|
@@ -1057,9 +1118,9 @@ function getManifestOverrides(manifestPath, manifest) {
|
|
|
1057
1118
|
const value = obj.background;
|
|
1058
1119
|
return value && 'object' == typeof value ? value : {};
|
|
1059
1120
|
};
|
|
1060
|
-
const common = manifestCommon(manifestContent, manifestPath);
|
|
1061
|
-
const mv2 = manifestV2(manifestContent);
|
|
1062
|
-
const mv3 = manifestV3(manifestContent, manifestPath);
|
|
1121
|
+
const common = manifestCommon(manifestContent, manifestPath, projectPath);
|
|
1122
|
+
const mv2 = manifestV2(manifestContent, manifestPath);
|
|
1123
|
+
const mv3 = manifestV3(manifestContent, manifestPath, projectPath);
|
|
1063
1124
|
const backgroundMerged = {
|
|
1064
1125
|
...manifestContent.background || {},
|
|
1065
1126
|
...pickBackground(common),
|
|
@@ -1138,11 +1199,12 @@ function getManifestContent(compilation, manifestPath) {
|
|
|
1138
1199
|
return manifest_cjsRequire(manifestPath);
|
|
1139
1200
|
}
|
|
1140
1201
|
}
|
|
1141
|
-
function buildCanonicalManifest(manifestPath, manifest, browser) {
|
|
1202
|
+
function buildCanonicalManifest(manifestPath, manifest, browser, projectPath) {
|
|
1142
1203
|
const filteredManifest = filterKeysForThisBrowser(manifest, browser);
|
|
1204
|
+
const forOverrides = shouldDropPageAction(filteredManifest, browser) ? dropPageAction(filteredManifest) : filteredManifest;
|
|
1143
1205
|
return {
|
|
1144
|
-
...
|
|
1145
|
-
...JSON.parse(getManifestOverrides(manifestPath,
|
|
1206
|
+
...forOverrides,
|
|
1207
|
+
...JSON.parse(getManifestOverrides(manifestPath, forOverrides, projectPath))
|
|
1146
1208
|
};
|
|
1147
1209
|
}
|
|
1148
1210
|
function resolveProcessShim() {
|
|
@@ -1452,7 +1514,7 @@ class ZipPlugin {
|
|
|
1452
1514
|
if (isDebug()) console.log(packagingDistributionFiles(distPath));
|
|
1453
1515
|
writeZipFile(distPath, listFilesUnder(outPath, new Set([
|
|
1454
1516
|
toPosix(zipName)
|
|
1455
|
-
])).map((file)=>({
|
|
1517
|
+
])).filter((file)=>!file.endsWith('.map')).map((file)=>({
|
|
1456
1518
|
name: file,
|
|
1457
1519
|
absPath: __rspack_external_node_path_c5b9b54f.join(outPath, file)
|
|
1458
1520
|
})));
|
|
@@ -1547,7 +1609,7 @@ class CompilationPlugin {
|
|
|
1547
1609
|
'process.env.NODE_ENV': JSON.stringify(compiler.options.mode || 'development')
|
|
1548
1610
|
}).apply(compiler);
|
|
1549
1611
|
} catch {}
|
|
1550
|
-
if ((this.zip || this.zipSource) && '
|
|
1612
|
+
if ((this.zip || this.zipSource) && 'dev' !== this.command) new ZipPlugin({
|
|
1551
1613
|
manifestPath: this.manifestPath,
|
|
1552
1614
|
browser: this.browser || 'chrome',
|
|
1553
1615
|
zipData: {
|
|
@@ -1557,7 +1619,7 @@ class CompilationPlugin {
|
|
|
1557
1619
|
}
|
|
1558
1620
|
}).apply(compiler);
|
|
1559
1621
|
else if (isDebug()) {
|
|
1560
|
-
const reason = '
|
|
1622
|
+
const reason = 'dev' === this.command ? 'a dev session never packages' : 'zip disabled';
|
|
1561
1623
|
console.log(zipPackagingSkipped(reason));
|
|
1562
1624
|
}
|
|
1563
1625
|
new BoringPlugin({
|
|
@@ -1716,6 +1778,10 @@ function getOptionalDependencyContract(contractId) {
|
|
|
1716
1778
|
if (!contract) throw new Error(`Unknown optional dependency contract: ${contractId}`);
|
|
1717
1779
|
return contract;
|
|
1718
1780
|
}
|
|
1781
|
+
function debugSwallowed(step, error) {
|
|
1782
|
+
if (!isVerboseMode()) return;
|
|
1783
|
+
console.log(`${messaging_prefix('debug')} optional-deps ${step}: ${String(error?.message || error)}`);
|
|
1784
|
+
}
|
|
1719
1785
|
function isVerboseMode() {
|
|
1720
1786
|
return '1' === String(process.env.EXTENSION_VERBOSE || '').trim();
|
|
1721
1787
|
}
|
|
@@ -1773,7 +1839,8 @@ function tryResolveWithBase(dependencyId, basePath) {
|
|
|
1773
1839
|
try {
|
|
1774
1840
|
const req = createRequire(optional_deps_resolver_packageJsonPath(basePath));
|
|
1775
1841
|
return req.resolve(dependencyId);
|
|
1776
|
-
} catch
|
|
1842
|
+
} catch (error) {
|
|
1843
|
+
debugSwallowed(`resolve ${dependencyId} from ${basePath}`, error);
|
|
1777
1844
|
return;
|
|
1778
1845
|
}
|
|
1779
1846
|
}
|
|
@@ -1794,7 +1861,8 @@ function resolveDependency(dependencyId, projectPath) {
|
|
|
1794
1861
|
resolvedPath,
|
|
1795
1862
|
basePath: projectPath
|
|
1796
1863
|
};
|
|
1797
|
-
} catch
|
|
1864
|
+
} catch (error) {
|
|
1865
|
+
debugSwallowed(`resolve ${dependencyId} from the project bases`, error);
|
|
1798
1866
|
return;
|
|
1799
1867
|
}
|
|
1800
1868
|
}
|
|
@@ -1806,7 +1874,8 @@ function resolveFromKnownLocations(dependencyId, projectPath) {
|
|
|
1806
1874
|
function declaresDependency(projectPath, dependencyId) {
|
|
1807
1875
|
try {
|
|
1808
1876
|
return hasProjectDependency(projectPath, dependencyId);
|
|
1809
|
-
} catch
|
|
1877
|
+
} catch (error) {
|
|
1878
|
+
debugSwallowed(`read the project manifest for ${dependencyId}`, error);
|
|
1810
1879
|
return false;
|
|
1811
1880
|
}
|
|
1812
1881
|
}
|
|
@@ -1816,7 +1885,8 @@ function dedupeFailures(packageIds) {
|
|
|
1816
1885
|
function resolveRealPathSafe(targetPath) {
|
|
1817
1886
|
try {
|
|
1818
1887
|
return __rspack_external_node_fs_5ea92f0c.realpathSync(targetPath);
|
|
1819
|
-
} catch
|
|
1888
|
+
} catch (error) {
|
|
1889
|
+
debugSwallowed(`realpath ${targetPath}`, error);
|
|
1820
1890
|
return __rspack_external_node_path_c5b9b54f.resolve(targetPath);
|
|
1821
1891
|
}
|
|
1822
1892
|
}
|
|
@@ -1843,7 +1913,8 @@ function evaluateModuleContextRule(rule, fromPackagePath, options) {
|
|
|
1843
1913
|
if (options?.expectedInstalledPath && !isSameInstalledPackage(resolvedPeer, options.expectedInstalledPath)) return rule.packageId;
|
|
1844
1914
|
if ('module-context-load' === rule.type) req(rule.packageId);
|
|
1845
1915
|
return;
|
|
1846
|
-
} catch
|
|
1916
|
+
} catch (error) {
|
|
1917
|
+
debugSwallowed(`verify ${rule.packageId}`, error);
|
|
1847
1918
|
return rule.packageId;
|
|
1848
1919
|
}
|
|
1849
1920
|
}
|
|
@@ -2204,14 +2275,20 @@ async function loadUserPostCssConfigObject(configPath, projectPath, mode) {
|
|
|
2204
2275
|
try {
|
|
2205
2276
|
if (configPath.endsWith('.postcssrc') || configPath.endsWith('.json')) loaded = JSON.parse(__rspack_external_node_fs_5ea92f0c.readFileSync(configPath, 'utf8'));
|
|
2206
2277
|
else if (configPath.endsWith('.yaml') || configPath.endsWith('.yml')) return;
|
|
2207
|
-
else if (configPath.endsWith('.cjs')) loaded = tryLoadCjsConfig(configPath
|
|
2278
|
+
else if (configPath.endsWith('.cjs')) loaded = tryLoadCjsConfig(configPath, {
|
|
2279
|
+
report: true
|
|
2280
|
+
});
|
|
2208
2281
|
else try {
|
|
2209
2282
|
const mod = await import(pathToFileURL(configPath).href);
|
|
2210
2283
|
loaded = mod?.default ?? mod;
|
|
2211
|
-
} catch
|
|
2212
|
-
loaded = tryLoadCjsConfig(configPath
|
|
2284
|
+
} catch (importError) {
|
|
2285
|
+
loaded = tryLoadCjsConfig(configPath, {
|
|
2286
|
+
report: false
|
|
2287
|
+
});
|
|
2288
|
+
if (void 0 === loaded) return void console.warn(postCssConfigUnreadable(configPath, importError));
|
|
2213
2289
|
}
|
|
2214
|
-
} catch
|
|
2290
|
+
} catch (error) {
|
|
2291
|
+
console.warn(postCssConfigUnreadable(configPath, error));
|
|
2215
2292
|
return;
|
|
2216
2293
|
}
|
|
2217
2294
|
if ('function' == typeof loaded) try {
|
|
@@ -2220,10 +2297,14 @@ async function loadUserPostCssConfigObject(configPath, projectPath, mode) {
|
|
|
2220
2297
|
mode,
|
|
2221
2298
|
cwd: projectPath
|
|
2222
2299
|
});
|
|
2223
|
-
} catch
|
|
2300
|
+
} catch (error) {
|
|
2301
|
+
console.warn(postCssConfigUnreadable(configPath, error));
|
|
2224
2302
|
return;
|
|
2225
2303
|
}
|
|
2226
|
-
|
|
2304
|
+
if (!loaded || 'object' != typeof loaded) return;
|
|
2305
|
+
const plugins = loaded.plugins;
|
|
2306
|
+
if (null != plugins && !Array.isArray(plugins) && 'object' != typeof plugins) return void console.warn(postCssConfigPluginsShape(configPath, typeof plugins));
|
|
2307
|
+
return loaded;
|
|
2227
2308
|
}
|
|
2228
2309
|
function unwrapDefaultExport(mod) {
|
|
2229
2310
|
return mod && 'object' == typeof mod && 'default' in mod ? mod.default : mod;
|
|
@@ -2304,7 +2385,9 @@ function resolveConfigPluginList(rawPlugins, ctx) {
|
|
|
2304
2385
|
unresolved
|
|
2305
2386
|
};
|
|
2306
2387
|
}
|
|
2307
|
-
function tryLoadCjsConfig(configPath
|
|
2388
|
+
function tryLoadCjsConfig(configPath, options = {
|
|
2389
|
+
report: true
|
|
2390
|
+
}) {
|
|
2308
2391
|
try {
|
|
2309
2392
|
const source = __rspack_external_node_fs_5ea92f0c.readFileSync(configPath, 'utf8');
|
|
2310
2393
|
const moduleObj = {
|
|
@@ -2315,7 +2398,8 @@ function tryLoadCjsConfig(configPath) {
|
|
|
2315
2398
|
const fn = new Function('require', 'module', 'exports', '__filename', '__dirname', source);
|
|
2316
2399
|
fn(req, moduleObj, exportsObj, configPath, __rspack_external_node_path_c5b9b54f.dirname(configPath));
|
|
2317
2400
|
return moduleObj.exports;
|
|
2318
|
-
} catch
|
|
2401
|
+
} catch (error) {
|
|
2402
|
+
if (options.report) console.warn(postCssConfigUnreadable(configPath, error));
|
|
2319
2403
|
return;
|
|
2320
2404
|
}
|
|
2321
2405
|
}
|
|
@@ -2726,22 +2810,51 @@ async function buildCssRules(projectPath, mode, usage, opts) {
|
|
|
2726
2810
|
if (missingTool) use.push({
|
|
2727
2811
|
loader: resolveDevelopDistFile('preprocessor-passthrough-loader')
|
|
2728
2812
|
});
|
|
2729
|
-
if ('css' === type || 'css/module' === type)
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
}
|
|
2738
|
-
}
|
|
2813
|
+
if ('css' === type || 'css/module' === type) {
|
|
2814
|
+
const guard = resolveDevelopDistFile('css-parse-guard-loader');
|
|
2815
|
+
const list = use;
|
|
2816
|
+
if (!list.some((entry)=>entry?.loader === guard)) list.unshift({
|
|
2817
|
+
loader: guard
|
|
2818
|
+
});
|
|
2819
|
+
list.unshift({
|
|
2820
|
+
loader: resolveDevelopDistFile('late-css-import-loader')
|
|
2821
|
+
});
|
|
2822
|
+
}
|
|
2823
|
+
let ruleType = type;
|
|
2824
|
+
let parser;
|
|
2825
|
+
if ('asset/inline' === type && manifestPath) {
|
|
2826
|
+
use.unshift({
|
|
2827
|
+
loader: resolveDevelopDistFile('dead-css-url-loader'),
|
|
2828
|
+
options: {
|
|
2829
|
+
manifestPath,
|
|
2830
|
+
projectPath,
|
|
2831
|
+
sheet: 'inline'
|
|
2832
|
+
}
|
|
2833
|
+
});
|
|
2834
|
+
ruleType = "javascript/auto";
|
|
2835
|
+
}
|
|
2836
|
+
if ('css/module' === type && 'asset/inline' === nonModuleType && manifestPath) {
|
|
2837
|
+
use.unshift({
|
|
2838
|
+
loader: resolveDevelopDistFile('dead-css-url-loader'),
|
|
2839
|
+
options: {
|
|
2840
|
+
manifestPath,
|
|
2841
|
+
projectPath,
|
|
2842
|
+
sheet: 'chunk'
|
|
2843
|
+
}
|
|
2844
|
+
});
|
|
2845
|
+
parser = {
|
|
2846
|
+
url: false
|
|
2847
|
+
};
|
|
2848
|
+
}
|
|
2739
2849
|
return {
|
|
2740
2850
|
test,
|
|
2741
2851
|
exclude,
|
|
2742
|
-
type,
|
|
2852
|
+
type: ruleType,
|
|
2743
2853
|
issuer,
|
|
2744
|
-
use
|
|
2854
|
+
use,
|
|
2855
|
+
...parser ? {
|
|
2856
|
+
parser
|
|
2857
|
+
} : {}
|
|
2745
2858
|
};
|
|
2746
2859
|
}));
|
|
2747
2860
|
}
|
|
@@ -2757,10 +2870,10 @@ function getContentScriptIndex(manifestPath, projectPath) {
|
|
|
2757
2870
|
const manifest = parseJsonSafe(__rspack_external_node_fs_5ea92f0c.readFileSync(manifestPath, 'utf8'));
|
|
2758
2871
|
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
2759
2872
|
const contentPaths = new Set();
|
|
2760
|
-
for (const content of manifest.content_scripts || [])if (content.js?.length) for (const js of content.js)contentPaths.add(__rspack_external_node_path_c5b9b54f.resolve(manifestDir, js));
|
|
2873
|
+
for (const content of manifest.content_scripts || [])if (content.js?.length) for (const js of content.js)contentPaths.add(toResourceKey(__rspack_external_node_path_c5b9b54f.resolve(manifestDir, js)));
|
|
2761
2874
|
const index = {
|
|
2762
2875
|
mtimeMs,
|
|
2763
|
-
scriptsDir: __rspack_external_node_path_c5b9b54f.resolve(projectPath, "scripts"),
|
|
2876
|
+
scriptsDir: canonicalizeDir(__rspack_external_node_path_c5b9b54f.resolve(projectPath, "scripts")),
|
|
2764
2877
|
contentPaths
|
|
2765
2878
|
};
|
|
2766
2879
|
indexCache.set(cacheKey, index);
|
|
@@ -2770,7 +2883,7 @@ function isContentScriptEntry(absolutePath, manifestPath, projectPath) {
|
|
|
2770
2883
|
if (!absolutePath || !manifestPath || !projectPath) return false;
|
|
2771
2884
|
if (!__rspack_external_node_fs_5ea92f0c.existsSync(manifestPath)) return false;
|
|
2772
2885
|
const { scriptsDir, contentPaths } = getContentScriptIndex(manifestPath, projectPath);
|
|
2773
|
-
const absPathNormalized =
|
|
2886
|
+
const absPathNormalized = toResourceKey(absolutePath);
|
|
2774
2887
|
const relToScripts = __rspack_external_node_path_c5b9b54f.relative(scriptsDir, absPathNormalized);
|
|
2775
2888
|
const isScriptsFolderScript = relToScripts && !relToScripts.startsWith('..') && !__rspack_external_node_path_c5b9b54f.isAbsolute(relToScripts);
|
|
2776
2889
|
if (isScriptsFolderScript) return true;
|
|
@@ -2839,6 +2952,38 @@ class CssPlugin {
|
|
|
2839
2952
|
console.log(cssConfigsDetected(postcssConfig, tailwindConfig, browserslistSource));
|
|
2840
2953
|
}
|
|
2841
2954
|
}
|
|
2955
|
+
keepCssParityInProduction(compiler) {
|
|
2956
|
+
if (!compiler.hooks?.thisCompilation?.tap) return;
|
|
2957
|
+
compiler.hooks.thisCompilation.tap(`${CssPlugin.name}:parity`, (c)=>{
|
|
2958
|
+
if (!c?.hooks?.processAssets?.tap) return;
|
|
2959
|
+
const beforeMinify = new Map();
|
|
2960
|
+
c.hooks.processAssets.tap({
|
|
2961
|
+
name: `${CssPlugin.name}:parity-snapshot`,
|
|
2962
|
+
stage: core_Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE - 1
|
|
2963
|
+
}, ()=>{
|
|
2964
|
+
for (const asset of c.getAssets())if (asset.name.endsWith('.css')) beforeMinify.set(asset.name, asset.source.source().toString());
|
|
2965
|
+
});
|
|
2966
|
+
c.hooks.processAssets.tap({
|
|
2967
|
+
name: `${CssPlugin.name}:parity-restore`,
|
|
2968
|
+
stage: core_Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1
|
|
2969
|
+
}, ()=>{
|
|
2970
|
+
const restored = new Set(restoreVerbatimCssAssets(c));
|
|
2971
|
+
for (const asset of c.getAssets()){
|
|
2972
|
+
if (!asset.name.endsWith('.css') || restored.has(asset.name)) continue;
|
|
2973
|
+
const before = beforeMinify.get(asset.name);
|
|
2974
|
+
if (void 0 === before) continue;
|
|
2975
|
+
const after = asset.source.source().toString();
|
|
2976
|
+
if (after === before) continue;
|
|
2977
|
+
const dropped = minifierDroppedTokens(before, after);
|
|
2978
|
+
if (0 === dropped.length) continue;
|
|
2979
|
+
c.updateAsset(asset.name, new core_sources.RawSource(before));
|
|
2980
|
+
const warning = new core_WebpackError(cssMinifierDroppedRules(asset.name, dropped));
|
|
2981
|
+
warning.file = asset.name;
|
|
2982
|
+
c.warnings.push(warning);
|
|
2983
|
+
}
|
|
2984
|
+
});
|
|
2985
|
+
});
|
|
2986
|
+
}
|
|
2842
2987
|
tolerateDeadUrlRefs(compiler) {
|
|
2843
2988
|
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(this.manifestPath);
|
|
2844
2989
|
const projectPath = compiler.options.context || process.cwd();
|
|
@@ -2886,10 +3031,12 @@ class CssPlugin {
|
|
|
2886
3031
|
});
|
|
2887
3032
|
}
|
|
2888
3033
|
async apply(compiler) {
|
|
3034
|
+
this.keepCssParityInProduction(compiler);
|
|
2889
3035
|
this.tolerateDeadUrlRefs(compiler);
|
|
2890
3036
|
const mode = compiler.options.mode || 'development';
|
|
2891
3037
|
if ('production' === mode) return void compiler.hooks.beforeRun.tapPromise(CssPlugin.name, ()=>this.configureOptions(compiler));
|
|
2892
3038
|
const configuring = this.configureOptions(compiler);
|
|
3039
|
+
compiler.hooks.beforeRun.tapPromise(CssPlugin.name, ()=>configuring);
|
|
2893
3040
|
compiler.hooks.watchRun.tapPromise(CssPlugin.name, ()=>configuring);
|
|
2894
3041
|
await configuring;
|
|
2895
3042
|
}
|
|
@@ -2915,299 +3062,19 @@ function findBrowserslistSource(projectPath) {
|
|
|
2915
3062
|
if (__rspack_external_node_fs_5ea92f0c.existsSync(p)) return p;
|
|
2916
3063
|
}
|
|
2917
3064
|
}
|
|
2918
|
-
function
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
} catch (err) {
|
|
2923
|
-
return false;
|
|
2924
|
-
}
|
|
2925
|
-
}
|
|
2926
|
-
function emitSrcsetCandidates(srcset, node, assetType, attributeName, onResourceFound) {
|
|
2927
|
-
for (const candidate of srcset.split(',')){
|
|
2928
|
-
const url = candidate.trim().split(/\s+/)[0];
|
|
2929
|
-
if (!url) continue;
|
|
2930
|
-
const { cleanPath } = cleanAssetUrl(url);
|
|
2931
|
-
if (cleanPath && !parse_html_isUrl(cleanPath)) onResourceFound({
|
|
2932
|
-
filePath: url,
|
|
2933
|
-
childNode: node,
|
|
2934
|
-
assetType,
|
|
2935
|
-
attributeName
|
|
2936
|
-
});
|
|
2937
|
-
}
|
|
2938
|
-
}
|
|
2939
|
-
function parseHtml(node, onResourceFound) {
|
|
2940
|
-
if ('#comment' === node.nodeName || '#text' === node.nodeName) return;
|
|
2941
|
-
if ("script" === node.nodeName) {
|
|
2942
|
-
const src = node.attrs?.find((attr)=>'src' === attr.name)?.value;
|
|
2943
|
-
if (!src) return;
|
|
2944
|
-
if (parse_html_isUrl(src)) return;
|
|
2945
|
-
onResourceFound({
|
|
2946
|
-
filePath: src,
|
|
2947
|
-
childNode: node,
|
|
2948
|
-
assetType: "script"
|
|
2949
|
-
});
|
|
2950
|
-
} else if ('link' === node.nodeName) {
|
|
2951
|
-
const href = node.attrs?.find((attr)=>'href' === attr.name)?.value;
|
|
2952
|
-
const rel = node.attrs?.find((attr)=>'rel' === attr.name)?.value;
|
|
2953
|
-
const imagesrcset = node.attrs?.find((attr)=>'imagesrcset' === attr.name)?.value;
|
|
2954
|
-
if (imagesrcset) emitSrcsetCandidates(imagesrcset, node, 'staticHref', 'imagesrcset', onResourceFound);
|
|
2955
|
-
if (!href) return;
|
|
2956
|
-
if (parse_html_isUrl(href)) return;
|
|
2957
|
-
const nonStylesheetRelTokens = [
|
|
2958
|
-
'dns-prefetch',
|
|
2959
|
-
'icon',
|
|
2960
|
-
'apple-touch-icon',
|
|
2961
|
-
'apple-touch-icon-precomposed',
|
|
2962
|
-
'mask-icon',
|
|
2963
|
-
'manifest',
|
|
2964
|
-
'modulepreload',
|
|
2965
|
-
'preconnect',
|
|
2966
|
-
'prefetch',
|
|
2967
|
-
'preload',
|
|
2968
|
-
'prerender'
|
|
2969
|
-
];
|
|
2970
|
-
const relTokens = rel ? rel.toLowerCase().split(/\s+/) : [];
|
|
2971
|
-
onResourceFound(relTokens.some((token)=>nonStylesheetRelTokens.includes(token)) ? {
|
|
2972
|
-
filePath: href,
|
|
2973
|
-
childNode: node,
|
|
2974
|
-
assetType: 'staticHref',
|
|
2975
|
-
attributeName: 'href'
|
|
2976
|
-
} : {
|
|
2977
|
-
filePath: href,
|
|
2978
|
-
childNode: node,
|
|
2979
|
-
assetType: 'css'
|
|
2980
|
-
});
|
|
2981
|
-
} else if ('audio' === node.nodeName || 'embed' === node.nodeName || 'iframe' === node.nodeName || 'img' === node.nodeName || 'input' === node.nodeName || 'source' === node.nodeName || 'track' === node.nodeName || 'video' === node.nodeName) {
|
|
2982
|
-
const src = node.attrs?.find((attr)=>'src' === attr.name)?.value;
|
|
2983
|
-
if (src && !parse_html_isUrl(src)) onResourceFound({
|
|
2984
|
-
filePath: src,
|
|
2985
|
-
childNode: node,
|
|
2986
|
-
assetType: 'staticSrc',
|
|
2987
|
-
attributeName: 'src'
|
|
2988
|
-
});
|
|
2989
|
-
const srcset = node.attrs?.find((attr)=>'srcset' === attr.name)?.value;
|
|
2990
|
-
if (srcset) emitSrcsetCandidates(srcset, node, 'staticSrc', 'srcset', onResourceFound);
|
|
2991
|
-
if ('video' === node.nodeName) {
|
|
2992
|
-
const poster = node.attrs?.find((attr)=>'poster' === attr.name)?.value;
|
|
2993
|
-
if (poster && !parse_html_isUrl(poster)) onResourceFound({
|
|
2994
|
-
filePath: poster,
|
|
2995
|
-
childNode: node,
|
|
2996
|
-
assetType: 'staticSrc',
|
|
2997
|
-
attributeName: 'poster'
|
|
2998
|
-
});
|
|
2999
|
-
}
|
|
3000
|
-
}
|
|
3001
|
-
const { childNodes = [] } = node;
|
|
3002
|
-
for (const childNode of childNodes)if ('#comment' !== childNode.nodeName && '#text' !== childNode.nodeName) parseHtml(childNode, onResourceFound);
|
|
3003
|
-
}
|
|
3004
|
-
const cloneParsedHtmlAsset = (assets)=>({
|
|
3005
|
-
css: [
|
|
3006
|
-
...assets.css || []
|
|
3007
|
-
],
|
|
3008
|
-
js: [
|
|
3009
|
-
...assets.js || []
|
|
3010
|
-
],
|
|
3011
|
-
moduleJs: [
|
|
3012
|
-
...assets.moduleJs || []
|
|
3013
|
-
],
|
|
3014
|
-
static: [
|
|
3015
|
-
...assets.static || []
|
|
3016
|
-
]
|
|
3065
|
+
function getResolvedManifestFieldsData(options) {
|
|
3066
|
+
const data = getManifestFieldsData({
|
|
3067
|
+
manifestPath: options.manifestPath,
|
|
3068
|
+
browser: options.browser
|
|
3017
3069
|
});
|
|
3018
|
-
const assetsFromHtmlCache = new Map();
|
|
3019
|
-
function getAssetsFromHtml(htmlFilePath, htmlContent) {
|
|
3020
|
-
const assets = {
|
|
3021
|
-
css: [],
|
|
3022
|
-
js: [],
|
|
3023
|
-
moduleJs: [],
|
|
3024
|
-
static: []
|
|
3025
|
-
};
|
|
3026
|
-
if (!htmlFilePath) return assets;
|
|
3027
|
-
let cacheKey;
|
|
3028
|
-
if (void 0 === htmlContent) try {
|
|
3029
|
-
const stat = __rspack_external_node_fs_5ea92f0c.statSync(htmlFilePath);
|
|
3030
|
-
cacheKey = `${stat.mtimeMs}:${stat.size}`;
|
|
3031
|
-
const cached = assetsFromHtmlCache.get(htmlFilePath);
|
|
3032
|
-
if (cached && cached.key === cacheKey) return cloneParsedHtmlAsset(cached.assets);
|
|
3033
|
-
} catch {
|
|
3034
|
-
cacheKey = void 0;
|
|
3035
|
-
}
|
|
3036
3070
|
try {
|
|
3037
|
-
const
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
const htmlDocument = __rspack_external_parse5_utilities_78b19c6a.parse(htmlString);
|
|
3042
|
-
const baseHref = getBaseHref(htmlDocument);
|
|
3043
|
-
const getAbsolutePath = (htmlFilePath, filePathWithParts)=>{
|
|
3044
|
-
const { cleanPath } = cleanAssetUrl(filePathWithParts);
|
|
3045
|
-
if (utils_isUrl(cleanPath)) return cleanPath;
|
|
3046
|
-
if (cleanPath.startsWith('/')) return cleanPath;
|
|
3047
|
-
const isBaseUrl = utils_isUrl(baseHref || '');
|
|
3048
|
-
const baseJoin = baseHref && !isBaseUrl ? __rspack_external_node_path_c5b9b54f.join(__rspack_external_node_path_c5b9b54f.dirname(htmlFilePath), baseHref) : __rspack_external_node_path_c5b9b54f.dirname(htmlFilePath);
|
|
3049
|
-
return __rspack_external_node_path_c5b9b54f.join(baseJoin, cleanPath);
|
|
3071
|
+
const manifest = filterKeysForThisBrowser(parseJsonSafe(__rspack_external_node_fs_5ea92f0c.readFileSync(options.manifestPath, 'utf-8')), options.browser || 'chrome');
|
|
3072
|
+
return {
|
|
3073
|
+
...data,
|
|
3074
|
+
html: applyIndependentHtmlSurfaces(data.html || {}, manifest, __rspack_external_node_path_c5b9b54f.dirname(options.manifestPath), options.browser)
|
|
3050
3075
|
};
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
switch(assetType){
|
|
3054
|
-
case "script":
|
|
3055
|
-
{
|
|
3056
|
-
assets.js?.push(fileAbsolutePath);
|
|
3057
|
-
const scriptType = childNode?.attrs?.find((attr)=>'type' === attr.name)?.value;
|
|
3058
|
-
if ('module' === String(scriptType || '').toLowerCase()) assets.moduleJs?.push(fileAbsolutePath);
|
|
3059
|
-
break;
|
|
3060
|
-
}
|
|
3061
|
-
case 'css':
|
|
3062
|
-
assets.css?.push(fileAbsolutePath);
|
|
3063
|
-
break;
|
|
3064
|
-
case 'staticSrc':
|
|
3065
|
-
case 'staticHref':
|
|
3066
|
-
if (filePath.startsWith('#')) break;
|
|
3067
|
-
assets.static?.push(fileAbsolutePath);
|
|
3068
|
-
break;
|
|
3069
|
-
default:
|
|
3070
|
-
break;
|
|
3071
|
-
}
|
|
3072
|
-
});
|
|
3073
|
-
} catch (error) {
|
|
3074
|
-
const code = error?.code;
|
|
3075
|
-
if (void 0 === htmlContent && 'ENOENT' === code) {
|
|
3076
|
-
assetsFromHtmlCache.delete(htmlFilePath);
|
|
3077
|
-
throw error;
|
|
3078
|
-
}
|
|
3079
|
-
return assets;
|
|
3080
|
-
}
|
|
3081
|
-
if (cacheKey) assetsFromHtmlCache.set(htmlFilePath, {
|
|
3082
|
-
key: cacheKey,
|
|
3083
|
-
assets: cloneParsedHtmlAsset(assets)
|
|
3084
|
-
});
|
|
3085
|
-
return assets;
|
|
3086
|
-
}
|
|
3087
|
-
function getHtmlPageDeclaredAssetPath(filepathList, filePath, extension) {
|
|
3088
|
-
const entryname = Object.keys(filepathList).find((key)=>{
|
|
3089
|
-
const includePath = filepathList[key];
|
|
3090
|
-
if (includePath === filePath) return true;
|
|
3091
|
-
if (!includePath || !__rspack_external_node_fs_5ea92f0c.existsSync(includePath)) return false;
|
|
3092
|
-
const assets = getAssetsFromHtml(includePath);
|
|
3093
|
-
return Boolean(assets?.js?.includes(filePath) || assets?.css?.includes(filePath));
|
|
3094
|
-
}) || '';
|
|
3095
|
-
const extname = getExtname(filePath);
|
|
3096
|
-
if (!entryname) return `${filePath.replace(extname, '')}${extension}`;
|
|
3097
|
-
return `/${entryname.replace(extname, '')}${extension}`;
|
|
3098
|
-
}
|
|
3099
|
-
function getExtname(filePath) {
|
|
3100
|
-
return __rspack_external_node_path_c5b9b54f.extname(filePath);
|
|
3101
|
-
}
|
|
3102
|
-
function getFilePath(filePath, extension, isPublic) {
|
|
3103
|
-
if (isPublic) return `/${filePath}${extension}`;
|
|
3104
|
-
return `${filePath}${extension}`;
|
|
3105
|
-
}
|
|
3106
|
-
function isFromIncludeList(filePath, includeList) {
|
|
3107
|
-
return Object.values(includeList || {}).some((value)=>value === filePath);
|
|
3108
|
-
}
|
|
3109
|
-
function utils_isUrl(src) {
|
|
3110
|
-
try {
|
|
3111
|
-
new URL(src);
|
|
3112
|
-
return true;
|
|
3113
|
-
} catch (err) {
|
|
3114
|
-
return false;
|
|
3115
|
-
}
|
|
3116
|
-
}
|
|
3117
|
-
function resolveStaticAttributeName(assetType, attributeName) {
|
|
3118
|
-
if (attributeName) return attributeName;
|
|
3119
|
-
return 'staticSrc' === assetType ? 'src' : 'href';
|
|
3120
|
-
}
|
|
3121
|
-
function rewriteSrcsetCandidate(srcset, fromCleanPath, toUrl) {
|
|
3122
|
-
return srcset.split(',').map((candidate)=>{
|
|
3123
|
-
const match = candidate.match(/^(\s*)(\S+)(.*)$/);
|
|
3124
|
-
if (!match) return candidate;
|
|
3125
|
-
const [, lead, url, rest] = match;
|
|
3126
|
-
const { cleanPath } = cleanAssetUrl(url);
|
|
3127
|
-
if (cleanPath !== fromCleanPath && url !== fromCleanPath) return candidate;
|
|
3128
|
-
return `${lead}${toUrl}${rest}`;
|
|
3129
|
-
}).join(',');
|
|
3130
|
-
}
|
|
3131
|
-
function applyRewrittenStaticUrl(node, attributeName, cleanPath, value) {
|
|
3132
|
-
if ('srcset' === attributeName || 'imagesrcset' === attributeName) {
|
|
3133
|
-
const current = __rspack_external_parse5_utilities_78b19c6a.getAttribute(node, attributeName) || '';
|
|
3134
|
-
return __rspack_external_parse5_utilities_78b19c6a.setAttribute(node, attributeName, rewriteSrcsetCandidate(current, cleanPath, value));
|
|
3135
|
-
}
|
|
3136
|
-
return __rspack_external_parse5_utilities_78b19c6a.setAttribute(node, attributeName, value);
|
|
3137
|
-
}
|
|
3138
|
-
function cleanAssetUrl(url) {
|
|
3139
|
-
const hashIndex = url.indexOf('#');
|
|
3140
|
-
const queryIndex = url.indexOf('?');
|
|
3141
|
-
let endIndex = url.length;
|
|
3142
|
-
if (-1 !== hashIndex && -1 !== queryIndex) endIndex = Math.min(hashIndex, queryIndex);
|
|
3143
|
-
else if (-1 !== hashIndex) endIndex = hashIndex;
|
|
3144
|
-
else if (-1 !== queryIndex) endIndex = queryIndex;
|
|
3145
|
-
const cleanPath = url.slice(0, endIndex);
|
|
3146
|
-
const hash = -1 !== hashIndex ? url.slice(hashIndex) : '';
|
|
3147
|
-
const search = -1 !== queryIndex ? url.slice(queryIndex, -1 !== hashIndex ? hashIndex : void 0) : '';
|
|
3148
|
-
return {
|
|
3149
|
-
cleanPath,
|
|
3150
|
-
hash,
|
|
3151
|
-
search
|
|
3152
|
-
};
|
|
3153
|
-
}
|
|
3154
|
-
function isHttpLike(inputUrl) {
|
|
3155
|
-
return /^https?:\/\//i.test(inputUrl) || inputUrl.startsWith('//');
|
|
3156
|
-
}
|
|
3157
|
-
function isSpecialScheme(u) {
|
|
3158
|
-
return /^(data:|blob:|chrome-extension:|javascript:|about:)/i.test(u);
|
|
3159
|
-
}
|
|
3160
|
-
function cleanLeading(s) {
|
|
3161
|
-
return s.replace(/^\/+/, '').replace(/^\.\//, '').replace(/^\./, '');
|
|
3162
|
-
}
|
|
3163
|
-
function joinEmittedAssetName(prefix, rel) {
|
|
3164
|
-
const parts = __rspack_external_node_path_c5b9b54f.posix.join(prefix, rel).split('/');
|
|
3165
|
-
let i = 0;
|
|
3166
|
-
while(i < parts.length && ('..' === parts[i] || '.' === parts[i]))i++;
|
|
3167
|
-
return parts.slice(i).join('/') || __rspack_external_node_path_c5b9b54f.posix.basename(rel);
|
|
3168
|
-
}
|
|
3169
|
-
function computePosixRelative(fromPath, toPath) {
|
|
3170
|
-
const fromRoot = __rspack_external_node_path_c5b9b54f.parse(fromPath).root;
|
|
3171
|
-
const toRoot = __rspack_external_node_path_c5b9b54f.parse(toPath).root;
|
|
3172
|
-
if (fromRoot && toRoot && String(fromRoot).toLowerCase() !== String(toRoot).toLowerCase()) {
|
|
3173
|
-
const base = __rspack_external_node_path_c5b9b54f.basename(toPath);
|
|
3174
|
-
return base.split(__rspack_external_node_path_c5b9b54f.sep).join('/');
|
|
3175
|
-
}
|
|
3176
|
-
const rel = __rspack_external_node_path_c5b9b54f.relative(__rspack_external_node_path_c5b9b54f.dirname(fromPath), toPath) || toPath;
|
|
3177
|
-
return rel.split(__rspack_external_node_path_c5b9b54f.sep).join('/');
|
|
3178
|
-
}
|
|
3179
|
-
function resolveAbsoluteFsPath(params) {
|
|
3180
|
-
const { asset, projectRoot, publicRootForResource, outputRoot, manifestRoot } = params;
|
|
3181
|
-
const isRootUrl = asset.startsWith('/') && !(asset.startsWith(projectRoot) || asset.startsWith(publicRootForResource) || asset.startsWith(outputRoot));
|
|
3182
|
-
const isDotPublic = asset.startsWith('./public/');
|
|
3183
|
-
const isPlainPublic = asset.startsWith('public/');
|
|
3184
|
-
const absoluteFsPath = isRootUrl ? (()=>{
|
|
3185
|
-
const rootRelative = asset.slice(1);
|
|
3186
|
-
const normalized = cleanLeading(rootRelative);
|
|
3187
|
-
const withoutPublicPrefix = normalized.replace(/^public\//, '');
|
|
3188
|
-
const candidate = __rspack_external_node_path_c5b9b54f.join(publicRootForResource, withoutPublicPrefix);
|
|
3189
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(candidate)) return candidate;
|
|
3190
|
-
const manifestCandidate = manifestRoot ? __rspack_external_node_path_c5b9b54f.join(manifestRoot, normalized) : '';
|
|
3191
|
-
if (manifestCandidate && __rspack_external_node_fs_5ea92f0c.existsSync(manifestCandidate)) return manifestCandidate;
|
|
3192
|
-
return manifestCandidate || candidate;
|
|
3193
|
-
})() : isDotPublic ? __rspack_external_node_path_c5b9b54f.join(projectRoot, cleanLeading(asset)) : isPlainPublic ? __rspack_external_node_path_c5b9b54f.join(projectRoot, asset.replace(/^\./, '')) : __rspack_external_node_path_c5b9b54f.isAbsolute(asset) ? asset : __rspack_external_node_path_c5b9b54f.join(projectRoot, asset);
|
|
3194
|
-
const relToPublic = __rspack_external_node_path_c5b9b54f.relative(publicRootForResource, absoluteFsPath);
|
|
3195
|
-
const isUnderPublicRoot = relToPublic && !relToPublic.startsWith('..') && !__rspack_external_node_path_c5b9b54f.isAbsolute(relToPublic);
|
|
3196
|
-
return {
|
|
3197
|
-
absoluteFsPath,
|
|
3198
|
-
isUnderPublicRoot: Boolean(isUnderPublicRoot),
|
|
3199
|
-
isRootUrl
|
|
3200
|
-
};
|
|
3201
|
-
}
|
|
3202
|
-
function getBaseHref(htmlDocument) {
|
|
3203
|
-
const htmlChildren = htmlDocument.childNodes || [];
|
|
3204
|
-
for (const node of htmlChildren)if (node?.nodeName === 'html') {
|
|
3205
|
-
for (const child of node.childNodes || [])if (child?.nodeName === 'head') {
|
|
3206
|
-
for (const headChild of child.childNodes || [])if (headChild?.nodeName === 'base') {
|
|
3207
|
-
const href = headChild.attrs?.find((a)=>'href' === a.name)?.value;
|
|
3208
|
-
if (href) return href;
|
|
3209
|
-
}
|
|
3210
|
-
}
|
|
3076
|
+
} catch {
|
|
3077
|
+
return data;
|
|
3211
3078
|
}
|
|
3212
3079
|
}
|
|
3213
3080
|
let preact_userMessageDelivered = false;
|
|
@@ -3238,6 +3105,8 @@ async function maybeUsePreact(projectPath) {
|
|
|
3238
3105
|
const preactJsxRuntime = resolveFromProject('preact/jsx-runtime');
|
|
3239
3106
|
const preactJsxDevRuntime = resolveFromProject('preact/jsx-dev-runtime');
|
|
3240
3107
|
const alias = {};
|
|
3108
|
+
if (preactJsxRuntime) alias['preact/jsx-runtime'] = preactJsxRuntime;
|
|
3109
|
+
if (preactJsxDevRuntime) alias['preact/jsx-dev-runtime'] = preactJsxDevRuntime;
|
|
3241
3110
|
if (preactDir) alias.preact = preactDir;
|
|
3242
3111
|
if (preactCompat) {
|
|
3243
3112
|
alias.react = preactCompat;
|
|
@@ -3322,6 +3191,40 @@ async function maybeUseReact(projectPath, options = {}) {
|
|
|
3322
3191
|
alias
|
|
3323
3192
|
};
|
|
3324
3193
|
}
|
|
3194
|
+
let solid_userMessageDelivered = false;
|
|
3195
|
+
function isUsingSolid(projectPath) {
|
|
3196
|
+
if (hasDependency(projectPath, 'solid-js')) {
|
|
3197
|
+
if (!solid_userMessageDelivered) {
|
|
3198
|
+
if (isDebug()) console.log(`${messaging_prefix('debug')} ${messages_isUsingIntegration('Solid')}`);
|
|
3199
|
+
solid_userMessageDelivered = true;
|
|
3200
|
+
}
|
|
3201
|
+
return true;
|
|
3202
|
+
}
|
|
3203
|
+
return false;
|
|
3204
|
+
}
|
|
3205
|
+
async function maybeUseSolid(projectPath) {
|
|
3206
|
+
if (!isUsingSolid(projectPath)) return;
|
|
3207
|
+
const requireFromProject = createRequire(__rspack_external_node_path_c5b9b54f.join(projectPath, 'package.json'));
|
|
3208
|
+
const resolveFromProject = (id)=>{
|
|
3209
|
+
try {
|
|
3210
|
+
return requireFromProject.resolve(id);
|
|
3211
|
+
} catch {
|
|
3212
|
+
return;
|
|
3213
|
+
}
|
|
3214
|
+
};
|
|
3215
|
+
const adapter = resolveDevelopDistFile('solid-jsx-runtime');
|
|
3216
|
+
const hyperscript = resolveFromProject('solid-js/h');
|
|
3217
|
+
const alias = {
|
|
3218
|
+
'solid-js/jsx-runtime$': adapter,
|
|
3219
|
+
'solid-js/jsx-dev-runtime$': adapter
|
|
3220
|
+
};
|
|
3221
|
+
if (hyperscript) alias['solid-js/h$'] = hyperscript;
|
|
3222
|
+
return {
|
|
3223
|
+
plugins: [],
|
|
3224
|
+
loaders: void 0,
|
|
3225
|
+
alias
|
|
3226
|
+
};
|
|
3227
|
+
}
|
|
3325
3228
|
let load_loader_options_userMessageDelivered = false;
|
|
3326
3229
|
function resolveLoaderConfigPath(projectPath, framework) {
|
|
3327
3230
|
const candidates = [
|
|
@@ -3351,6 +3254,106 @@ async function loadLoaderOptions(projectPath, framework) {
|
|
|
3351
3254
|
}
|
|
3352
3255
|
return null;
|
|
3353
3256
|
}
|
|
3257
|
+
let vue_userMessageDelivered = false;
|
|
3258
|
+
function isUsingVue(projectPath) {
|
|
3259
|
+
const using = hasDependency(projectPath, 'vue');
|
|
3260
|
+
if (using && !vue_userMessageDelivered) {
|
|
3261
|
+
if (isDebug()) console.log(`${messaging_prefix('debug')} ${messages_isUsingIntegration('Vue')}`);
|
|
3262
|
+
vue_userMessageDelivered = true;
|
|
3263
|
+
}
|
|
3264
|
+
return using;
|
|
3265
|
+
}
|
|
3266
|
+
async function maybeUseVue(projectPath, mode = 'development') {
|
|
3267
|
+
if (!isUsingVue(projectPath)) return;
|
|
3268
|
+
const vueLoaderPath = await ensureOptionalContractPackageResolved({
|
|
3269
|
+
contractId: 'vue',
|
|
3270
|
+
projectPath,
|
|
3271
|
+
dependencyId: 'vue-loader'
|
|
3272
|
+
});
|
|
3273
|
+
const VueLoaderPlugin = await ensureOptionalContractModuleLoaded({
|
|
3274
|
+
contractId: 'vue',
|
|
3275
|
+
projectPath,
|
|
3276
|
+
dependencyId: 'vue-loader',
|
|
3277
|
+
moduleAdapter: (mod)=>mod?.VueLoaderPlugin || mod?.default?.VueLoaderPlugin
|
|
3278
|
+
});
|
|
3279
|
+
const customOptions = await loadLoaderOptions(projectPath, 'vue');
|
|
3280
|
+
const defaultLoaders = [
|
|
3281
|
+
{
|
|
3282
|
+
test: /\.vue$/,
|
|
3283
|
+
loader: vueLoaderPath,
|
|
3284
|
+
options: {
|
|
3285
|
+
experimentalInlineMatchResource: true,
|
|
3286
|
+
...customOptions || {}
|
|
3287
|
+
},
|
|
3288
|
+
include: projectPath,
|
|
3289
|
+
exclude: /node_modules/
|
|
3290
|
+
}
|
|
3291
|
+
];
|
|
3292
|
+
const isProd = 'production' === mode;
|
|
3293
|
+
const defaultPlugins = [
|
|
3294
|
+
new VueLoaderPlugin(),
|
|
3295
|
+
new DefinePlugin({
|
|
3296
|
+
__VUE_OPTIONS_API__: JSON.stringify(!isProd),
|
|
3297
|
+
__VUE_PROD_DEVTOOLS__: JSON.stringify(!isProd),
|
|
3298
|
+
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: JSON.stringify(!isProd)
|
|
3299
|
+
})
|
|
3300
|
+
];
|
|
3301
|
+
const requireFromProject = createRequire(__rspack_external_node_path_c5b9b54f.join(projectPath, 'package.json'));
|
|
3302
|
+
const resolveFromProject = (id)=>{
|
|
3303
|
+
try {
|
|
3304
|
+
return requireFromProject.resolve(id);
|
|
3305
|
+
} catch {
|
|
3306
|
+
return;
|
|
3307
|
+
}
|
|
3308
|
+
};
|
|
3309
|
+
const alias = {};
|
|
3310
|
+
const vuePath = resolveFromProject('vue');
|
|
3311
|
+
const vueRuntimeDom = resolveFromProject('@vue/runtime-dom');
|
|
3312
|
+
const vueRuntimeCore = resolveFromProject('@vue/runtime-core');
|
|
3313
|
+
const vueShared = resolveFromProject('@vue/shared');
|
|
3314
|
+
if (vuePath) alias.vue$ = vuePath;
|
|
3315
|
+
if (vueRuntimeDom) alias['@vue/runtime-dom'] = vueRuntimeDom;
|
|
3316
|
+
if (vueRuntimeCore) alias['@vue/runtime-core'] = vueRuntimeCore;
|
|
3317
|
+
if (vueShared) alias['@vue/shared'] = vueShared;
|
|
3318
|
+
return {
|
|
3319
|
+
plugins: defaultPlugins,
|
|
3320
|
+
loaders: defaultLoaders,
|
|
3321
|
+
alias
|
|
3322
|
+
};
|
|
3323
|
+
}
|
|
3324
|
+
function isUsingJsxFramework(projectPath) {
|
|
3325
|
+
return isUsingReact(projectPath) || isUsingPreact(projectPath) || isUsingSolid(projectPath) || isUsingVue(projectPath);
|
|
3326
|
+
}
|
|
3327
|
+
function getJsxImportSource(projectPath) {
|
|
3328
|
+
if (isUsingSolid(projectPath)) return 'solid-js';
|
|
3329
|
+
if (isUsingPreact(projectPath) && !isUsingReact(projectPath)) return 'preact';
|
|
3330
|
+
if (isUsingVue(projectPath) && !isUsingReact(projectPath) && !isUsingPreact(projectPath)) return 'vue';
|
|
3331
|
+
return 'react';
|
|
3332
|
+
}
|
|
3333
|
+
function swcParserForFile(resourcePath, jsxInPlainJs) {
|
|
3334
|
+
const clean = String(resourcePath || '').split('?')[0];
|
|
3335
|
+
const ext = __rspack_external_node_path_c5b9b54f.extname(clean).toLowerCase();
|
|
3336
|
+
if ('.tsx' === ext || '.mtsx' === ext) return {
|
|
3337
|
+
syntax: "typescript",
|
|
3338
|
+
tsx: true,
|
|
3339
|
+
dynamicImport: true
|
|
3340
|
+
};
|
|
3341
|
+
if ('.ts' === ext || '.mts' === ext || '.cts' === ext) return {
|
|
3342
|
+
syntax: "typescript",
|
|
3343
|
+
tsx: false,
|
|
3344
|
+
dynamicImport: true
|
|
3345
|
+
};
|
|
3346
|
+
if ('.jsx' === ext || '.mjsx' === ext) return {
|
|
3347
|
+
syntax: "ecmascript",
|
|
3348
|
+
jsx: true,
|
|
3349
|
+
dynamicImport: true
|
|
3350
|
+
};
|
|
3351
|
+
return {
|
|
3352
|
+
syntax: "ecmascript",
|
|
3353
|
+
jsx: jsxInPlainJs,
|
|
3354
|
+
dynamicImport: true
|
|
3355
|
+
};
|
|
3356
|
+
}
|
|
3354
3357
|
let svelte_userMessageDelivered = false;
|
|
3355
3358
|
function svelte_resolveFromProject(id, projectPath) {
|
|
3356
3359
|
for (const base of [
|
|
@@ -3457,72 +3460,30 @@ async function maybeUseSvelte(projectPath, mode) {
|
|
|
3457
3460
|
alias: Object.keys(alias).length > 0 ? alias : void 0
|
|
3458
3461
|
};
|
|
3459
3462
|
}
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3463
|
+
const DEFAULT_SWC_TARGETS = [
|
|
3464
|
+
'chrome >= 100'
|
|
3465
|
+
];
|
|
3466
|
+
function resolveSwcTargets(rawManifest, browser) {
|
|
3467
|
+
if (!rawManifest || 'object' != typeof rawManifest) return [
|
|
3468
|
+
...DEFAULT_SWC_TARGETS
|
|
3469
|
+
];
|
|
3470
|
+
const name = String(browser || 'chrome');
|
|
3471
|
+
const manifest = filterKeysForThisBrowser(rawManifest, name);
|
|
3472
|
+
if (isGeckoBasedBrowser(name)) {
|
|
3473
|
+
const geckoMin = manifest.browser_specific_settings?.gecko?.strict_min_version || manifest.applications?.gecko?.strict_min_version;
|
|
3474
|
+
const major = parseInt(String(geckoMin ?? '').split('.')[0], 10);
|
|
3475
|
+
return Number.isNaN(major) ? [
|
|
3476
|
+
...DEFAULT_SWC_TARGETS
|
|
3477
|
+
] : [
|
|
3478
|
+
`firefox >= ${major}`
|
|
3479
|
+
];
|
|
3466
3480
|
}
|
|
3467
|
-
return
|
|
3468
|
-
}
|
|
3469
|
-
async function maybeUseVue(projectPath, mode = 'development') {
|
|
3470
|
-
if (!isUsingVue(projectPath)) return;
|
|
3471
|
-
const vueLoaderPath = await ensureOptionalContractPackageResolved({
|
|
3472
|
-
contractId: 'vue',
|
|
3473
|
-
projectPath,
|
|
3474
|
-
dependencyId: 'vue-loader'
|
|
3475
|
-
});
|
|
3476
|
-
const VueLoaderPlugin = await ensureOptionalContractModuleLoaded({
|
|
3477
|
-
contractId: 'vue',
|
|
3478
|
-
projectPath,
|
|
3479
|
-
dependencyId: 'vue-loader',
|
|
3480
|
-
moduleAdapter: (mod)=>mod?.VueLoaderPlugin || mod?.default?.VueLoaderPlugin
|
|
3481
|
-
});
|
|
3482
|
-
const customOptions = await loadLoaderOptions(projectPath, 'vue');
|
|
3483
|
-
const defaultLoaders = [
|
|
3484
|
-
{
|
|
3485
|
-
test: /\.vue$/,
|
|
3486
|
-
loader: vueLoaderPath,
|
|
3487
|
-
options: {
|
|
3488
|
-
experimentalInlineMatchResource: true,
|
|
3489
|
-
...customOptions || {}
|
|
3490
|
-
},
|
|
3491
|
-
include: projectPath,
|
|
3492
|
-
exclude: /node_modules/
|
|
3493
|
-
}
|
|
3481
|
+
if (isChromiumBasedBrowser(name) && manifest.minimum_chrome_version) return [
|
|
3482
|
+
`chrome >= ${manifest.minimum_chrome_version}`
|
|
3494
3483
|
];
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
new VueLoaderPlugin(),
|
|
3498
|
-
new DefinePlugin({
|
|
3499
|
-
__VUE_OPTIONS_API__: JSON.stringify(!isProd),
|
|
3500
|
-
__VUE_PROD_DEVTOOLS__: JSON.stringify(!isProd),
|
|
3501
|
-
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: JSON.stringify(!isProd)
|
|
3502
|
-
})
|
|
3484
|
+
return [
|
|
3485
|
+
...DEFAULT_SWC_TARGETS
|
|
3503
3486
|
];
|
|
3504
|
-
const requireFromProject = createRequire(__rspack_external_node_path_c5b9b54f.join(projectPath, 'package.json'));
|
|
3505
|
-
const resolveFromProject = (id)=>{
|
|
3506
|
-
try {
|
|
3507
|
-
return requireFromProject.resolve(id);
|
|
3508
|
-
} catch {
|
|
3509
|
-
return;
|
|
3510
|
-
}
|
|
3511
|
-
};
|
|
3512
|
-
const alias = {};
|
|
3513
|
-
const vuePath = resolveFromProject('vue');
|
|
3514
|
-
const vueRuntimeDom = resolveFromProject('@vue/runtime-dom');
|
|
3515
|
-
const vueRuntimeCore = resolveFromProject('@vue/runtime-core');
|
|
3516
|
-
const vueShared = resolveFromProject('@vue/shared');
|
|
3517
|
-
if (vuePath) alias.vue$ = vuePath;
|
|
3518
|
-
if (vueRuntimeDom) alias['@vue/runtime-dom'] = vueRuntimeDom;
|
|
3519
|
-
if (vueRuntimeCore) alias['@vue/runtime-core'] = vueRuntimeCore;
|
|
3520
|
-
if (vueShared) alias['@vue/shared'] = vueShared;
|
|
3521
|
-
return {
|
|
3522
|
-
plugins: defaultPlugins,
|
|
3523
|
-
loaders: defaultLoaders,
|
|
3524
|
-
alias
|
|
3525
|
-
};
|
|
3526
3487
|
}
|
|
3527
3488
|
class JsFrameworksPlugin {
|
|
3528
3489
|
static name = 'plugin-js-frameworks';
|
|
@@ -3598,7 +3559,7 @@ class JsFrameworksPlugin {
|
|
|
3598
3559
|
loader: rule.loader
|
|
3599
3560
|
}
|
|
3600
3561
|
] : [];
|
|
3601
|
-
const hasReactRefreshLoader = uses.some((useEntry)=>String(useEntry?.loader || '').includes('react-refresh-loader'));
|
|
3562
|
+
const hasReactRefreshLoader = uses.some((useEntry)=>'object' == typeof useEntry && String(useEntry?.loader || '').includes('react-refresh-loader'));
|
|
3602
3563
|
if (hasReactRefreshLoader) rule.issuerLayer = {
|
|
3603
3564
|
not: EXTENSIONJS_CONTENT_SCRIPT_LAYER
|
|
3604
3565
|
};
|
|
@@ -3661,7 +3622,7 @@ class JsFrameworksPlugin {
|
|
|
3661
3622
|
const background = browserManifest?.background;
|
|
3662
3623
|
if (background?.type === 'module' && 'string' == typeof background?.service_worker) addBothPathForms(platformModulePaths, __rspack_external_node_path_c5b9b54f.resolve(manifestDir, background.service_worker));
|
|
3663
3624
|
const htmlPages = {
|
|
3664
|
-
...
|
|
3625
|
+
...getResolvedManifestFieldsData({
|
|
3665
3626
|
manifestPath: this.manifestPath,
|
|
3666
3627
|
browser: this.browser
|
|
3667
3628
|
}).html,
|
|
@@ -3675,26 +3636,18 @@ class JsFrameworksPlugin {
|
|
|
3675
3636
|
});
|
|
3676
3637
|
const maybeInstallPreact = await maybeUsePreact(projectPath);
|
|
3677
3638
|
const maybeInstallVue = await maybeUseVue(projectPath, mode);
|
|
3639
|
+
const maybeInstallSolid = await maybeUseSolid(projectPath);
|
|
3678
3640
|
const maybeInstallSvelte = await maybeUseSvelte(projectPath, mode);
|
|
3679
3641
|
const tsConfigPath = getUserTypeScriptConfigFile(projectPath);
|
|
3680
3642
|
const tsRoot = tsConfigPath ? __rspack_external_node_path_c5b9b54f.dirname(tsConfigPath) : manifestDir;
|
|
3681
3643
|
const transpilePackageDirs = swcIncludeDirs.filter((dir)=>dir !== projectPath && dir !== manifestDir);
|
|
3682
3644
|
const preferTypeScript = !!tsConfigPath;
|
|
3683
|
-
|
|
3684
|
-
'chrome >= 100'
|
|
3685
|
-
];
|
|
3686
|
-
if (manifest?.minimum_chrome_version) targets = [
|
|
3687
|
-
`chrome >= ${manifest.minimum_chrome_version}`
|
|
3688
|
-
];
|
|
3689
|
-
const geckoMin = manifest?.browser_specific_settings?.gecko?.strict_min_version || manifest?.applications?.gecko?.strict_min_version;
|
|
3690
|
-
if (geckoMin) {
|
|
3691
|
-
const major = parseInt(String(geckoMin).split('.')[0], 10);
|
|
3692
|
-
if (!Number.isNaN(major)) targets.push(`firefox >= ${major}`);
|
|
3693
|
-
}
|
|
3645
|
+
const targets = resolveSwcTargets(manifest, this.browser);
|
|
3694
3646
|
compiler.options.resolve.alias = {
|
|
3695
3647
|
...maybeInstallReact?.alias || {},
|
|
3696
3648
|
...maybeInstallPreact?.alias || {},
|
|
3697
3649
|
...maybeInstallVue?.alias || {},
|
|
3650
|
+
...maybeInstallSolid?.alias || {},
|
|
3698
3651
|
...maybeInstallSvelte?.alias || {},
|
|
3699
3652
|
...compiler.options.resolve.alias
|
|
3700
3653
|
};
|
|
@@ -3726,42 +3679,52 @@ class JsFrameworksPlugin {
|
|
|
3726
3679
|
}
|
|
3727
3680
|
]
|
|
3728
3681
|
};
|
|
3729
|
-
const
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
syntax: preferTypeScript ? "typescript" : "ecmascript",
|
|
3745
|
-
tsx: preferTypeScript ? true : isUsingTypeScript(projectPath) && (isUsingReact(projectPath) || isUsingPreact(projectPath)),
|
|
3746
|
-
jsx: !preferTypeScript && (isUsingReact(projectPath) || isUsingPreact(projectPath)),
|
|
3747
|
-
dynamicImport: true
|
|
3682
|
+
const jsxInPlainJs = isUsingJsxFramework(projectPath);
|
|
3683
|
+
const jsxImportSource = getJsxImportSource(projectPath);
|
|
3684
|
+
const isPlatformModule = (resourcePath)=>platformModulePaths.has(toResourceKey(resourcePath));
|
|
3685
|
+
const swcLoaderFor = (resourcePath, options)=>({
|
|
3686
|
+
loader: 'builtin:swc-loader',
|
|
3687
|
+
options: {
|
|
3688
|
+
sync: true,
|
|
3689
|
+
module: {
|
|
3690
|
+
type: 'es6'
|
|
3691
|
+
},
|
|
3692
|
+
minify: false,
|
|
3693
|
+
isModule: options.module ? true : 'unknown',
|
|
3694
|
+
sourceMap: wantsSourceMaps,
|
|
3695
|
+
env: {
|
|
3696
|
+
targets
|
|
3748
3697
|
},
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
useBuiltins: false
|
|
3759
|
-
} : {}
|
|
3698
|
+
jsc: {
|
|
3699
|
+
parser: swcParserForFile(resourcePath, jsxInPlainJs),
|
|
3700
|
+
transform: {
|
|
3701
|
+
react: {
|
|
3702
|
+
development: 'development' === mode,
|
|
3703
|
+
runtime: 'automatic',
|
|
3704
|
+
importSource: jsxImportSource,
|
|
3705
|
+
refresh: options.refresh
|
|
3706
|
+
}
|
|
3760
3707
|
}
|
|
3761
3708
|
}
|
|
3762
3709
|
}
|
|
3763
|
-
}
|
|
3764
|
-
|
|
3710
|
+
});
|
|
3711
|
+
const parserVariants = (options)=>[
|
|
3712
|
+
{
|
|
3713
|
+
test: /\.(tsx|mtsx)$/,
|
|
3714
|
+
use: swcLoaderFor('file.tsx', options)
|
|
3715
|
+
},
|
|
3716
|
+
{
|
|
3717
|
+
test: /\.(ts|mts|cts)$/,
|
|
3718
|
+
use: swcLoaderFor('file.ts', options)
|
|
3719
|
+
},
|
|
3720
|
+
{
|
|
3721
|
+
test: /\.(jsx|mjsx)$/,
|
|
3722
|
+
use: swcLoaderFor('file.jsx', options)
|
|
3723
|
+
},
|
|
3724
|
+
{
|
|
3725
|
+
use: swcLoaderFor('file.js', options)
|
|
3726
|
+
}
|
|
3727
|
+
];
|
|
3765
3728
|
const swcRules = [
|
|
3766
3729
|
{
|
|
3767
3730
|
...swcRuleBase,
|
|
@@ -3770,43 +3733,19 @@ class JsFrameworksPlugin {
|
|
|
3770
3733
|
tsRoot,
|
|
3771
3734
|
...swcIncludeDirs
|
|
3772
3735
|
]))).some((dir)=>isSubPath(resourcePath, dir)) && isfeatureScriptsContentLike(resourcePath),
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
jsc: {
|
|
3778
|
-
...swcLoaderBase.options.jsc,
|
|
3779
|
-
transform: {
|
|
3780
|
-
...swcLoaderBase.options.jsc.transform,
|
|
3781
|
-
react: {
|
|
3782
|
-
...swcLoaderBase.options.jsc.transform.react,
|
|
3783
|
-
refresh: false
|
|
3784
|
-
}
|
|
3785
|
-
}
|
|
3786
|
-
}
|
|
3787
|
-
}
|
|
3788
|
-
}
|
|
3736
|
+
oneOf: parserVariants({
|
|
3737
|
+
refresh: false,
|
|
3738
|
+
module: false
|
|
3739
|
+
})
|
|
3789
3740
|
},
|
|
3790
3741
|
{
|
|
3791
3742
|
...swcRuleBase,
|
|
3792
3743
|
issuerLayer: EXTENSIONJS_CONTENT_SCRIPT_LAYER,
|
|
3793
3744
|
layer: EXTENSIONJS_CONTENT_SCRIPT_LAYER,
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
jsc: {
|
|
3799
|
-
...swcLoaderBase.options.jsc,
|
|
3800
|
-
transform: {
|
|
3801
|
-
...swcLoaderBase.options.jsc.transform,
|
|
3802
|
-
react: {
|
|
3803
|
-
...swcLoaderBase.options.jsc.transform.react,
|
|
3804
|
-
refresh: false
|
|
3805
|
-
}
|
|
3806
|
-
}
|
|
3807
|
-
}
|
|
3808
|
-
}
|
|
3809
|
-
}
|
|
3745
|
+
oneOf: parserVariants({
|
|
3746
|
+
refresh: false,
|
|
3747
|
+
module: false
|
|
3748
|
+
})
|
|
3810
3749
|
},
|
|
3811
3750
|
{
|
|
3812
3751
|
...swcRuleBase,
|
|
@@ -3818,36 +3757,32 @@ class JsFrameworksPlugin {
|
|
|
3818
3757
|
},
|
|
3819
3758
|
exclude: [
|
|
3820
3759
|
...swcRuleBase.exclude,
|
|
3821
|
-
(resourcePath)=>isfeatureScriptsContentLike(resourcePath)
|
|
3760
|
+
(resourcePath)=>isfeatureScriptsContentLike(resourcePath),
|
|
3761
|
+
(resourcePath)=>isPlatformModule(resourcePath)
|
|
3822
3762
|
],
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
jsc: {
|
|
3828
|
-
...swcLoaderBase.options.jsc,
|
|
3829
|
-
transform: {
|
|
3830
|
-
...swcLoaderBase.options.jsc.transform,
|
|
3831
|
-
react: {
|
|
3832
|
-
...swcLoaderBase.options.jsc.transform.react,
|
|
3833
|
-
refresh: 'development' === mode
|
|
3834
|
-
}
|
|
3835
|
-
}
|
|
3836
|
-
}
|
|
3837
|
-
}
|
|
3838
|
-
}
|
|
3763
|
+
oneOf: parserVariants({
|
|
3764
|
+
refresh: 'development' === mode,
|
|
3765
|
+
module: false
|
|
3766
|
+
})
|
|
3839
3767
|
},
|
|
3840
3768
|
...platformModulePaths.size > 0 ? [
|
|
3841
3769
|
{
|
|
3842
3770
|
test: swcRuleBase.test,
|
|
3843
|
-
|
|
3771
|
+
issuerLayer: {
|
|
3772
|
+
not: EXTENSIONJS_CONTENT_SCRIPT_LAYER
|
|
3773
|
+
},
|
|
3774
|
+
include: (resourcePath)=>isPlatformModule(resourcePath),
|
|
3844
3775
|
exclude: [
|
|
3845
3776
|
(resourcePath)=>isfeatureScriptsContentLike(resourcePath)
|
|
3846
3777
|
],
|
|
3847
3778
|
resourceQuery: {
|
|
3848
3779
|
not: /__extensionjs_classic_concat__/
|
|
3849
3780
|
},
|
|
3850
|
-
type: "javascript/esm"
|
|
3781
|
+
type: "javascript/esm",
|
|
3782
|
+
oneOf: parserVariants({
|
|
3783
|
+
refresh: 'development' === mode,
|
|
3784
|
+
module: true
|
|
3785
|
+
})
|
|
3851
3786
|
}
|
|
3852
3787
|
] : []
|
|
3853
3788
|
];
|
|
@@ -3880,6 +3815,7 @@ class JsFrameworksPlugin {
|
|
|
3880
3815
|
if (maybeInstallReact) integrations.push('React');
|
|
3881
3816
|
if (maybeInstallPreact) integrations.push('Preact');
|
|
3882
3817
|
if (maybeInstallVue) integrations.push('Vue');
|
|
3818
|
+
if (maybeInstallSolid) integrations.push('Solid');
|
|
3883
3819
|
if (maybeInstallSvelte) integrations.push('Svelte');
|
|
3884
3820
|
if (preferTypeScript) integrations.push('TypeScript');
|
|
3885
3821
|
console.log(jsFrameworksIntegrationsEnabled(integrations));
|
|
@@ -3894,6 +3830,7 @@ class JsFrameworksPlugin {
|
|
|
3894
3830
|
const mode = compiler.options.mode || 'development';
|
|
3895
3831
|
if ('production' === mode) return void compiler.hooks.beforeRun.tapPromise(JsFrameworksPlugin.name, ()=>this.configureOptions(compiler));
|
|
3896
3832
|
const configuring = this.configureOptions(compiler);
|
|
3833
|
+
compiler.hooks.beforeRun.tapPromise(JsFrameworksPlugin.name, ()=>configuring);
|
|
3897
3834
|
compiler.hooks.watchRun.tapPromise(JsFrameworksPlugin.name, ()=>configuring);
|
|
3898
3835
|
await configuring;
|
|
3899
3836
|
}
|
|
@@ -4786,6 +4723,22 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
4786
4723
|
}
|
|
4787
4724
|
}
|
|
4788
4725
|
|
|
4726
|
+
// The scripts-replay shim (plugin-reload) keeps the SW's own
|
|
4727
|
+
// executeScript registry; the replay is fire-and-forget by design.
|
|
4728
|
+
function replayProgrammaticScripts(changedScriptFiles) {
|
|
4729
|
+
if (!Array.isArray(changedScriptFiles) || changedScriptFiles.length === 0) return;
|
|
4730
|
+
var replay = g.__extjsScriptsReplay;
|
|
4731
|
+
if (typeof replay !== "function") return;
|
|
4732
|
+
try {
|
|
4733
|
+
var outcome = replay(changedScriptFiles);
|
|
4734
|
+
if (outcome && typeof outcome.then === "function") {
|
|
4735
|
+
outcome.then(null, function () {});
|
|
4736
|
+
}
|
|
4737
|
+
} catch (e) {
|
|
4738
|
+
// Ignore
|
|
4739
|
+
}
|
|
4740
|
+
}
|
|
4741
|
+
|
|
4789
4742
|
function handleDevReloadFrame(frame) {
|
|
4790
4743
|
var kind = frame.reloadType || "full";
|
|
4791
4744
|
var label = typeof frame.label === "string" ? frame.label : "";
|
|
@@ -4798,6 +4751,10 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
4798
4751
|
|
|
4799
4752
|
notifyDevtoolsCompanion("reloading", label, kind);
|
|
4800
4753
|
|
|
4754
|
+
// A scripts/ bundle edit: re-run the executeScript calls that named it
|
|
4755
|
+
// on their recorded tabs, before any reload decision below.
|
|
4756
|
+
replayProgrammaticScripts(frame.changedScriptFiles);
|
|
4757
|
+
|
|
4801
4758
|
if (kind === "page") {
|
|
4802
4759
|
// Notify-only: rspack-dev-server's livereload refreshes the open
|
|
4803
4760
|
// surface; reloading the extension here would race it.
|
|
@@ -5333,6 +5290,21 @@ function buildBridgeProducerSource(opts) {
|
|
|
5333
5290
|
if (!opts.controlPort || opts.controlPort < 1) return '';
|
|
5334
5291
|
return BRIDGE_PRODUCER_SOURCE.replace(/__EXTJS_CONTROL_PORT__/g, String(opts.controlPort)).replace(/__EXTJS_INSTANCE_ID__/g, String(opts.instanceId)).replace(/__EXTJS_CONTEXT__/g, String(opts.context || 'background')).replace(/__EXTJS_CONTROL_HOST__/g, String(opts.host || '127.0.0.1'));
|
|
5335
5292
|
}
|
|
5293
|
+
function prependToEmittedAsset(compilation, asset, prefix) {
|
|
5294
|
+
const assetName = asset.name;
|
|
5295
|
+
const original = asset.source.source().toString();
|
|
5296
|
+
compilation.updateAsset(assetName, new core_sources.RawSource(`${prefix}${original}`));
|
|
5297
|
+
const mapAsset = 'function' == typeof compilation.getAsset ? compilation.getAsset(`${assetName}.map`) : void 0;
|
|
5298
|
+
if (!mapAsset) return;
|
|
5299
|
+
const prefixLines = prefix.split('\n').length - 1;
|
|
5300
|
+
if (prefixLines <= 0) return;
|
|
5301
|
+
try {
|
|
5302
|
+
const map = JSON.parse(mapAsset.source.source().toString());
|
|
5303
|
+
if ('string' != typeof map.mappings) return;
|
|
5304
|
+
map.mappings = `${';'.repeat(prefixLines)}${map.mappings}`;
|
|
5305
|
+
compilation.updateAsset(`${assetName}.map`, new core_sources.RawSource(JSON.stringify(map)));
|
|
5306
|
+
} catch {}
|
|
5307
|
+
}
|
|
5336
5308
|
const BACKGROUND_ASSET = /(^|\/)background\/(?:service_worker|scripts?)\.js$/i;
|
|
5337
5309
|
class InjectBridgeProducer {
|
|
5338
5310
|
apply(compiler) {
|
|
@@ -5358,9 +5330,7 @@ class InjectBridgeProducer {
|
|
|
5358
5330
|
for (const asset of compilation.getAssets()){
|
|
5359
5331
|
if (!BACKGROUND_ASSET.test(asset.name)) continue;
|
|
5360
5332
|
const original = asset.source.source().toString();
|
|
5361
|
-
if (-1
|
|
5362
|
-
const next = `${source}\n${original}`;
|
|
5363
|
-
compilation.updateAsset(asset.name, new core_sources.RawSource(next));
|
|
5333
|
+
if (-1 === original.indexOf('__extjsBridgeProducerInstalled')) prependToEmittedAsset(compilation, asset, `${source}\n`);
|
|
5364
5334
|
}
|
|
5365
5335
|
});
|
|
5366
5336
|
});
|
|
@@ -5417,9 +5387,7 @@ class InjectBridgeRelay {
|
|
|
5417
5387
|
const target = RELAY_TARGETS.find((t)=>t.re.test(asset.name));
|
|
5418
5388
|
if (!target) continue;
|
|
5419
5389
|
const original = asset.source.source().toString();
|
|
5420
|
-
if (-1
|
|
5421
|
-
const next = `${sourceFor.get(target.context)}\n${original}`;
|
|
5422
|
-
compilation.updateAsset(asset.name, new core_sources.RawSource(next));
|
|
5390
|
+
if (-1 === original.indexOf('__extjsBridgeRelayInstalled')) prependToEmittedAsset(compilation, asset, `${sourceFor.get(target.context)}\n`);
|
|
5423
5391
|
}
|
|
5424
5392
|
});
|
|
5425
5393
|
});
|
|
@@ -5549,9 +5517,7 @@ class InjectScriptsReplayShim {
|
|
|
5549
5517
|
for (const asset of compilation.getAssets()){
|
|
5550
5518
|
if (!inject_scripts_replay_shim_BACKGROUND_ASSET.test(asset.name)) continue;
|
|
5551
5519
|
const original = asset.source.source().toString();
|
|
5552
|
-
if (-1
|
|
5553
|
-
const next = `${SCRIPTS_REPLAY_SHIM_SOURCE}\n${original}`;
|
|
5554
|
-
compilation.updateAsset(asset.name, new core_sources.RawSource(next));
|
|
5520
|
+
if (-1 === original.indexOf('__extjsScriptsReplayInstalled')) prependToEmittedAsset(compilation, asset, `${SCRIPTS_REPLAY_SHIM_SOURCE}\n`);
|
|
5555
5521
|
}
|
|
5556
5522
|
});
|
|
5557
5523
|
});
|
|
@@ -6853,12 +6819,14 @@ class ReloadPlugin {
|
|
|
6853
6819
|
static name = 'plugin-reload';
|
|
6854
6820
|
manifestPath;
|
|
6855
6821
|
browser;
|
|
6822
|
+
devSession;
|
|
6856
6823
|
constructor(options){
|
|
6857
6824
|
this.manifestPath = options.manifestPath;
|
|
6858
6825
|
this.browser = options.browser || 'chrome';
|
|
6826
|
+
this.devSession = options.devSession;
|
|
6859
6827
|
}
|
|
6860
6828
|
apply(compiler) {
|
|
6861
|
-
if ('production' === compiler.options.mode || 'true' === process.env.EXTENSION_NO_RELOAD) return;
|
|
6829
|
+
if ('production' === compiler.options.mode || false === this.devSession || 'true' === process.env.EXTENSION_NO_RELOAD) return;
|
|
6862
6830
|
const hasValidManifest = !!this.manifestPath && __rspack_external_node_fs_5ea92f0c.existsSync(this.manifestPath) && __rspack_external_node_fs_5ea92f0c.lstatSync(this.manifestPath).isFile();
|
|
6863
6831
|
if (!hasValidManifest) return;
|
|
6864
6832
|
new StripContentScriptDevServerRuntime().apply(compiler);
|
|
@@ -7543,6 +7511,74 @@ function emitRootAbsoluteRefs(compilation, context, publicDir) {
|
|
|
7543
7511
|
if (0 === emitted) return;
|
|
7544
7512
|
}
|
|
7545
7513
|
}
|
|
7514
|
+
const DEV_SESSION_RESTART_DEBOUNCE_MS = 300;
|
|
7515
|
+
class DevSessionRestartScheduler {
|
|
7516
|
+
debounceMs;
|
|
7517
|
+
handler = null;
|
|
7518
|
+
timer;
|
|
7519
|
+
latest = null;
|
|
7520
|
+
inFlight = false;
|
|
7521
|
+
constructor(debounceMs = DEV_SESSION_RESTART_DEBOUNCE_MS){
|
|
7522
|
+
this.debounceMs = Math.max(0, debounceMs);
|
|
7523
|
+
}
|
|
7524
|
+
setHandler(handler) {
|
|
7525
|
+
this.handler = handler;
|
|
7526
|
+
}
|
|
7527
|
+
request(request) {
|
|
7528
|
+
this.latest = request;
|
|
7529
|
+
if (this.inFlight) return;
|
|
7530
|
+
this.schedule();
|
|
7531
|
+
}
|
|
7532
|
+
isPending() {
|
|
7533
|
+
return null != this.latest || this.inFlight;
|
|
7534
|
+
}
|
|
7535
|
+
dispose() {
|
|
7536
|
+
if (this.timer) clearTimeout(this.timer);
|
|
7537
|
+
this.timer = void 0;
|
|
7538
|
+
this.latest = null;
|
|
7539
|
+
this.handler = null;
|
|
7540
|
+
}
|
|
7541
|
+
schedule() {
|
|
7542
|
+
if (this.timer) clearTimeout(this.timer);
|
|
7543
|
+
if (0 === this.debounceMs) return void this.flush();
|
|
7544
|
+
this.timer = setTimeout(()=>{
|
|
7545
|
+
this.timer = void 0;
|
|
7546
|
+
this.flush();
|
|
7547
|
+
}, this.debounceMs);
|
|
7548
|
+
this.timer.unref?.();
|
|
7549
|
+
}
|
|
7550
|
+
async flush() {
|
|
7551
|
+
if (this.inFlight) return;
|
|
7552
|
+
const request = this.latest;
|
|
7553
|
+
const handler = this.handler;
|
|
7554
|
+
if (!request || !handler) return;
|
|
7555
|
+
this.latest = null;
|
|
7556
|
+
this.inFlight = true;
|
|
7557
|
+
try {
|
|
7558
|
+
await handler(request);
|
|
7559
|
+
} catch {} finally{
|
|
7560
|
+
this.inFlight = false;
|
|
7561
|
+
if (this.latest) this.schedule();
|
|
7562
|
+
}
|
|
7563
|
+
}
|
|
7564
|
+
}
|
|
7565
|
+
let boundScheduler = null;
|
|
7566
|
+
const restartingCompilers = new WeakSet();
|
|
7567
|
+
function bindDevSessionRestart(scheduler) {
|
|
7568
|
+
boundScheduler = scheduler;
|
|
7569
|
+
}
|
|
7570
|
+
function unbindDevSessionRestart() {
|
|
7571
|
+
boundScheduler = null;
|
|
7572
|
+
}
|
|
7573
|
+
function requestDevSessionRestart(compiler, request) {
|
|
7574
|
+
if (!boundScheduler) return false;
|
|
7575
|
+
if (compiler) restartingCompilers.add(compiler);
|
|
7576
|
+
boundScheduler.request(request);
|
|
7577
|
+
return true;
|
|
7578
|
+
}
|
|
7579
|
+
function isCompilerRestarting(compiler) {
|
|
7580
|
+
return null != compiler && restartingCompilers.has(compiler);
|
|
7581
|
+
}
|
|
7546
7582
|
class WarnUponFolderChanges {
|
|
7547
7583
|
pendingChanges = [];
|
|
7548
7584
|
knownFolderFiles = new Set();
|
|
@@ -7600,6 +7636,10 @@ class WarnUponFolderChanges {
|
|
|
7600
7636
|
const typeOfAsset = 'pages' === folder ? 'HTML pages' : "script files";
|
|
7601
7637
|
const errorMessage = serverRestartRequiredFromSpecialFolderMessageOnly(addingOrRemoving, folder, typeOfAsset);
|
|
7602
7638
|
if (isAddition) {
|
|
7639
|
+
if (requestDevSessionRestart(compilation.compiler, {
|
|
7640
|
+
reason: 'pages' === folder ? 'html' : "scripts",
|
|
7641
|
+
pathAfter: filePath
|
|
7642
|
+
})) return;
|
|
7603
7643
|
const warn = new core_WebpackError(errorMessage);
|
|
7604
7644
|
warn.name = 'SpecialFoldersChange';
|
|
7605
7645
|
warn.file = filePath;
|
|
@@ -7679,8 +7719,14 @@ class SpecialFoldersPlugin {
|
|
|
7679
7719
|
apply(compiler) {
|
|
7680
7720
|
const { manifestPath } = this.options;
|
|
7681
7721
|
const context = compiler.options.context || __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
7682
|
-
const
|
|
7722
|
+
const inspection = inspectPublicFolders(manifestPath, context);
|
|
7723
|
+
const publicDir = inspection.publicDir || __rspack_external_node_path_c5b9b54f.join(context, 'public');
|
|
7724
|
+
rememberPublicRoots(compiler, inspection.publicDir ? [
|
|
7725
|
+
publicDir
|
|
7726
|
+
] : []);
|
|
7683
7727
|
compiler.hooks.thisCompilation.tap(SpecialFoldersPlugin.name, (compilation)=>{
|
|
7728
|
+
if (inspection.bothExist) pushLayoutWarning(compiler, compilation, 'PublicFolderShadowedWarning', publicFolderShadowed(inspection.fromRoot, inspection.fromManifest));
|
|
7729
|
+
else if (inspection.usedFallback) pushLayoutWarning(compiler, compilation, 'PublicLayoutWarning', publicMustBeAtProjectRoot(inspection.fromManifest, inspection.fromRoot));
|
|
7684
7730
|
compilation.hooks.processAssets.tap({
|
|
7685
7731
|
name: `${SpecialFoldersPlugin.name}:root-absolute-refs`,
|
|
7686
7732
|
stage: compilation.constructor.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
@@ -7688,8 +7734,9 @@ class SpecialFoldersPlugin {
|
|
|
7688
7734
|
emitRootAbsoluteRefs(compilation, __rspack_external_node_path_c5b9b54f.dirname(manifestPath), publicDir);
|
|
7689
7735
|
});
|
|
7690
7736
|
});
|
|
7691
|
-
if (
|
|
7737
|
+
if (inspection.publicDir) {
|
|
7692
7738
|
compiler.hooks.thisCompilation.tap(SpecialFoldersPlugin.name, (compilation)=>{
|
|
7739
|
+
compilation.contextDependencies?.add(publicDir);
|
|
7693
7740
|
compilation.hooks.processAssets.tap({
|
|
7694
7741
|
name: `${SpecialFoldersPlugin.name}:guards`,
|
|
7695
7742
|
stage: compilation.constructor.PROCESS_ASSETS_STAGE_PRE_PROCESS
|
|
@@ -7719,6 +7766,13 @@ class SpecialFoldersPlugin {
|
|
|
7719
7766
|
}
|
|
7720
7767
|
}
|
|
7721
7768
|
}
|
|
7769
|
+
function pushLayoutWarning(compiler, compilation, name, message) {
|
|
7770
|
+
const ErrorConstructor = compiler?.rspack?.WebpackError || Error;
|
|
7771
|
+
const warning = new ErrorConstructor(message);
|
|
7772
|
+
warning.name = name;
|
|
7773
|
+
if (!compilation.warnings) compilation.warnings = [];
|
|
7774
|
+
compilation.warnings.push(warning);
|
|
7775
|
+
}
|
|
7722
7776
|
function assetsRulesEnabled(rules) {
|
|
7723
7777
|
const kinds = rules.length > 0 ? rules.join(',').toLowerCase() : 'none';
|
|
7724
7778
|
return `${messaging_prefix('debug')} assets rules=${rules.length} kinds=${kinds}`;
|
|
@@ -8112,7 +8166,7 @@ function resolveCssAsset(compilation, feature) {
|
|
|
8112
8166
|
href: void 0
|
|
8113
8167
|
};
|
|
8114
8168
|
}
|
|
8115
|
-
function handleStaticAsset(compilation, htmlEntry, htmlDir, absolutePath, assetType, cleanPath, search, hash,
|
|
8169
|
+
function handleStaticAsset(compilation, htmlEntry, htmlDir, absolutePath, assetType, cleanPath, search, hash, includeList, extname, childNode, attributeName, manifestDir) {
|
|
8116
8170
|
const isFilepathListEntry = isFromFilepathList(absolutePath, includeList);
|
|
8117
8171
|
__rspack_external_node_path_c5b9b54f.posix.join('/', cleanPath);
|
|
8118
8172
|
const attrName = resolveStaticAttributeName(assetType, attributeName);
|
|
@@ -8128,15 +8182,50 @@ function handleStaticAsset(compilation, htmlEntry, htmlDir, absolutePath, assetT
|
|
|
8128
8182
|
node = applyRewrittenStaticUrl(node, attrName, cleanPath, cleanPath + (search || '') + (hash || ''));
|
|
8129
8183
|
return node;
|
|
8130
8184
|
}
|
|
8131
|
-
const
|
|
8132
|
-
const fromRoot = __rspack_external_node_path_c5b9b54f.parse(baseJoin).root;
|
|
8133
|
-
const toRoot = __rspack_external_node_path_c5b9b54f.parse(absolutePath).root;
|
|
8134
|
-
const relativeFromHtml = fromRoot && toRoot && String(fromRoot).toLowerCase() !== String(toRoot).toLowerCase() ? __rspack_external_node_path_c5b9b54f.basename(absolutePath) : __rspack_external_node_path_c5b9b54f.relative(baseJoin, absolutePath);
|
|
8135
|
-
const posixRelative = relativeFromHtml.split(__rspack_external_node_path_c5b9b54f.sep).join('/');
|
|
8136
|
-
const filepath = joinEmittedAssetName('assets', posixRelative);
|
|
8185
|
+
const filepath = htmlStaticAssetOutputName(manifestDir, htmlEntry, absolutePath);
|
|
8137
8186
|
if (__rspack_external_node_fs_5ea92f0c.existsSync(absolutePath)) node = applyRewrittenStaticUrl(node, attrName, cleanPath, getFilePath(filepath, '', true) + (search || '') + (hash || ''));
|
|
8138
8187
|
return node;
|
|
8139
8188
|
}
|
|
8189
|
+
const LINK_ATTRIBUTES = {
|
|
8190
|
+
a: 'href',
|
|
8191
|
+
area: 'href',
|
|
8192
|
+
form: 'action'
|
|
8193
|
+
};
|
|
8194
|
+
function isBakeable(value) {
|
|
8195
|
+
const trimmed = value.trim();
|
|
8196
|
+
if (!trimmed) return false;
|
|
8197
|
+
if (trimmed.startsWith('#')) return false;
|
|
8198
|
+
if (trimmed.startsWith('//')) return false;
|
|
8199
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(trimmed)) return false;
|
|
8200
|
+
return true;
|
|
8201
|
+
}
|
|
8202
|
+
function resolveLinkThroughBase(baseHref, value) {
|
|
8203
|
+
if (utils_isUrl(baseHref)) return new URL(value, baseHref).href;
|
|
8204
|
+
if (value.startsWith('/')) return value;
|
|
8205
|
+
const joined = __rspack_external_node_path_c5b9b54f.posix.join(baseHref.replace(/\\/g, '/'), value);
|
|
8206
|
+
return baseHref.startsWith('/') && !joined.startsWith('/') ? `/${joined}` : joined;
|
|
8207
|
+
}
|
|
8208
|
+
function base_href_walk(node, visit) {
|
|
8209
|
+
visit(node);
|
|
8210
|
+
for (const child of node.childNodes || [])base_href_walk(child, visit);
|
|
8211
|
+
}
|
|
8212
|
+
function bakeBaseHref(htmlDocument) {
|
|
8213
|
+
const baseNode = getBaseNode(htmlDocument);
|
|
8214
|
+
const baseHref = baseNode?.attrs?.find((attr)=>'href' === attr.name)?.value;
|
|
8215
|
+
if (!baseNode || !baseHref) return;
|
|
8216
|
+
base_href_walk(htmlDocument, (node)=>{
|
|
8217
|
+
const attrName = LINK_ATTRIBUTES[String(node.nodeName || '')];
|
|
8218
|
+
if (!attrName) return;
|
|
8219
|
+
const attr = node.attrs?.find((entry)=>entry.name === attrName);
|
|
8220
|
+
if (!attr || !isBakeable(attr.value)) return;
|
|
8221
|
+
attr.value = resolveLinkThroughBase(baseHref, attr.value.trim());
|
|
8222
|
+
});
|
|
8223
|
+
baseNode.attrs = (baseNode.attrs || []).filter((attr)=>'href' !== attr.name);
|
|
8224
|
+
if (0 === baseNode.attrs.length) base_href_walk(htmlDocument, (node)=>{
|
|
8225
|
+
if (!node.childNodes) return;
|
|
8226
|
+
node.childNodes = node.childNodes.filter((child)=>child !== baseNode);
|
|
8227
|
+
});
|
|
8228
|
+
}
|
|
8140
8229
|
function injectJsScript(bodyNode, feature, firstScriptAttrs) {
|
|
8141
8230
|
const scriptTag = __rspack_external_parse5_utilities_78b19c6a.createNode("script");
|
|
8142
8231
|
scriptTag.attrs = [
|
|
@@ -8169,7 +8258,7 @@ function warnIfPublicRootAssetMissing(compilation, htmlEntry, cleanPath) {
|
|
|
8169
8258
|
warn.message = filtered.join('\n').trim();
|
|
8170
8259
|
compilation.warnings.push(warn);
|
|
8171
8260
|
}
|
|
8172
|
-
function patchHtml(compilation, feature, htmlEntry, includeList) {
|
|
8261
|
+
function patchHtml(compilation, feature, htmlEntry, includeList, manifestDir) {
|
|
8173
8262
|
const htmlFile = __rspack_external_node_fs_5ea92f0c.readFileSync(htmlEntry, {
|
|
8174
8263
|
encoding: 'utf8'
|
|
8175
8264
|
});
|
|
@@ -8188,7 +8277,7 @@ function patchHtml(compilation, feature, htmlEntry, includeList) {
|
|
|
8188
8277
|
if ('head' === htmlChildNode.nodeName || 'body' === htmlChildNode.nodeName) parseHtml(htmlChildNode, ({ filePath, childNode, assetType, attributeName })=>{
|
|
8189
8278
|
const htmlDir = __rspack_external_node_path_c5b9b54f.dirname(htmlEntry);
|
|
8190
8279
|
const { cleanPath, hash, search } = cleanAssetUrl(filePath);
|
|
8191
|
-
const absolutePath =
|
|
8280
|
+
const absolutePath = resolveHtmlRefPath(htmlEntry, baseHref, cleanPath);
|
|
8192
8281
|
const extname = getExtname(absolutePath);
|
|
8193
8282
|
__rspack_external_node_path_c5b9b54f.posix.join('/', cleanPath);
|
|
8194
8283
|
let thisChildNode = childNode;
|
|
@@ -8215,7 +8304,7 @@ function patchHtml(compilation, feature, htmlEntry, includeList) {
|
|
|
8215
8304
|
break;
|
|
8216
8305
|
case 'staticHref':
|
|
8217
8306
|
case 'staticSrc':
|
|
8218
|
-
thisChildNode = handleStaticAsset(compilation, htmlEntry, htmlDir, absolutePath, assetType, cleanPath, search, hash,
|
|
8307
|
+
thisChildNode = handleStaticAsset(compilation, htmlEntry, htmlDir, absolutePath, assetType, cleanPath, search, hash, includeList, extname, thisChildNode, attributeName, manifestDir);
|
|
8219
8308
|
break;
|
|
8220
8309
|
default:
|
|
8221
8310
|
break;
|
|
@@ -8244,20 +8333,21 @@ function patchHtml(compilation, feature, htmlEntry, includeList) {
|
|
|
8244
8333
|
];
|
|
8245
8334
|
} else if (bodyNode) injectJsScript(bodyNode, feature, firstScriptAttrs);
|
|
8246
8335
|
}
|
|
8336
|
+
bakeBaseHref(htmlDocument);
|
|
8247
8337
|
return __rspack_external_parse5_utilities_78b19c6a.stringify(htmlDocument);
|
|
8248
8338
|
}
|
|
8249
8339
|
return '';
|
|
8250
8340
|
}
|
|
8251
|
-
function patchHtmlNested(compilation, htmlEntry) {
|
|
8341
|
+
function patchHtmlNested(compilation, htmlEntry, manifestDir) {
|
|
8252
8342
|
const htmlFile = __rspack_external_node_fs_5ea92f0c.readFileSync(htmlEntry, {
|
|
8253
8343
|
encoding: 'utf8'
|
|
8254
8344
|
});
|
|
8255
8345
|
const htmlDocument = __rspack_external_parse5_utilities_78b19c6a.parse(htmlFile);
|
|
8346
|
+
const baseHref = getBaseHref(htmlDocument);
|
|
8256
8347
|
for (const node of htmlDocument.childNodes)if ('html' === node.nodeName) {
|
|
8257
8348
|
for (const htmlChildNode of node.childNodes)if ('head' === htmlChildNode.nodeName || 'body' === htmlChildNode.nodeName) parseHtml(htmlChildNode, ({ filePath, childNode, assetType, attributeName })=>{
|
|
8258
|
-
const htmlDir = __rspack_external_node_path_c5b9b54f.dirname(htmlEntry);
|
|
8259
8349
|
const { cleanPath, hash, search } = cleanAssetUrl(filePath);
|
|
8260
|
-
const absolutePath =
|
|
8350
|
+
const absolutePath = resolveHtmlRefPath(htmlEntry, baseHref, cleanPath);
|
|
8261
8351
|
const attrName = 'staticSrc' === assetType || 'staticHref' === assetType ? resolveStaticAttributeName(assetType, attributeName) : void 0;
|
|
8262
8352
|
let thisChildNode = childNode;
|
|
8263
8353
|
switch(assetType){
|
|
@@ -8279,9 +8369,7 @@ function patchHtmlNested(compilation, htmlEntry) {
|
|
|
8279
8369
|
warnIfPublicRootAssetMissing(compilation, htmlEntry, cleanPath);
|
|
8280
8370
|
thisChildNode = applyRewrittenStaticUrl(thisChildNode, attrName || resolveStaticAttributeName(assetType), cleanPath, cleanPath + (search || '') + (hash || ''));
|
|
8281
8371
|
} else if (__rspack_external_node_fs_5ea92f0c.existsSync(absolutePath)) {
|
|
8282
|
-
const
|
|
8283
|
-
const posixRelative = relativeFromHtml.split(__rspack_external_node_path_c5b9b54f.sep).join('/');
|
|
8284
|
-
const filepath = joinEmittedAssetName('assets', posixRelative);
|
|
8372
|
+
const filepath = htmlStaticAssetOutputName(manifestDir, htmlEntry, absolutePath);
|
|
8285
8373
|
thisChildNode = applyRewrittenStaticUrl(thisChildNode, attrName || resolveStaticAttributeName(assetType), cleanPath, getFilePath(filepath, '', true) + (search || '') + (hash || ''));
|
|
8286
8374
|
}
|
|
8287
8375
|
break;
|
|
@@ -8289,6 +8377,7 @@ function patchHtmlNested(compilation, htmlEntry) {
|
|
|
8289
8377
|
break;
|
|
8290
8378
|
}
|
|
8291
8379
|
});
|
|
8380
|
+
bakeBaseHref(htmlDocument);
|
|
8292
8381
|
return __rspack_external_parse5_utilities_78b19c6a.stringify(htmlDocument);
|
|
8293
8382
|
}
|
|
8294
8383
|
return '';
|
|
@@ -8343,9 +8432,9 @@ function checkMissingLocalEntries(params) {
|
|
|
8343
8432
|
css?.forEach(check);
|
|
8344
8433
|
}
|
|
8345
8434
|
function emitNestedHtmlAndReferencedAssets(params) {
|
|
8346
|
-
const { compilation, filepath, absoluteFsPath } = params;
|
|
8435
|
+
const { compilation, filepath, absoluteFsPath, manifestDir } = params;
|
|
8347
8436
|
const source = __rspack_external_node_fs_5ea92f0c.readFileSync(absoluteFsPath);
|
|
8348
|
-
const updatedHtml = patchHtmlNested(compilation, absoluteFsPath);
|
|
8437
|
+
const updatedHtml = patchHtmlNested(compilation, absoluteFsPath, manifestDir);
|
|
8349
8438
|
const htmlAssets = getAssetsFromHtml(absoluteFsPath);
|
|
8350
8439
|
const assetsFromHtml = [
|
|
8351
8440
|
...htmlAssets?.js || [],
|
|
@@ -8357,7 +8446,7 @@ function emitNestedHtmlAndReferencedAssets(params) {
|
|
|
8357
8446
|
if (!__rspack_external_node_path_c5b9b54f.isAbsolute(assetFromHtml) || !__rspack_external_node_fs_5ea92f0c.existsSync(assetFromHtml)) return;
|
|
8358
8447
|
const s = __rspack_external_node_fs_5ea92f0c.readFileSync(assetFromHtml);
|
|
8359
8448
|
const r = new core_sources.RawSource(s);
|
|
8360
|
-
const assetFilepath =
|
|
8449
|
+
const assetFilepath = htmlStaticAssetOutputName(manifestDir, absoluteFsPath, assetFromHtml);
|
|
8361
8450
|
if (!compilation.getAsset(assetFilepath)) compilation.emitAsset(assetFilepath, r);
|
|
8362
8451
|
});
|
|
8363
8452
|
}
|
|
@@ -8462,14 +8551,15 @@ class AddAssetsToCompilation {
|
|
|
8462
8551
|
} catch {}
|
|
8463
8552
|
continue;
|
|
8464
8553
|
}
|
|
8465
|
-
const filepath =
|
|
8554
|
+
const filepath = htmlStaticAssetOutputName(manifestDir, resource, absoluteFsPath);
|
|
8466
8555
|
const isNestedHtml = asset.endsWith('.html');
|
|
8467
8556
|
const nestedHtmlAsset = isNestedHtml ? 'function' == typeof getAssetFn ? getAssetFn.call(compilation, __rspack_external_node_path_c5b9b54f.basename(asset)) : null : null;
|
|
8468
8557
|
if (!isFromIncludeList(asset, this.includeList) || nestedHtmlAsset) {
|
|
8469
8558
|
if (!('function' == typeof getAssetFn && getAssetFn.call(compilation, filepath))) if (asset.endsWith('.html')) emitNestedHtmlAndReferencedAssets({
|
|
8470
8559
|
compilation,
|
|
8471
8560
|
filepath,
|
|
8472
|
-
absoluteFsPath
|
|
8561
|
+
absoluteFsPath,
|
|
8562
|
+
manifestDir
|
|
8473
8563
|
});
|
|
8474
8564
|
else {
|
|
8475
8565
|
const source = __rspack_external_node_fs_5ea92f0c.readFileSync(absoluteFsPath);
|
|
@@ -8763,6 +8853,8 @@ function manifestFieldForHtmlFeature(featureName, manifestPath) {
|
|
|
8763
8853
|
if (has('action')) return 'action.default_popup';
|
|
8764
8854
|
if (has('browser_action')) return 'browser_action.default_popup';
|
|
8765
8855
|
return 'page_action.default_popup';
|
|
8856
|
+
case 'page_action/index':
|
|
8857
|
+
return 'page_action.default_popup';
|
|
8766
8858
|
case 'options/index':
|
|
8767
8859
|
return has('options_page') ? 'options_page' : 'options_ui.page';
|
|
8768
8860
|
case 'background/index':
|
|
@@ -8928,6 +9020,11 @@ class ThrowIfRecompileIsNeeded {
|
|
|
8928
9020
|
if (this.hasEntriesChanged(updatedCssEntries, css) || this.hasEntriesChanged(updatedJsEntries, js)) {
|
|
8929
9021
|
const projectRoot = __rspack_external_node_path_c5b9b54f.dirname(this.manifestPath);
|
|
8930
9022
|
const relToManifest = __rspack_external_node_path_c5b9b54f.relative(projectRoot, changedFile);
|
|
9023
|
+
if (requestDevSessionRestart(compiler, {
|
|
9024
|
+
reason: 'html',
|
|
9025
|
+
pathAfter: changedFile,
|
|
9026
|
+
manifestField: relToManifest
|
|
9027
|
+
})) continue;
|
|
8931
9028
|
const err = new core_WebpackError(serverRestartRequiredFromHtml(relToManifest, changedFile));
|
|
8932
9029
|
err.name = 'HtmlEntrypointChanged';
|
|
8933
9030
|
err.file = relToManifest;
|
|
@@ -8960,7 +9057,7 @@ class UpdateHtmlFile {
|
|
|
8960
9057
|
const getAssetFn = compilation.getAsset;
|
|
8961
9058
|
const existing = 'function' == typeof getAssetFn ? getAssetFn.call(compilation, assetFilename) : compilation.assets?.[assetFilename];
|
|
8962
9059
|
if (!existing) continue;
|
|
8963
|
-
const updated = patchHtml(compilation, feature, resolved, this.includeList || {});
|
|
9060
|
+
const updated = patchHtml(compilation, feature, resolved, this.includeList || {}, projectDir);
|
|
8964
9061
|
const updatedHtml = 'string' == typeof updated ? updated : updated && 'string' == typeof updated.html ? updated.html : null;
|
|
8965
9062
|
if ('string' == typeof updatedHtml) compilation.updateAsset(assetFilename, new core_sources.RawSource(updatedHtml));
|
|
8966
9063
|
}
|
|
@@ -8978,9 +9075,11 @@ class HtmlPlugin {
|
|
|
8978
9075
|
manifestPath;
|
|
8979
9076
|
includeList;
|
|
8980
9077
|
browser;
|
|
9078
|
+
devSession;
|
|
8981
9079
|
constructor(options){
|
|
8982
9080
|
this.manifestPath = options.manifestPath;
|
|
8983
9081
|
this.includeList = options.includeList;
|
|
9082
|
+
this.devSession = options.devSession;
|
|
8984
9083
|
this.browser = options.browser || 'chrome';
|
|
8985
9084
|
}
|
|
8986
9085
|
apply(compiler) {
|
|
@@ -9007,7 +9106,8 @@ class HtmlPlugin {
|
|
|
9007
9106
|
includeList,
|
|
9008
9107
|
browser: this.browser
|
|
9009
9108
|
}).apply(compiler);
|
|
9010
|
-
|
|
9109
|
+
const devSession = this.devSession ?? 'production' !== (compiler.options.mode || 'development');
|
|
9110
|
+
if (devSession) {
|
|
9011
9111
|
const contentScriptEntryPaths = new Set();
|
|
9012
9112
|
try {
|
|
9013
9113
|
const manifest = parseJsonSafe(__rspack_external_node_fs_5ea92f0c.readFileSync(this.manifestPath, 'utf-8'));
|
|
@@ -9018,11 +9118,16 @@ class HtmlPlugin {
|
|
|
9018
9118
|
for (const jsFile of jsList)contentScriptEntryPaths.add(toResourceKey(__rspack_external_node_path_c5b9b54f.resolve(manifestDir, jsFile)));
|
|
9019
9119
|
}
|
|
9020
9120
|
} catch {}
|
|
9121
|
+
const projectRoot = String(compiler.options.context || '');
|
|
9122
|
+
const pageDirs = new Set([
|
|
9123
|
+
__rspack_external_node_path_c5b9b54f.dirname(this.manifestPath)
|
|
9124
|
+
]);
|
|
9125
|
+
if (projectRoot) pageDirs.add(projectRoot);
|
|
9126
|
+
for (const pagePath of Object.values(includeList))if ('string' == typeof pagePath && pagePath) pageDirs.add(__rspack_external_node_path_c5b9b54f.dirname(pagePath));
|
|
9127
|
+
const frameworkOwnsRefresh = Boolean(projectRoot && (isUsingReact(projectRoot) || isUsingVue(projectRoot) || isUsingSvelte(projectRoot)));
|
|
9021
9128
|
compiler.options.module.rules.push({
|
|
9022
9129
|
test: /\.(js|cjs|mjs|jsx|mjsx|ts|mts|tsx|mtsx)$/,
|
|
9023
|
-
include:
|
|
9024
|
-
__rspack_external_node_path_c5b9b54f.dirname(this.manifestPath)
|
|
9025
|
-
],
|
|
9130
|
+
include: Array.from(pageDirs),
|
|
9026
9131
|
issuerLayer: {
|
|
9027
9132
|
not: EXTENSIONJS_CONTENT_SCRIPT_LAYER
|
|
9028
9133
|
},
|
|
@@ -9035,7 +9140,8 @@ class HtmlPlugin {
|
|
|
9035
9140
|
loader: resolveDevelopDistFile("ensure-hmr-for-scripts"),
|
|
9036
9141
|
options: {
|
|
9037
9142
|
manifestPath: this.manifestPath,
|
|
9038
|
-
includeList
|
|
9143
|
+
includeList,
|
|
9144
|
+
frameworkOwnsRefresh
|
|
9039
9145
|
}
|
|
9040
9146
|
}
|
|
9041
9147
|
]
|
|
@@ -9058,6 +9164,32 @@ class HtmlPlugin {
|
|
|
9058
9164
|
}).apply(compiler);
|
|
9059
9165
|
}
|
|
9060
9166
|
}
|
|
9167
|
+
function resolveManifestIconPath(context, relativePath) {
|
|
9168
|
+
const unix = relativePath.replace(/\\/g, '/');
|
|
9169
|
+
if (/^\/public\//i.test(unix)) return __rspack_external_node_path_c5b9b54f.join(context, 'public', unix.replace(/^\/public\//i, ''));
|
|
9170
|
+
if (/^(?:\.\/)?public\//i.test(unix)) return __rspack_external_node_path_c5b9b54f.join(context, 'public', unix.replace(/^(?:\.\/)?public\//i, ''));
|
|
9171
|
+
if (/^\//.test(unix)) return __rspack_external_node_path_c5b9b54f.join(context, unix.slice(1));
|
|
9172
|
+
return __rspack_external_node_path_c5b9b54f.join(context, unix);
|
|
9173
|
+
}
|
|
9174
|
+
function extractActionThemeIcons(manifestPath) {
|
|
9175
|
+
let manifest;
|
|
9176
|
+
try {
|
|
9177
|
+
manifest = JSON.parse(stripBom(__rspack_external_node_fs_5ea92f0c.readFileSync(manifestPath, 'utf8')));
|
|
9178
|
+
} catch {
|
|
9179
|
+
return {};
|
|
9180
|
+
}
|
|
9181
|
+
const themeIcons = manifest?.action?.theme_icons;
|
|
9182
|
+
if (!Array.isArray(themeIcons) || 0 === themeIcons.length) return {};
|
|
9183
|
+
const context = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
9184
|
+
const paths = [];
|
|
9185
|
+
for (const icon of themeIcons)if (icon && 'object' == typeof icon) {
|
|
9186
|
+
if ('string' == typeof icon.light && icon.light) paths.push(resolveManifestIconPath(context, icon.light));
|
|
9187
|
+
if ('string' == typeof icon.dark && icon.dark) paths.push(resolveManifestIconPath(context, icon.dark));
|
|
9188
|
+
}
|
|
9189
|
+
return paths.length ? {
|
|
9190
|
+
'action/theme_icons': paths
|
|
9191
|
+
} : {};
|
|
9192
|
+
}
|
|
9061
9193
|
function iconsMissingFile(manifestField, filePath, opts) {
|
|
9062
9194
|
const lines = [];
|
|
9063
9195
|
lines.push(`Can't find an icon file listed in ${pintor.blue(manifestField)}.`);
|
|
@@ -9141,15 +9273,20 @@ class add_to_file_dependencies_AddToFileDependencies {
|
|
|
9141
9273
|
name: 'icons:add-to-file-dependencies',
|
|
9142
9274
|
stage: core_Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
|
9143
9275
|
}, ()=>{
|
|
9144
|
-
if (compilation.errors?.length) return;
|
|
9145
9276
|
const iconFields = this.includeList || {};
|
|
9146
9277
|
let added = 0;
|
|
9147
9278
|
for (const field of Object.entries(iconFields)){
|
|
9148
9279
|
const [, resource] = field;
|
|
9149
9280
|
const stringEntries = iconValuesToStrings(resource);
|
|
9150
|
-
for (const entry of stringEntries)if (entry &&
|
|
9151
|
-
|
|
9152
|
-
|
|
9281
|
+
for (const entry of stringEntries)if (entry && __rspack_external_node_path_c5b9b54f.isAbsolute(entry)) {
|
|
9282
|
+
if (!__rspack_external_node_fs_5ea92f0c.existsSync(entry)) {
|
|
9283
|
+
compilation.missingDependencies?.add(entry);
|
|
9284
|
+
continue;
|
|
9285
|
+
}
|
|
9286
|
+
if (!compilation.fileDependencies.has(entry)) {
|
|
9287
|
+
compilation.fileDependencies.add(entry);
|
|
9288
|
+
added++;
|
|
9289
|
+
}
|
|
9153
9290
|
}
|
|
9154
9291
|
}
|
|
9155
9292
|
if (isDebug()) console.log(iconsDepsTracked(added));
|
|
@@ -9231,7 +9368,7 @@ class EmitFile {
|
|
|
9231
9368
|
const parts = String(feature).split('/');
|
|
9232
9369
|
const group = parts[0];
|
|
9233
9370
|
const sub = parts[1] || '';
|
|
9234
|
-
const isDefaultIconFamily = ('action' === group || 'browser_action' === group || 'page_action' === group || 'sidebar_action' === group) && 'default_icon' === sub;
|
|
9371
|
+
const isDefaultIconFamily = ('action' === group || 'browser_action' === group || 'page_action' === group || 'sidebar_action' === group || 'omnibox' === group) && 'default_icon' === sub;
|
|
9235
9372
|
const isThemeImage = 'theme' === group && 'images' === sub;
|
|
9236
9373
|
if (!__rspack_external_node_fs_5ea92f0c.existsSync(resolved)) {
|
|
9237
9374
|
const isPublicRoot = entry.startsWith('/') && !entry.startsWith(projectPath);
|
|
@@ -9258,14 +9395,25 @@ class EmitFile {
|
|
|
9258
9395
|
const source = __rspack_external_node_fs_5ea92f0c.readFileSync(resolved);
|
|
9259
9396
|
const rawSource = new core_sources.RawSource(source);
|
|
9260
9397
|
const basename = __rspack_external_node_path_c5b9b54f.basename(resolved);
|
|
9398
|
+
const isThemeIcons = ('browser_action' === group || 'action' === group) && 'theme_icons' === sub;
|
|
9261
9399
|
let outputDir = group;
|
|
9262
9400
|
if (isDefaultIconFamily) outputDir = 'icons';
|
|
9263
|
-
else if (
|
|
9401
|
+
else if (isThemeIcons) outputDir = group;
|
|
9264
9402
|
else if (isThemeImage) outputDir = 'theme/images';
|
|
9265
9403
|
let filename = `${outputDir}/${basename}`;
|
|
9404
|
+
const relFromManifest = __rspack_external_node_path_c5b9b54f.relative(manifestDir, resolved).replace(/\\/g, '/');
|
|
9266
9405
|
if ('icons' === outputDir) {
|
|
9267
|
-
|
|
9268
|
-
if (
|
|
9406
|
+
if (relFromManifest && !__rspack_external_node_path_c5b9b54f.isAbsolute(relFromManifest)) filename = iconOutputPath(relFromManifest);
|
|
9407
|
+
else if (resolved) filename = iconOutputPath(resolved);
|
|
9408
|
+
}
|
|
9409
|
+
if (isThemeIcons) {
|
|
9410
|
+
const folder = 'action' === group ? 'action' : 'browser_action';
|
|
9411
|
+
if (relFromManifest && !__rspack_external_node_path_c5b9b54f.isAbsolute(relFromManifest)) filename = themeIconOutputPath(relFromManifest, folder);
|
|
9412
|
+
else if (resolved) filename = themeIconOutputPath(resolved, folder);
|
|
9413
|
+
}
|
|
9414
|
+
if (isThemeImage) {
|
|
9415
|
+
if (relFromManifest && !__rspack_external_node_path_c5b9b54f.isAbsolute(relFromManifest)) filename = themeImageOutputPath(relFromManifest);
|
|
9416
|
+
else if (resolved) filename = themeImageOutputPath(resolved);
|
|
9269
9417
|
}
|
|
9270
9418
|
compilation.emitAsset(filename, rawSource);
|
|
9271
9419
|
emittedCount++;
|
|
@@ -9289,7 +9437,10 @@ class IconsPlugin {
|
|
|
9289
9437
|
this.includeList = options.includeList;
|
|
9290
9438
|
}
|
|
9291
9439
|
apply(compiler) {
|
|
9292
|
-
const normalizedIncludeList =
|
|
9440
|
+
const normalizedIncludeList = {
|
|
9441
|
+
...normalizeIconIncludeKeys(this.includeList),
|
|
9442
|
+
...extractActionThemeIcons(this.manifestPath)
|
|
9443
|
+
};
|
|
9293
9444
|
if (isDebug()) {
|
|
9294
9445
|
const beforeKeys = Object.keys(this.includeList || {});
|
|
9295
9446
|
const afterKeys = Object.keys(normalizedIncludeList || {});
|
|
@@ -9306,6 +9457,47 @@ class IconsPlugin {
|
|
|
9306
9457
|
}).apply(compiler);
|
|
9307
9458
|
}
|
|
9308
9459
|
}
|
|
9460
|
+
function omniboxIconFields(manifestPath) {
|
|
9461
|
+
let manifest;
|
|
9462
|
+
try {
|
|
9463
|
+
manifest = JSON.parse(stripBom(__rspack_external_node_fs_5ea92f0c.readFileSync(manifestPath, 'utf8')));
|
|
9464
|
+
} catch {
|
|
9465
|
+
return {};
|
|
9466
|
+
}
|
|
9467
|
+
const icon = manifest?.omnibox?.default_icon;
|
|
9468
|
+
if (!icon) return {};
|
|
9469
|
+
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
9470
|
+
const resolve = (value)=>'string' != typeof value || value.startsWith('/') || __rspack_external_node_path_c5b9b54f.isAbsolute(value) ? String(value) : __rspack_external_node_path_c5b9b54f.join(manifestDir, value);
|
|
9471
|
+
if ('string' == typeof icon) return {
|
|
9472
|
+
'omnibox/default_icon': resolve(icon)
|
|
9473
|
+
};
|
|
9474
|
+
if ('object' == typeof icon) return {
|
|
9475
|
+
'omnibox/default_icon': Object.fromEntries(Object.entries(icon).map(([size, value])=>[
|
|
9476
|
+
size,
|
|
9477
|
+
resolve(value)
|
|
9478
|
+
]))
|
|
9479
|
+
};
|
|
9480
|
+
return {};
|
|
9481
|
+
}
|
|
9482
|
+
function themeImageFields(manifestPath) {
|
|
9483
|
+
let manifest;
|
|
9484
|
+
try {
|
|
9485
|
+
manifest = JSON.parse(stripBom(__rspack_external_node_fs_5ea92f0c.readFileSync(manifestPath, 'utf8')));
|
|
9486
|
+
} catch {
|
|
9487
|
+
return {};
|
|
9488
|
+
}
|
|
9489
|
+
const images = manifest?.theme?.images;
|
|
9490
|
+
if (!images || 'object' != typeof images || Array.isArray(images)) return {};
|
|
9491
|
+
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
9492
|
+
const resolve = (value)=>value.startsWith('/') || __rspack_external_node_path_c5b9b54f.isAbsolute(value) ? value : __rspack_external_node_path_c5b9b54f.join(manifestDir, value);
|
|
9493
|
+
const out = {};
|
|
9494
|
+
for (const [key, value] of Object.entries(images))if ('string' == typeof value) out[`theme/images/${key}`] = resolve(value);
|
|
9495
|
+
else if (Array.isArray(value)) {
|
|
9496
|
+
const entries = value.filter((entry)=>'string' == typeof entry);
|
|
9497
|
+
if (entries.length) out[`theme/images/${key}`] = entries.map(resolve);
|
|
9498
|
+
}
|
|
9499
|
+
return out;
|
|
9500
|
+
}
|
|
9309
9501
|
function jsonMissingFile(manifestField, filePath, opts) {
|
|
9310
9502
|
const lines = [];
|
|
9311
9503
|
lines.push(`Can't find the JSON file listed in ${pintor.blue(manifestField)}.`);
|
|
@@ -9366,8 +9558,11 @@ function jsonDepsTracked(addedCount) {
|
|
|
9366
9558
|
function jsonIncludeSummary(totalFeatures, criticalCount) {
|
|
9367
9559
|
return `${messaging_prefix('debug')} json include features=${String(totalFeatures)} critical=${String(criticalCount)}`;
|
|
9368
9560
|
}
|
|
9561
|
+
function isManagedSchemaFeature(feature) {
|
|
9562
|
+
return 'storage/managed_schema' === feature || 'storage.managed_schema' === feature;
|
|
9563
|
+
}
|
|
9369
9564
|
function isCriticalJsonFeature(feature) {
|
|
9370
|
-
return feature.startsWith('declarative_net_request') ||
|
|
9565
|
+
return feature.startsWith('declarative_net_request') || isManagedSchemaFeature(feature);
|
|
9371
9566
|
}
|
|
9372
9567
|
function isPlainObject(value) {
|
|
9373
9568
|
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
@@ -9421,7 +9616,7 @@ function validateJsonAsset(compilation, feature, filePath, buf) {
|
|
|
9421
9616
|
compilation.warnings.push(warn);
|
|
9422
9617
|
}
|
|
9423
9618
|
}
|
|
9424
|
-
} else if (
|
|
9619
|
+
} else if (isManagedSchemaFeature(feature)) {
|
|
9425
9620
|
if (null === parsed || Array.isArray(parsed) || 'object' != typeof parsed) {
|
|
9426
9621
|
const err = new core_WebpackError(invalidManagedSchemaStructure(feature, filePath));
|
|
9427
9622
|
err.file = filePath;
|
|
@@ -9440,23 +9635,40 @@ function firstExisting(candidates) {
|
|
|
9440
9635
|
for (const candidate of candidates)if (candidate && __rspack_external_node_fs_5ea92f0c.existsSync(candidate)) return candidate;
|
|
9441
9636
|
}
|
|
9442
9637
|
function resolveJsonResource(thisResource, manifestDir, projectPath) {
|
|
9443
|
-
const
|
|
9638
|
+
const manifestPath = __rspack_external_node_path_c5b9b54f.join(manifestDir, 'manifest.json');
|
|
9639
|
+
const inspection = inspectPublicFolders(manifestPath, projectPath);
|
|
9640
|
+
const publicRoots = [
|
|
9641
|
+
inspection.fromRoot
|
|
9642
|
+
];
|
|
9643
|
+
if (__rspack_external_node_path_c5b9b54f.resolve(inspection.fromManifest) !== __rspack_external_node_path_c5b9b54f.resolve(inspection.fromRoot)) publicRoots.push(inspection.fromManifest);
|
|
9444
9644
|
const rawRef = String(thisResource);
|
|
9445
9645
|
const looksLikeRootRef = rawRef.startsWith('/') && !rawRef.startsWith('//') && !(projectPath && rawRef.startsWith(projectPath));
|
|
9446
9646
|
const isPublicRoot = looksLikeRootRef && (!__rspack_external_node_path_c5b9b54f.isAbsolute(rawRef) || __rspack_external_node_path_c5b9b54f.dirname(rawRef) === __rspack_external_node_path_c5b9b54f.parse(rawRef).root);
|
|
9447
9647
|
const joined = __rspack_external_node_path_c5b9b54f.isAbsolute(rawRef) ? rawRef : __rspack_external_node_path_c5b9b54f.join(manifestDir, rawRef);
|
|
9448
|
-
const
|
|
9449
|
-
const
|
|
9450
|
-
const
|
|
9451
|
-
const
|
|
9452
|
-
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9648
|
+
const relFromManifest = isInsideDir(joined, manifestDir) ? __rspack_external_node_path_c5b9b54f.relative(manifestDir, joined) : '';
|
|
9649
|
+
const relFromProject = isInsideDir(joined, projectPath) ? __rspack_external_node_path_c5b9b54f.relative(projectPath, joined) : '';
|
|
9650
|
+
const trimmedRootRef = looksLikeRootRef ? rawRef.replace(/^\/+/, '') : '';
|
|
9651
|
+
const relativeRef = __rspack_external_node_path_c5b9b54f.isAbsolute(rawRef) || rawRef.startsWith('public/') ? '' : rawRef;
|
|
9652
|
+
const candidates = [
|
|
9653
|
+
joined
|
|
9654
|
+
];
|
|
9655
|
+
for (const publicRoot of publicRoots){
|
|
9656
|
+
const rels = [
|
|
9657
|
+
relFromManifest,
|
|
9658
|
+
trimmedRootRef,
|
|
9659
|
+
relativeRef
|
|
9660
|
+
];
|
|
9661
|
+
if (publicRoot === inspection.fromRoot) rels.push(relFromProject);
|
|
9662
|
+
for (const rel of rels)if (rel) candidates.push(__rspack_external_node_path_c5b9b54f.join(publicRoot, rel));
|
|
9663
|
+
}
|
|
9664
|
+
const abs = firstExisting(candidates) || joined;
|
|
9665
|
+
const isUnderPublic = publicRoots.some((publicRoot)=>{
|
|
9666
|
+
if (!isInsideDir(abs, publicRoot)) return false;
|
|
9667
|
+
return !inspection.bothExist || publicRoot === inspection.fromRoot;
|
|
9668
|
+
});
|
|
9457
9669
|
return {
|
|
9458
9670
|
abs,
|
|
9459
|
-
isUnderPublic
|
|
9671
|
+
isUnderPublic,
|
|
9460
9672
|
isPublicRoot
|
|
9461
9673
|
};
|
|
9462
9674
|
}
|
|
@@ -9541,7 +9753,6 @@ function processJsonAssets(compilation, manifestPath, includeList) {
|
|
|
9541
9753
|
}
|
|
9542
9754
|
}
|
|
9543
9755
|
function trackJsonDependencies(compilation, manifestPath, includeList) {
|
|
9544
|
-
if (compilation.errors?.length) return;
|
|
9545
9756
|
const jsonFields = includeList || {};
|
|
9546
9757
|
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
9547
9758
|
const projectPath = compilation.compiler.options.context || compilation.options.context || manifestDir;
|
|
@@ -9553,7 +9764,11 @@ function trackJsonDependencies(compilation, manifestPath, includeList) {
|
|
|
9553
9764
|
];
|
|
9554
9765
|
for (const thisResource of resourceArr)if (thisResource) {
|
|
9555
9766
|
const { abs } = resolveJsonResource(thisResource, manifestDir, projectPath);
|
|
9556
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(abs)
|
|
9767
|
+
if (!__rspack_external_node_fs_5ea92f0c.existsSync(abs)) {
|
|
9768
|
+
compilation.missingDependencies?.add(abs);
|
|
9769
|
+
continue;
|
|
9770
|
+
}
|
|
9771
|
+
if (!compilation.fileDependencies.has(abs)) {
|
|
9557
9772
|
compilation.fileDependencies.add(abs);
|
|
9558
9773
|
added++;
|
|
9559
9774
|
}
|
|
@@ -9669,9 +9884,8 @@ function processLocaleAssets(compiler, compilation, manifestPath) {
|
|
|
9669
9884
|
const resolvedLocalesRoot = resolveLocalesFolder(manifestPath, projectRoot);
|
|
9670
9885
|
let emittedCount = 0;
|
|
9671
9886
|
let missingCount = 0;
|
|
9672
|
-
for (const
|
|
9673
|
-
const
|
|
9674
|
-
const thisResource = resource;
|
|
9887
|
+
for (const thisResource of localesFields || []){
|
|
9888
|
+
const feature = resolvedLocalesRoot ? __rspack_external_node_path_c5b9b54f.join('_locales', __rspack_external_node_path_c5b9b54f.relative(resolvedLocalesRoot, thisResource)).split(__rspack_external_node_path_c5b9b54f.sep).join('/') : thisResource;
|
|
9675
9889
|
if (thisResource) {
|
|
9676
9890
|
if ('.json' !== __rspack_external_node_path_c5b9b54f.extname(thisResource)) continue;
|
|
9677
9891
|
if (!__rspack_external_node_fs_5ea92f0c.existsSync(thisResource)) {
|
|
@@ -9697,10 +9911,13 @@ function processLocaleAssets(compiler, compilation, manifestPath) {
|
|
|
9697
9911
|
if (isDebug()) console.log(localesEmitSummary(emittedCount, missingCount, discoveredList.length));
|
|
9698
9912
|
}
|
|
9699
9913
|
function trackLocaleDependencies(compilation, manifestPath, projectRoot) {
|
|
9700
|
-
if (compilation.errors?.length) return;
|
|
9701
9914
|
const localesFields = getLocales(manifestPath, projectRoot) || [];
|
|
9702
9915
|
let added = 0;
|
|
9703
|
-
for (const thisResource of localesFields)if (
|
|
9916
|
+
for (const thisResource of localesFields)if ('.json' === __rspack_external_node_path_c5b9b54f.extname(thisResource)) {
|
|
9917
|
+
if (!__rspack_external_node_fs_5ea92f0c.existsSync(thisResource)) {
|
|
9918
|
+
compilation.missingDependencies?.add(thisResource);
|
|
9919
|
+
continue;
|
|
9920
|
+
}
|
|
9704
9921
|
if (!compilation.fileDependencies.has(thisResource)) {
|
|
9705
9922
|
compilation.fileDependencies.add(thisResource);
|
|
9706
9923
|
added++;
|
|
@@ -9708,6 +9925,38 @@ function trackLocaleDependencies(compilation, manifestPath, projectRoot) {
|
|
|
9708
9925
|
}
|
|
9709
9926
|
if (isDebug()) console.log(localesDepsTracked(added));
|
|
9710
9927
|
}
|
|
9928
|
+
const MSG_REFERENCE = /__MSG_([A-Za-z0-9_@]+?)__/g;
|
|
9929
|
+
function collectMsgReferences(value) {
|
|
9930
|
+
const found = [];
|
|
9931
|
+
const seen = new Set();
|
|
9932
|
+
const visit = (node)=>{
|
|
9933
|
+
if ('string' == typeof node) {
|
|
9934
|
+
MSG_REFERENCE.lastIndex = 0;
|
|
9935
|
+
let match = MSG_REFERENCE.exec(node);
|
|
9936
|
+
while(null !== match){
|
|
9937
|
+
const name = match[1];
|
|
9938
|
+
if (name && !name.startsWith('@@') && !seen.has(name)) {
|
|
9939
|
+
seen.add(name);
|
|
9940
|
+
found.push(name);
|
|
9941
|
+
}
|
|
9942
|
+
match = MSG_REFERENCE.exec(node);
|
|
9943
|
+
}
|
|
9944
|
+
return;
|
|
9945
|
+
}
|
|
9946
|
+
if (Array.isArray(node)) {
|
|
9947
|
+
for (const item of node)visit(item);
|
|
9948
|
+
return;
|
|
9949
|
+
}
|
|
9950
|
+
if (node && 'object' == typeof node) for (const item of Object.values(node))visit(item);
|
|
9951
|
+
};
|
|
9952
|
+
visit(value);
|
|
9953
|
+
return found;
|
|
9954
|
+
}
|
|
9955
|
+
function findUndefinedMsgReferences(value, catalogKeys) {
|
|
9956
|
+
const lower = new Set();
|
|
9957
|
+
for (const key of catalogKeys)lower.add(String(key).toLowerCase());
|
|
9958
|
+
return collectMsgReferences(value).filter((name)=>!lower.has(name.toLowerCase()));
|
|
9959
|
+
}
|
|
9711
9960
|
function pushCompilationError(compiler, compilation, name, message, file) {
|
|
9712
9961
|
const ErrorConstructor = compiler?.rspack?.WebpackError || Error;
|
|
9713
9962
|
const error = new ErrorConstructor(message);
|
|
@@ -9767,26 +10016,11 @@ function validateLocales(compiler, compilation, manifestPath) {
|
|
|
9767
10016
|
}
|
|
9768
10017
|
try {
|
|
9769
10018
|
const dict = defaultLocaleMessages;
|
|
9770
|
-
const
|
|
9771
|
-
if ('string' == typeof value) {
|
|
9772
|
-
const regex = /__MSG_([A-Za-z0-9_@]+?)__/g;
|
|
9773
|
-
let matches;
|
|
9774
|
-
while(null !== (matches = regex.exec(value))){
|
|
9775
|
-
const key = matches[1];
|
|
9776
|
-
if (key && !key.startsWith('@@')) acc.add(key);
|
|
9777
|
-
}
|
|
9778
|
-
} else if (Array.isArray(value)) for (const item of value)collectMsgKeys(item, acc);
|
|
9779
|
-
else if (value && 'object' == typeof value) for (const v of Object.values(value))collectMsgKeys(v, acc);
|
|
9780
|
-
};
|
|
9781
|
-
const referenced = new Set();
|
|
9782
|
-
collectMsgKeys(manifest, referenced);
|
|
10019
|
+
const referenced = findUndefinedMsgReferences(manifest, Object.keys(dict || {}).filter((key)=>'string' == typeof dict?.[key]?.message));
|
|
9783
10020
|
for (const key of referenced){
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
pushCompilationError(compiler, compilation, 'LocalesValidationError', missingManifestMessageKey(key, defaultLocale), 'manifest.json');
|
|
9788
|
-
return false;
|
|
9789
|
-
}
|
|
10021
|
+
if (isDebug()) console.log(localesValidationDetected(`missing key "${key}" in default locale`));
|
|
10022
|
+
pushCompilationError(compiler, compilation, 'LocalesValidationError', missingManifestMessageKey(key, defaultLocale), 'manifest.json');
|
|
10023
|
+
return false;
|
|
9790
10024
|
}
|
|
9791
10025
|
} catch (error) {
|
|
9792
10026
|
if (isDebug()) console.log(localesValidationDetected(`could not scan __MSG__ placeholders in _locales/${defaultLocale}/messages.json: ${String(error?.message || error)}`));
|
|
@@ -9919,6 +10153,12 @@ function manifestDepsTracked(addedCount) {
|
|
|
9919
10153
|
function manifestLegacyWarningsSummary(count) {
|
|
9920
10154
|
return `${messaging_prefix('debug')} manifest legacyWarnings=${String(count)}`;
|
|
9921
10155
|
}
|
|
10156
|
+
function pageActionNotSupportedByBrowser(browser) {
|
|
10157
|
+
return `${messaging_prefix('warn')} ${pintor.blue(browser)} does not show the ${pintor.yellow('page_action')} address bar surface.\nThe field was dropped from the built manifest and its page was not emitted.`;
|
|
10158
|
+
}
|
|
10159
|
+
function pageActionDroppedForBrowserAction(browser) {
|
|
10160
|
+
return `${messaging_prefix('warn')} ${pintor.blue(browser)} refuses a Manifest V2 manifest that declares both ${pintor.yellow('browser_action')} and ${pintor.yellow('page_action')}.\nThe build kept ${pintor.yellow('browser_action')} and dropped ${pintor.yellow('page_action')} from the built manifest, so its page was not emitted. Remove one of the two keys, or scope page_action with the firefox: prefix.`;
|
|
10161
|
+
}
|
|
9922
10162
|
class AddDependencies {
|
|
9923
10163
|
dependencyList;
|
|
9924
10164
|
constructor(dependencyList){
|
|
@@ -10025,7 +10265,18 @@ function loosenConnectSrcForDev(csp) {
|
|
|
10025
10265
|
...devSources
|
|
10026
10266
|
]);
|
|
10027
10267
|
}
|
|
10268
|
+
function keepSiblingSlots(policy, extensionPages) {
|
|
10269
|
+
if (policy && 'object' == typeof policy && !Array.isArray(policy)) return {
|
|
10270
|
+
...policy,
|
|
10271
|
+
extension_pages: extensionPages
|
|
10272
|
+
};
|
|
10273
|
+
return extensionPages;
|
|
10274
|
+
}
|
|
10028
10275
|
function patchV2CSP(manifest) {
|
|
10276
|
+
const authored = manifest.content_security_policy;
|
|
10277
|
+
return keepSiblingSlots(authored, patchV2PagesPolicy(manifest));
|
|
10278
|
+
}
|
|
10279
|
+
function patchV2PagesPolicy(manifest) {
|
|
10029
10280
|
const policy = resolveV2Policy(manifest.content_security_policy);
|
|
10030
10281
|
if (!policy) return buildCSP({
|
|
10031
10282
|
"script-src": [
|
|
@@ -10079,7 +10330,8 @@ function patchV3CSP(manifest) {
|
|
|
10079
10330
|
]
|
|
10080
10331
|
})
|
|
10081
10332
|
};
|
|
10082
|
-
const
|
|
10333
|
+
const extensionPages = 'string' == typeof policy ? policy : policy.extension_pages;
|
|
10334
|
+
const csp = content_security_policy_parser('string' == typeof extensionPages ? extensionPages : '');
|
|
10083
10335
|
const defaultDirectives = {
|
|
10084
10336
|
"script-src": [
|
|
10085
10337
|
"'self'"
|
|
@@ -10092,9 +10344,7 @@ function patchV3CSP(manifest) {
|
|
|
10092
10344
|
loosenConnectSrcForDev(csp);
|
|
10093
10345
|
const cspObject = Object.fromEntries(csp.entries());
|
|
10094
10346
|
const extensionPagesPolicy = buildCSP(cspObject);
|
|
10095
|
-
return
|
|
10096
|
-
extension_pages: extensionPagesPolicy
|
|
10097
|
-
};
|
|
10347
|
+
return keepSiblingSlots(policy, extensionPagesPolicy);
|
|
10098
10348
|
}
|
|
10099
10349
|
function patchExternallyConnectable(manifest) {
|
|
10100
10350
|
if (manifest.externally_connectable && !manifest.externally_connectable.ids) return {
|
|
@@ -10211,13 +10461,16 @@ function findInjectedOnlyPermissionUses(compilation, declared, injected) {
|
|
|
10211
10461
|
class ApplyDevDefaults {
|
|
10212
10462
|
manifestPath;
|
|
10213
10463
|
browser;
|
|
10464
|
+
devSession;
|
|
10214
10465
|
constructor(options){
|
|
10215
10466
|
this.manifestPath = options.manifestPath;
|
|
10216
10467
|
this.browser = options.browser || 'chrome';
|
|
10468
|
+
this.devSession = options.devSession;
|
|
10217
10469
|
}
|
|
10218
10470
|
apply(compiler) {
|
|
10219
10471
|
if (!compiler?.hooks?.thisCompilation) return;
|
|
10220
10472
|
if ('development' !== compiler.options.mode) return;
|
|
10473
|
+
if (false === this.devSession) return;
|
|
10221
10474
|
compiler.hooks.thisCompilation.tap('manifest:apply-dev-defaults', (compilation)=>{
|
|
10222
10475
|
if (!compilation?.hooks?.processAssets) return;
|
|
10223
10476
|
compilation.hooks.processAssets.tap({
|
|
@@ -10243,6 +10496,31 @@ class ApplyDevDefaults {
|
|
|
10243
10496
|
])
|
|
10244
10497
|
]
|
|
10245
10498
|
} : {};
|
|
10499
|
+
const pushDevWarning = (name, text)=>{
|
|
10500
|
+
const WebpackErrorCtor = compiler.rspack?.WebpackError;
|
|
10501
|
+
const warning = WebpackErrorCtor ? new WebpackErrorCtor(text) : new Error(text);
|
|
10502
|
+
warning.name = name;
|
|
10503
|
+
if (!compilation.warnings) compilation.warnings = [];
|
|
10504
|
+
compilation.warnings.push(warning);
|
|
10505
|
+
};
|
|
10506
|
+
const optionalPermissions = new Set(canonicalManifest.optional_permissions || []);
|
|
10507
|
+
const optionalHosts = new Set([
|
|
10508
|
+
...canonicalManifest.optional_host_permissions || [],
|
|
10509
|
+
...3 === canonicalManifest.manifest_version ? [] : [
|
|
10510
|
+
...optionalPermissions
|
|
10511
|
+
]
|
|
10512
|
+
]);
|
|
10513
|
+
const devInjectedPermissions = 3 === canonicalManifest.manifest_version ? [
|
|
10514
|
+
"scripting",
|
|
10515
|
+
'tabs',
|
|
10516
|
+
'management',
|
|
10517
|
+
'storage'
|
|
10518
|
+
] : [
|
|
10519
|
+
'tabs',
|
|
10520
|
+
'storage'
|
|
10521
|
+
];
|
|
10522
|
+
for (const permission of devInjectedPermissions)if (optionalPermissions.has(permission) && !(canonicalManifest.permissions || []).includes(permission)) pushDevWarning('DevPromotedOptionalPermissionWarning', `manifest.json lists "${permission}" under optional_permissions, but the dev build needs it and lists it under permissions too. Listed in both means required, so in development it is granted at install and your runtime request flow never runs. The production build keeps it optional.`);
|
|
10523
|
+
for (const match of contentScriptMatches)if (optionalHosts.has(match)) pushDevWarning('DevPromotedOptionalHostWarning', `manifest.json keeps "${match}" optional, but a content script matches it and the dev build grants that host at install so it can re-inject the script on save. In development the host is required; the production build keeps it optional.`);
|
|
10246
10524
|
const patchedManifest = {
|
|
10247
10525
|
...canonicalManifest,
|
|
10248
10526
|
content_security_policy: 3 === canonicalManifest.manifest_version ? patchV3CSP(canonicalManifest) : patchV2CSP(canonicalManifest),
|
|
@@ -10272,20 +10550,15 @@ class ApplyDevDefaults {
|
|
|
10272
10550
|
web_accessible_resources: 3 === canonicalManifest.manifest_version ? patchWebResourcesV3(canonicalManifest) : patchWebResourcesV2(canonicalManifest)
|
|
10273
10551
|
};
|
|
10274
10552
|
try {
|
|
10275
|
-
const declared = new Set([
|
|
10276
|
-
...canonicalManifest.permissions || [],
|
|
10277
|
-
...canonicalManifest.optional_permissions || []
|
|
10278
|
-
]);
|
|
10553
|
+
const declared = new Set(canonicalManifest.permissions || []);
|
|
10279
10554
|
const injectedForEra = 3 === canonicalManifest.manifest_version ? INJECTED_PERMISSION_APIS : [
|
|
10280
10555
|
'storage'
|
|
10281
10556
|
];
|
|
10282
10557
|
const uses = findInjectedOnlyPermissionUses(compilation, declared, injectedForEra);
|
|
10283
10558
|
for (const [api, file] of uses){
|
|
10284
|
-
const
|
|
10285
|
-
const text = `manifest.json
|
|
10286
|
-
|
|
10287
|
-
warning.name = 'DevInjectedPermissionWarning';
|
|
10288
|
-
compilation.warnings.push(warning);
|
|
10559
|
+
const relative = __rspack_external_path.relative(__rspack_external_path.dirname(this.manifestPath), file);
|
|
10560
|
+
const text = optionalPermissions.has(api) ? `manifest.json only lists the "${api}" permission under optional_permissions, but ${relative} uses chrome.${api}. It works in development only because the dev instrumentation injects "${api}" as required: the production build has it only after a runtime chrome.permissions.request, so guard the use or move "${api}" to permissions.` : `manifest.json does not declare the "${api}" permission, but ${relative} uses chrome.${api}. It works in development only because the dev instrumentation injects "${api}": the production build will fail at runtime. Add "${api}" to permissions in manifest.json.`;
|
|
10561
|
+
pushDevWarning('DevInjectedPermissionWarning', text);
|
|
10289
10562
|
}
|
|
10290
10563
|
} catch {}
|
|
10291
10564
|
const source = JSON.stringify(patchedManifest, null, 2);
|
|
@@ -10448,8 +10721,8 @@ function collectReferencedRuntimePayloads(source, emittedAssetNames) {
|
|
|
10448
10721
|
const found = new Set();
|
|
10449
10722
|
const patternHits = source.match(EMITTED_ASSET_REF_PATTERN) || [];
|
|
10450
10723
|
for (const hit of patternHits)if (!isExcludedFromWar(hit)) found.add(hit);
|
|
10451
|
-
const eligible = emittedAssetNames.filter((name)=>!isExcludedFromWar(name)).sort((a, b)=>b.length - a.length);
|
|
10452
|
-
for (const asset of eligible)if (source.includes(asset)) found.add(
|
|
10724
|
+
const eligible = emittedAssetNames.map((name)=>unixify(name)).filter((name)=>!isExcludedFromWar(name)).sort((a, b)=>b.length - a.length);
|
|
10725
|
+
for (const asset of eligible)if (source.includes(asset)) found.add(asset);
|
|
10453
10726
|
return Array.from(found);
|
|
10454
10727
|
}
|
|
10455
10728
|
function forEachStringKey(objectOrMap, callback) {
|
|
@@ -10474,6 +10747,33 @@ function getAssetSource(compilation, filename) {
|
|
|
10474
10747
|
if ('string' == typeof src) return src;
|
|
10475
10748
|
return '';
|
|
10476
10749
|
}
|
|
10750
|
+
function collectContentScriptAsyncChunkFiles(compilation) {
|
|
10751
|
+
const result = {};
|
|
10752
|
+
if ('function' != typeof compilation.entrypoints?.forEach) return result;
|
|
10753
|
+
compilation.entrypoints.forEach((entry, entryName)=>{
|
|
10754
|
+
if (!String(entryName).startsWith("content_scripts/")) return;
|
|
10755
|
+
const initial = new Set();
|
|
10756
|
+
for (const chunk of toFileArray(entry.chunks))for (const file of toFileArray(chunk.files))initial.add(file);
|
|
10757
|
+
const asyncFiles = new Set();
|
|
10758
|
+
const visitChunk = (chunk)=>{
|
|
10759
|
+
for (const file of toFileArray(chunk.files))if (!(!file.endsWith('.js') || initial.has(file))) asyncFiles.add(unixify(file));
|
|
10760
|
+
};
|
|
10761
|
+
for (const chunk of toFileArray(entry.chunks)){
|
|
10762
|
+
const withAsync = chunk;
|
|
10763
|
+
if ('function' == typeof withAsync.getAllAsyncChunks) for (const asyncChunk of withAsync.getAllAsyncChunks())visitChunk(asyncChunk);
|
|
10764
|
+
}
|
|
10765
|
+
const seenGroups = new Set();
|
|
10766
|
+
const visitGroup = (group)=>{
|
|
10767
|
+
if (seenGroups.has(group)) return;
|
|
10768
|
+
seenGroups.add(group);
|
|
10769
|
+
for (const chunk of toFileArray(group.chunks))visitChunk(chunk);
|
|
10770
|
+
if ('function' == typeof group.getChildren) for (const child of group.getChildren())visitGroup(child);
|
|
10771
|
+
};
|
|
10772
|
+
if ('function' == typeof entry.getChildren) for (const child of entry.getChildren?.() || [])visitGroup(child);
|
|
10773
|
+
if (asyncFiles.size > 0) result[entryName] = Array.from(asyncFiles).sort();
|
|
10774
|
+
});
|
|
10775
|
+
return result;
|
|
10776
|
+
}
|
|
10477
10777
|
function collectContentScriptEntryImports(compilation, includeList) {
|
|
10478
10778
|
const entryImports = {};
|
|
10479
10779
|
const contentEntryNames = new Set(Object.keys(includeList || {}).filter((k)=>k.startsWith("content_scripts")));
|
|
@@ -10970,6 +11270,14 @@ function generateManifestPatches(compilation, manifestPath, entryImports, browse
|
|
|
10970
11270
|
});
|
|
10971
11271
|
}
|
|
10972
11272
|
}
|
|
11273
|
+
const asyncChunks = collectContentScriptAsyncChunkFiles(compilation);
|
|
11274
|
+
for (const [entryName, chunkFiles] of Object.entries(asyncChunks)){
|
|
11275
|
+
const contentScript = canonicalManifest.content_scripts?.find((script)=>script.js?.some((jsFile)=>jsFile.includes(entryName)));
|
|
11276
|
+
if (contentScript) {
|
|
11277
|
+
if (3 === canonicalManifest.manifest_version) mergeIntoV3Group(webAccessibleResourcesV3, cleanMatches(contentScript.matches || []), chunkFiles);
|
|
11278
|
+
else for (const file of chunkFiles)if (!webAccessibleResourcesV2.includes(file)) webAccessibleResourcesV2.push(file);
|
|
11279
|
+
}
|
|
11280
|
+
}
|
|
10973
11281
|
if (3 === canonicalManifest.manifest_version) {
|
|
10974
11282
|
const assetKeys = Object.keys(compilation.assets || {});
|
|
10975
11283
|
const staticAssets = assetKeys.filter((k)=>k.startsWith('assets/')).filter((k)=>!k.endsWith('.js') && !k.endsWith('.map')).sort();
|
|
@@ -11090,7 +11398,7 @@ function normalizeManifestFile(filePath) {
|
|
|
11090
11398
|
if ('string' != typeof filePath) return;
|
|
11091
11399
|
const normalized = filePath.trim().replace(/^\/+/, '');
|
|
11092
11400
|
if (!normalized) return;
|
|
11093
|
-
if (
|
|
11401
|
+
if (isManifestAddress(filePath)) return;
|
|
11094
11402
|
if (/[*?[\]{}]/.test(normalized)) return;
|
|
11095
11403
|
return normalized;
|
|
11096
11404
|
}
|
|
@@ -11116,6 +11424,10 @@ function collectRequiredManifestFiles(manifest) {
|
|
|
11116
11424
|
addFile(manifestObj?.chrome_url_overrides?.newtab);
|
|
11117
11425
|
addFile(manifestObj?.chrome_url_overrides?.history);
|
|
11118
11426
|
addFile(manifestObj?.chrome_url_overrides?.bookmarks);
|
|
11427
|
+
addFile(manifestObj?.theme_experiment?.stylesheet);
|
|
11428
|
+
addFile(manifestObj?.chrome_settings_overrides?.search_provider?.favicon_url);
|
|
11429
|
+
const startupPages = manifestObj?.chrome_settings_overrides?.startup_pages;
|
|
11430
|
+
if (Array.isArray(startupPages)) for (const page of startupPages)addFile(page);
|
|
11119
11431
|
const contentScripts = manifestObj?.content_scripts;
|
|
11120
11432
|
if (Array.isArray(contentScripts)) for (const contentScript of contentScripts){
|
|
11121
11433
|
const js = contentScript?.js;
|
|
@@ -11177,6 +11489,7 @@ class PersistManifestToDisk {
|
|
|
11177
11489
|
const requiredFiles = collectRequiredManifestFiles(manifest);
|
|
11178
11490
|
const missingFiles = findMissingFilesOnDisk(outputPath, requiredFiles);
|
|
11179
11491
|
if (missingFiles.length > 0) {
|
|
11492
|
+
if (isCompilerRestarting(compiler)) return;
|
|
11180
11493
|
const sample = missingFiles.slice(0, 5).join('\n - ');
|
|
11181
11494
|
const more = missingFiles.length > 5 ? `\n ... and ${missingFiles.length - 5} more` : '';
|
|
11182
11495
|
const err = new core.WebpackError([
|
|
@@ -12350,11 +12663,14 @@ class UpdateManifest {
|
|
|
12350
12663
|
}, ()=>{
|
|
12351
12664
|
if (compilation.errors.length > 0) return;
|
|
12352
12665
|
const manifest = getManifestContent(compilation, this.manifestPath);
|
|
12353
|
-
|
|
12666
|
+
const dropReason = pageActionDropReason(filterKeysForThisBrowser(manifest, this.browser), this.browser);
|
|
12667
|
+
if (dropReason) reportToCompilation(compilation, compiler, 'conflicts' === dropReason ? pageActionDroppedForBrowserAction(String(this.browser)) : pageActionNotSupportedByBrowser(String(this.browser)), 'warning', 'manifest.json');
|
|
12668
|
+
const projectPath = compiler.options.context || __rspack_external_node_path_c5b9b54f.dirname(this.manifestPath);
|
|
12669
|
+
let patchedManifest = buildCanonicalManifest(this.manifestPath, manifest, this.browser, projectPath);
|
|
12354
12670
|
patchedManifest = patchGeckoBackground(patchedManifest, this.browser);
|
|
12355
12671
|
patchedManifest = patchChromiumBackground(patchedManifest, this.browser);
|
|
12356
12672
|
patchedManifest = patchChromiumThemeColors(patchedManifest, this.browser);
|
|
12357
|
-
const overrides = getManifestOverrides(this.manifestPath, manifest);
|
|
12673
|
+
const overrides = getManifestOverrides(this.manifestPath, manifest, projectPath);
|
|
12358
12674
|
if ('development' === compiler.options.mode) {
|
|
12359
12675
|
if (patchedManifest.content_scripts) patchedManifest.content_scripts = this.applyDevOverrides(patchedManifest);
|
|
12360
12676
|
patchedManifest = patchDevContentScriptManifestPaths(compilation, patchedManifest);
|
|
@@ -12437,10 +12753,12 @@ class ManifestPlugin {
|
|
|
12437
12753
|
manifestPath;
|
|
12438
12754
|
browser;
|
|
12439
12755
|
includeList;
|
|
12756
|
+
devSession;
|
|
12440
12757
|
constructor(options){
|
|
12441
12758
|
this.manifestPath = options.manifestPath;
|
|
12442
12759
|
this.browser = options.browser || 'chrome';
|
|
12443
12760
|
this.includeList = options.includeList;
|
|
12761
|
+
this.devSession = options.devSession;
|
|
12444
12762
|
}
|
|
12445
12763
|
apply(compiler) {
|
|
12446
12764
|
if (isDebug()) console.log(manifestIncludeSummary(String(this.browser || 'chrome'), this.manifestPath));
|
|
@@ -12462,7 +12780,8 @@ class ManifestPlugin {
|
|
|
12462
12780
|
}).apply(compiler);
|
|
12463
12781
|
new ApplyDevDefaults({
|
|
12464
12782
|
manifestPath: this.manifestPath,
|
|
12465
|
-
browser: this.browser
|
|
12783
|
+
browser: this.browser,
|
|
12784
|
+
devSession: this.devSession
|
|
12466
12785
|
}).apply(compiler);
|
|
12467
12786
|
new PersistManifestToDisk().apply(compiler);
|
|
12468
12787
|
new AddDependencies([
|
|
@@ -13059,9 +13378,7 @@ function discoverDevtoolsPanelPages(manifestPath) {
|
|
|
13059
13378
|
}
|
|
13060
13379
|
return pages;
|
|
13061
13380
|
}
|
|
13062
|
-
|
|
13063
|
-
return key.startsWith('declarative_net_request') || 'storage.managed_schema' === key;
|
|
13064
|
-
}
|
|
13381
|
+
const isCriticalJsonFeatureKey = isCriticalJsonFeature;
|
|
13065
13382
|
function toComparablePath(value) {
|
|
13066
13383
|
return 'string' == typeof value ? value : JSON.stringify(value);
|
|
13067
13384
|
}
|
|
@@ -13110,7 +13427,7 @@ class ManifestFieldsChangeDetector {
|
|
|
13110
13427
|
this.browser = options.browser || 'chrome';
|
|
13111
13428
|
}
|
|
13112
13429
|
readSnapshot() {
|
|
13113
|
-
const fields =
|
|
13430
|
+
const fields = getResolvedManifestFieldsData({
|
|
13114
13431
|
manifestPath: this.manifestPath,
|
|
13115
13432
|
browser: this.browser
|
|
13116
13433
|
});
|
|
@@ -13160,6 +13477,11 @@ class ManifestFieldsChangeDetector {
|
|
|
13160
13477
|
if (htmlDiff) this.pending.html = htmlDiff;
|
|
13161
13478
|
if (iconsDiff) this.pending.icons = iconsDiff;
|
|
13162
13479
|
if (jsonDiff) this.pending.json = jsonDiff;
|
|
13480
|
+
if (this.tryAutoRestart(compiler)) {
|
|
13481
|
+
this.pending = {};
|
|
13482
|
+
done();
|
|
13483
|
+
return;
|
|
13484
|
+
}
|
|
13163
13485
|
this.prev = next;
|
|
13164
13486
|
done();
|
|
13165
13487
|
} catch {
|
|
@@ -13176,6 +13498,24 @@ class ManifestFieldsChangeDetector {
|
|
|
13176
13498
|
});
|
|
13177
13499
|
});
|
|
13178
13500
|
}
|
|
13501
|
+
tryAutoRestart(compiler) {
|
|
13502
|
+
const order = [
|
|
13503
|
+
"scripts",
|
|
13504
|
+
'html',
|
|
13505
|
+
'icons',
|
|
13506
|
+
'json'
|
|
13507
|
+
];
|
|
13508
|
+
for (const reason of order){
|
|
13509
|
+
const change = this.pending[reason];
|
|
13510
|
+
if (change) return requestDevSessionRestart(compiler, {
|
|
13511
|
+
reason,
|
|
13512
|
+
pathAfter: change.pathAfter,
|
|
13513
|
+
pathBefore: change.pathBefore,
|
|
13514
|
+
manifestField: change.manifestField
|
|
13515
|
+
});
|
|
13516
|
+
}
|
|
13517
|
+
return false;
|
|
13518
|
+
}
|
|
13179
13519
|
emitErrors(compilation) {
|
|
13180
13520
|
if (this.pending.scripts) {
|
|
13181
13521
|
const p = this.pending.scripts;
|
|
@@ -13212,23 +13552,81 @@ class ManifestFieldsChangeDetector {
|
|
|
13212
13552
|
}
|
|
13213
13553
|
}
|
|
13214
13554
|
}
|
|
13555
|
+
function readManifest(manifestPath) {
|
|
13556
|
+
try {
|
|
13557
|
+
return JSON.parse(stripBom(__rspack_external_node_fs_5ea92f0c.readFileSync(manifestPath, 'utf8')));
|
|
13558
|
+
} catch {
|
|
13559
|
+
return {};
|
|
13560
|
+
}
|
|
13561
|
+
}
|
|
13562
|
+
function isPublicSpelling(value) {
|
|
13563
|
+
return /^(?:\/public\/|(?:\.\/)?public\/)/i.test(value);
|
|
13564
|
+
}
|
|
13565
|
+
function resolveAsset(manifestDir, value) {
|
|
13566
|
+
if (isPublicSpelling(value) || value.startsWith('/')) return value;
|
|
13567
|
+
return __rspack_external_node_path_c5b9b54f.isAbsolute(value) ? value : __rspack_external_node_path_c5b9b54f.join(manifestDir, value);
|
|
13568
|
+
}
|
|
13569
|
+
function localFile(manifestDir, value) {
|
|
13570
|
+
if ('string' != typeof value || !value.trim()) return;
|
|
13571
|
+
if (isManifestAddress(value) || isPublicSpelling(value)) return;
|
|
13572
|
+
const resolved = resolveAsset(manifestDir, value);
|
|
13573
|
+
if (resolved.startsWith('/') && !__rspack_external_node_path_c5b9b54f.isAbsolute(resolved)) return;
|
|
13574
|
+
if (resolved.startsWith('/') && !__rspack_external_node_fs_5ea92f0c.existsSync(resolved) && __rspack_external_node_fs_5ea92f0c.existsSync(__rspack_external_node_path_c5b9b54f.join(manifestDir, 'public', resolved.slice(1)))) return;
|
|
13575
|
+
return resolved.startsWith('/') && !__rspack_external_node_fs_5ea92f0c.existsSync(resolved) ? __rspack_external_node_path_c5b9b54f.join(manifestDir, resolved.slice(1)) : resolved;
|
|
13576
|
+
}
|
|
13577
|
+
function themeExperimentStylesheetEntries(manifestPath) {
|
|
13578
|
+
const manifest = readManifest(manifestPath);
|
|
13579
|
+
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
13580
|
+
const file = localFile(manifestDir, manifest.theme_experiment?.stylesheet);
|
|
13581
|
+
if (!file) return {};
|
|
13582
|
+
const name = __rspack_external_node_path_c5b9b54f.basename(file).replace(/\.[^.]+$/, '');
|
|
13583
|
+
return {
|
|
13584
|
+
[`theme_experiment/${name}`]: [
|
|
13585
|
+
file
|
|
13586
|
+
]
|
|
13587
|
+
};
|
|
13588
|
+
}
|
|
13589
|
+
function settingsOverridesIconFields(manifestPath) {
|
|
13590
|
+
const manifest = readManifest(manifestPath);
|
|
13591
|
+
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
13592
|
+
const fav = manifest.chrome_settings_overrides?.search_provider?.favicon_url;
|
|
13593
|
+
if ('string' != typeof fav || !fav.trim() || isManifestAddress(fav)) return {};
|
|
13594
|
+
return {
|
|
13595
|
+
'chrome_settings_overrides/favicon_url': resolveAsset(manifestDir, fav)
|
|
13596
|
+
};
|
|
13597
|
+
}
|
|
13598
|
+
function settingsOverridesStartupPages(manifestPath) {
|
|
13599
|
+
const manifest = readManifest(manifestPath);
|
|
13600
|
+
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
13601
|
+
const pages = manifest.chrome_settings_overrides?.startup_pages;
|
|
13602
|
+
if (!Array.isArray(pages)) return {};
|
|
13603
|
+
const out = {};
|
|
13604
|
+
pages.forEach((page, index)=>{
|
|
13605
|
+
const file = localFile(manifestDir, page);
|
|
13606
|
+
if (file) out[`chrome_settings_overrides/startup-${index}`] = file;
|
|
13607
|
+
});
|
|
13608
|
+
return out;
|
|
13609
|
+
}
|
|
13215
13610
|
class plugin_web_extension_WebExtensionPlugin {
|
|
13216
13611
|
static name = 'plugin-extension';
|
|
13217
13612
|
manifestPath;
|
|
13218
13613
|
browser;
|
|
13614
|
+
devSession;
|
|
13219
13615
|
constructor(options){
|
|
13220
13616
|
this.manifestPath = options.manifestPath;
|
|
13221
13617
|
this.browser = options.browser || 'chrome';
|
|
13618
|
+
this.devSession = options.devSession;
|
|
13222
13619
|
}
|
|
13223
13620
|
apply(compiler) {
|
|
13224
13621
|
const manifestPath = this.manifestPath;
|
|
13225
|
-
const manifestFieldsData =
|
|
13622
|
+
const manifestFieldsData = getResolvedManifestFieldsData({
|
|
13226
13623
|
manifestPath,
|
|
13227
13624
|
browser: this.browser
|
|
13228
13625
|
});
|
|
13229
13626
|
const specialFoldersData = getSpecialFoldersDataForCompiler(compiler);
|
|
13230
13627
|
new ManifestPlugin({
|
|
13231
13628
|
browser: this.browser,
|
|
13629
|
+
devSession: this.devSession,
|
|
13232
13630
|
manifestPath,
|
|
13233
13631
|
includeList: {
|
|
13234
13632
|
...manifestFieldsData.html,
|
|
@@ -13238,11 +13636,13 @@ class plugin_web_extension_WebExtensionPlugin {
|
|
|
13238
13636
|
}
|
|
13239
13637
|
}).apply(compiler);
|
|
13240
13638
|
new HtmlPlugin({
|
|
13639
|
+
devSession: this.devSession,
|
|
13241
13640
|
manifestPath,
|
|
13242
13641
|
browser: this.browser,
|
|
13243
13642
|
includeList: {
|
|
13244
13643
|
...manifestFieldsData.html,
|
|
13245
13644
|
...discoverDevtoolsPanelPages(manifestPath),
|
|
13645
|
+
...settingsOverridesStartupPages(manifestPath),
|
|
13246
13646
|
...specialFoldersData.pages
|
|
13247
13647
|
}
|
|
13248
13648
|
}).apply(compiler);
|
|
@@ -13251,7 +13651,8 @@ class plugin_web_extension_WebExtensionPlugin {
|
|
|
13251
13651
|
browser: this.browser,
|
|
13252
13652
|
includeList: {
|
|
13253
13653
|
...manifestFieldsData.scripts,
|
|
13254
|
-
...specialFoldersData.scripts
|
|
13654
|
+
...specialFoldersData.scripts,
|
|
13655
|
+
...themeExperimentStylesheetEntries(manifestPath)
|
|
13255
13656
|
}
|
|
13256
13657
|
}).apply(compiler);
|
|
13257
13658
|
new LocalesPlugin({
|
|
@@ -13266,7 +13667,9 @@ class plugin_web_extension_WebExtensionPlugin {
|
|
|
13266
13667
|
manifestPath,
|
|
13267
13668
|
includeList: {
|
|
13268
13669
|
...manifestFieldsData.icons,
|
|
13269
|
-
...
|
|
13670
|
+
...themeImageFields(manifestPath),
|
|
13671
|
+
...omniboxIconFields(manifestPath),
|
|
13672
|
+
...settingsOverridesIconFields(manifestPath)
|
|
13270
13673
|
},
|
|
13271
13674
|
browser: this.browser
|
|
13272
13675
|
}).apply(compiler);
|
|
@@ -13286,6 +13689,7 @@ class plugin_web_extension_WebExtensionPlugin {
|
|
|
13286
13689
|
function webpackConfig(projectStructure, devOptions) {
|
|
13287
13690
|
const { manifestPath } = projectStructure;
|
|
13288
13691
|
const { packageJsonDir } = getDirs(projectStructure);
|
|
13692
|
+
const devSession = devOptions.metadataCommand ? 'dev' === devOptions.metadataCommand : 'development' === (devOptions.mode || 'development');
|
|
13289
13693
|
let rawManifest;
|
|
13290
13694
|
try {
|
|
13291
13695
|
rawManifest = JSON.parse(stripBom(__rspack_external_node_fs_5ea92f0c.readFileSync(manifestPath, 'utf-8')));
|
|
@@ -13297,7 +13701,8 @@ function webpackConfig(projectStructure, devOptions) {
|
|
|
13297
13701
|
const publishedExtensionOutputDir = devOptions.output.finalPath ? asAbsolute(__rspack_external_node_path_c5b9b54f.isAbsolute(devOptions.output.finalPath) ? devOptions.output.finalPath : __rspack_external_node_path_c5b9b54f.resolve(packageJsonDir, devOptions.output.finalPath)) : primaryExtensionOutputDir;
|
|
13298
13702
|
const companionUnpackedExtensionDirs = resolveCompanionExtensionDirs({
|
|
13299
13703
|
projectRoot: packageJsonDir,
|
|
13300
|
-
config: devOptions.extensions
|
|
13704
|
+
config: devOptions.extensions,
|
|
13705
|
+
browser: devOptions.browser
|
|
13301
13706
|
});
|
|
13302
13707
|
const unpackedExtensionDirsToLoad = computeExtensionsToLoad(__rspack_external_node_path_c5b9b54f.resolve(__rspack_import_meta_dirname__, '..'), devOptions.mode, devOptions.browser, primaryExtensionOutputDir, companionUnpackedExtensionDirs, manifestPath);
|
|
13303
13708
|
const debug = isDebug();
|
|
@@ -13351,11 +13756,13 @@ function webpackConfig(projectStructure, devOptions) {
|
|
|
13351
13756
|
}),
|
|
13352
13757
|
new plugin_web_extension_WebExtensionPlugin({
|
|
13353
13758
|
manifestPath,
|
|
13354
|
-
browser: devOptions.browser
|
|
13759
|
+
browser: devOptions.browser,
|
|
13760
|
+
devSession
|
|
13355
13761
|
}),
|
|
13356
13762
|
new ReloadPlugin({
|
|
13357
13763
|
manifestPath,
|
|
13358
|
-
browser: devOptions.browser
|
|
13764
|
+
browser: devOptions.browser,
|
|
13765
|
+
devSession
|
|
13359
13766
|
}),
|
|
13360
13767
|
new SetupChunkLoadingTarget({
|
|
13361
13768
|
manifestPath,
|
|
@@ -13473,7 +13880,7 @@ function webpackConfig(projectStructure, devOptions) {
|
|
|
13473
13880
|
],
|
|
13474
13881
|
context: packageJsonDir,
|
|
13475
13882
|
cache: false,
|
|
13476
|
-
devtool: 'production' === (devOptions.mode || 'development') ? false :
|
|
13883
|
+
devtool: 'production' === (devOptions.mode || 'development') ? false : 'cheap-module-source-map',
|
|
13477
13884
|
output: {
|
|
13478
13885
|
clean: devOptions.output.clean,
|
|
13479
13886
|
path: primaryExtensionOutputDir,
|
|
@@ -13547,10 +13954,7 @@ function webpackConfig(projectStructure, devOptions) {
|
|
|
13547
13954
|
'node_modules',
|
|
13548
13955
|
__rspack_external_node_path_c5b9b54f.join(process.cwd(), 'node_modules')
|
|
13549
13956
|
],
|
|
13550
|
-
roots:
|
|
13551
|
-
__rspack_external_node_path_c5b9b54f.join(packageJsonDir, 'public'),
|
|
13552
|
-
__rspack_external_node_path_c5b9b54f.dirname(manifestPath)
|
|
13553
|
-
],
|
|
13957
|
+
roots: publicResolveRoots(packageJsonDir, manifestPath),
|
|
13554
13958
|
extensionAlias: {
|
|
13555
13959
|
'.js': [
|
|
13556
13960
|
'.ts',
|
|
@@ -13646,4 +14050,4 @@ function webpackConfig(projectStructure, devOptions) {
|
|
|
13646
14050
|
}
|
|
13647
14051
|
};
|
|
13648
14052
|
}
|
|
13649
|
-
export { resolveConnectableHost, rspack_config_namespaceObject, setupCompilerLifecycleHooks, setupNoBrowserBannerOnFirstDone, webpackConfig };
|
|
14053
|
+
export { DevSessionRestartScheduler, bindDevSessionRestart, resolveConnectableHost, rspack_config_namespaceObject, setupCompilerLifecycleHooks, setupNoBrowserBannerOnFirstDone, unbindDevSessionRestart, webpackConfig };
|