extension-develop 4.1.6 → 4.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/0~rspack-config.mjs
CHANGED
|
@@ -6617,6 +6617,65 @@ class WebExtensionPlugin {
|
|
|
6617
6617
|
}
|
|
6618
6618
|
}
|
|
6619
6619
|
const webpack_target_webextension_fork = WebExtensionPlugin;
|
|
6620
|
+
function getBackgroundEntryName(manifest, browser) {
|
|
6621
|
+
if (manifest.background) {
|
|
6622
|
+
if (isGeckoBasedBrowser(String(browser))) return {
|
|
6623
|
+
pageEntry: "background/script",
|
|
6624
|
+
tryCatchWrapper: true,
|
|
6625
|
+
eagerChunkLoading: false
|
|
6626
|
+
};
|
|
6627
|
+
if (3 === manifest.manifest_version) return {
|
|
6628
|
+
serviceWorkerEntry: 'background/service_worker',
|
|
6629
|
+
tryCatchWrapper: true,
|
|
6630
|
+
eagerChunkLoading: false
|
|
6631
|
+
};
|
|
6632
|
+
if (2 === manifest.manifest_version) return {
|
|
6633
|
+
pageEntry: "background/script",
|
|
6634
|
+
tryCatchWrapper: true,
|
|
6635
|
+
eagerChunkLoading: false
|
|
6636
|
+
};
|
|
6637
|
+
}
|
|
6638
|
+
return {
|
|
6639
|
+
pageEntry: 'background',
|
|
6640
|
+
tryCatchWrapper: true,
|
|
6641
|
+
eagerChunkLoading: false
|
|
6642
|
+
};
|
|
6643
|
+
}
|
|
6644
|
+
function buildContentScriptsMeta(patchedManifest) {
|
|
6645
|
+
const contentScriptsMeta = {};
|
|
6646
|
+
try {
|
|
6647
|
+
const csList = Array.isArray(patchedManifest.content_scripts) ? patchedManifest.content_scripts : [];
|
|
6648
|
+
const originalCount = csList.length;
|
|
6649
|
+
let bridgeOrdinal = 0;
|
|
6650
|
+
for(let i = 0; i < csList.length; i++){
|
|
6651
|
+
const cs = csList[i];
|
|
6652
|
+
const bundleId = getCanonicalContentScriptJsAssetName(i);
|
|
6653
|
+
const isMain = cs?.world === 'MAIN';
|
|
6654
|
+
if (isMain) {
|
|
6655
|
+
const bridgeIndex = originalCount + bridgeOrdinal++;
|
|
6656
|
+
const bridgeBundleId = getCanonicalContentScriptJsAssetName(bridgeIndex);
|
|
6657
|
+
contentScriptsMeta[bundleId] = {
|
|
6658
|
+
index: i,
|
|
6659
|
+
bundleId,
|
|
6660
|
+
world: 'main',
|
|
6661
|
+
bridgeBundleId
|
|
6662
|
+
};
|
|
6663
|
+
contentScriptsMeta[bridgeBundleId] = {
|
|
6664
|
+
index: bridgeIndex,
|
|
6665
|
+
bundleId: bridgeBundleId,
|
|
6666
|
+
world: 'extension',
|
|
6667
|
+
role: 'main_world_bridge',
|
|
6668
|
+
mainBundleId: bundleId
|
|
6669
|
+
};
|
|
6670
|
+
} else contentScriptsMeta[bundleId] = {
|
|
6671
|
+
index: i,
|
|
6672
|
+
bundleId,
|
|
6673
|
+
world: 'extension'
|
|
6674
|
+
};
|
|
6675
|
+
}
|
|
6676
|
+
} catch {}
|
|
6677
|
+
return contentScriptsMeta;
|
|
6678
|
+
}
|
|
6620
6679
|
class SetupReloadStrategy {
|
|
6621
6680
|
manifestPath;
|
|
6622
6681
|
browser;
|
|
@@ -6624,71 +6683,16 @@ class SetupReloadStrategy {
|
|
|
6624
6683
|
this.manifestPath = options.manifestPath;
|
|
6625
6684
|
this.browser = options.browser || 'chrome';
|
|
6626
6685
|
}
|
|
6627
|
-
getEntryName(manifest) {
|
|
6628
|
-
if (manifest.background) {
|
|
6629
|
-
if (isGeckoBasedBrowser(String(this.browser))) return {
|
|
6630
|
-
pageEntry: "background/script",
|
|
6631
|
-
tryCatchWrapper: true,
|
|
6632
|
-
eagerChunkLoading: false
|
|
6633
|
-
};
|
|
6634
|
-
if (3 === manifest.manifest_version) return {
|
|
6635
|
-
serviceWorkerEntry: 'background/service_worker',
|
|
6636
|
-
tryCatchWrapper: true,
|
|
6637
|
-
eagerChunkLoading: false
|
|
6638
|
-
};
|
|
6639
|
-
if (2 === manifest.manifest_version) return {
|
|
6640
|
-
pageEntry: "background/script",
|
|
6641
|
-
tryCatchWrapper: true,
|
|
6642
|
-
eagerChunkLoading: false
|
|
6643
|
-
};
|
|
6644
|
-
}
|
|
6645
|
-
return {
|
|
6646
|
-
pageEntry: 'background',
|
|
6647
|
-
tryCatchWrapper: true,
|
|
6648
|
-
eagerChunkLoading: false
|
|
6649
|
-
};
|
|
6650
|
-
}
|
|
6651
6686
|
apply(compiler) {
|
|
6652
6687
|
const manifest = JSON.parse(stripBom(__rspack_external_node_fs_5ea92f0c.readFileSync(this.manifestPath, 'utf-8')));
|
|
6653
6688
|
const patchedManifest = filterKeysForThisBrowser(manifest, this.browser);
|
|
6654
|
-
const contentScriptsMeta =
|
|
6655
|
-
try {
|
|
6656
|
-
const csList = Array.isArray(patchedManifest.content_scripts) ? patchedManifest.content_scripts : [];
|
|
6657
|
-
const originalCount = csList.length;
|
|
6658
|
-
let bridgeOrdinal = 0;
|
|
6659
|
-
for(let i = 0; i < csList.length; i++){
|
|
6660
|
-
const cs = csList[i];
|
|
6661
|
-
const bundleId = getCanonicalContentScriptJsAssetName(i);
|
|
6662
|
-
const isMain = cs?.world === 'MAIN';
|
|
6663
|
-
if (isMain) {
|
|
6664
|
-
const bridgeIndex = originalCount + bridgeOrdinal++;
|
|
6665
|
-
const bridgeBundleId = getCanonicalContentScriptJsAssetName(bridgeIndex);
|
|
6666
|
-
contentScriptsMeta[bundleId] = {
|
|
6667
|
-
index: i,
|
|
6668
|
-
bundleId,
|
|
6669
|
-
world: 'main',
|
|
6670
|
-
bridgeBundleId
|
|
6671
|
-
};
|
|
6672
|
-
contentScriptsMeta[bridgeBundleId] = {
|
|
6673
|
-
index: bridgeIndex,
|
|
6674
|
-
bundleId: bridgeBundleId,
|
|
6675
|
-
world: 'extension',
|
|
6676
|
-
role: 'main_world_bridge',
|
|
6677
|
-
mainBundleId: bundleId
|
|
6678
|
-
};
|
|
6679
|
-
} else contentScriptsMeta[bundleId] = {
|
|
6680
|
-
index: i,
|
|
6681
|
-
bundleId,
|
|
6682
|
-
world: 'extension'
|
|
6683
|
-
};
|
|
6684
|
-
}
|
|
6685
|
-
} catch {}
|
|
6689
|
+
const contentScriptsMeta = buildContentScriptsMeta(patchedManifest);
|
|
6686
6690
|
new SetupBackgroundEntry({
|
|
6687
6691
|
manifestPath: this.manifestPath,
|
|
6688
6692
|
browser: this.browser
|
|
6689
6693
|
}).apply(compiler);
|
|
6690
6694
|
new webpack_target_webextension_fork({
|
|
6691
|
-
background: this.
|
|
6695
|
+
background: getBackgroundEntryName(patchedManifest, this.browser),
|
|
6692
6696
|
hmrConfig: false,
|
|
6693
6697
|
weakRuntimeCheck: true,
|
|
6694
6698
|
contentScriptsMeta
|
|
@@ -6793,6 +6797,35 @@ class ReloadPlugin {
|
|
|
6793
6797
|
new PruneStaleHotUpdates().apply(compiler);
|
|
6794
6798
|
}
|
|
6795
6799
|
}
|
|
6800
|
+
class SetupChunkLoadingTarget {
|
|
6801
|
+
manifestPath;
|
|
6802
|
+
browser;
|
|
6803
|
+
constructor(options){
|
|
6804
|
+
this.manifestPath = options.manifestPath;
|
|
6805
|
+
this.browser = options.browser || 'chrome';
|
|
6806
|
+
}
|
|
6807
|
+
apply(compiler) {
|
|
6808
|
+
if ('production' !== compiler.options.mode) return;
|
|
6809
|
+
const hasValidManifest = !!this.manifestPath && __rspack_external_node_fs_5ea92f0c.existsSync(this.manifestPath) && __rspack_external_node_fs_5ea92f0c.lstatSync(this.manifestPath).isFile();
|
|
6810
|
+
if (!hasValidManifest) return;
|
|
6811
|
+
let patchedManifest;
|
|
6812
|
+
try {
|
|
6813
|
+
const manifest = JSON.parse(stripBom(__rspack_external_node_fs_5ea92f0c.readFileSync(this.manifestPath, 'utf-8')));
|
|
6814
|
+
patchedManifest = filterKeysForThisBrowser(manifest, this.browser);
|
|
6815
|
+
} catch {
|
|
6816
|
+
return;
|
|
6817
|
+
}
|
|
6818
|
+
new webpack_target_webextension_fork({
|
|
6819
|
+
background: {
|
|
6820
|
+
...getBackgroundEntryName(patchedManifest, this.browser),
|
|
6821
|
+
classicLoader: false
|
|
6822
|
+
},
|
|
6823
|
+
hmrConfig: false,
|
|
6824
|
+
weakRuntimeCheck: true,
|
|
6825
|
+
contentScriptsMeta: buildContentScriptsMeta(patchedManifest)
|
|
6826
|
+
}).apply(compiler);
|
|
6827
|
+
}
|
|
6828
|
+
}
|
|
6796
6829
|
function checkManifestInPublic(compilation, publicDir) {
|
|
6797
6830
|
try {
|
|
6798
6831
|
const manifestInPublic = __rspack_external_node_path_c5b9b54f.join(publicDir, 'manifest.json');
|
|
@@ -13214,6 +13247,10 @@ function webpackConfig(projectStructure, devOptions) {
|
|
|
13214
13247
|
manifestPath,
|
|
13215
13248
|
browser: devOptions.browser
|
|
13216
13249
|
}),
|
|
13250
|
+
new SetupChunkLoadingTarget({
|
|
13251
|
+
manifestPath,
|
|
13252
|
+
browser: devOptions.browser
|
|
13253
|
+
}),
|
|
13217
13254
|
new SpecialFoldersPlugin({
|
|
13218
13255
|
manifestPath
|
|
13219
13256
|
}),
|
package/dist/101.mjs
CHANGED
|
@@ -699,7 +699,7 @@ async function config_loader_isUsingExperimentalConfig(projectPath) {
|
|
|
699
699
|
}
|
|
700
700
|
return false;
|
|
701
701
|
}
|
|
702
|
-
var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.1.
|
|
702
|
+
var package_namespaceObject = /*#__PURE__*/ JSON.parse('{"rE":"4.1.8","El":{"@prefresh/core":"1.5.9","@prefresh/utils":"1.2.1","@rspack/core":"^2.1.1","@rspack/dev-server":"2.1.0","@rspack/plugin-preact-refresh":"2.0.1","@rspack/plugin-react-refresh":"2.0.2","@vue/compiler-sfc":"3.5.26","acorn":"^8.16.0","browser-extension-manifest-fields":"^2.3.0","case-sensitive-paths-webpack-plugin":"^2.4.0","content-security-policy-parser":"^0.6.0","dotenv":"^17.2.3","es-module-lexer":"^2.1.0","extension-from-store":"^0.2.5","fflate":"^0.8.3","go-git-it":"^5.1.5","ignore":"^7.0.5","less":"4.6.7","less-loader":"13.0.0","parse5-utilities":"^1.0.0","pintor":"0.3.0","postcss":"8.5.23","postcss-loader":"8.2.1","postcss-preset-env":"11.1.1","postcss-scss":"4.0.9","preact":"10.27.3","prefers-yarn":"2.0.1","react-refresh":"0.18.0","sass-loader":"17.0.0","schema-utils":"^4.3.3","svelte-loader":"3.2.4","tiny-glob":"^0.2.9","vue":"3.5.26","vue-loader":"17.4.2","webextension-polyfill":"^0.12.0","webpack-merge":"^6.0.1","webpack-target-webextension":"^2.1.3","ws":"^8.20.1"}}');
|
|
703
703
|
function asAbsolute(p) {
|
|
704
704
|
return __rspack_external_node_path_c5b9b54f.isAbsolute(p) ? p : __rspack_external_node_path_c5b9b54f.resolve(p);
|
|
705
705
|
}
|
|
@@ -2,6 +2,7 @@ import type { Compiler } from '@rspack/core';
|
|
|
2
2
|
import type { DevOptions, PluginInterface } from '../types';
|
|
3
3
|
export { buildSourceFeatureIndex, classifyReloadFromSources, formatReloadContextLabel, pageContextFromSources, type ReloadInstruction, type ReloadType, readContentScriptCount, type SourceFeatureIndex } from './classify-reload';
|
|
4
4
|
export { type ChangedSourcesSnapshot, type ChangedSourcesTracker, createChangedSourcesTracker, dispatchReload, type ReloadBroker, type ReloadExecutor } from './reload-dispatch';
|
|
5
|
+
export { SetupChunkLoadingTarget } from './steps/setup-chunk-loading-target';
|
|
5
6
|
/**
|
|
6
7
|
* ReloadPlugin owns the dev-only reload/HMR strategy end to end:
|
|
7
8
|
*
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Compiler } from '@rspack/core';
|
|
2
|
+
import type { PluginInterface } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* How a chunk gets loaded is a property of the extension platform, not of dev
|
|
5
|
+
* mode. Without this, a production build falls back to rspack's web target,
|
|
6
|
+
* whose loader appends a `<script>` to the host document: that runs in the MAIN
|
|
7
|
+
* world while the content script lives in the isolated world, so the chunk never
|
|
8
|
+
* reaches the requester and a dynamic `import()` dies with ChunkLoadError. Dev
|
|
9
|
+
* looked fine only because the target rode along inside the reload plugin
|
|
10
|
+
* (issue #507).
|
|
11
|
+
*
|
|
12
|
+
* This is the target ALONE. Everything reload-specific, including the
|
|
13
|
+
* synthesized background entry, stays in SetupReloadStrategy: production must
|
|
14
|
+
* never gain a background script the author did not write.
|
|
15
|
+
*/
|
|
16
|
+
export declare class SetupChunkLoadingTarget {
|
|
17
|
+
private readonly manifestPath;
|
|
18
|
+
private readonly browser;
|
|
19
|
+
constructor(options: PluginInterface);
|
|
20
|
+
apply(compiler: Compiler): void;
|
|
21
|
+
}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import type { Compiler } from '@rspack/core';
|
|
2
|
-
import type { PluginInterface } from '../../../types';
|
|
2
|
+
import type { DevOptions, Manifest, PluginInterface } from '../../../types';
|
|
3
|
+
export declare function getBackgroundEntryName(manifest: Manifest, browser: DevOptions['browser']): {
|
|
4
|
+
pageEntry: string;
|
|
5
|
+
tryCatchWrapper: boolean;
|
|
6
|
+
eagerChunkLoading: boolean;
|
|
7
|
+
serviceWorkerEntry?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
pageEntry?: undefined;
|
|
10
|
+
serviceWorkerEntry: string;
|
|
11
|
+
tryCatchWrapper: boolean;
|
|
12
|
+
eagerChunkLoading: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare function buildContentScriptsMeta(patchedManifest: Manifest): Record<string, unknown>;
|
|
3
15
|
export declare class SetupReloadStrategy {
|
|
4
16
|
private readonly manifestPath;
|
|
5
17
|
private readonly browser;
|
|
6
18
|
constructor(options: PluginInterface);
|
|
7
|
-
private getEntryName;
|
|
8
19
|
apply(compiler: Compiler): void;
|
|
9
20
|
}
|
package/package.json
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"runtime"
|
|
44
44
|
],
|
|
45
45
|
"name": "extension-develop",
|
|
46
|
-
"version": "4.1.
|
|
46
|
+
"version": "4.1.8",
|
|
47
47
|
"description": "Develop, build, preview, and package Extension.js projects.",
|
|
48
48
|
"author": {
|
|
49
49
|
"name": "Cezar Augusto",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"@rspack/plugin-react-refresh": "2.0.2",
|
|
100
100
|
"@vue/compiler-sfc": "3.5.26",
|
|
101
101
|
"acorn": "^8.16.0",
|
|
102
|
-
"browser-extension-manifest-fields": "^2.
|
|
102
|
+
"browser-extension-manifest-fields": "^2.3.0",
|
|
103
103
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
104
104
|
"content-security-policy-parser": "^0.6.0",
|
|
105
105
|
"dotenv": "^17.2.3",
|