extension-develop 4.1.12 → 4.1.13
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 +1096 -694
- package/dist/0~zip.mjs +1 -1
- package/dist/101.mjs +185 -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 +928 -0
- 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;
|
|
@@ -3322,6 +3189,40 @@ async function maybeUseReact(projectPath, options = {}) {
|
|
|
3322
3189
|
alias
|
|
3323
3190
|
};
|
|
3324
3191
|
}
|
|
3192
|
+
let solid_userMessageDelivered = false;
|
|
3193
|
+
function isUsingSolid(projectPath) {
|
|
3194
|
+
if (hasDependency(projectPath, 'solid-js')) {
|
|
3195
|
+
if (!solid_userMessageDelivered) {
|
|
3196
|
+
if (isDebug()) console.log(`${messaging_prefix('debug')} ${messages_isUsingIntegration('Solid')}`);
|
|
3197
|
+
solid_userMessageDelivered = true;
|
|
3198
|
+
}
|
|
3199
|
+
return true;
|
|
3200
|
+
}
|
|
3201
|
+
return false;
|
|
3202
|
+
}
|
|
3203
|
+
async function maybeUseSolid(projectPath) {
|
|
3204
|
+
if (!isUsingSolid(projectPath)) return;
|
|
3205
|
+
const requireFromProject = createRequire(__rspack_external_node_path_c5b9b54f.join(projectPath, 'package.json'));
|
|
3206
|
+
const resolveFromProject = (id)=>{
|
|
3207
|
+
try {
|
|
3208
|
+
return requireFromProject.resolve(id);
|
|
3209
|
+
} catch {
|
|
3210
|
+
return;
|
|
3211
|
+
}
|
|
3212
|
+
};
|
|
3213
|
+
const adapter = resolveDevelopDistFile('solid-jsx-runtime');
|
|
3214
|
+
const hyperscript = resolveFromProject('solid-js/h');
|
|
3215
|
+
const alias = {
|
|
3216
|
+
'solid-js/jsx-runtime$': adapter,
|
|
3217
|
+
'solid-js/jsx-dev-runtime$': adapter
|
|
3218
|
+
};
|
|
3219
|
+
if (hyperscript) alias['solid-js/h$'] = hyperscript;
|
|
3220
|
+
return {
|
|
3221
|
+
plugins: [],
|
|
3222
|
+
loaders: void 0,
|
|
3223
|
+
alias
|
|
3224
|
+
};
|
|
3225
|
+
}
|
|
3325
3226
|
let load_loader_options_userMessageDelivered = false;
|
|
3326
3227
|
function resolveLoaderConfigPath(projectPath, framework) {
|
|
3327
3228
|
const candidates = [
|
|
@@ -3351,6 +3252,106 @@ async function loadLoaderOptions(projectPath, framework) {
|
|
|
3351
3252
|
}
|
|
3352
3253
|
return null;
|
|
3353
3254
|
}
|
|
3255
|
+
let vue_userMessageDelivered = false;
|
|
3256
|
+
function isUsingVue(projectPath) {
|
|
3257
|
+
const using = hasDependency(projectPath, 'vue');
|
|
3258
|
+
if (using && !vue_userMessageDelivered) {
|
|
3259
|
+
if (isDebug()) console.log(`${messaging_prefix('debug')} ${messages_isUsingIntegration('Vue')}`);
|
|
3260
|
+
vue_userMessageDelivered = true;
|
|
3261
|
+
}
|
|
3262
|
+
return using;
|
|
3263
|
+
}
|
|
3264
|
+
async function maybeUseVue(projectPath, mode = 'development') {
|
|
3265
|
+
if (!isUsingVue(projectPath)) return;
|
|
3266
|
+
const vueLoaderPath = await ensureOptionalContractPackageResolved({
|
|
3267
|
+
contractId: 'vue',
|
|
3268
|
+
projectPath,
|
|
3269
|
+
dependencyId: 'vue-loader'
|
|
3270
|
+
});
|
|
3271
|
+
const VueLoaderPlugin = await ensureOptionalContractModuleLoaded({
|
|
3272
|
+
contractId: 'vue',
|
|
3273
|
+
projectPath,
|
|
3274
|
+
dependencyId: 'vue-loader',
|
|
3275
|
+
moduleAdapter: (mod)=>mod?.VueLoaderPlugin || mod?.default?.VueLoaderPlugin
|
|
3276
|
+
});
|
|
3277
|
+
const customOptions = await loadLoaderOptions(projectPath, 'vue');
|
|
3278
|
+
const defaultLoaders = [
|
|
3279
|
+
{
|
|
3280
|
+
test: /\.vue$/,
|
|
3281
|
+
loader: vueLoaderPath,
|
|
3282
|
+
options: {
|
|
3283
|
+
experimentalInlineMatchResource: true,
|
|
3284
|
+
...customOptions || {}
|
|
3285
|
+
},
|
|
3286
|
+
include: projectPath,
|
|
3287
|
+
exclude: /node_modules/
|
|
3288
|
+
}
|
|
3289
|
+
];
|
|
3290
|
+
const isProd = 'production' === mode;
|
|
3291
|
+
const defaultPlugins = [
|
|
3292
|
+
new VueLoaderPlugin(),
|
|
3293
|
+
new DefinePlugin({
|
|
3294
|
+
__VUE_OPTIONS_API__: JSON.stringify(!isProd),
|
|
3295
|
+
__VUE_PROD_DEVTOOLS__: JSON.stringify(!isProd),
|
|
3296
|
+
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: JSON.stringify(!isProd)
|
|
3297
|
+
})
|
|
3298
|
+
];
|
|
3299
|
+
const requireFromProject = createRequire(__rspack_external_node_path_c5b9b54f.join(projectPath, 'package.json'));
|
|
3300
|
+
const resolveFromProject = (id)=>{
|
|
3301
|
+
try {
|
|
3302
|
+
return requireFromProject.resolve(id);
|
|
3303
|
+
} catch {
|
|
3304
|
+
return;
|
|
3305
|
+
}
|
|
3306
|
+
};
|
|
3307
|
+
const alias = {};
|
|
3308
|
+
const vuePath = resolveFromProject('vue');
|
|
3309
|
+
const vueRuntimeDom = resolveFromProject('@vue/runtime-dom');
|
|
3310
|
+
const vueRuntimeCore = resolveFromProject('@vue/runtime-core');
|
|
3311
|
+
const vueShared = resolveFromProject('@vue/shared');
|
|
3312
|
+
if (vuePath) alias.vue$ = vuePath;
|
|
3313
|
+
if (vueRuntimeDom) alias['@vue/runtime-dom'] = vueRuntimeDom;
|
|
3314
|
+
if (vueRuntimeCore) alias['@vue/runtime-core'] = vueRuntimeCore;
|
|
3315
|
+
if (vueShared) alias['@vue/shared'] = vueShared;
|
|
3316
|
+
return {
|
|
3317
|
+
plugins: defaultPlugins,
|
|
3318
|
+
loaders: defaultLoaders,
|
|
3319
|
+
alias
|
|
3320
|
+
};
|
|
3321
|
+
}
|
|
3322
|
+
function isUsingJsxFramework(projectPath) {
|
|
3323
|
+
return isUsingReact(projectPath) || isUsingPreact(projectPath) || isUsingSolid(projectPath) || isUsingVue(projectPath);
|
|
3324
|
+
}
|
|
3325
|
+
function getJsxImportSource(projectPath) {
|
|
3326
|
+
if (isUsingSolid(projectPath)) return 'solid-js';
|
|
3327
|
+
if (isUsingPreact(projectPath) && !isUsingReact(projectPath)) return 'preact';
|
|
3328
|
+
if (isUsingVue(projectPath) && !isUsingReact(projectPath) && !isUsingPreact(projectPath)) return 'vue';
|
|
3329
|
+
return 'react';
|
|
3330
|
+
}
|
|
3331
|
+
function swcParserForFile(resourcePath, jsxInPlainJs) {
|
|
3332
|
+
const clean = String(resourcePath || '').split('?')[0];
|
|
3333
|
+
const ext = __rspack_external_node_path_c5b9b54f.extname(clean).toLowerCase();
|
|
3334
|
+
if ('.tsx' === ext || '.mtsx' === ext) return {
|
|
3335
|
+
syntax: "typescript",
|
|
3336
|
+
tsx: true,
|
|
3337
|
+
dynamicImport: true
|
|
3338
|
+
};
|
|
3339
|
+
if ('.ts' === ext || '.mts' === ext || '.cts' === ext) return {
|
|
3340
|
+
syntax: "typescript",
|
|
3341
|
+
tsx: false,
|
|
3342
|
+
dynamicImport: true
|
|
3343
|
+
};
|
|
3344
|
+
if ('.jsx' === ext || '.mjsx' === ext) return {
|
|
3345
|
+
syntax: "ecmascript",
|
|
3346
|
+
jsx: true,
|
|
3347
|
+
dynamicImport: true
|
|
3348
|
+
};
|
|
3349
|
+
return {
|
|
3350
|
+
syntax: "ecmascript",
|
|
3351
|
+
jsx: jsxInPlainJs,
|
|
3352
|
+
dynamicImport: true
|
|
3353
|
+
};
|
|
3354
|
+
}
|
|
3354
3355
|
let svelte_userMessageDelivered = false;
|
|
3355
3356
|
function svelte_resolveFromProject(id, projectPath) {
|
|
3356
3357
|
for (const base of [
|
|
@@ -3457,72 +3458,30 @@ async function maybeUseSvelte(projectPath, mode) {
|
|
|
3457
3458
|
alias: Object.keys(alias).length > 0 ? alias : void 0
|
|
3458
3459
|
};
|
|
3459
3460
|
}
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3461
|
+
const DEFAULT_SWC_TARGETS = [
|
|
3462
|
+
'chrome >= 100'
|
|
3463
|
+
];
|
|
3464
|
+
function resolveSwcTargets(rawManifest, browser) {
|
|
3465
|
+
if (!rawManifest || 'object' != typeof rawManifest) return [
|
|
3466
|
+
...DEFAULT_SWC_TARGETS
|
|
3467
|
+
];
|
|
3468
|
+
const name = String(browser || 'chrome');
|
|
3469
|
+
const manifest = filterKeysForThisBrowser(rawManifest, name);
|
|
3470
|
+
if (isGeckoBasedBrowser(name)) {
|
|
3471
|
+
const geckoMin = manifest.browser_specific_settings?.gecko?.strict_min_version || manifest.applications?.gecko?.strict_min_version;
|
|
3472
|
+
const major = parseInt(String(geckoMin ?? '').split('.')[0], 10);
|
|
3473
|
+
return Number.isNaN(major) ? [
|
|
3474
|
+
...DEFAULT_SWC_TARGETS
|
|
3475
|
+
] : [
|
|
3476
|
+
`firefox >= ${major}`
|
|
3477
|
+
];
|
|
3466
3478
|
}
|
|
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
|
-
}
|
|
3479
|
+
if (isChromiumBasedBrowser(name) && manifest.minimum_chrome_version) return [
|
|
3480
|
+
`chrome >= ${manifest.minimum_chrome_version}`
|
|
3494
3481
|
];
|
|
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
|
-
})
|
|
3482
|
+
return [
|
|
3483
|
+
...DEFAULT_SWC_TARGETS
|
|
3503
3484
|
];
|
|
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
3485
|
}
|
|
3527
3486
|
class JsFrameworksPlugin {
|
|
3528
3487
|
static name = 'plugin-js-frameworks';
|
|
@@ -3598,7 +3557,7 @@ class JsFrameworksPlugin {
|
|
|
3598
3557
|
loader: rule.loader
|
|
3599
3558
|
}
|
|
3600
3559
|
] : [];
|
|
3601
|
-
const hasReactRefreshLoader = uses.some((useEntry)=>String(useEntry?.loader || '').includes('react-refresh-loader'));
|
|
3560
|
+
const hasReactRefreshLoader = uses.some((useEntry)=>'object' == typeof useEntry && String(useEntry?.loader || '').includes('react-refresh-loader'));
|
|
3602
3561
|
if (hasReactRefreshLoader) rule.issuerLayer = {
|
|
3603
3562
|
not: EXTENSIONJS_CONTENT_SCRIPT_LAYER
|
|
3604
3563
|
};
|
|
@@ -3661,7 +3620,7 @@ class JsFrameworksPlugin {
|
|
|
3661
3620
|
const background = browserManifest?.background;
|
|
3662
3621
|
if (background?.type === 'module' && 'string' == typeof background?.service_worker) addBothPathForms(platformModulePaths, __rspack_external_node_path_c5b9b54f.resolve(manifestDir, background.service_worker));
|
|
3663
3622
|
const htmlPages = {
|
|
3664
|
-
...
|
|
3623
|
+
...getResolvedManifestFieldsData({
|
|
3665
3624
|
manifestPath: this.manifestPath,
|
|
3666
3625
|
browser: this.browser
|
|
3667
3626
|
}).html,
|
|
@@ -3675,26 +3634,18 @@ class JsFrameworksPlugin {
|
|
|
3675
3634
|
});
|
|
3676
3635
|
const maybeInstallPreact = await maybeUsePreact(projectPath);
|
|
3677
3636
|
const maybeInstallVue = await maybeUseVue(projectPath, mode);
|
|
3637
|
+
const maybeInstallSolid = await maybeUseSolid(projectPath);
|
|
3678
3638
|
const maybeInstallSvelte = await maybeUseSvelte(projectPath, mode);
|
|
3679
3639
|
const tsConfigPath = getUserTypeScriptConfigFile(projectPath);
|
|
3680
3640
|
const tsRoot = tsConfigPath ? __rspack_external_node_path_c5b9b54f.dirname(tsConfigPath) : manifestDir;
|
|
3681
3641
|
const transpilePackageDirs = swcIncludeDirs.filter((dir)=>dir !== projectPath && dir !== manifestDir);
|
|
3682
3642
|
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
|
-
}
|
|
3643
|
+
const targets = resolveSwcTargets(manifest, this.browser);
|
|
3694
3644
|
compiler.options.resolve.alias = {
|
|
3695
3645
|
...maybeInstallReact?.alias || {},
|
|
3696
3646
|
...maybeInstallPreact?.alias || {},
|
|
3697
3647
|
...maybeInstallVue?.alias || {},
|
|
3648
|
+
...maybeInstallSolid?.alias || {},
|
|
3698
3649
|
...maybeInstallSvelte?.alias || {},
|
|
3699
3650
|
...compiler.options.resolve.alias
|
|
3700
3651
|
};
|
|
@@ -3726,42 +3677,52 @@ class JsFrameworksPlugin {
|
|
|
3726
3677
|
}
|
|
3727
3678
|
]
|
|
3728
3679
|
};
|
|
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
|
|
3680
|
+
const jsxInPlainJs = isUsingJsxFramework(projectPath);
|
|
3681
|
+
const jsxImportSource = getJsxImportSource(projectPath);
|
|
3682
|
+
const isPlatformModule = (resourcePath)=>platformModulePaths.has(toResourceKey(resourcePath));
|
|
3683
|
+
const swcLoaderFor = (resourcePath, options)=>({
|
|
3684
|
+
loader: 'builtin:swc-loader',
|
|
3685
|
+
options: {
|
|
3686
|
+
sync: true,
|
|
3687
|
+
module: {
|
|
3688
|
+
type: 'es6'
|
|
3689
|
+
},
|
|
3690
|
+
minify: false,
|
|
3691
|
+
isModule: options.module ? true : 'unknown',
|
|
3692
|
+
sourceMap: wantsSourceMaps,
|
|
3693
|
+
env: {
|
|
3694
|
+
targets
|
|
3748
3695
|
},
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
useBuiltins: false
|
|
3759
|
-
} : {}
|
|
3696
|
+
jsc: {
|
|
3697
|
+
parser: swcParserForFile(resourcePath, jsxInPlainJs),
|
|
3698
|
+
transform: {
|
|
3699
|
+
react: {
|
|
3700
|
+
development: 'development' === mode,
|
|
3701
|
+
runtime: 'automatic',
|
|
3702
|
+
importSource: jsxImportSource,
|
|
3703
|
+
refresh: options.refresh
|
|
3704
|
+
}
|
|
3760
3705
|
}
|
|
3761
3706
|
}
|
|
3762
3707
|
}
|
|
3763
|
-
}
|
|
3764
|
-
|
|
3708
|
+
});
|
|
3709
|
+
const parserVariants = (options)=>[
|
|
3710
|
+
{
|
|
3711
|
+
test: /\.(tsx|mtsx)$/,
|
|
3712
|
+
use: swcLoaderFor('file.tsx', options)
|
|
3713
|
+
},
|
|
3714
|
+
{
|
|
3715
|
+
test: /\.(ts|mts|cts)$/,
|
|
3716
|
+
use: swcLoaderFor('file.ts', options)
|
|
3717
|
+
},
|
|
3718
|
+
{
|
|
3719
|
+
test: /\.(jsx|mjsx)$/,
|
|
3720
|
+
use: swcLoaderFor('file.jsx', options)
|
|
3721
|
+
},
|
|
3722
|
+
{
|
|
3723
|
+
use: swcLoaderFor('file.js', options)
|
|
3724
|
+
}
|
|
3725
|
+
];
|
|
3765
3726
|
const swcRules = [
|
|
3766
3727
|
{
|
|
3767
3728
|
...swcRuleBase,
|
|
@@ -3770,43 +3731,19 @@ class JsFrameworksPlugin {
|
|
|
3770
3731
|
tsRoot,
|
|
3771
3732
|
...swcIncludeDirs
|
|
3772
3733
|
]))).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
|
-
}
|
|
3734
|
+
oneOf: parserVariants({
|
|
3735
|
+
refresh: false,
|
|
3736
|
+
module: false
|
|
3737
|
+
})
|
|
3789
3738
|
},
|
|
3790
3739
|
{
|
|
3791
3740
|
...swcRuleBase,
|
|
3792
3741
|
issuerLayer: EXTENSIONJS_CONTENT_SCRIPT_LAYER,
|
|
3793
3742
|
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
|
-
}
|
|
3743
|
+
oneOf: parserVariants({
|
|
3744
|
+
refresh: false,
|
|
3745
|
+
module: false
|
|
3746
|
+
})
|
|
3810
3747
|
},
|
|
3811
3748
|
{
|
|
3812
3749
|
...swcRuleBase,
|
|
@@ -3818,36 +3755,32 @@ class JsFrameworksPlugin {
|
|
|
3818
3755
|
},
|
|
3819
3756
|
exclude: [
|
|
3820
3757
|
...swcRuleBase.exclude,
|
|
3821
|
-
(resourcePath)=>isfeatureScriptsContentLike(resourcePath)
|
|
3758
|
+
(resourcePath)=>isfeatureScriptsContentLike(resourcePath),
|
|
3759
|
+
(resourcePath)=>isPlatformModule(resourcePath)
|
|
3822
3760
|
],
|
|
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
|
-
}
|
|
3761
|
+
oneOf: parserVariants({
|
|
3762
|
+
refresh: 'development' === mode,
|
|
3763
|
+
module: false
|
|
3764
|
+
})
|
|
3839
3765
|
},
|
|
3840
3766
|
...platformModulePaths.size > 0 ? [
|
|
3841
3767
|
{
|
|
3842
3768
|
test: swcRuleBase.test,
|
|
3843
|
-
|
|
3769
|
+
issuerLayer: {
|
|
3770
|
+
not: EXTENSIONJS_CONTENT_SCRIPT_LAYER
|
|
3771
|
+
},
|
|
3772
|
+
include: (resourcePath)=>isPlatformModule(resourcePath),
|
|
3844
3773
|
exclude: [
|
|
3845
3774
|
(resourcePath)=>isfeatureScriptsContentLike(resourcePath)
|
|
3846
3775
|
],
|
|
3847
3776
|
resourceQuery: {
|
|
3848
3777
|
not: /__extensionjs_classic_concat__/
|
|
3849
3778
|
},
|
|
3850
|
-
type: "javascript/esm"
|
|
3779
|
+
type: "javascript/esm",
|
|
3780
|
+
oneOf: parserVariants({
|
|
3781
|
+
refresh: 'development' === mode,
|
|
3782
|
+
module: true
|
|
3783
|
+
})
|
|
3851
3784
|
}
|
|
3852
3785
|
] : []
|
|
3853
3786
|
];
|
|
@@ -3880,6 +3813,7 @@ class JsFrameworksPlugin {
|
|
|
3880
3813
|
if (maybeInstallReact) integrations.push('React');
|
|
3881
3814
|
if (maybeInstallPreact) integrations.push('Preact');
|
|
3882
3815
|
if (maybeInstallVue) integrations.push('Vue');
|
|
3816
|
+
if (maybeInstallSolid) integrations.push('Solid');
|
|
3883
3817
|
if (maybeInstallSvelte) integrations.push('Svelte');
|
|
3884
3818
|
if (preferTypeScript) integrations.push('TypeScript');
|
|
3885
3819
|
console.log(jsFrameworksIntegrationsEnabled(integrations));
|
|
@@ -3894,6 +3828,7 @@ class JsFrameworksPlugin {
|
|
|
3894
3828
|
const mode = compiler.options.mode || 'development';
|
|
3895
3829
|
if ('production' === mode) return void compiler.hooks.beforeRun.tapPromise(JsFrameworksPlugin.name, ()=>this.configureOptions(compiler));
|
|
3896
3830
|
const configuring = this.configureOptions(compiler);
|
|
3831
|
+
compiler.hooks.beforeRun.tapPromise(JsFrameworksPlugin.name, ()=>configuring);
|
|
3897
3832
|
compiler.hooks.watchRun.tapPromise(JsFrameworksPlugin.name, ()=>configuring);
|
|
3898
3833
|
await configuring;
|
|
3899
3834
|
}
|
|
@@ -4786,6 +4721,22 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
4786
4721
|
}
|
|
4787
4722
|
}
|
|
4788
4723
|
|
|
4724
|
+
// The scripts-replay shim (plugin-reload) keeps the SW's own
|
|
4725
|
+
// executeScript registry; the replay is fire-and-forget by design.
|
|
4726
|
+
function replayProgrammaticScripts(changedScriptFiles) {
|
|
4727
|
+
if (!Array.isArray(changedScriptFiles) || changedScriptFiles.length === 0) return;
|
|
4728
|
+
var replay = g.__extjsScriptsReplay;
|
|
4729
|
+
if (typeof replay !== "function") return;
|
|
4730
|
+
try {
|
|
4731
|
+
var outcome = replay(changedScriptFiles);
|
|
4732
|
+
if (outcome && typeof outcome.then === "function") {
|
|
4733
|
+
outcome.then(null, function () {});
|
|
4734
|
+
}
|
|
4735
|
+
} catch (e) {
|
|
4736
|
+
// Ignore
|
|
4737
|
+
}
|
|
4738
|
+
}
|
|
4739
|
+
|
|
4789
4740
|
function handleDevReloadFrame(frame) {
|
|
4790
4741
|
var kind = frame.reloadType || "full";
|
|
4791
4742
|
var label = typeof frame.label === "string" ? frame.label : "";
|
|
@@ -4798,6 +4749,10 @@ const BRIDGE_PRODUCER_SOURCE = `;(function () {
|
|
|
4798
4749
|
|
|
4799
4750
|
notifyDevtoolsCompanion("reloading", label, kind);
|
|
4800
4751
|
|
|
4752
|
+
// A scripts/ bundle edit: re-run the executeScript calls that named it
|
|
4753
|
+
// on their recorded tabs, before any reload decision below.
|
|
4754
|
+
replayProgrammaticScripts(frame.changedScriptFiles);
|
|
4755
|
+
|
|
4801
4756
|
if (kind === "page") {
|
|
4802
4757
|
// Notify-only: rspack-dev-server's livereload refreshes the open
|
|
4803
4758
|
// surface; reloading the extension here would race it.
|
|
@@ -5333,6 +5288,21 @@ function buildBridgeProducerSource(opts) {
|
|
|
5333
5288
|
if (!opts.controlPort || opts.controlPort < 1) return '';
|
|
5334
5289
|
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
5290
|
}
|
|
5291
|
+
function prependToEmittedAsset(compilation, asset, prefix) {
|
|
5292
|
+
const assetName = asset.name;
|
|
5293
|
+
const original = asset.source.source().toString();
|
|
5294
|
+
compilation.updateAsset(assetName, new core_sources.RawSource(`${prefix}${original}`));
|
|
5295
|
+
const mapAsset = 'function' == typeof compilation.getAsset ? compilation.getAsset(`${assetName}.map`) : void 0;
|
|
5296
|
+
if (!mapAsset) return;
|
|
5297
|
+
const prefixLines = prefix.split('\n').length - 1;
|
|
5298
|
+
if (prefixLines <= 0) return;
|
|
5299
|
+
try {
|
|
5300
|
+
const map = JSON.parse(mapAsset.source.source().toString());
|
|
5301
|
+
if ('string' != typeof map.mappings) return;
|
|
5302
|
+
map.mappings = `${';'.repeat(prefixLines)}${map.mappings}`;
|
|
5303
|
+
compilation.updateAsset(`${assetName}.map`, new core_sources.RawSource(JSON.stringify(map)));
|
|
5304
|
+
} catch {}
|
|
5305
|
+
}
|
|
5336
5306
|
const BACKGROUND_ASSET = /(^|\/)background\/(?:service_worker|scripts?)\.js$/i;
|
|
5337
5307
|
class InjectBridgeProducer {
|
|
5338
5308
|
apply(compiler) {
|
|
@@ -5358,9 +5328,7 @@ class InjectBridgeProducer {
|
|
|
5358
5328
|
for (const asset of compilation.getAssets()){
|
|
5359
5329
|
if (!BACKGROUND_ASSET.test(asset.name)) continue;
|
|
5360
5330
|
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));
|
|
5331
|
+
if (-1 === original.indexOf('__extjsBridgeProducerInstalled')) prependToEmittedAsset(compilation, asset, `${source}\n`);
|
|
5364
5332
|
}
|
|
5365
5333
|
});
|
|
5366
5334
|
});
|
|
@@ -5417,9 +5385,7 @@ class InjectBridgeRelay {
|
|
|
5417
5385
|
const target = RELAY_TARGETS.find((t)=>t.re.test(asset.name));
|
|
5418
5386
|
if (!target) continue;
|
|
5419
5387
|
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));
|
|
5388
|
+
if (-1 === original.indexOf('__extjsBridgeRelayInstalled')) prependToEmittedAsset(compilation, asset, `${sourceFor.get(target.context)}\n`);
|
|
5423
5389
|
}
|
|
5424
5390
|
});
|
|
5425
5391
|
});
|
|
@@ -5549,9 +5515,7 @@ class InjectScriptsReplayShim {
|
|
|
5549
5515
|
for (const asset of compilation.getAssets()){
|
|
5550
5516
|
if (!inject_scripts_replay_shim_BACKGROUND_ASSET.test(asset.name)) continue;
|
|
5551
5517
|
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));
|
|
5518
|
+
if (-1 === original.indexOf('__extjsScriptsReplayInstalled')) prependToEmittedAsset(compilation, asset, `${SCRIPTS_REPLAY_SHIM_SOURCE}\n`);
|
|
5555
5519
|
}
|
|
5556
5520
|
});
|
|
5557
5521
|
});
|
|
@@ -6853,12 +6817,14 @@ class ReloadPlugin {
|
|
|
6853
6817
|
static name = 'plugin-reload';
|
|
6854
6818
|
manifestPath;
|
|
6855
6819
|
browser;
|
|
6820
|
+
devSession;
|
|
6856
6821
|
constructor(options){
|
|
6857
6822
|
this.manifestPath = options.manifestPath;
|
|
6858
6823
|
this.browser = options.browser || 'chrome';
|
|
6824
|
+
this.devSession = options.devSession;
|
|
6859
6825
|
}
|
|
6860
6826
|
apply(compiler) {
|
|
6861
|
-
if ('production' === compiler.options.mode || 'true' === process.env.EXTENSION_NO_RELOAD) return;
|
|
6827
|
+
if ('production' === compiler.options.mode || false === this.devSession || 'true' === process.env.EXTENSION_NO_RELOAD) return;
|
|
6862
6828
|
const hasValidManifest = !!this.manifestPath && __rspack_external_node_fs_5ea92f0c.existsSync(this.manifestPath) && __rspack_external_node_fs_5ea92f0c.lstatSync(this.manifestPath).isFile();
|
|
6863
6829
|
if (!hasValidManifest) return;
|
|
6864
6830
|
new StripContentScriptDevServerRuntime().apply(compiler);
|
|
@@ -7543,6 +7509,74 @@ function emitRootAbsoluteRefs(compilation, context, publicDir) {
|
|
|
7543
7509
|
if (0 === emitted) return;
|
|
7544
7510
|
}
|
|
7545
7511
|
}
|
|
7512
|
+
const DEV_SESSION_RESTART_DEBOUNCE_MS = 300;
|
|
7513
|
+
class DevSessionRestartScheduler {
|
|
7514
|
+
debounceMs;
|
|
7515
|
+
handler = null;
|
|
7516
|
+
timer;
|
|
7517
|
+
latest = null;
|
|
7518
|
+
inFlight = false;
|
|
7519
|
+
constructor(debounceMs = DEV_SESSION_RESTART_DEBOUNCE_MS){
|
|
7520
|
+
this.debounceMs = Math.max(0, debounceMs);
|
|
7521
|
+
}
|
|
7522
|
+
setHandler(handler) {
|
|
7523
|
+
this.handler = handler;
|
|
7524
|
+
}
|
|
7525
|
+
request(request) {
|
|
7526
|
+
this.latest = request;
|
|
7527
|
+
if (this.inFlight) return;
|
|
7528
|
+
this.schedule();
|
|
7529
|
+
}
|
|
7530
|
+
isPending() {
|
|
7531
|
+
return null != this.latest || this.inFlight;
|
|
7532
|
+
}
|
|
7533
|
+
dispose() {
|
|
7534
|
+
if (this.timer) clearTimeout(this.timer);
|
|
7535
|
+
this.timer = void 0;
|
|
7536
|
+
this.latest = null;
|
|
7537
|
+
this.handler = null;
|
|
7538
|
+
}
|
|
7539
|
+
schedule() {
|
|
7540
|
+
if (this.timer) clearTimeout(this.timer);
|
|
7541
|
+
if (0 === this.debounceMs) return void this.flush();
|
|
7542
|
+
this.timer = setTimeout(()=>{
|
|
7543
|
+
this.timer = void 0;
|
|
7544
|
+
this.flush();
|
|
7545
|
+
}, this.debounceMs);
|
|
7546
|
+
this.timer.unref?.();
|
|
7547
|
+
}
|
|
7548
|
+
async flush() {
|
|
7549
|
+
if (this.inFlight) return;
|
|
7550
|
+
const request = this.latest;
|
|
7551
|
+
const handler = this.handler;
|
|
7552
|
+
if (!request || !handler) return;
|
|
7553
|
+
this.latest = null;
|
|
7554
|
+
this.inFlight = true;
|
|
7555
|
+
try {
|
|
7556
|
+
await handler(request);
|
|
7557
|
+
} catch {} finally{
|
|
7558
|
+
this.inFlight = false;
|
|
7559
|
+
if (this.latest) this.schedule();
|
|
7560
|
+
}
|
|
7561
|
+
}
|
|
7562
|
+
}
|
|
7563
|
+
let boundScheduler = null;
|
|
7564
|
+
const restartingCompilers = new WeakSet();
|
|
7565
|
+
function bindDevSessionRestart(scheduler) {
|
|
7566
|
+
boundScheduler = scheduler;
|
|
7567
|
+
}
|
|
7568
|
+
function unbindDevSessionRestart() {
|
|
7569
|
+
boundScheduler = null;
|
|
7570
|
+
}
|
|
7571
|
+
function requestDevSessionRestart(compiler, request) {
|
|
7572
|
+
if (!boundScheduler) return false;
|
|
7573
|
+
if (compiler) restartingCompilers.add(compiler);
|
|
7574
|
+
boundScheduler.request(request);
|
|
7575
|
+
return true;
|
|
7576
|
+
}
|
|
7577
|
+
function isCompilerRestarting(compiler) {
|
|
7578
|
+
return null != compiler && restartingCompilers.has(compiler);
|
|
7579
|
+
}
|
|
7546
7580
|
class WarnUponFolderChanges {
|
|
7547
7581
|
pendingChanges = [];
|
|
7548
7582
|
knownFolderFiles = new Set();
|
|
@@ -7600,6 +7634,10 @@ class WarnUponFolderChanges {
|
|
|
7600
7634
|
const typeOfAsset = 'pages' === folder ? 'HTML pages' : "script files";
|
|
7601
7635
|
const errorMessage = serverRestartRequiredFromSpecialFolderMessageOnly(addingOrRemoving, folder, typeOfAsset);
|
|
7602
7636
|
if (isAddition) {
|
|
7637
|
+
if (requestDevSessionRestart(compilation.compiler, {
|
|
7638
|
+
reason: 'pages' === folder ? 'html' : "scripts",
|
|
7639
|
+
pathAfter: filePath
|
|
7640
|
+
})) return;
|
|
7603
7641
|
const warn = new core_WebpackError(errorMessage);
|
|
7604
7642
|
warn.name = 'SpecialFoldersChange';
|
|
7605
7643
|
warn.file = filePath;
|
|
@@ -7679,8 +7717,14 @@ class SpecialFoldersPlugin {
|
|
|
7679
7717
|
apply(compiler) {
|
|
7680
7718
|
const { manifestPath } = this.options;
|
|
7681
7719
|
const context = compiler.options.context || __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
7682
|
-
const
|
|
7720
|
+
const inspection = inspectPublicFolders(manifestPath, context);
|
|
7721
|
+
const publicDir = inspection.publicDir || __rspack_external_node_path_c5b9b54f.join(context, 'public');
|
|
7722
|
+
rememberPublicRoots(compiler, inspection.publicDir ? [
|
|
7723
|
+
publicDir
|
|
7724
|
+
] : []);
|
|
7683
7725
|
compiler.hooks.thisCompilation.tap(SpecialFoldersPlugin.name, (compilation)=>{
|
|
7726
|
+
if (inspection.bothExist) pushLayoutWarning(compiler, compilation, 'PublicFolderShadowedWarning', publicFolderShadowed(inspection.fromRoot, inspection.fromManifest));
|
|
7727
|
+
else if (inspection.usedFallback) pushLayoutWarning(compiler, compilation, 'PublicLayoutWarning', publicMustBeAtProjectRoot(inspection.fromManifest, inspection.fromRoot));
|
|
7684
7728
|
compilation.hooks.processAssets.tap({
|
|
7685
7729
|
name: `${SpecialFoldersPlugin.name}:root-absolute-refs`,
|
|
7686
7730
|
stage: compilation.constructor.PROCESS_ASSETS_STAGE_SUMMARIZE
|
|
@@ -7688,8 +7732,9 @@ class SpecialFoldersPlugin {
|
|
|
7688
7732
|
emitRootAbsoluteRefs(compilation, __rspack_external_node_path_c5b9b54f.dirname(manifestPath), publicDir);
|
|
7689
7733
|
});
|
|
7690
7734
|
});
|
|
7691
|
-
if (
|
|
7735
|
+
if (inspection.publicDir) {
|
|
7692
7736
|
compiler.hooks.thisCompilation.tap(SpecialFoldersPlugin.name, (compilation)=>{
|
|
7737
|
+
compilation.contextDependencies?.add(publicDir);
|
|
7693
7738
|
compilation.hooks.processAssets.tap({
|
|
7694
7739
|
name: `${SpecialFoldersPlugin.name}:guards`,
|
|
7695
7740
|
stage: compilation.constructor.PROCESS_ASSETS_STAGE_PRE_PROCESS
|
|
@@ -7719,6 +7764,13 @@ class SpecialFoldersPlugin {
|
|
|
7719
7764
|
}
|
|
7720
7765
|
}
|
|
7721
7766
|
}
|
|
7767
|
+
function pushLayoutWarning(compiler, compilation, name, message) {
|
|
7768
|
+
const ErrorConstructor = compiler?.rspack?.WebpackError || Error;
|
|
7769
|
+
const warning = new ErrorConstructor(message);
|
|
7770
|
+
warning.name = name;
|
|
7771
|
+
if (!compilation.warnings) compilation.warnings = [];
|
|
7772
|
+
compilation.warnings.push(warning);
|
|
7773
|
+
}
|
|
7722
7774
|
function assetsRulesEnabled(rules) {
|
|
7723
7775
|
const kinds = rules.length > 0 ? rules.join(',').toLowerCase() : 'none';
|
|
7724
7776
|
return `${messaging_prefix('debug')} assets rules=${rules.length} kinds=${kinds}`;
|
|
@@ -8112,7 +8164,7 @@ function resolveCssAsset(compilation, feature) {
|
|
|
8112
8164
|
href: void 0
|
|
8113
8165
|
};
|
|
8114
8166
|
}
|
|
8115
|
-
function handleStaticAsset(compilation, htmlEntry, htmlDir, absolutePath, assetType, cleanPath, search, hash,
|
|
8167
|
+
function handleStaticAsset(compilation, htmlEntry, htmlDir, absolutePath, assetType, cleanPath, search, hash, includeList, extname, childNode, attributeName, manifestDir) {
|
|
8116
8168
|
const isFilepathListEntry = isFromFilepathList(absolutePath, includeList);
|
|
8117
8169
|
__rspack_external_node_path_c5b9b54f.posix.join('/', cleanPath);
|
|
8118
8170
|
const attrName = resolveStaticAttributeName(assetType, attributeName);
|
|
@@ -8128,15 +8180,50 @@ function handleStaticAsset(compilation, htmlEntry, htmlDir, absolutePath, assetT
|
|
|
8128
8180
|
node = applyRewrittenStaticUrl(node, attrName, cleanPath, cleanPath + (search || '') + (hash || ''));
|
|
8129
8181
|
return node;
|
|
8130
8182
|
}
|
|
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);
|
|
8183
|
+
const filepath = htmlStaticAssetOutputName(manifestDir, htmlEntry, absolutePath);
|
|
8137
8184
|
if (__rspack_external_node_fs_5ea92f0c.existsSync(absolutePath)) node = applyRewrittenStaticUrl(node, attrName, cleanPath, getFilePath(filepath, '', true) + (search || '') + (hash || ''));
|
|
8138
8185
|
return node;
|
|
8139
8186
|
}
|
|
8187
|
+
const LINK_ATTRIBUTES = {
|
|
8188
|
+
a: 'href',
|
|
8189
|
+
area: 'href',
|
|
8190
|
+
form: 'action'
|
|
8191
|
+
};
|
|
8192
|
+
function isBakeable(value) {
|
|
8193
|
+
const trimmed = value.trim();
|
|
8194
|
+
if (!trimmed) return false;
|
|
8195
|
+
if (trimmed.startsWith('#')) return false;
|
|
8196
|
+
if (trimmed.startsWith('//')) return false;
|
|
8197
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(trimmed)) return false;
|
|
8198
|
+
return true;
|
|
8199
|
+
}
|
|
8200
|
+
function resolveLinkThroughBase(baseHref, value) {
|
|
8201
|
+
if (utils_isUrl(baseHref)) return new URL(value, baseHref).href;
|
|
8202
|
+
if (value.startsWith('/')) return value;
|
|
8203
|
+
const joined = __rspack_external_node_path_c5b9b54f.posix.join(baseHref.replace(/\\/g, '/'), value);
|
|
8204
|
+
return baseHref.startsWith('/') && !joined.startsWith('/') ? `/${joined}` : joined;
|
|
8205
|
+
}
|
|
8206
|
+
function base_href_walk(node, visit) {
|
|
8207
|
+
visit(node);
|
|
8208
|
+
for (const child of node.childNodes || [])base_href_walk(child, visit);
|
|
8209
|
+
}
|
|
8210
|
+
function bakeBaseHref(htmlDocument) {
|
|
8211
|
+
const baseNode = getBaseNode(htmlDocument);
|
|
8212
|
+
const baseHref = baseNode?.attrs?.find((attr)=>'href' === attr.name)?.value;
|
|
8213
|
+
if (!baseNode || !baseHref) return;
|
|
8214
|
+
base_href_walk(htmlDocument, (node)=>{
|
|
8215
|
+
const attrName = LINK_ATTRIBUTES[String(node.nodeName || '')];
|
|
8216
|
+
if (!attrName) return;
|
|
8217
|
+
const attr = node.attrs?.find((entry)=>entry.name === attrName);
|
|
8218
|
+
if (!attr || !isBakeable(attr.value)) return;
|
|
8219
|
+
attr.value = resolveLinkThroughBase(baseHref, attr.value.trim());
|
|
8220
|
+
});
|
|
8221
|
+
baseNode.attrs = (baseNode.attrs || []).filter((attr)=>'href' !== attr.name);
|
|
8222
|
+
if (0 === baseNode.attrs.length) base_href_walk(htmlDocument, (node)=>{
|
|
8223
|
+
if (!node.childNodes) return;
|
|
8224
|
+
node.childNodes = node.childNodes.filter((child)=>child !== baseNode);
|
|
8225
|
+
});
|
|
8226
|
+
}
|
|
8140
8227
|
function injectJsScript(bodyNode, feature, firstScriptAttrs) {
|
|
8141
8228
|
const scriptTag = __rspack_external_parse5_utilities_78b19c6a.createNode("script");
|
|
8142
8229
|
scriptTag.attrs = [
|
|
@@ -8169,7 +8256,7 @@ function warnIfPublicRootAssetMissing(compilation, htmlEntry, cleanPath) {
|
|
|
8169
8256
|
warn.message = filtered.join('\n').trim();
|
|
8170
8257
|
compilation.warnings.push(warn);
|
|
8171
8258
|
}
|
|
8172
|
-
function patchHtml(compilation, feature, htmlEntry, includeList) {
|
|
8259
|
+
function patchHtml(compilation, feature, htmlEntry, includeList, manifestDir) {
|
|
8173
8260
|
const htmlFile = __rspack_external_node_fs_5ea92f0c.readFileSync(htmlEntry, {
|
|
8174
8261
|
encoding: 'utf8'
|
|
8175
8262
|
});
|
|
@@ -8188,7 +8275,7 @@ function patchHtml(compilation, feature, htmlEntry, includeList) {
|
|
|
8188
8275
|
if ('head' === htmlChildNode.nodeName || 'body' === htmlChildNode.nodeName) parseHtml(htmlChildNode, ({ filePath, childNode, assetType, attributeName })=>{
|
|
8189
8276
|
const htmlDir = __rspack_external_node_path_c5b9b54f.dirname(htmlEntry);
|
|
8190
8277
|
const { cleanPath, hash, search } = cleanAssetUrl(filePath);
|
|
8191
|
-
const absolutePath =
|
|
8278
|
+
const absolutePath = resolveHtmlRefPath(htmlEntry, baseHref, cleanPath);
|
|
8192
8279
|
const extname = getExtname(absolutePath);
|
|
8193
8280
|
__rspack_external_node_path_c5b9b54f.posix.join('/', cleanPath);
|
|
8194
8281
|
let thisChildNode = childNode;
|
|
@@ -8215,7 +8302,7 @@ function patchHtml(compilation, feature, htmlEntry, includeList) {
|
|
|
8215
8302
|
break;
|
|
8216
8303
|
case 'staticHref':
|
|
8217
8304
|
case 'staticSrc':
|
|
8218
|
-
thisChildNode = handleStaticAsset(compilation, htmlEntry, htmlDir, absolutePath, assetType, cleanPath, search, hash,
|
|
8305
|
+
thisChildNode = handleStaticAsset(compilation, htmlEntry, htmlDir, absolutePath, assetType, cleanPath, search, hash, includeList, extname, thisChildNode, attributeName, manifestDir);
|
|
8219
8306
|
break;
|
|
8220
8307
|
default:
|
|
8221
8308
|
break;
|
|
@@ -8244,20 +8331,21 @@ function patchHtml(compilation, feature, htmlEntry, includeList) {
|
|
|
8244
8331
|
];
|
|
8245
8332
|
} else if (bodyNode) injectJsScript(bodyNode, feature, firstScriptAttrs);
|
|
8246
8333
|
}
|
|
8334
|
+
bakeBaseHref(htmlDocument);
|
|
8247
8335
|
return __rspack_external_parse5_utilities_78b19c6a.stringify(htmlDocument);
|
|
8248
8336
|
}
|
|
8249
8337
|
return '';
|
|
8250
8338
|
}
|
|
8251
|
-
function patchHtmlNested(compilation, htmlEntry) {
|
|
8339
|
+
function patchHtmlNested(compilation, htmlEntry, manifestDir) {
|
|
8252
8340
|
const htmlFile = __rspack_external_node_fs_5ea92f0c.readFileSync(htmlEntry, {
|
|
8253
8341
|
encoding: 'utf8'
|
|
8254
8342
|
});
|
|
8255
8343
|
const htmlDocument = __rspack_external_parse5_utilities_78b19c6a.parse(htmlFile);
|
|
8344
|
+
const baseHref = getBaseHref(htmlDocument);
|
|
8256
8345
|
for (const node of htmlDocument.childNodes)if ('html' === node.nodeName) {
|
|
8257
8346
|
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
8347
|
const { cleanPath, hash, search } = cleanAssetUrl(filePath);
|
|
8260
|
-
const absolutePath =
|
|
8348
|
+
const absolutePath = resolveHtmlRefPath(htmlEntry, baseHref, cleanPath);
|
|
8261
8349
|
const attrName = 'staticSrc' === assetType || 'staticHref' === assetType ? resolveStaticAttributeName(assetType, attributeName) : void 0;
|
|
8262
8350
|
let thisChildNode = childNode;
|
|
8263
8351
|
switch(assetType){
|
|
@@ -8279,9 +8367,7 @@ function patchHtmlNested(compilation, htmlEntry) {
|
|
|
8279
8367
|
warnIfPublicRootAssetMissing(compilation, htmlEntry, cleanPath);
|
|
8280
8368
|
thisChildNode = applyRewrittenStaticUrl(thisChildNode, attrName || resolveStaticAttributeName(assetType), cleanPath, cleanPath + (search || '') + (hash || ''));
|
|
8281
8369
|
} 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);
|
|
8370
|
+
const filepath = htmlStaticAssetOutputName(manifestDir, htmlEntry, absolutePath);
|
|
8285
8371
|
thisChildNode = applyRewrittenStaticUrl(thisChildNode, attrName || resolveStaticAttributeName(assetType), cleanPath, getFilePath(filepath, '', true) + (search || '') + (hash || ''));
|
|
8286
8372
|
}
|
|
8287
8373
|
break;
|
|
@@ -8289,6 +8375,7 @@ function patchHtmlNested(compilation, htmlEntry) {
|
|
|
8289
8375
|
break;
|
|
8290
8376
|
}
|
|
8291
8377
|
});
|
|
8378
|
+
bakeBaseHref(htmlDocument);
|
|
8292
8379
|
return __rspack_external_parse5_utilities_78b19c6a.stringify(htmlDocument);
|
|
8293
8380
|
}
|
|
8294
8381
|
return '';
|
|
@@ -8343,9 +8430,9 @@ function checkMissingLocalEntries(params) {
|
|
|
8343
8430
|
css?.forEach(check);
|
|
8344
8431
|
}
|
|
8345
8432
|
function emitNestedHtmlAndReferencedAssets(params) {
|
|
8346
|
-
const { compilation, filepath, absoluteFsPath } = params;
|
|
8433
|
+
const { compilation, filepath, absoluteFsPath, manifestDir } = params;
|
|
8347
8434
|
const source = __rspack_external_node_fs_5ea92f0c.readFileSync(absoluteFsPath);
|
|
8348
|
-
const updatedHtml = patchHtmlNested(compilation, absoluteFsPath);
|
|
8435
|
+
const updatedHtml = patchHtmlNested(compilation, absoluteFsPath, manifestDir);
|
|
8349
8436
|
const htmlAssets = getAssetsFromHtml(absoluteFsPath);
|
|
8350
8437
|
const assetsFromHtml = [
|
|
8351
8438
|
...htmlAssets?.js || [],
|
|
@@ -8357,7 +8444,7 @@ function emitNestedHtmlAndReferencedAssets(params) {
|
|
|
8357
8444
|
if (!__rspack_external_node_path_c5b9b54f.isAbsolute(assetFromHtml) || !__rspack_external_node_fs_5ea92f0c.existsSync(assetFromHtml)) return;
|
|
8358
8445
|
const s = __rspack_external_node_fs_5ea92f0c.readFileSync(assetFromHtml);
|
|
8359
8446
|
const r = new core_sources.RawSource(s);
|
|
8360
|
-
const assetFilepath =
|
|
8447
|
+
const assetFilepath = htmlStaticAssetOutputName(manifestDir, absoluteFsPath, assetFromHtml);
|
|
8361
8448
|
if (!compilation.getAsset(assetFilepath)) compilation.emitAsset(assetFilepath, r);
|
|
8362
8449
|
});
|
|
8363
8450
|
}
|
|
@@ -8462,14 +8549,15 @@ class AddAssetsToCompilation {
|
|
|
8462
8549
|
} catch {}
|
|
8463
8550
|
continue;
|
|
8464
8551
|
}
|
|
8465
|
-
const filepath =
|
|
8552
|
+
const filepath = htmlStaticAssetOutputName(manifestDir, resource, absoluteFsPath);
|
|
8466
8553
|
const isNestedHtml = asset.endsWith('.html');
|
|
8467
8554
|
const nestedHtmlAsset = isNestedHtml ? 'function' == typeof getAssetFn ? getAssetFn.call(compilation, __rspack_external_node_path_c5b9b54f.basename(asset)) : null : null;
|
|
8468
8555
|
if (!isFromIncludeList(asset, this.includeList) || nestedHtmlAsset) {
|
|
8469
8556
|
if (!('function' == typeof getAssetFn && getAssetFn.call(compilation, filepath))) if (asset.endsWith('.html')) emitNestedHtmlAndReferencedAssets({
|
|
8470
8557
|
compilation,
|
|
8471
8558
|
filepath,
|
|
8472
|
-
absoluteFsPath
|
|
8559
|
+
absoluteFsPath,
|
|
8560
|
+
manifestDir
|
|
8473
8561
|
});
|
|
8474
8562
|
else {
|
|
8475
8563
|
const source = __rspack_external_node_fs_5ea92f0c.readFileSync(absoluteFsPath);
|
|
@@ -8763,6 +8851,8 @@ function manifestFieldForHtmlFeature(featureName, manifestPath) {
|
|
|
8763
8851
|
if (has('action')) return 'action.default_popup';
|
|
8764
8852
|
if (has('browser_action')) return 'browser_action.default_popup';
|
|
8765
8853
|
return 'page_action.default_popup';
|
|
8854
|
+
case 'page_action/index':
|
|
8855
|
+
return 'page_action.default_popup';
|
|
8766
8856
|
case 'options/index':
|
|
8767
8857
|
return has('options_page') ? 'options_page' : 'options_ui.page';
|
|
8768
8858
|
case 'background/index':
|
|
@@ -8928,6 +9018,11 @@ class ThrowIfRecompileIsNeeded {
|
|
|
8928
9018
|
if (this.hasEntriesChanged(updatedCssEntries, css) || this.hasEntriesChanged(updatedJsEntries, js)) {
|
|
8929
9019
|
const projectRoot = __rspack_external_node_path_c5b9b54f.dirname(this.manifestPath);
|
|
8930
9020
|
const relToManifest = __rspack_external_node_path_c5b9b54f.relative(projectRoot, changedFile);
|
|
9021
|
+
if (requestDevSessionRestart(compiler, {
|
|
9022
|
+
reason: 'html',
|
|
9023
|
+
pathAfter: changedFile,
|
|
9024
|
+
manifestField: relToManifest
|
|
9025
|
+
})) continue;
|
|
8931
9026
|
const err = new core_WebpackError(serverRestartRequiredFromHtml(relToManifest, changedFile));
|
|
8932
9027
|
err.name = 'HtmlEntrypointChanged';
|
|
8933
9028
|
err.file = relToManifest;
|
|
@@ -8960,7 +9055,7 @@ class UpdateHtmlFile {
|
|
|
8960
9055
|
const getAssetFn = compilation.getAsset;
|
|
8961
9056
|
const existing = 'function' == typeof getAssetFn ? getAssetFn.call(compilation, assetFilename) : compilation.assets?.[assetFilename];
|
|
8962
9057
|
if (!existing) continue;
|
|
8963
|
-
const updated = patchHtml(compilation, feature, resolved, this.includeList || {});
|
|
9058
|
+
const updated = patchHtml(compilation, feature, resolved, this.includeList || {}, projectDir);
|
|
8964
9059
|
const updatedHtml = 'string' == typeof updated ? updated : updated && 'string' == typeof updated.html ? updated.html : null;
|
|
8965
9060
|
if ('string' == typeof updatedHtml) compilation.updateAsset(assetFilename, new core_sources.RawSource(updatedHtml));
|
|
8966
9061
|
}
|
|
@@ -8978,9 +9073,11 @@ class HtmlPlugin {
|
|
|
8978
9073
|
manifestPath;
|
|
8979
9074
|
includeList;
|
|
8980
9075
|
browser;
|
|
9076
|
+
devSession;
|
|
8981
9077
|
constructor(options){
|
|
8982
9078
|
this.manifestPath = options.manifestPath;
|
|
8983
9079
|
this.includeList = options.includeList;
|
|
9080
|
+
this.devSession = options.devSession;
|
|
8984
9081
|
this.browser = options.browser || 'chrome';
|
|
8985
9082
|
}
|
|
8986
9083
|
apply(compiler) {
|
|
@@ -9007,7 +9104,8 @@ class HtmlPlugin {
|
|
|
9007
9104
|
includeList,
|
|
9008
9105
|
browser: this.browser
|
|
9009
9106
|
}).apply(compiler);
|
|
9010
|
-
|
|
9107
|
+
const devSession = this.devSession ?? 'production' !== (compiler.options.mode || 'development');
|
|
9108
|
+
if (devSession) {
|
|
9011
9109
|
const contentScriptEntryPaths = new Set();
|
|
9012
9110
|
try {
|
|
9013
9111
|
const manifest = parseJsonSafe(__rspack_external_node_fs_5ea92f0c.readFileSync(this.manifestPath, 'utf-8'));
|
|
@@ -9018,11 +9116,16 @@ class HtmlPlugin {
|
|
|
9018
9116
|
for (const jsFile of jsList)contentScriptEntryPaths.add(toResourceKey(__rspack_external_node_path_c5b9b54f.resolve(manifestDir, jsFile)));
|
|
9019
9117
|
}
|
|
9020
9118
|
} catch {}
|
|
9119
|
+
const projectRoot = String(compiler.options.context || '');
|
|
9120
|
+
const pageDirs = new Set([
|
|
9121
|
+
__rspack_external_node_path_c5b9b54f.dirname(this.manifestPath)
|
|
9122
|
+
]);
|
|
9123
|
+
if (projectRoot) pageDirs.add(projectRoot);
|
|
9124
|
+
for (const pagePath of Object.values(includeList))if ('string' == typeof pagePath && pagePath) pageDirs.add(__rspack_external_node_path_c5b9b54f.dirname(pagePath));
|
|
9125
|
+
const frameworkOwnsRefresh = Boolean(projectRoot && (isUsingReact(projectRoot) || isUsingVue(projectRoot) || isUsingSvelte(projectRoot)));
|
|
9021
9126
|
compiler.options.module.rules.push({
|
|
9022
9127
|
test: /\.(js|cjs|mjs|jsx|mjsx|ts|mts|tsx|mtsx)$/,
|
|
9023
|
-
include:
|
|
9024
|
-
__rspack_external_node_path_c5b9b54f.dirname(this.manifestPath)
|
|
9025
|
-
],
|
|
9128
|
+
include: Array.from(pageDirs),
|
|
9026
9129
|
issuerLayer: {
|
|
9027
9130
|
not: EXTENSIONJS_CONTENT_SCRIPT_LAYER
|
|
9028
9131
|
},
|
|
@@ -9035,7 +9138,8 @@ class HtmlPlugin {
|
|
|
9035
9138
|
loader: resolveDevelopDistFile("ensure-hmr-for-scripts"),
|
|
9036
9139
|
options: {
|
|
9037
9140
|
manifestPath: this.manifestPath,
|
|
9038
|
-
includeList
|
|
9141
|
+
includeList,
|
|
9142
|
+
frameworkOwnsRefresh
|
|
9039
9143
|
}
|
|
9040
9144
|
}
|
|
9041
9145
|
]
|
|
@@ -9058,6 +9162,32 @@ class HtmlPlugin {
|
|
|
9058
9162
|
}).apply(compiler);
|
|
9059
9163
|
}
|
|
9060
9164
|
}
|
|
9165
|
+
function resolveManifestIconPath(context, relativePath) {
|
|
9166
|
+
const unix = relativePath.replace(/\\/g, '/');
|
|
9167
|
+
if (/^\/public\//i.test(unix)) return __rspack_external_node_path_c5b9b54f.join(context, 'public', unix.replace(/^\/public\//i, ''));
|
|
9168
|
+
if (/^(?:\.\/)?public\//i.test(unix)) return __rspack_external_node_path_c5b9b54f.join(context, 'public', unix.replace(/^(?:\.\/)?public\//i, ''));
|
|
9169
|
+
if (/^\//.test(unix)) return __rspack_external_node_path_c5b9b54f.join(context, unix.slice(1));
|
|
9170
|
+
return __rspack_external_node_path_c5b9b54f.join(context, unix);
|
|
9171
|
+
}
|
|
9172
|
+
function extractActionThemeIcons(manifestPath) {
|
|
9173
|
+
let manifest;
|
|
9174
|
+
try {
|
|
9175
|
+
manifest = JSON.parse(stripBom(__rspack_external_node_fs_5ea92f0c.readFileSync(manifestPath, 'utf8')));
|
|
9176
|
+
} catch {
|
|
9177
|
+
return {};
|
|
9178
|
+
}
|
|
9179
|
+
const themeIcons = manifest?.action?.theme_icons;
|
|
9180
|
+
if (!Array.isArray(themeIcons) || 0 === themeIcons.length) return {};
|
|
9181
|
+
const context = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
9182
|
+
const paths = [];
|
|
9183
|
+
for (const icon of themeIcons)if (icon && 'object' == typeof icon) {
|
|
9184
|
+
if ('string' == typeof icon.light && icon.light) paths.push(resolveManifestIconPath(context, icon.light));
|
|
9185
|
+
if ('string' == typeof icon.dark && icon.dark) paths.push(resolveManifestIconPath(context, icon.dark));
|
|
9186
|
+
}
|
|
9187
|
+
return paths.length ? {
|
|
9188
|
+
'action/theme_icons': paths
|
|
9189
|
+
} : {};
|
|
9190
|
+
}
|
|
9061
9191
|
function iconsMissingFile(manifestField, filePath, opts) {
|
|
9062
9192
|
const lines = [];
|
|
9063
9193
|
lines.push(`Can't find an icon file listed in ${pintor.blue(manifestField)}.`);
|
|
@@ -9141,15 +9271,20 @@ class add_to_file_dependencies_AddToFileDependencies {
|
|
|
9141
9271
|
name: 'icons:add-to-file-dependencies',
|
|
9142
9272
|
stage: core_Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
|
|
9143
9273
|
}, ()=>{
|
|
9144
|
-
if (compilation.errors?.length) return;
|
|
9145
9274
|
const iconFields = this.includeList || {};
|
|
9146
9275
|
let added = 0;
|
|
9147
9276
|
for (const field of Object.entries(iconFields)){
|
|
9148
9277
|
const [, resource] = field;
|
|
9149
9278
|
const stringEntries = iconValuesToStrings(resource);
|
|
9150
|
-
for (const entry of stringEntries)if (entry &&
|
|
9151
|
-
|
|
9152
|
-
|
|
9279
|
+
for (const entry of stringEntries)if (entry && __rspack_external_node_path_c5b9b54f.isAbsolute(entry)) {
|
|
9280
|
+
if (!__rspack_external_node_fs_5ea92f0c.existsSync(entry)) {
|
|
9281
|
+
compilation.missingDependencies?.add(entry);
|
|
9282
|
+
continue;
|
|
9283
|
+
}
|
|
9284
|
+
if (!compilation.fileDependencies.has(entry)) {
|
|
9285
|
+
compilation.fileDependencies.add(entry);
|
|
9286
|
+
added++;
|
|
9287
|
+
}
|
|
9153
9288
|
}
|
|
9154
9289
|
}
|
|
9155
9290
|
if (isDebug()) console.log(iconsDepsTracked(added));
|
|
@@ -9231,7 +9366,7 @@ class EmitFile {
|
|
|
9231
9366
|
const parts = String(feature).split('/');
|
|
9232
9367
|
const group = parts[0];
|
|
9233
9368
|
const sub = parts[1] || '';
|
|
9234
|
-
const isDefaultIconFamily = ('action' === group || 'browser_action' === group || 'page_action' === group || 'sidebar_action' === group) && 'default_icon' === sub;
|
|
9369
|
+
const isDefaultIconFamily = ('action' === group || 'browser_action' === group || 'page_action' === group || 'sidebar_action' === group || 'omnibox' === group) && 'default_icon' === sub;
|
|
9235
9370
|
const isThemeImage = 'theme' === group && 'images' === sub;
|
|
9236
9371
|
if (!__rspack_external_node_fs_5ea92f0c.existsSync(resolved)) {
|
|
9237
9372
|
const isPublicRoot = entry.startsWith('/') && !entry.startsWith(projectPath);
|
|
@@ -9258,14 +9393,25 @@ class EmitFile {
|
|
|
9258
9393
|
const source = __rspack_external_node_fs_5ea92f0c.readFileSync(resolved);
|
|
9259
9394
|
const rawSource = new core_sources.RawSource(source);
|
|
9260
9395
|
const basename = __rspack_external_node_path_c5b9b54f.basename(resolved);
|
|
9396
|
+
const isThemeIcons = ('browser_action' === group || 'action' === group) && 'theme_icons' === sub;
|
|
9261
9397
|
let outputDir = group;
|
|
9262
9398
|
if (isDefaultIconFamily) outputDir = 'icons';
|
|
9263
|
-
else if (
|
|
9399
|
+
else if (isThemeIcons) outputDir = group;
|
|
9264
9400
|
else if (isThemeImage) outputDir = 'theme/images';
|
|
9265
9401
|
let filename = `${outputDir}/${basename}`;
|
|
9402
|
+
const relFromManifest = __rspack_external_node_path_c5b9b54f.relative(manifestDir, resolved).replace(/\\/g, '/');
|
|
9266
9403
|
if ('icons' === outputDir) {
|
|
9267
|
-
|
|
9268
|
-
if (
|
|
9404
|
+
if (relFromManifest && !__rspack_external_node_path_c5b9b54f.isAbsolute(relFromManifest)) filename = iconOutputPath(relFromManifest);
|
|
9405
|
+
else if (resolved) filename = iconOutputPath(resolved);
|
|
9406
|
+
}
|
|
9407
|
+
if (isThemeIcons) {
|
|
9408
|
+
const folder = 'action' === group ? 'action' : 'browser_action';
|
|
9409
|
+
if (relFromManifest && !__rspack_external_node_path_c5b9b54f.isAbsolute(relFromManifest)) filename = themeIconOutputPath(relFromManifest, folder);
|
|
9410
|
+
else if (resolved) filename = themeIconOutputPath(resolved, folder);
|
|
9411
|
+
}
|
|
9412
|
+
if (isThemeImage) {
|
|
9413
|
+
if (relFromManifest && !__rspack_external_node_path_c5b9b54f.isAbsolute(relFromManifest)) filename = themeImageOutputPath(relFromManifest);
|
|
9414
|
+
else if (resolved) filename = themeImageOutputPath(resolved);
|
|
9269
9415
|
}
|
|
9270
9416
|
compilation.emitAsset(filename, rawSource);
|
|
9271
9417
|
emittedCount++;
|
|
@@ -9289,7 +9435,10 @@ class IconsPlugin {
|
|
|
9289
9435
|
this.includeList = options.includeList;
|
|
9290
9436
|
}
|
|
9291
9437
|
apply(compiler) {
|
|
9292
|
-
const normalizedIncludeList =
|
|
9438
|
+
const normalizedIncludeList = {
|
|
9439
|
+
...normalizeIconIncludeKeys(this.includeList),
|
|
9440
|
+
...extractActionThemeIcons(this.manifestPath)
|
|
9441
|
+
};
|
|
9293
9442
|
if (isDebug()) {
|
|
9294
9443
|
const beforeKeys = Object.keys(this.includeList || {});
|
|
9295
9444
|
const afterKeys = Object.keys(normalizedIncludeList || {});
|
|
@@ -9306,6 +9455,47 @@ class IconsPlugin {
|
|
|
9306
9455
|
}).apply(compiler);
|
|
9307
9456
|
}
|
|
9308
9457
|
}
|
|
9458
|
+
function omniboxIconFields(manifestPath) {
|
|
9459
|
+
let manifest;
|
|
9460
|
+
try {
|
|
9461
|
+
manifest = JSON.parse(stripBom(__rspack_external_node_fs_5ea92f0c.readFileSync(manifestPath, 'utf8')));
|
|
9462
|
+
} catch {
|
|
9463
|
+
return {};
|
|
9464
|
+
}
|
|
9465
|
+
const icon = manifest?.omnibox?.default_icon;
|
|
9466
|
+
if (!icon) return {};
|
|
9467
|
+
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
9468
|
+
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);
|
|
9469
|
+
if ('string' == typeof icon) return {
|
|
9470
|
+
'omnibox/default_icon': resolve(icon)
|
|
9471
|
+
};
|
|
9472
|
+
if ('object' == typeof icon) return {
|
|
9473
|
+
'omnibox/default_icon': Object.fromEntries(Object.entries(icon).map(([size, value])=>[
|
|
9474
|
+
size,
|
|
9475
|
+
resolve(value)
|
|
9476
|
+
]))
|
|
9477
|
+
};
|
|
9478
|
+
return {};
|
|
9479
|
+
}
|
|
9480
|
+
function themeImageFields(manifestPath) {
|
|
9481
|
+
let manifest;
|
|
9482
|
+
try {
|
|
9483
|
+
manifest = JSON.parse(stripBom(__rspack_external_node_fs_5ea92f0c.readFileSync(manifestPath, 'utf8')));
|
|
9484
|
+
} catch {
|
|
9485
|
+
return {};
|
|
9486
|
+
}
|
|
9487
|
+
const images = manifest?.theme?.images;
|
|
9488
|
+
if (!images || 'object' != typeof images || Array.isArray(images)) return {};
|
|
9489
|
+
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
9490
|
+
const resolve = (value)=>value.startsWith('/') || __rspack_external_node_path_c5b9b54f.isAbsolute(value) ? value : __rspack_external_node_path_c5b9b54f.join(manifestDir, value);
|
|
9491
|
+
const out = {};
|
|
9492
|
+
for (const [key, value] of Object.entries(images))if ('string' == typeof value) out[`theme/images/${key}`] = resolve(value);
|
|
9493
|
+
else if (Array.isArray(value)) {
|
|
9494
|
+
const entries = value.filter((entry)=>'string' == typeof entry);
|
|
9495
|
+
if (entries.length) out[`theme/images/${key}`] = entries.map(resolve);
|
|
9496
|
+
}
|
|
9497
|
+
return out;
|
|
9498
|
+
}
|
|
9309
9499
|
function jsonMissingFile(manifestField, filePath, opts) {
|
|
9310
9500
|
const lines = [];
|
|
9311
9501
|
lines.push(`Can't find the JSON file listed in ${pintor.blue(manifestField)}.`);
|
|
@@ -9366,8 +9556,11 @@ function jsonDepsTracked(addedCount) {
|
|
|
9366
9556
|
function jsonIncludeSummary(totalFeatures, criticalCount) {
|
|
9367
9557
|
return `${messaging_prefix('debug')} json include features=${String(totalFeatures)} critical=${String(criticalCount)}`;
|
|
9368
9558
|
}
|
|
9559
|
+
function isManagedSchemaFeature(feature) {
|
|
9560
|
+
return 'storage/managed_schema' === feature || 'storage.managed_schema' === feature;
|
|
9561
|
+
}
|
|
9369
9562
|
function isCriticalJsonFeature(feature) {
|
|
9370
|
-
return feature.startsWith('declarative_net_request') ||
|
|
9563
|
+
return feature.startsWith('declarative_net_request') || isManagedSchemaFeature(feature);
|
|
9371
9564
|
}
|
|
9372
9565
|
function isPlainObject(value) {
|
|
9373
9566
|
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
@@ -9421,7 +9614,7 @@ function validateJsonAsset(compilation, feature, filePath, buf) {
|
|
|
9421
9614
|
compilation.warnings.push(warn);
|
|
9422
9615
|
}
|
|
9423
9616
|
}
|
|
9424
|
-
} else if (
|
|
9617
|
+
} else if (isManagedSchemaFeature(feature)) {
|
|
9425
9618
|
if (null === parsed || Array.isArray(parsed) || 'object' != typeof parsed) {
|
|
9426
9619
|
const err = new core_WebpackError(invalidManagedSchemaStructure(feature, filePath));
|
|
9427
9620
|
err.file = filePath;
|
|
@@ -9440,23 +9633,40 @@ function firstExisting(candidates) {
|
|
|
9440
9633
|
for (const candidate of candidates)if (candidate && __rspack_external_node_fs_5ea92f0c.existsSync(candidate)) return candidate;
|
|
9441
9634
|
}
|
|
9442
9635
|
function resolveJsonResource(thisResource, manifestDir, projectPath) {
|
|
9443
|
-
const
|
|
9636
|
+
const manifestPath = __rspack_external_node_path_c5b9b54f.join(manifestDir, 'manifest.json');
|
|
9637
|
+
const inspection = inspectPublicFolders(manifestPath, projectPath);
|
|
9638
|
+
const publicRoots = [
|
|
9639
|
+
inspection.fromRoot
|
|
9640
|
+
];
|
|
9641
|
+
if (__rspack_external_node_path_c5b9b54f.resolve(inspection.fromManifest) !== __rspack_external_node_path_c5b9b54f.resolve(inspection.fromRoot)) publicRoots.push(inspection.fromManifest);
|
|
9444
9642
|
const rawRef = String(thisResource);
|
|
9445
9643
|
const looksLikeRootRef = rawRef.startsWith('/') && !rawRef.startsWith('//') && !(projectPath && rawRef.startsWith(projectPath));
|
|
9446
9644
|
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
9645
|
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
|
-
|
|
9646
|
+
const relFromManifest = isInsideDir(joined, manifestDir) ? __rspack_external_node_path_c5b9b54f.relative(manifestDir, joined) : '';
|
|
9647
|
+
const relFromProject = isInsideDir(joined, projectPath) ? __rspack_external_node_path_c5b9b54f.relative(projectPath, joined) : '';
|
|
9648
|
+
const trimmedRootRef = looksLikeRootRef ? rawRef.replace(/^\/+/, '') : '';
|
|
9649
|
+
const relativeRef = __rspack_external_node_path_c5b9b54f.isAbsolute(rawRef) || rawRef.startsWith('public/') ? '' : rawRef;
|
|
9650
|
+
const candidates = [
|
|
9651
|
+
joined
|
|
9652
|
+
];
|
|
9653
|
+
for (const publicRoot of publicRoots){
|
|
9654
|
+
const rels = [
|
|
9655
|
+
relFromManifest,
|
|
9656
|
+
trimmedRootRef,
|
|
9657
|
+
relativeRef
|
|
9658
|
+
];
|
|
9659
|
+
if (publicRoot === inspection.fromRoot) rels.push(relFromProject);
|
|
9660
|
+
for (const rel of rels)if (rel) candidates.push(__rspack_external_node_path_c5b9b54f.join(publicRoot, rel));
|
|
9661
|
+
}
|
|
9662
|
+
const abs = firstExisting(candidates) || joined;
|
|
9663
|
+
const isUnderPublic = publicRoots.some((publicRoot)=>{
|
|
9664
|
+
if (!isInsideDir(abs, publicRoot)) return false;
|
|
9665
|
+
return !inspection.bothExist || publicRoot === inspection.fromRoot;
|
|
9666
|
+
});
|
|
9457
9667
|
return {
|
|
9458
9668
|
abs,
|
|
9459
|
-
isUnderPublic
|
|
9669
|
+
isUnderPublic,
|
|
9460
9670
|
isPublicRoot
|
|
9461
9671
|
};
|
|
9462
9672
|
}
|
|
@@ -9541,7 +9751,6 @@ function processJsonAssets(compilation, manifestPath, includeList) {
|
|
|
9541
9751
|
}
|
|
9542
9752
|
}
|
|
9543
9753
|
function trackJsonDependencies(compilation, manifestPath, includeList) {
|
|
9544
|
-
if (compilation.errors?.length) return;
|
|
9545
9754
|
const jsonFields = includeList || {};
|
|
9546
9755
|
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
9547
9756
|
const projectPath = compilation.compiler.options.context || compilation.options.context || manifestDir;
|
|
@@ -9553,7 +9762,11 @@ function trackJsonDependencies(compilation, manifestPath, includeList) {
|
|
|
9553
9762
|
];
|
|
9554
9763
|
for (const thisResource of resourceArr)if (thisResource) {
|
|
9555
9764
|
const { abs } = resolveJsonResource(thisResource, manifestDir, projectPath);
|
|
9556
|
-
if (__rspack_external_node_fs_5ea92f0c.existsSync(abs)
|
|
9765
|
+
if (!__rspack_external_node_fs_5ea92f0c.existsSync(abs)) {
|
|
9766
|
+
compilation.missingDependencies?.add(abs);
|
|
9767
|
+
continue;
|
|
9768
|
+
}
|
|
9769
|
+
if (!compilation.fileDependencies.has(abs)) {
|
|
9557
9770
|
compilation.fileDependencies.add(abs);
|
|
9558
9771
|
added++;
|
|
9559
9772
|
}
|
|
@@ -9669,9 +9882,8 @@ function processLocaleAssets(compiler, compilation, manifestPath) {
|
|
|
9669
9882
|
const resolvedLocalesRoot = resolveLocalesFolder(manifestPath, projectRoot);
|
|
9670
9883
|
let emittedCount = 0;
|
|
9671
9884
|
let missingCount = 0;
|
|
9672
|
-
for (const
|
|
9673
|
-
const
|
|
9674
|
-
const thisResource = resource;
|
|
9885
|
+
for (const thisResource of localesFields || []){
|
|
9886
|
+
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
9887
|
if (thisResource) {
|
|
9676
9888
|
if ('.json' !== __rspack_external_node_path_c5b9b54f.extname(thisResource)) continue;
|
|
9677
9889
|
if (!__rspack_external_node_fs_5ea92f0c.existsSync(thisResource)) {
|
|
@@ -9697,10 +9909,13 @@ function processLocaleAssets(compiler, compilation, manifestPath) {
|
|
|
9697
9909
|
if (isDebug()) console.log(localesEmitSummary(emittedCount, missingCount, discoveredList.length));
|
|
9698
9910
|
}
|
|
9699
9911
|
function trackLocaleDependencies(compilation, manifestPath, projectRoot) {
|
|
9700
|
-
if (compilation.errors?.length) return;
|
|
9701
9912
|
const localesFields = getLocales(manifestPath, projectRoot) || [];
|
|
9702
9913
|
let added = 0;
|
|
9703
|
-
for (const thisResource of localesFields)if (
|
|
9914
|
+
for (const thisResource of localesFields)if ('.json' === __rspack_external_node_path_c5b9b54f.extname(thisResource)) {
|
|
9915
|
+
if (!__rspack_external_node_fs_5ea92f0c.existsSync(thisResource)) {
|
|
9916
|
+
compilation.missingDependencies?.add(thisResource);
|
|
9917
|
+
continue;
|
|
9918
|
+
}
|
|
9704
9919
|
if (!compilation.fileDependencies.has(thisResource)) {
|
|
9705
9920
|
compilation.fileDependencies.add(thisResource);
|
|
9706
9921
|
added++;
|
|
@@ -9708,6 +9923,38 @@ function trackLocaleDependencies(compilation, manifestPath, projectRoot) {
|
|
|
9708
9923
|
}
|
|
9709
9924
|
if (isDebug()) console.log(localesDepsTracked(added));
|
|
9710
9925
|
}
|
|
9926
|
+
const MSG_REFERENCE = /__MSG_([A-Za-z0-9_@]+?)__/g;
|
|
9927
|
+
function collectMsgReferences(value) {
|
|
9928
|
+
const found = [];
|
|
9929
|
+
const seen = new Set();
|
|
9930
|
+
const visit = (node)=>{
|
|
9931
|
+
if ('string' == typeof node) {
|
|
9932
|
+
MSG_REFERENCE.lastIndex = 0;
|
|
9933
|
+
let match = MSG_REFERENCE.exec(node);
|
|
9934
|
+
while(null !== match){
|
|
9935
|
+
const name = match[1];
|
|
9936
|
+
if (name && !name.startsWith('@@') && !seen.has(name)) {
|
|
9937
|
+
seen.add(name);
|
|
9938
|
+
found.push(name);
|
|
9939
|
+
}
|
|
9940
|
+
match = MSG_REFERENCE.exec(node);
|
|
9941
|
+
}
|
|
9942
|
+
return;
|
|
9943
|
+
}
|
|
9944
|
+
if (Array.isArray(node)) {
|
|
9945
|
+
for (const item of node)visit(item);
|
|
9946
|
+
return;
|
|
9947
|
+
}
|
|
9948
|
+
if (node && 'object' == typeof node) for (const item of Object.values(node))visit(item);
|
|
9949
|
+
};
|
|
9950
|
+
visit(value);
|
|
9951
|
+
return found;
|
|
9952
|
+
}
|
|
9953
|
+
function findUndefinedMsgReferences(value, catalogKeys) {
|
|
9954
|
+
const lower = new Set();
|
|
9955
|
+
for (const key of catalogKeys)lower.add(String(key).toLowerCase());
|
|
9956
|
+
return collectMsgReferences(value).filter((name)=>!lower.has(name.toLowerCase()));
|
|
9957
|
+
}
|
|
9711
9958
|
function pushCompilationError(compiler, compilation, name, message, file) {
|
|
9712
9959
|
const ErrorConstructor = compiler?.rspack?.WebpackError || Error;
|
|
9713
9960
|
const error = new ErrorConstructor(message);
|
|
@@ -9767,26 +10014,11 @@ function validateLocales(compiler, compilation, manifestPath) {
|
|
|
9767
10014
|
}
|
|
9768
10015
|
try {
|
|
9769
10016
|
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);
|
|
10017
|
+
const referenced = findUndefinedMsgReferences(manifest, Object.keys(dict || {}).filter((key)=>'string' == typeof dict?.[key]?.message));
|
|
9783
10018
|
for (const key of referenced){
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
pushCompilationError(compiler, compilation, 'LocalesValidationError', missingManifestMessageKey(key, defaultLocale), 'manifest.json');
|
|
9788
|
-
return false;
|
|
9789
|
-
}
|
|
10019
|
+
if (isDebug()) console.log(localesValidationDetected(`missing key "${key}" in default locale`));
|
|
10020
|
+
pushCompilationError(compiler, compilation, 'LocalesValidationError', missingManifestMessageKey(key, defaultLocale), 'manifest.json');
|
|
10021
|
+
return false;
|
|
9790
10022
|
}
|
|
9791
10023
|
} catch (error) {
|
|
9792
10024
|
if (isDebug()) console.log(localesValidationDetected(`could not scan __MSG__ placeholders in _locales/${defaultLocale}/messages.json: ${String(error?.message || error)}`));
|
|
@@ -9919,6 +10151,12 @@ function manifestDepsTracked(addedCount) {
|
|
|
9919
10151
|
function manifestLegacyWarningsSummary(count) {
|
|
9920
10152
|
return `${messaging_prefix('debug')} manifest legacyWarnings=${String(count)}`;
|
|
9921
10153
|
}
|
|
10154
|
+
function pageActionNotSupportedByBrowser(browser) {
|
|
10155
|
+
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.`;
|
|
10156
|
+
}
|
|
10157
|
+
function pageActionDroppedForBrowserAction(browser) {
|
|
10158
|
+
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.`;
|
|
10159
|
+
}
|
|
9922
10160
|
class AddDependencies {
|
|
9923
10161
|
dependencyList;
|
|
9924
10162
|
constructor(dependencyList){
|
|
@@ -10025,7 +10263,18 @@ function loosenConnectSrcForDev(csp) {
|
|
|
10025
10263
|
...devSources
|
|
10026
10264
|
]);
|
|
10027
10265
|
}
|
|
10266
|
+
function keepSiblingSlots(policy, extensionPages) {
|
|
10267
|
+
if (policy && 'object' == typeof policy && !Array.isArray(policy)) return {
|
|
10268
|
+
...policy,
|
|
10269
|
+
extension_pages: extensionPages
|
|
10270
|
+
};
|
|
10271
|
+
return extensionPages;
|
|
10272
|
+
}
|
|
10028
10273
|
function patchV2CSP(manifest) {
|
|
10274
|
+
const authored = manifest.content_security_policy;
|
|
10275
|
+
return keepSiblingSlots(authored, patchV2PagesPolicy(manifest));
|
|
10276
|
+
}
|
|
10277
|
+
function patchV2PagesPolicy(manifest) {
|
|
10029
10278
|
const policy = resolveV2Policy(manifest.content_security_policy);
|
|
10030
10279
|
if (!policy) return buildCSP({
|
|
10031
10280
|
"script-src": [
|
|
@@ -10079,7 +10328,8 @@ function patchV3CSP(manifest) {
|
|
|
10079
10328
|
]
|
|
10080
10329
|
})
|
|
10081
10330
|
};
|
|
10082
|
-
const
|
|
10331
|
+
const extensionPages = 'string' == typeof policy ? policy : policy.extension_pages;
|
|
10332
|
+
const csp = content_security_policy_parser('string' == typeof extensionPages ? extensionPages : '');
|
|
10083
10333
|
const defaultDirectives = {
|
|
10084
10334
|
"script-src": [
|
|
10085
10335
|
"'self'"
|
|
@@ -10092,9 +10342,7 @@ function patchV3CSP(manifest) {
|
|
|
10092
10342
|
loosenConnectSrcForDev(csp);
|
|
10093
10343
|
const cspObject = Object.fromEntries(csp.entries());
|
|
10094
10344
|
const extensionPagesPolicy = buildCSP(cspObject);
|
|
10095
|
-
return
|
|
10096
|
-
extension_pages: extensionPagesPolicy
|
|
10097
|
-
};
|
|
10345
|
+
return keepSiblingSlots(policy, extensionPagesPolicy);
|
|
10098
10346
|
}
|
|
10099
10347
|
function patchExternallyConnectable(manifest) {
|
|
10100
10348
|
if (manifest.externally_connectable && !manifest.externally_connectable.ids) return {
|
|
@@ -10211,13 +10459,16 @@ function findInjectedOnlyPermissionUses(compilation, declared, injected) {
|
|
|
10211
10459
|
class ApplyDevDefaults {
|
|
10212
10460
|
manifestPath;
|
|
10213
10461
|
browser;
|
|
10462
|
+
devSession;
|
|
10214
10463
|
constructor(options){
|
|
10215
10464
|
this.manifestPath = options.manifestPath;
|
|
10216
10465
|
this.browser = options.browser || 'chrome';
|
|
10466
|
+
this.devSession = options.devSession;
|
|
10217
10467
|
}
|
|
10218
10468
|
apply(compiler) {
|
|
10219
10469
|
if (!compiler?.hooks?.thisCompilation) return;
|
|
10220
10470
|
if ('development' !== compiler.options.mode) return;
|
|
10471
|
+
if (false === this.devSession) return;
|
|
10221
10472
|
compiler.hooks.thisCompilation.tap('manifest:apply-dev-defaults', (compilation)=>{
|
|
10222
10473
|
if (!compilation?.hooks?.processAssets) return;
|
|
10223
10474
|
compilation.hooks.processAssets.tap({
|
|
@@ -10243,6 +10494,31 @@ class ApplyDevDefaults {
|
|
|
10243
10494
|
])
|
|
10244
10495
|
]
|
|
10245
10496
|
} : {};
|
|
10497
|
+
const pushDevWarning = (name, text)=>{
|
|
10498
|
+
const WebpackErrorCtor = compiler.rspack?.WebpackError;
|
|
10499
|
+
const warning = WebpackErrorCtor ? new WebpackErrorCtor(text) : new Error(text);
|
|
10500
|
+
warning.name = name;
|
|
10501
|
+
if (!compilation.warnings) compilation.warnings = [];
|
|
10502
|
+
compilation.warnings.push(warning);
|
|
10503
|
+
};
|
|
10504
|
+
const optionalPermissions = new Set(canonicalManifest.optional_permissions || []);
|
|
10505
|
+
const optionalHosts = new Set([
|
|
10506
|
+
...canonicalManifest.optional_host_permissions || [],
|
|
10507
|
+
...3 === canonicalManifest.manifest_version ? [] : [
|
|
10508
|
+
...optionalPermissions
|
|
10509
|
+
]
|
|
10510
|
+
]);
|
|
10511
|
+
const devInjectedPermissions = 3 === canonicalManifest.manifest_version ? [
|
|
10512
|
+
"scripting",
|
|
10513
|
+
'tabs',
|
|
10514
|
+
'management',
|
|
10515
|
+
'storage'
|
|
10516
|
+
] : [
|
|
10517
|
+
'tabs',
|
|
10518
|
+
'storage'
|
|
10519
|
+
];
|
|
10520
|
+
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.`);
|
|
10521
|
+
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
10522
|
const patchedManifest = {
|
|
10247
10523
|
...canonicalManifest,
|
|
10248
10524
|
content_security_policy: 3 === canonicalManifest.manifest_version ? patchV3CSP(canonicalManifest) : patchV2CSP(canonicalManifest),
|
|
@@ -10272,20 +10548,15 @@ class ApplyDevDefaults {
|
|
|
10272
10548
|
web_accessible_resources: 3 === canonicalManifest.manifest_version ? patchWebResourcesV3(canonicalManifest) : patchWebResourcesV2(canonicalManifest)
|
|
10273
10549
|
};
|
|
10274
10550
|
try {
|
|
10275
|
-
const declared = new Set([
|
|
10276
|
-
...canonicalManifest.permissions || [],
|
|
10277
|
-
...canonicalManifest.optional_permissions || []
|
|
10278
|
-
]);
|
|
10551
|
+
const declared = new Set(canonicalManifest.permissions || []);
|
|
10279
10552
|
const injectedForEra = 3 === canonicalManifest.manifest_version ? INJECTED_PERMISSION_APIS : [
|
|
10280
10553
|
'storage'
|
|
10281
10554
|
];
|
|
10282
10555
|
const uses = findInjectedOnlyPermissionUses(compilation, declared, injectedForEra);
|
|
10283
10556
|
for (const [api, file] of uses){
|
|
10284
|
-
const
|
|
10285
|
-
const text = `manifest.json
|
|
10286
|
-
|
|
10287
|
-
warning.name = 'DevInjectedPermissionWarning';
|
|
10288
|
-
compilation.warnings.push(warning);
|
|
10557
|
+
const relative = __rspack_external_path.relative(__rspack_external_path.dirname(this.manifestPath), file);
|
|
10558
|
+
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.`;
|
|
10559
|
+
pushDevWarning('DevInjectedPermissionWarning', text);
|
|
10289
10560
|
}
|
|
10290
10561
|
} catch {}
|
|
10291
10562
|
const source = JSON.stringify(patchedManifest, null, 2);
|
|
@@ -10448,8 +10719,8 @@ function collectReferencedRuntimePayloads(source, emittedAssetNames) {
|
|
|
10448
10719
|
const found = new Set();
|
|
10449
10720
|
const patternHits = source.match(EMITTED_ASSET_REF_PATTERN) || [];
|
|
10450
10721
|
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(
|
|
10722
|
+
const eligible = emittedAssetNames.map((name)=>unixify(name)).filter((name)=>!isExcludedFromWar(name)).sort((a, b)=>b.length - a.length);
|
|
10723
|
+
for (const asset of eligible)if (source.includes(asset)) found.add(asset);
|
|
10453
10724
|
return Array.from(found);
|
|
10454
10725
|
}
|
|
10455
10726
|
function forEachStringKey(objectOrMap, callback) {
|
|
@@ -10474,6 +10745,33 @@ function getAssetSource(compilation, filename) {
|
|
|
10474
10745
|
if ('string' == typeof src) return src;
|
|
10475
10746
|
return '';
|
|
10476
10747
|
}
|
|
10748
|
+
function collectContentScriptAsyncChunkFiles(compilation) {
|
|
10749
|
+
const result = {};
|
|
10750
|
+
if ('function' != typeof compilation.entrypoints?.forEach) return result;
|
|
10751
|
+
compilation.entrypoints.forEach((entry, entryName)=>{
|
|
10752
|
+
if (!String(entryName).startsWith("content_scripts/")) return;
|
|
10753
|
+
const initial = new Set();
|
|
10754
|
+
for (const chunk of toFileArray(entry.chunks))for (const file of toFileArray(chunk.files))initial.add(file);
|
|
10755
|
+
const asyncFiles = new Set();
|
|
10756
|
+
const visitChunk = (chunk)=>{
|
|
10757
|
+
for (const file of toFileArray(chunk.files))if (!(!file.endsWith('.js') || initial.has(file))) asyncFiles.add(unixify(file));
|
|
10758
|
+
};
|
|
10759
|
+
for (const chunk of toFileArray(entry.chunks)){
|
|
10760
|
+
const withAsync = chunk;
|
|
10761
|
+
if ('function' == typeof withAsync.getAllAsyncChunks) for (const asyncChunk of withAsync.getAllAsyncChunks())visitChunk(asyncChunk);
|
|
10762
|
+
}
|
|
10763
|
+
const seenGroups = new Set();
|
|
10764
|
+
const visitGroup = (group)=>{
|
|
10765
|
+
if (seenGroups.has(group)) return;
|
|
10766
|
+
seenGroups.add(group);
|
|
10767
|
+
for (const chunk of toFileArray(group.chunks))visitChunk(chunk);
|
|
10768
|
+
if ('function' == typeof group.getChildren) for (const child of group.getChildren())visitGroup(child);
|
|
10769
|
+
};
|
|
10770
|
+
if ('function' == typeof entry.getChildren) for (const child of entry.getChildren?.() || [])visitGroup(child);
|
|
10771
|
+
if (asyncFiles.size > 0) result[entryName] = Array.from(asyncFiles).sort();
|
|
10772
|
+
});
|
|
10773
|
+
return result;
|
|
10774
|
+
}
|
|
10477
10775
|
function collectContentScriptEntryImports(compilation, includeList) {
|
|
10478
10776
|
const entryImports = {};
|
|
10479
10777
|
const contentEntryNames = new Set(Object.keys(includeList || {}).filter((k)=>k.startsWith("content_scripts")));
|
|
@@ -10970,6 +11268,14 @@ function generateManifestPatches(compilation, manifestPath, entryImports, browse
|
|
|
10970
11268
|
});
|
|
10971
11269
|
}
|
|
10972
11270
|
}
|
|
11271
|
+
const asyncChunks = collectContentScriptAsyncChunkFiles(compilation);
|
|
11272
|
+
for (const [entryName, chunkFiles] of Object.entries(asyncChunks)){
|
|
11273
|
+
const contentScript = canonicalManifest.content_scripts?.find((script)=>script.js?.some((jsFile)=>jsFile.includes(entryName)));
|
|
11274
|
+
if (contentScript) {
|
|
11275
|
+
if (3 === canonicalManifest.manifest_version) mergeIntoV3Group(webAccessibleResourcesV3, cleanMatches(contentScript.matches || []), chunkFiles);
|
|
11276
|
+
else for (const file of chunkFiles)if (!webAccessibleResourcesV2.includes(file)) webAccessibleResourcesV2.push(file);
|
|
11277
|
+
}
|
|
11278
|
+
}
|
|
10973
11279
|
if (3 === canonicalManifest.manifest_version) {
|
|
10974
11280
|
const assetKeys = Object.keys(compilation.assets || {});
|
|
10975
11281
|
const staticAssets = assetKeys.filter((k)=>k.startsWith('assets/')).filter((k)=>!k.endsWith('.js') && !k.endsWith('.map')).sort();
|
|
@@ -11090,7 +11396,7 @@ function normalizeManifestFile(filePath) {
|
|
|
11090
11396
|
if ('string' != typeof filePath) return;
|
|
11091
11397
|
const normalized = filePath.trim().replace(/^\/+/, '');
|
|
11092
11398
|
if (!normalized) return;
|
|
11093
|
-
if (
|
|
11399
|
+
if (isManifestAddress(filePath)) return;
|
|
11094
11400
|
if (/[*?[\]{}]/.test(normalized)) return;
|
|
11095
11401
|
return normalized;
|
|
11096
11402
|
}
|
|
@@ -11116,6 +11422,10 @@ function collectRequiredManifestFiles(manifest) {
|
|
|
11116
11422
|
addFile(manifestObj?.chrome_url_overrides?.newtab);
|
|
11117
11423
|
addFile(manifestObj?.chrome_url_overrides?.history);
|
|
11118
11424
|
addFile(manifestObj?.chrome_url_overrides?.bookmarks);
|
|
11425
|
+
addFile(manifestObj?.theme_experiment?.stylesheet);
|
|
11426
|
+
addFile(manifestObj?.chrome_settings_overrides?.search_provider?.favicon_url);
|
|
11427
|
+
const startupPages = manifestObj?.chrome_settings_overrides?.startup_pages;
|
|
11428
|
+
if (Array.isArray(startupPages)) for (const page of startupPages)addFile(page);
|
|
11119
11429
|
const contentScripts = manifestObj?.content_scripts;
|
|
11120
11430
|
if (Array.isArray(contentScripts)) for (const contentScript of contentScripts){
|
|
11121
11431
|
const js = contentScript?.js;
|
|
@@ -11177,6 +11487,7 @@ class PersistManifestToDisk {
|
|
|
11177
11487
|
const requiredFiles = collectRequiredManifestFiles(manifest);
|
|
11178
11488
|
const missingFiles = findMissingFilesOnDisk(outputPath, requiredFiles);
|
|
11179
11489
|
if (missingFiles.length > 0) {
|
|
11490
|
+
if (isCompilerRestarting(compiler)) return;
|
|
11180
11491
|
const sample = missingFiles.slice(0, 5).join('\n - ');
|
|
11181
11492
|
const more = missingFiles.length > 5 ? `\n ... and ${missingFiles.length - 5} more` : '';
|
|
11182
11493
|
const err = new core.WebpackError([
|
|
@@ -12350,11 +12661,14 @@ class UpdateManifest {
|
|
|
12350
12661
|
}, ()=>{
|
|
12351
12662
|
if (compilation.errors.length > 0) return;
|
|
12352
12663
|
const manifest = getManifestContent(compilation, this.manifestPath);
|
|
12353
|
-
|
|
12664
|
+
const dropReason = pageActionDropReason(filterKeysForThisBrowser(manifest, this.browser), this.browser);
|
|
12665
|
+
if (dropReason) reportToCompilation(compilation, compiler, 'conflicts' === dropReason ? pageActionDroppedForBrowserAction(String(this.browser)) : pageActionNotSupportedByBrowser(String(this.browser)), 'warning', 'manifest.json');
|
|
12666
|
+
const projectPath = compiler.options.context || __rspack_external_node_path_c5b9b54f.dirname(this.manifestPath);
|
|
12667
|
+
let patchedManifest = buildCanonicalManifest(this.manifestPath, manifest, this.browser, projectPath);
|
|
12354
12668
|
patchedManifest = patchGeckoBackground(patchedManifest, this.browser);
|
|
12355
12669
|
patchedManifest = patchChromiumBackground(patchedManifest, this.browser);
|
|
12356
12670
|
patchedManifest = patchChromiumThemeColors(patchedManifest, this.browser);
|
|
12357
|
-
const overrides = getManifestOverrides(this.manifestPath, manifest);
|
|
12671
|
+
const overrides = getManifestOverrides(this.manifestPath, manifest, projectPath);
|
|
12358
12672
|
if ('development' === compiler.options.mode) {
|
|
12359
12673
|
if (patchedManifest.content_scripts) patchedManifest.content_scripts = this.applyDevOverrides(patchedManifest);
|
|
12360
12674
|
patchedManifest = patchDevContentScriptManifestPaths(compilation, patchedManifest);
|
|
@@ -12437,10 +12751,12 @@ class ManifestPlugin {
|
|
|
12437
12751
|
manifestPath;
|
|
12438
12752
|
browser;
|
|
12439
12753
|
includeList;
|
|
12754
|
+
devSession;
|
|
12440
12755
|
constructor(options){
|
|
12441
12756
|
this.manifestPath = options.manifestPath;
|
|
12442
12757
|
this.browser = options.browser || 'chrome';
|
|
12443
12758
|
this.includeList = options.includeList;
|
|
12759
|
+
this.devSession = options.devSession;
|
|
12444
12760
|
}
|
|
12445
12761
|
apply(compiler) {
|
|
12446
12762
|
if (isDebug()) console.log(manifestIncludeSummary(String(this.browser || 'chrome'), this.manifestPath));
|
|
@@ -12462,7 +12778,8 @@ class ManifestPlugin {
|
|
|
12462
12778
|
}).apply(compiler);
|
|
12463
12779
|
new ApplyDevDefaults({
|
|
12464
12780
|
manifestPath: this.manifestPath,
|
|
12465
|
-
browser: this.browser
|
|
12781
|
+
browser: this.browser,
|
|
12782
|
+
devSession: this.devSession
|
|
12466
12783
|
}).apply(compiler);
|
|
12467
12784
|
new PersistManifestToDisk().apply(compiler);
|
|
12468
12785
|
new AddDependencies([
|
|
@@ -13059,9 +13376,7 @@ function discoverDevtoolsPanelPages(manifestPath) {
|
|
|
13059
13376
|
}
|
|
13060
13377
|
return pages;
|
|
13061
13378
|
}
|
|
13062
|
-
|
|
13063
|
-
return key.startsWith('declarative_net_request') || 'storage.managed_schema' === key;
|
|
13064
|
-
}
|
|
13379
|
+
const isCriticalJsonFeatureKey = isCriticalJsonFeature;
|
|
13065
13380
|
function toComparablePath(value) {
|
|
13066
13381
|
return 'string' == typeof value ? value : JSON.stringify(value);
|
|
13067
13382
|
}
|
|
@@ -13110,7 +13425,7 @@ class ManifestFieldsChangeDetector {
|
|
|
13110
13425
|
this.browser = options.browser || 'chrome';
|
|
13111
13426
|
}
|
|
13112
13427
|
readSnapshot() {
|
|
13113
|
-
const fields =
|
|
13428
|
+
const fields = getResolvedManifestFieldsData({
|
|
13114
13429
|
manifestPath: this.manifestPath,
|
|
13115
13430
|
browser: this.browser
|
|
13116
13431
|
});
|
|
@@ -13160,6 +13475,11 @@ class ManifestFieldsChangeDetector {
|
|
|
13160
13475
|
if (htmlDiff) this.pending.html = htmlDiff;
|
|
13161
13476
|
if (iconsDiff) this.pending.icons = iconsDiff;
|
|
13162
13477
|
if (jsonDiff) this.pending.json = jsonDiff;
|
|
13478
|
+
if (this.tryAutoRestart(compiler)) {
|
|
13479
|
+
this.pending = {};
|
|
13480
|
+
done();
|
|
13481
|
+
return;
|
|
13482
|
+
}
|
|
13163
13483
|
this.prev = next;
|
|
13164
13484
|
done();
|
|
13165
13485
|
} catch {
|
|
@@ -13176,6 +13496,24 @@ class ManifestFieldsChangeDetector {
|
|
|
13176
13496
|
});
|
|
13177
13497
|
});
|
|
13178
13498
|
}
|
|
13499
|
+
tryAutoRestart(compiler) {
|
|
13500
|
+
const order = [
|
|
13501
|
+
"scripts",
|
|
13502
|
+
'html',
|
|
13503
|
+
'icons',
|
|
13504
|
+
'json'
|
|
13505
|
+
];
|
|
13506
|
+
for (const reason of order){
|
|
13507
|
+
const change = this.pending[reason];
|
|
13508
|
+
if (change) return requestDevSessionRestart(compiler, {
|
|
13509
|
+
reason,
|
|
13510
|
+
pathAfter: change.pathAfter,
|
|
13511
|
+
pathBefore: change.pathBefore,
|
|
13512
|
+
manifestField: change.manifestField
|
|
13513
|
+
});
|
|
13514
|
+
}
|
|
13515
|
+
return false;
|
|
13516
|
+
}
|
|
13179
13517
|
emitErrors(compilation) {
|
|
13180
13518
|
if (this.pending.scripts) {
|
|
13181
13519
|
const p = this.pending.scripts;
|
|
@@ -13212,23 +13550,81 @@ class ManifestFieldsChangeDetector {
|
|
|
13212
13550
|
}
|
|
13213
13551
|
}
|
|
13214
13552
|
}
|
|
13553
|
+
function readManifest(manifestPath) {
|
|
13554
|
+
try {
|
|
13555
|
+
return JSON.parse(stripBom(__rspack_external_node_fs_5ea92f0c.readFileSync(manifestPath, 'utf8')));
|
|
13556
|
+
} catch {
|
|
13557
|
+
return {};
|
|
13558
|
+
}
|
|
13559
|
+
}
|
|
13560
|
+
function isPublicSpelling(value) {
|
|
13561
|
+
return /^(?:\/public\/|(?:\.\/)?public\/)/i.test(value);
|
|
13562
|
+
}
|
|
13563
|
+
function resolveAsset(manifestDir, value) {
|
|
13564
|
+
if (isPublicSpelling(value) || value.startsWith('/')) return value;
|
|
13565
|
+
return __rspack_external_node_path_c5b9b54f.isAbsolute(value) ? value : __rspack_external_node_path_c5b9b54f.join(manifestDir, value);
|
|
13566
|
+
}
|
|
13567
|
+
function localFile(manifestDir, value) {
|
|
13568
|
+
if ('string' != typeof value || !value.trim()) return;
|
|
13569
|
+
if (isManifestAddress(value) || isPublicSpelling(value)) return;
|
|
13570
|
+
const resolved = resolveAsset(manifestDir, value);
|
|
13571
|
+
if (resolved.startsWith('/') && !__rspack_external_node_path_c5b9b54f.isAbsolute(resolved)) return;
|
|
13572
|
+
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;
|
|
13573
|
+
return resolved.startsWith('/') && !__rspack_external_node_fs_5ea92f0c.existsSync(resolved) ? __rspack_external_node_path_c5b9b54f.join(manifestDir, resolved.slice(1)) : resolved;
|
|
13574
|
+
}
|
|
13575
|
+
function themeExperimentStylesheetEntries(manifestPath) {
|
|
13576
|
+
const manifest = readManifest(manifestPath);
|
|
13577
|
+
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
13578
|
+
const file = localFile(manifestDir, manifest.theme_experiment?.stylesheet);
|
|
13579
|
+
if (!file) return {};
|
|
13580
|
+
const name = __rspack_external_node_path_c5b9b54f.basename(file).replace(/\.[^.]+$/, '');
|
|
13581
|
+
return {
|
|
13582
|
+
[`theme_experiment/${name}`]: [
|
|
13583
|
+
file
|
|
13584
|
+
]
|
|
13585
|
+
};
|
|
13586
|
+
}
|
|
13587
|
+
function settingsOverridesIconFields(manifestPath) {
|
|
13588
|
+
const manifest = readManifest(manifestPath);
|
|
13589
|
+
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
13590
|
+
const fav = manifest.chrome_settings_overrides?.search_provider?.favicon_url;
|
|
13591
|
+
if ('string' != typeof fav || !fav.trim() || isManifestAddress(fav)) return {};
|
|
13592
|
+
return {
|
|
13593
|
+
'chrome_settings_overrides/favicon_url': resolveAsset(manifestDir, fav)
|
|
13594
|
+
};
|
|
13595
|
+
}
|
|
13596
|
+
function settingsOverridesStartupPages(manifestPath) {
|
|
13597
|
+
const manifest = readManifest(manifestPath);
|
|
13598
|
+
const manifestDir = __rspack_external_node_path_c5b9b54f.dirname(manifestPath);
|
|
13599
|
+
const pages = manifest.chrome_settings_overrides?.startup_pages;
|
|
13600
|
+
if (!Array.isArray(pages)) return {};
|
|
13601
|
+
const out = {};
|
|
13602
|
+
pages.forEach((page, index)=>{
|
|
13603
|
+
const file = localFile(manifestDir, page);
|
|
13604
|
+
if (file) out[`chrome_settings_overrides/startup-${index}`] = file;
|
|
13605
|
+
});
|
|
13606
|
+
return out;
|
|
13607
|
+
}
|
|
13215
13608
|
class plugin_web_extension_WebExtensionPlugin {
|
|
13216
13609
|
static name = 'plugin-extension';
|
|
13217
13610
|
manifestPath;
|
|
13218
13611
|
browser;
|
|
13612
|
+
devSession;
|
|
13219
13613
|
constructor(options){
|
|
13220
13614
|
this.manifestPath = options.manifestPath;
|
|
13221
13615
|
this.browser = options.browser || 'chrome';
|
|
13616
|
+
this.devSession = options.devSession;
|
|
13222
13617
|
}
|
|
13223
13618
|
apply(compiler) {
|
|
13224
13619
|
const manifestPath = this.manifestPath;
|
|
13225
|
-
const manifestFieldsData =
|
|
13620
|
+
const manifestFieldsData = getResolvedManifestFieldsData({
|
|
13226
13621
|
manifestPath,
|
|
13227
13622
|
browser: this.browser
|
|
13228
13623
|
});
|
|
13229
13624
|
const specialFoldersData = getSpecialFoldersDataForCompiler(compiler);
|
|
13230
13625
|
new ManifestPlugin({
|
|
13231
13626
|
browser: this.browser,
|
|
13627
|
+
devSession: this.devSession,
|
|
13232
13628
|
manifestPath,
|
|
13233
13629
|
includeList: {
|
|
13234
13630
|
...manifestFieldsData.html,
|
|
@@ -13238,11 +13634,13 @@ class plugin_web_extension_WebExtensionPlugin {
|
|
|
13238
13634
|
}
|
|
13239
13635
|
}).apply(compiler);
|
|
13240
13636
|
new HtmlPlugin({
|
|
13637
|
+
devSession: this.devSession,
|
|
13241
13638
|
manifestPath,
|
|
13242
13639
|
browser: this.browser,
|
|
13243
13640
|
includeList: {
|
|
13244
13641
|
...manifestFieldsData.html,
|
|
13245
13642
|
...discoverDevtoolsPanelPages(manifestPath),
|
|
13643
|
+
...settingsOverridesStartupPages(manifestPath),
|
|
13246
13644
|
...specialFoldersData.pages
|
|
13247
13645
|
}
|
|
13248
13646
|
}).apply(compiler);
|
|
@@ -13251,7 +13649,8 @@ class plugin_web_extension_WebExtensionPlugin {
|
|
|
13251
13649
|
browser: this.browser,
|
|
13252
13650
|
includeList: {
|
|
13253
13651
|
...manifestFieldsData.scripts,
|
|
13254
|
-
...specialFoldersData.scripts
|
|
13652
|
+
...specialFoldersData.scripts,
|
|
13653
|
+
...themeExperimentStylesheetEntries(manifestPath)
|
|
13255
13654
|
}
|
|
13256
13655
|
}).apply(compiler);
|
|
13257
13656
|
new LocalesPlugin({
|
|
@@ -13266,7 +13665,9 @@ class plugin_web_extension_WebExtensionPlugin {
|
|
|
13266
13665
|
manifestPath,
|
|
13267
13666
|
includeList: {
|
|
13268
13667
|
...manifestFieldsData.icons,
|
|
13269
|
-
...
|
|
13668
|
+
...themeImageFields(manifestPath),
|
|
13669
|
+
...omniboxIconFields(manifestPath),
|
|
13670
|
+
...settingsOverridesIconFields(manifestPath)
|
|
13270
13671
|
},
|
|
13271
13672
|
browser: this.browser
|
|
13272
13673
|
}).apply(compiler);
|
|
@@ -13286,6 +13687,7 @@ class plugin_web_extension_WebExtensionPlugin {
|
|
|
13286
13687
|
function webpackConfig(projectStructure, devOptions) {
|
|
13287
13688
|
const { manifestPath } = projectStructure;
|
|
13288
13689
|
const { packageJsonDir } = getDirs(projectStructure);
|
|
13690
|
+
const devSession = devOptions.metadataCommand ? 'dev' === devOptions.metadataCommand : 'development' === (devOptions.mode || 'development');
|
|
13289
13691
|
let rawManifest;
|
|
13290
13692
|
try {
|
|
13291
13693
|
rawManifest = JSON.parse(stripBom(__rspack_external_node_fs_5ea92f0c.readFileSync(manifestPath, 'utf-8')));
|
|
@@ -13297,7 +13699,8 @@ function webpackConfig(projectStructure, devOptions) {
|
|
|
13297
13699
|
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
13700
|
const companionUnpackedExtensionDirs = resolveCompanionExtensionDirs({
|
|
13299
13701
|
projectRoot: packageJsonDir,
|
|
13300
|
-
config: devOptions.extensions
|
|
13702
|
+
config: devOptions.extensions,
|
|
13703
|
+
browser: devOptions.browser
|
|
13301
13704
|
});
|
|
13302
13705
|
const unpackedExtensionDirsToLoad = computeExtensionsToLoad(__rspack_external_node_path_c5b9b54f.resolve(__rspack_import_meta_dirname__, '..'), devOptions.mode, devOptions.browser, primaryExtensionOutputDir, companionUnpackedExtensionDirs, manifestPath);
|
|
13303
13706
|
const debug = isDebug();
|
|
@@ -13351,11 +13754,13 @@ function webpackConfig(projectStructure, devOptions) {
|
|
|
13351
13754
|
}),
|
|
13352
13755
|
new plugin_web_extension_WebExtensionPlugin({
|
|
13353
13756
|
manifestPath,
|
|
13354
|
-
browser: devOptions.browser
|
|
13757
|
+
browser: devOptions.browser,
|
|
13758
|
+
devSession
|
|
13355
13759
|
}),
|
|
13356
13760
|
new ReloadPlugin({
|
|
13357
13761
|
manifestPath,
|
|
13358
|
-
browser: devOptions.browser
|
|
13762
|
+
browser: devOptions.browser,
|
|
13763
|
+
devSession
|
|
13359
13764
|
}),
|
|
13360
13765
|
new SetupChunkLoadingTarget({
|
|
13361
13766
|
manifestPath,
|
|
@@ -13473,7 +13878,7 @@ function webpackConfig(projectStructure, devOptions) {
|
|
|
13473
13878
|
],
|
|
13474
13879
|
context: packageJsonDir,
|
|
13475
13880
|
cache: false,
|
|
13476
|
-
devtool: 'production' === (devOptions.mode || 'development') ? false :
|
|
13881
|
+
devtool: 'production' === (devOptions.mode || 'development') ? false : 'cheap-module-source-map',
|
|
13477
13882
|
output: {
|
|
13478
13883
|
clean: devOptions.output.clean,
|
|
13479
13884
|
path: primaryExtensionOutputDir,
|
|
@@ -13547,10 +13952,7 @@ function webpackConfig(projectStructure, devOptions) {
|
|
|
13547
13952
|
'node_modules',
|
|
13548
13953
|
__rspack_external_node_path_c5b9b54f.join(process.cwd(), 'node_modules')
|
|
13549
13954
|
],
|
|
13550
|
-
roots:
|
|
13551
|
-
__rspack_external_node_path_c5b9b54f.join(packageJsonDir, 'public'),
|
|
13552
|
-
__rspack_external_node_path_c5b9b54f.dirname(manifestPath)
|
|
13553
|
-
],
|
|
13955
|
+
roots: publicResolveRoots(packageJsonDir, manifestPath),
|
|
13554
13956
|
extensionAlias: {
|
|
13555
13957
|
'.js': [
|
|
13556
13958
|
'.ts',
|
|
@@ -13646,4 +14048,4 @@ function webpackConfig(projectStructure, devOptions) {
|
|
|
13646
14048
|
}
|
|
13647
14049
|
};
|
|
13648
14050
|
}
|
|
13649
|
-
export { resolveConnectableHost, rspack_config_namespaceObject, setupCompilerLifecycleHooks, setupNoBrowserBannerOnFirstDone, webpackConfig };
|
|
14051
|
+
export { DevSessionRestartScheduler, bindDevSessionRestart, resolveConnectableHost, rspack_config_namespaceObject, setupCompilerLifecycleHooks, setupNoBrowserBannerOnFirstDone, unbindDevSessionRestart, webpackConfig };
|