@rspack-canary/core 1.6.7-canary-5041023c-20251208041143 → 1.6.7-canary-e27a87e9-20251209100543
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/builtin-plugin/css-extract/loader.d.ts +4 -4
- package/dist/container/ModuleFederationManifestPlugin.d.ts +9 -2
- package/dist/container/ModuleFederationPlugin.d.ts +15 -1
- package/dist/cssExtractLoader.js +2 -2
- package/dist/exports.d.ts +3 -0
- package/dist/index.js +620 -245
- package/dist/moduleFederationDefaultRuntime.js +1 -1
- package/dist/sharing/CollectSharedEntryPlugin.d.ts +22 -0
- package/dist/sharing/ConsumeSharedPlugin.d.ts +16 -0
- package/dist/sharing/IndependentSharedPlugin.d.ts +33 -0
- package/dist/sharing/ProvideSharedPlugin.d.ts +19 -0
- package/dist/sharing/SharePlugin.d.ts +36 -0
- package/dist/sharing/SharedContainerPlugin.d.ts +23 -0
- package/dist/sharing/SharedUsedExportsOptimizerPlugin.d.ts +14 -0
- package/dist/sharing/TreeShakeSharedPlugin.d.ts +19 -0
- package/dist/sharing/utils.d.ts +1 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -5785,7 +5785,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5785
5785
|
}, applyExperimentsDefaults = (experiments, { development })=>{
|
|
5786
5786
|
F(experiments, "cache", ()=>development), D(experiments, "futureDefaults", !1), D(experiments, "lazyCompilation", !1), D(experiments, "asyncWebAssembly", experiments.futureDefaults), D(experiments, "css", !!experiments.futureDefaults || void 0), D(experiments, "topLevelAwait", !0), D(experiments, "deferImport", !1), D(experiments, "buildHttp", void 0), experiments.buildHttp && "object" == typeof experiments.buildHttp && D(experiments.buildHttp, "upgrade", !1), D(experiments, "incremental", {}), "object" == typeof experiments.incremental && (D(experiments.incremental, "silent", !0), D(experiments.incremental, "make", !0), D(experiments.incremental, "inferAsyncModules", !0), D(experiments.incremental, "providedExports", !0), D(experiments.incremental, "dependenciesDiagnostics", !0), D(experiments.incremental, "sideEffects", !0), D(experiments.incremental, "buildChunkGraph", !1), D(experiments.incremental, "moduleIds", !0), D(experiments.incremental, "chunkIds", !0), D(experiments.incremental, "modulesHashes", !0), D(experiments.incremental, "modulesCodegen", !0), D(experiments.incremental, "modulesRuntimeRequirements", !0), D(experiments.incremental, "chunksRuntimeRequirements", !0), D(experiments.incremental, "chunksHashes", !0), D(experiments.incremental, "chunksRender", !0), D(experiments.incremental, "emitAssets", !0)), D(experiments, "rspackFuture", {}), D(experiments, "parallelCodeSplitting", !1), D(experiments, "parallelLoader", !1), D(experiments, "useInputFileSystem", !1), D(experiments, "inlineConst", !1), D(experiments, "inlineEnum", !1), D(experiments, "typeReexportsPresence", !1), D(experiments, "lazyBarrel", !0);
|
|
5787
5787
|
}, applybundlerInfoDefaults = (rspackFuture, library)=>{
|
|
5788
|
-
"object" == typeof rspackFuture && (D(rspackFuture, "bundlerInfo", {}), "object" == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, "version", "1.6.7-canary-
|
|
5788
|
+
"object" == typeof rspackFuture && (D(rspackFuture, "bundlerInfo", {}), "object" == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, "version", "1.6.7-canary-e27a87e9-20251209100543"), D(rspackFuture.bundlerInfo, "bundler", "rspack"), D(rspackFuture.bundlerInfo, "force", !library)));
|
|
5789
5789
|
}, applySnapshotDefaults = (_snapshot, _env)=>{}, applyModuleDefaults = (module1, { cache, asyncWebAssembly, css, targetProperties, mode, uniqueName, usedExports, inlineConst, deferImport })=>{
|
|
5790
5790
|
if (assertNotNill(module1.parser), assertNotNill(module1.generator), cache ? D(module1, "unsafeCache", /[\\/]node_modules[\\/]/) : D(module1, "unsafeCache", !1), F(module1.parser, "asset", ()=>({})), assertNotNill(module1.parser.asset), F(module1.parser.asset, "dataUrlCondition", ()=>({})), "object" == typeof module1.parser.asset.dataUrlCondition && D(module1.parser.asset.dataUrlCondition, "maxSize", 8096), F(module1.parser, "javascript", ()=>({})), assertNotNill(module1.parser.javascript), ((parserOptions, { usedExports, inlineConst, deferImport })=>{
|
|
5791
5791
|
D(parserOptions, "dynamicImportMode", "lazy"), D(parserOptions, "dynamicImportPrefetch", !1), D(parserOptions, "dynamicImportPreload", !1), D(parserOptions, "url", !0), D(parserOptions, "exprContextCritical", !0), D(parserOptions, "unknownContextCritical", !0), D(parserOptions, "wrappedContextCritical", !1), D(parserOptions, "wrappedContextRegExp", /.*/), D(parserOptions, "strictExportPresence", !1), D(parserOptions, "requireAsExpression", !0), D(parserOptions, "requireDynamic", !0), D(parserOptions, "requireResolve", !0), D(parserOptions, "commonjs", !0), D(parserOptions, "importDynamic", !0), D(parserOptions, "worker", [
|
|
@@ -7545,7 +7545,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
7545
7545
|
});
|
|
7546
7546
|
}
|
|
7547
7547
|
}
|
|
7548
|
-
let CORE_VERSION = "1.6.7-canary-
|
|
7548
|
+
let CORE_VERSION = "1.6.7-canary-e27a87e9-20251209100543", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
|
|
7549
7549
|
|
|
7550
7550
|
Help:
|
|
7551
7551
|
Looks like you are using a custom binding (via environment variable 'RSPACK_BINDING=${process.env.RSPACK_BINDING}').
|
|
@@ -8854,7 +8854,7 @@ Help:
|
|
|
8854
8854
|
obj.children = this.stats.map((stat, idx)=>{
|
|
8855
8855
|
let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
|
|
8856
8856
|
return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
|
|
8857
|
-
}), childOptions.version && (obj.rspackVersion = "1.6.7-canary-
|
|
8857
|
+
}), childOptions.version && (obj.rspackVersion = "1.6.7-canary-e27a87e9-20251209100543", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(""));
|
|
8858
8858
|
let mapError = (j, obj)=>({
|
|
8859
8859
|
...obj,
|
|
8860
8860
|
compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
|
|
@@ -9753,7 +9753,7 @@ Help:
|
|
|
9753
9753
|
object.hash = context.getStatsCompilation(compilation).hash;
|
|
9754
9754
|
},
|
|
9755
9755
|
version: (object)=>{
|
|
9756
|
-
object.version = "5.75.0", object.rspackVersion = "1.6.7-canary-
|
|
9756
|
+
object.version = "5.75.0", object.rspackVersion = "1.6.7-canary-e27a87e9-20251209100543";
|
|
9757
9757
|
},
|
|
9758
9758
|
env: (object, _compilation, _context, { _env })=>{
|
|
9759
9759
|
object.env = _env;
|
|
@@ -11598,30 +11598,120 @@ Help:
|
|
|
11598
11598
|
function isRequiredVersion(str) {
|
|
11599
11599
|
return VERSION_PATTERN_REGEXP.test(str);
|
|
11600
11600
|
}
|
|
11601
|
-
let
|
|
11601
|
+
let encodeName = function(name, prefix = "", withExt = !1) {
|
|
11602
|
+
return `${prefix}${name.replace(/@/g, "scope_").replace(/-/g, "_").replace(/\//g, "__").replace(/\./g, "")}${withExt ? ".js" : ""}`;
|
|
11603
|
+
}, parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
11604
|
+
let items = [];
|
|
11605
|
+
var options1 = options, normalizeSimple1 = normalizeSimple, normalizeOptions1 = normalizeOptions, fn = (key, value)=>{
|
|
11606
|
+
items.push([
|
|
11607
|
+
key,
|
|
11608
|
+
value
|
|
11609
|
+
]);
|
|
11610
|
+
};
|
|
11611
|
+
let object = (obj)=>{
|
|
11612
|
+
for (let [key, value] of Object.entries(obj))"string" == typeof value || Array.isArray(value) ? fn(key, normalizeSimple1(value, key)) : fn(key, normalizeOptions1(value, key));
|
|
11613
|
+
};
|
|
11614
|
+
if (options1) if (Array.isArray(options1)) {
|
|
11615
|
+
var items1 = options1;
|
|
11616
|
+
for (let item of items1)if ("string" == typeof item) fn(item, normalizeSimple1(item, item));
|
|
11617
|
+
else if (item && "object" == typeof item) object(item);
|
|
11618
|
+
else throw Error("Unexpected options format");
|
|
11619
|
+
} else if ("object" == typeof options1) object(options1);
|
|
11620
|
+
else throw Error("Unexpected options format");
|
|
11621
|
+
return items;
|
|
11622
|
+
}, MANIFEST_FILE_NAME = "mf-manifest.json", STATS_FILE_NAME = "mf-stats.json", JSON_EXT = ".json";
|
|
11602
11623
|
function isPlainObject(value) {
|
|
11603
11624
|
return !!value && "object" == typeof value && !Array.isArray(value);
|
|
11604
11625
|
}
|
|
11626
|
+
function getFileName(manifestOptions) {
|
|
11627
|
+
var name;
|
|
11628
|
+
if (!manifestOptions) return {
|
|
11629
|
+
statsFileName: "",
|
|
11630
|
+
manifestFileName: ""
|
|
11631
|
+
};
|
|
11632
|
+
if ("boolean" == typeof manifestOptions) return {
|
|
11633
|
+
statsFileName: STATS_FILE_NAME,
|
|
11634
|
+
manifestFileName: MANIFEST_FILE_NAME
|
|
11635
|
+
};
|
|
11636
|
+
let filePath = "boolean" == typeof manifestOptions ? "" : manifestOptions.filePath || "", fileName = "boolean" == typeof manifestOptions ? "" : manifestOptions.fileName || "", manifestFileName = fileName ? (name = fileName).endsWith(JSON_EXT) ? name : `${name}${JSON_EXT}` : MANIFEST_FILE_NAME, statsFileName = fileName ? manifestFileName.replace(JSON_EXT, `-stats${JSON_EXT}`) : STATS_FILE_NAME;
|
|
11637
|
+
return {
|
|
11638
|
+
statsFileName: (0, external_node_path_namespaceObject.join)(filePath, statsFileName),
|
|
11639
|
+
manifestFileName: (0, external_node_path_namespaceObject.join)(filePath, manifestFileName)
|
|
11640
|
+
};
|
|
11641
|
+
}
|
|
11605
11642
|
class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
11606
11643
|
name = binding_.BuiltinPluginName.ModuleFederationManifestPlugin;
|
|
11607
11644
|
opts;
|
|
11608
11645
|
constructor(opts){
|
|
11609
|
-
|
|
11646
|
+
var mfConfig;
|
|
11647
|
+
let manifestOptions, containerName, globalName, remoteAliasMap, manifestExposes, manifestShared;
|
|
11648
|
+
super(), this.opts = (manifestOptions = !0 === (mfConfig = opts).manifest ? {} : {
|
|
11649
|
+
...mfConfig.manifest
|
|
11650
|
+
}, containerName = mfConfig.name, globalName = function(library) {
|
|
11651
|
+
if (!library) return;
|
|
11652
|
+
let libName = library.name;
|
|
11653
|
+
if (libName) {
|
|
11654
|
+
if ("string" == typeof libName) return libName;
|
|
11655
|
+
if (Array.isArray(libName)) return libName[0];
|
|
11656
|
+
if ("object" == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
11657
|
+
}
|
|
11658
|
+
}(mfConfig.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(mfConfig)).reduce((sum, cur)=>{
|
|
11659
|
+
if (cur[1].length > 1) return sum;
|
|
11660
|
+
let { entry, alias, name } = cur[1][0];
|
|
11661
|
+
return entry && name && (sum[alias] = {
|
|
11662
|
+
name,
|
|
11663
|
+
entry
|
|
11664
|
+
}), sum;
|
|
11665
|
+
}, {}), manifestExposes = function(exposes) {
|
|
11666
|
+
if (!exposes) return;
|
|
11667
|
+
let result = parseOptions(exposes, (value)=>({
|
|
11668
|
+
import: Array.isArray(value) ? value : [
|
|
11669
|
+
value
|
|
11670
|
+
],
|
|
11671
|
+
name: void 0
|
|
11672
|
+
}), (value)=>({
|
|
11673
|
+
import: Array.isArray(value.import) ? value.import : [
|
|
11674
|
+
value.import
|
|
11675
|
+
],
|
|
11676
|
+
name: value.name ?? void 0
|
|
11677
|
+
})).map(([exposeKey, info])=>{
|
|
11678
|
+
let exposeName = info.name ?? exposeKey.replace(/^\.\//, "");
|
|
11679
|
+
return {
|
|
11680
|
+
path: exposeKey,
|
|
11681
|
+
name: exposeName
|
|
11682
|
+
};
|
|
11683
|
+
});
|
|
11684
|
+
return result.length > 0 ? result : void 0;
|
|
11685
|
+
}(mfConfig.exposes), void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes), manifestShared = function(shared) {
|
|
11686
|
+
if (!shared) return;
|
|
11687
|
+
let result = parseOptions(shared, (item, key)=>{
|
|
11688
|
+
if ("string" != typeof item) throw Error("Unexpected array in shared");
|
|
11689
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
11690
|
+
import: key,
|
|
11691
|
+
requiredVersion: item
|
|
11692
|
+
} : {
|
|
11693
|
+
import: item
|
|
11694
|
+
};
|
|
11695
|
+
}, (item)=>item).map(([key, config])=>{
|
|
11696
|
+
let name = config.shareKey || key, version = "string" == typeof config.version ? config.version : void 0;
|
|
11697
|
+
return {
|
|
11698
|
+
name,
|
|
11699
|
+
version,
|
|
11700
|
+
requiredVersion: "string" == typeof config.requiredVersion ? config.requiredVersion : void 0,
|
|
11701
|
+
singleton: config.singleton
|
|
11702
|
+
};
|
|
11703
|
+
});
|
|
11704
|
+
return result.length > 0 ? result : void 0;
|
|
11705
|
+
}(mfConfig.shared), void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), {
|
|
11706
|
+
...manifestOptions,
|
|
11707
|
+
remoteAliasMap,
|
|
11708
|
+
globalName,
|
|
11709
|
+
name: containerName
|
|
11710
|
+
});
|
|
11610
11711
|
}
|
|
11611
11712
|
raw(compiler) {
|
|
11612
11713
|
var isDev;
|
|
11613
|
-
let pkg, buildVersion, { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts, { statsFileName, manifestFileName } =
|
|
11614
|
-
var name;
|
|
11615
|
-
if (!manifestOptions) return {
|
|
11616
|
-
statsFileName: STATS_FILE_NAME,
|
|
11617
|
-
manifestFileName: MANIFEST_FILE_NAME
|
|
11618
|
-
};
|
|
11619
|
-
let filePath = "boolean" == typeof manifestOptions ? "" : manifestOptions.filePath || "", fileName = "boolean" == typeof manifestOptions ? "" : manifestOptions.fileName || "", manifestFileName = fileName ? (name = fileName).endsWith(JSON_EXT) ? name : `${name}${JSON_EXT}` : MANIFEST_FILE_NAME, statsFileName = fileName ? manifestFileName.replace(JSON_EXT, `-stats${JSON_EXT}`) : STATS_FILE_NAME;
|
|
11620
|
-
return {
|
|
11621
|
-
statsFileName: (0, external_node_path_namespaceObject.join)(filePath, statsFileName),
|
|
11622
|
-
manifestFileName: (0, external_node_path_namespaceObject.join)(filePath, manifestFileName)
|
|
11623
|
-
};
|
|
11624
|
-
}(this.opts), rawOptions = {
|
|
11714
|
+
let pkg, buildVersion, { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts, { statsFileName, manifestFileName } = getFileName(this.opts), rawOptions = {
|
|
11625
11715
|
name: this.opts.name,
|
|
11626
11716
|
globalName: this.opts.globalName,
|
|
11627
11717
|
fileName,
|
|
@@ -11656,81 +11746,6 @@ Help:
|
|
|
11656
11746
|
return createBuiltinPlugin(this.name, rawOptions);
|
|
11657
11747
|
}
|
|
11658
11748
|
}
|
|
11659
|
-
let ModuleFederationRuntimePlugin = base_create(binding_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options), parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
11660
|
-
let items = [];
|
|
11661
|
-
var options1 = options, normalizeSimple1 = normalizeSimple, normalizeOptions1 = normalizeOptions, fn = (key, value)=>{
|
|
11662
|
-
items.push([
|
|
11663
|
-
key,
|
|
11664
|
-
value
|
|
11665
|
-
]);
|
|
11666
|
-
};
|
|
11667
|
-
let object = (obj)=>{
|
|
11668
|
-
for (let [key, value] of Object.entries(obj))"string" == typeof value || Array.isArray(value) ? fn(key, normalizeSimple1(value, key)) : fn(key, normalizeOptions1(value, key));
|
|
11669
|
-
};
|
|
11670
|
-
if (options1) if (Array.isArray(options1)) {
|
|
11671
|
-
var items1 = options1;
|
|
11672
|
-
for (let item of items1)if ("string" == typeof item) fn(item, normalizeSimple1(item, item));
|
|
11673
|
-
else if (item && "object" == typeof item) object(item);
|
|
11674
|
-
else throw Error("Unexpected options format");
|
|
11675
|
-
} else if ("object" == typeof options1) object(options1);
|
|
11676
|
-
else throw Error("Unexpected options format");
|
|
11677
|
-
return items;
|
|
11678
|
-
};
|
|
11679
|
-
function getRemoteInfos(options) {
|
|
11680
|
-
if (!options.remotes) return {};
|
|
11681
|
-
let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
|
|
11682
|
-
external: Array.isArray(item) ? item : [
|
|
11683
|
-
item
|
|
11684
|
-
],
|
|
11685
|
-
shareScope: options.shareScope || "default"
|
|
11686
|
-
}), (item)=>({
|
|
11687
|
-
external: Array.isArray(item.external) ? item.external : [
|
|
11688
|
-
item.external
|
|
11689
|
-
],
|
|
11690
|
-
shareScope: item.shareScope || options.shareScope || "default"
|
|
11691
|
-
})), remoteInfos = {};
|
|
11692
|
-
for (let [key, config] of remotes)for (let external of config.external){
|
|
11693
|
-
let [externalType, externalRequest] = function(external) {
|
|
11694
|
-
let result = function(external) {
|
|
11695
|
-
if (/^[a-z0-9-]+ /.test(external)) {
|
|
11696
|
-
let idx = external.indexOf(" ");
|
|
11697
|
-
return [
|
|
11698
|
-
external.slice(0, idx),
|
|
11699
|
-
external.slice(idx + 1)
|
|
11700
|
-
];
|
|
11701
|
-
}
|
|
11702
|
-
return null;
|
|
11703
|
-
}(external);
|
|
11704
|
-
return null === result ? [
|
|
11705
|
-
remoteType,
|
|
11706
|
-
external
|
|
11707
|
-
] : result;
|
|
11708
|
-
}(external);
|
|
11709
|
-
if (remoteInfos[key] ??= [], "script" === externalType) {
|
|
11710
|
-
let [url, global] = function(urlAndGlobal) {
|
|
11711
|
-
let index = urlAndGlobal.indexOf("@");
|
|
11712
|
-
return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
|
|
11713
|
-
urlAndGlobal.substring(index + 1),
|
|
11714
|
-
urlAndGlobal.substring(0, index)
|
|
11715
|
-
];
|
|
11716
|
-
}(externalRequest);
|
|
11717
|
-
remoteInfos[key].push({
|
|
11718
|
-
alias: key,
|
|
11719
|
-
name: global,
|
|
11720
|
-
entry: url,
|
|
11721
|
-
externalType,
|
|
11722
|
-
shareScope: config.shareScope
|
|
11723
|
-
});
|
|
11724
|
-
} else remoteInfos[key].push({
|
|
11725
|
-
alias: key,
|
|
11726
|
-
name: void 0,
|
|
11727
|
-
entry: void 0,
|
|
11728
|
-
externalType,
|
|
11729
|
-
shareScope: config.shareScope
|
|
11730
|
-
});
|
|
11731
|
-
}
|
|
11732
|
-
return remoteInfos;
|
|
11733
|
-
}
|
|
11734
11749
|
let compilerSet = new WeakSet();
|
|
11735
11750
|
class ShareRuntimePlugin extends RspackBuiltinPlugin {
|
|
11736
11751
|
enhanced;
|
|
@@ -11743,42 +11758,48 @@ Help:
|
|
|
11743
11758
|
if (compiler1 = compiler, !compilerSet.has(compiler1)) return compiler2 = compiler, compilerSet.add(compiler2), createBuiltinPlugin(this.name, this.enhanced);
|
|
11744
11759
|
}
|
|
11745
11760
|
}
|
|
11761
|
+
function normalizeConsumeShareOptions(consumes, shareScope) {
|
|
11762
|
+
return parseOptions(consumes, (item, key)=>{
|
|
11763
|
+
if (Array.isArray(item)) throw Error("Unexpected array in options");
|
|
11764
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
11765
|
+
import: key,
|
|
11766
|
+
shareScope: shareScope || "default",
|
|
11767
|
+
shareKey: key,
|
|
11768
|
+
requiredVersion: item,
|
|
11769
|
+
strictVersion: !0,
|
|
11770
|
+
packageName: void 0,
|
|
11771
|
+
singleton: !1,
|
|
11772
|
+
eager: !1,
|
|
11773
|
+
treeshakeStrategy: void 0
|
|
11774
|
+
} : {
|
|
11775
|
+
import: key,
|
|
11776
|
+
shareScope: shareScope || "default",
|
|
11777
|
+
shareKey: key,
|
|
11778
|
+
requiredVersion: void 0,
|
|
11779
|
+
packageName: void 0,
|
|
11780
|
+
strictVersion: !1,
|
|
11781
|
+
singleton: !1,
|
|
11782
|
+
eager: !1,
|
|
11783
|
+
treeshakeStrategy: void 0
|
|
11784
|
+
};
|
|
11785
|
+
}, (item, key)=>({
|
|
11786
|
+
import: !1 === item.import ? void 0 : item.import || key,
|
|
11787
|
+
shareScope: item.shareScope || shareScope || "default",
|
|
11788
|
+
shareKey: item.shareKey || key,
|
|
11789
|
+
requiredVersion: item.requiredVersion,
|
|
11790
|
+
strictVersion: "boolean" == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
|
|
11791
|
+
packageName: item.packageName,
|
|
11792
|
+
singleton: !!item.singleton,
|
|
11793
|
+
eager: !!item.eager,
|
|
11794
|
+
treeshakeStrategy: item.treeshakeStrategy
|
|
11795
|
+
}));
|
|
11796
|
+
}
|
|
11746
11797
|
class ConsumeSharedPlugin extends RspackBuiltinPlugin {
|
|
11747
11798
|
name = binding_.BuiltinPluginName.ConsumeSharedPlugin;
|
|
11748
11799
|
_options;
|
|
11749
11800
|
constructor(options){
|
|
11750
11801
|
super(), this._options = {
|
|
11751
|
-
consumes:
|
|
11752
|
-
if (Array.isArray(item)) throw Error("Unexpected array in options");
|
|
11753
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
11754
|
-
import: key,
|
|
11755
|
-
shareScope: options.shareScope || "default",
|
|
11756
|
-
shareKey: key,
|
|
11757
|
-
requiredVersion: item,
|
|
11758
|
-
strictVersion: !0,
|
|
11759
|
-
packageName: void 0,
|
|
11760
|
-
singleton: !1,
|
|
11761
|
-
eager: !1
|
|
11762
|
-
} : {
|
|
11763
|
-
import: key,
|
|
11764
|
-
shareScope: options.shareScope || "default",
|
|
11765
|
-
shareKey: key,
|
|
11766
|
-
requiredVersion: void 0,
|
|
11767
|
-
packageName: void 0,
|
|
11768
|
-
strictVersion: !1,
|
|
11769
|
-
singleton: !1,
|
|
11770
|
-
eager: !1
|
|
11771
|
-
};
|
|
11772
|
-
}, (item, key)=>({
|
|
11773
|
-
import: !1 === item.import ? void 0 : item.import || key,
|
|
11774
|
-
shareScope: item.shareScope || options.shareScope || "default",
|
|
11775
|
-
shareKey: item.shareKey || key,
|
|
11776
|
-
requiredVersion: item.requiredVersion,
|
|
11777
|
-
strictVersion: "boolean" == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
|
|
11778
|
-
packageName: item.packageName,
|
|
11779
|
-
singleton: !!item.singleton,
|
|
11780
|
-
eager: !!item.eager
|
|
11781
|
-
})),
|
|
11802
|
+
consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
|
|
11782
11803
|
enhanced: options.enhanced ?? !1
|
|
11783
11804
|
};
|
|
11784
11805
|
}
|
|
@@ -11799,28 +11820,30 @@ Help:
|
|
|
11799
11820
|
_provides;
|
|
11800
11821
|
_enhanced;
|
|
11801
11822
|
constructor(options){
|
|
11802
|
-
|
|
11823
|
+
var options1, shareScope, enhanced;
|
|
11824
|
+
super(), this._provides = (options1 = options.provides, shareScope = options.shareScope, enhanced = options.enhanced, parseOptions(options1, (item)=>{
|
|
11803
11825
|
if (Array.isArray(item)) throw Error("Unexpected array of provides");
|
|
11804
11826
|
return {
|
|
11805
11827
|
shareKey: item,
|
|
11806
11828
|
version: void 0,
|
|
11807
|
-
shareScope:
|
|
11829
|
+
shareScope: shareScope || "default",
|
|
11808
11830
|
eager: !1
|
|
11809
11831
|
};
|
|
11810
11832
|
}, (item)=>{
|
|
11811
11833
|
let raw = {
|
|
11812
11834
|
shareKey: item.shareKey,
|
|
11813
11835
|
version: item.version,
|
|
11814
|
-
shareScope: item.shareScope ||
|
|
11836
|
+
shareScope: item.shareScope || shareScope || "default",
|
|
11815
11837
|
eager: !!item.eager
|
|
11816
11838
|
};
|
|
11817
|
-
return
|
|
11839
|
+
return enhanced ? {
|
|
11818
11840
|
...raw,
|
|
11819
11841
|
singleton: item.singleton,
|
|
11820
11842
|
requiredVersion: item.requiredVersion,
|
|
11821
|
-
strictVersion: item.strictVersion
|
|
11843
|
+
strictVersion: item.strictVersion,
|
|
11844
|
+
treeshakeStrategy: item.treeshakeStrategy
|
|
11822
11845
|
} : raw;
|
|
11823
|
-
}), this._enhanced = options.enhanced;
|
|
11846
|
+
})), this._enhanced = options.enhanced;
|
|
11824
11847
|
}
|
|
11825
11848
|
raw(compiler) {
|
|
11826
11849
|
new ShareRuntimePlugin(this._enhanced ?? !1).apply(compiler);
|
|
@@ -11831,32 +11854,40 @@ Help:
|
|
|
11831
11854
|
return createBuiltinPlugin(this.name, rawOptions);
|
|
11832
11855
|
}
|
|
11833
11856
|
}
|
|
11857
|
+
function normalizeSharedOptions(shared) {
|
|
11858
|
+
return parseOptions(shared, (item, key)=>{
|
|
11859
|
+
if ("string" != typeof item) throw Error("Unexpected array in shared");
|
|
11860
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
11861
|
+
import: key,
|
|
11862
|
+
requiredVersion: item
|
|
11863
|
+
} : {
|
|
11864
|
+
import: item
|
|
11865
|
+
};
|
|
11866
|
+
}, (item)=>item);
|
|
11867
|
+
}
|
|
11868
|
+
function createConsumeShareOptions(normalizedSharedOptions) {
|
|
11869
|
+
return normalizedSharedOptions.map(([key, options])=>({
|
|
11870
|
+
[key]: {
|
|
11871
|
+
import: options.import,
|
|
11872
|
+
shareKey: options.shareKey || key,
|
|
11873
|
+
shareScope: options.shareScope,
|
|
11874
|
+
requiredVersion: options.requiredVersion,
|
|
11875
|
+
strictVersion: options.strictVersion,
|
|
11876
|
+
singleton: options.singleton,
|
|
11877
|
+
packageName: options.packageName,
|
|
11878
|
+
eager: options.eager,
|
|
11879
|
+
treeshakeStrategy: options.treeshake?.strategy
|
|
11880
|
+
}
|
|
11881
|
+
}));
|
|
11882
|
+
}
|
|
11834
11883
|
class SharePlugin {
|
|
11835
11884
|
_shareScope;
|
|
11836
11885
|
_consumes;
|
|
11837
11886
|
_provides;
|
|
11838
11887
|
_enhanced;
|
|
11888
|
+
_sharedOptions;
|
|
11839
11889
|
constructor(options){
|
|
11840
|
-
const sharedOptions =
|
|
11841
|
-
if ("string" != typeof item) throw Error("Unexpected array in shared");
|
|
11842
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
11843
|
-
import: key,
|
|
11844
|
-
requiredVersion: item
|
|
11845
|
-
} : {
|
|
11846
|
-
import: item
|
|
11847
|
-
};
|
|
11848
|
-
}, (item)=>item), consumes = sharedOptions.map(([key, options])=>({
|
|
11849
|
-
[key]: {
|
|
11850
|
-
import: options.import,
|
|
11851
|
-
shareKey: options.shareKey || key,
|
|
11852
|
-
shareScope: options.shareScope,
|
|
11853
|
-
requiredVersion: options.requiredVersion,
|
|
11854
|
-
strictVersion: options.strictVersion,
|
|
11855
|
-
singleton: options.singleton,
|
|
11856
|
-
packageName: options.packageName,
|
|
11857
|
-
eager: options.eager
|
|
11858
|
-
}
|
|
11859
|
-
})), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
|
|
11890
|
+
const sharedOptions = normalizeSharedOptions(options.shared), consumes = createConsumeShareOptions(sharedOptions), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
|
|
11860
11891
|
[options.import || key]: {
|
|
11861
11892
|
shareKey: options.shareKey || key,
|
|
11862
11893
|
shareScope: options.shareScope,
|
|
@@ -11864,10 +11895,11 @@ Help:
|
|
|
11864
11895
|
eager: options.eager,
|
|
11865
11896
|
singleton: options.singleton,
|
|
11866
11897
|
requiredVersion: options.requiredVersion,
|
|
11867
|
-
strictVersion: options.strictVersion
|
|
11898
|
+
strictVersion: options.strictVersion,
|
|
11899
|
+
treeshakeStrategy: options.treeshake?.strategy
|
|
11868
11900
|
}
|
|
11869
11901
|
}));
|
|
11870
|
-
this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1;
|
|
11902
|
+
this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1, this._sharedOptions = sharedOptions;
|
|
11871
11903
|
}
|
|
11872
11904
|
apply(compiler) {
|
|
11873
11905
|
new ConsumeSharedPlugin({
|
|
@@ -11881,6 +11913,394 @@ Help:
|
|
|
11881
11913
|
}).apply(compiler);
|
|
11882
11914
|
}
|
|
11883
11915
|
}
|
|
11916
|
+
let SHARE_ENTRY_ASSET = "collect-shared-entries.json";
|
|
11917
|
+
class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
|
|
11918
|
+
name = binding_.BuiltinPluginName.CollectSharedEntryPlugin;
|
|
11919
|
+
sharedOptions;
|
|
11920
|
+
_collectedEntries;
|
|
11921
|
+
constructor(options){
|
|
11922
|
+
super();
|
|
11923
|
+
const { sharedOptions } = options;
|
|
11924
|
+
this.sharedOptions = sharedOptions, this._collectedEntries = {};
|
|
11925
|
+
}
|
|
11926
|
+
getData() {
|
|
11927
|
+
return this._collectedEntries;
|
|
11928
|
+
}
|
|
11929
|
+
getFilename() {
|
|
11930
|
+
return SHARE_ENTRY_ASSET;
|
|
11931
|
+
}
|
|
11932
|
+
apply(compiler) {
|
|
11933
|
+
super.apply(compiler), compiler.hooks.thisCompilation.tap("Collect shared entry", (compilation)=>{
|
|
11934
|
+
compilation.hooks.processAssets.tapPromise({
|
|
11935
|
+
name: "CollectSharedEntry",
|
|
11936
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
|
|
11937
|
+
}, async ()=>{
|
|
11938
|
+
compilation.getAssets().forEach((asset)=>{
|
|
11939
|
+
asset.name === SHARE_ENTRY_ASSET && (this._collectedEntries = JSON.parse(asset.source.source().toString())), compilation.deleteAsset(asset.name);
|
|
11940
|
+
});
|
|
11941
|
+
});
|
|
11942
|
+
});
|
|
11943
|
+
}
|
|
11944
|
+
raw() {
|
|
11945
|
+
let rawOptions = {
|
|
11946
|
+
consumes: normalizeConsumeShareOptions(createConsumeShareOptions(this.sharedOptions)).map(([key, v])=>({
|
|
11947
|
+
key,
|
|
11948
|
+
...v
|
|
11949
|
+
})),
|
|
11950
|
+
filename: this.getFilename()
|
|
11951
|
+
};
|
|
11952
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
11953
|
+
}
|
|
11954
|
+
}
|
|
11955
|
+
function assert(condition, msg) {
|
|
11956
|
+
if (!condition) throw Error(msg);
|
|
11957
|
+
}
|
|
11958
|
+
class SharedContainerPlugin extends RspackBuiltinPlugin {
|
|
11959
|
+
name = binding_.BuiltinPluginName.SharedContainerPlugin;
|
|
11960
|
+
filename = "";
|
|
11961
|
+
_options;
|
|
11962
|
+
_shareName;
|
|
11963
|
+
_globalName;
|
|
11964
|
+
constructor(options){
|
|
11965
|
+
super();
|
|
11966
|
+
const { shareName, library, request, independentShareFileName, mfName } = options, version = options.version || "0.0.0";
|
|
11967
|
+
this._globalName = encodeName(`${mfName}_${shareName}_${version}`);
|
|
11968
|
+
const fileName = independentShareFileName || `${version}/share-entry.js`;
|
|
11969
|
+
this._shareName = shareName, this._options = {
|
|
11970
|
+
name: shareName,
|
|
11971
|
+
request: request,
|
|
11972
|
+
library: (library ? {
|
|
11973
|
+
...library,
|
|
11974
|
+
name: this._globalName
|
|
11975
|
+
} : void 0) || {
|
|
11976
|
+
type: "global",
|
|
11977
|
+
name: this._globalName
|
|
11978
|
+
},
|
|
11979
|
+
version,
|
|
11980
|
+
fileName
|
|
11981
|
+
};
|
|
11982
|
+
}
|
|
11983
|
+
getData() {
|
|
11984
|
+
return [
|
|
11985
|
+
this._options.fileName,
|
|
11986
|
+
this._globalName,
|
|
11987
|
+
this._options.version
|
|
11988
|
+
];
|
|
11989
|
+
}
|
|
11990
|
+
raw(compiler) {
|
|
11991
|
+
let { library } = this._options;
|
|
11992
|
+
return compiler.options.output.enabledLibraryTypes.includes(library.type) || compiler.options.output.enabledLibraryTypes.push(library.type), createBuiltinPlugin(this.name, this._options);
|
|
11993
|
+
}
|
|
11994
|
+
apply(compiler) {
|
|
11995
|
+
super.apply(compiler);
|
|
11996
|
+
let shareName = this._shareName;
|
|
11997
|
+
compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
|
|
11998
|
+
compilation.hooks.processAssets.tapPromise({
|
|
11999
|
+
name: "getShareContainerFile"
|
|
12000
|
+
}, async ()=>{
|
|
12001
|
+
assert(compilation.entrypoints.get(shareName), `Can not get shared ${shareName} entryPoint!`);
|
|
12002
|
+
let remoteEntryNameChunk = compilation.namedChunks.get(shareName);
|
|
12003
|
+
assert(remoteEntryNameChunk, `Can not get shared ${shareName} chunk!`);
|
|
12004
|
+
let files = Array.from(remoteEntryNameChunk.files).filter((f)=>!f.includes(".hot-update") && !f.endsWith(".css"));
|
|
12005
|
+
assert(files.length > 0, `no files found for shared ${shareName} chunk`), assert(1 === files.length, `shared ${shareName} chunk should not have multiple files!, current files: ${files.join(",")}`), this.filename = files[0];
|
|
12006
|
+
});
|
|
12007
|
+
});
|
|
12008
|
+
}
|
|
12009
|
+
}
|
|
12010
|
+
class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
|
|
12011
|
+
name = binding_.BuiltinPluginName.SharedUsedExportsOptimizerPlugin;
|
|
12012
|
+
sharedOptions;
|
|
12013
|
+
injectUsedExports;
|
|
12014
|
+
manifestOptions;
|
|
12015
|
+
constructor(sharedOptions, injectUsedExports, manifestOptions){
|
|
12016
|
+
super(), this.sharedOptions = sharedOptions, this.injectUsedExports = injectUsedExports ?? !0, this.manifestOptions = manifestOptions ?? {};
|
|
12017
|
+
}
|
|
12018
|
+
buildOptions() {
|
|
12019
|
+
let shared = this.sharedOptions.map(([shareKey, config])=>({
|
|
12020
|
+
shareKey,
|
|
12021
|
+
treeshake: !!config.treeshake,
|
|
12022
|
+
usedExports: config.treeshake?.usedExports
|
|
12023
|
+
})), { manifestFileName, statsFileName } = getFileName(this.manifestOptions);
|
|
12024
|
+
return {
|
|
12025
|
+
shared,
|
|
12026
|
+
injectUsedExports: this.injectUsedExports,
|
|
12027
|
+
manifestFileName,
|
|
12028
|
+
statsFileName
|
|
12029
|
+
};
|
|
12030
|
+
}
|
|
12031
|
+
raw() {
|
|
12032
|
+
if (this.sharedOptions.length) return createBuiltinPlugin(this.name, this.buildOptions());
|
|
12033
|
+
}
|
|
12034
|
+
}
|
|
12035
|
+
let VIRTUAL_ENTRY = "./virtual-entry.js", VIRTUAL_ENTRY_NAME = "virtual-entry";
|
|
12036
|
+
class VirtualEntryPlugin {
|
|
12037
|
+
sharedOptions;
|
|
12038
|
+
constructor(sharedOptions){
|
|
12039
|
+
this.sharedOptions = sharedOptions;
|
|
12040
|
+
}
|
|
12041
|
+
createEntry() {
|
|
12042
|
+
let { sharedOptions } = this;
|
|
12043
|
+
return sharedOptions.reduce((acc, cur, index)=>`${acc}import shared_${index} from '${cur[0]}';\n`, "");
|
|
12044
|
+
}
|
|
12045
|
+
static entry() {
|
|
12046
|
+
return {
|
|
12047
|
+
[VIRTUAL_ENTRY_NAME]: VIRTUAL_ENTRY
|
|
12048
|
+
};
|
|
12049
|
+
}
|
|
12050
|
+
apply(compiler) {
|
|
12051
|
+
new compiler.rspack.experiments.VirtualModulesPlugin({
|
|
12052
|
+
[VIRTUAL_ENTRY]: this.createEntry()
|
|
12053
|
+
}).apply(compiler), compiler.hooks.thisCompilation.tap("RemoveVirtualEntryAsset", (compilation)=>{
|
|
12054
|
+
compilation.hooks.processAssets.tapPromise({
|
|
12055
|
+
name: "RemoveVirtualEntryAsset",
|
|
12056
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
|
|
12057
|
+
}, async ()=>{
|
|
12058
|
+
try {
|
|
12059
|
+
let chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
|
|
12060
|
+
chunk?.files.forEach((f)=>{
|
|
12061
|
+
compilation.deleteAsset(f);
|
|
12062
|
+
});
|
|
12063
|
+
} catch (_e) {
|
|
12064
|
+
console.error("Failed to remove virtual entry file!");
|
|
12065
|
+
}
|
|
12066
|
+
});
|
|
12067
|
+
});
|
|
12068
|
+
}
|
|
12069
|
+
}
|
|
12070
|
+
let resolveOutputDir = (outputDir, shareName)=>shareName ? (0, external_node_path_namespaceObject.join)(outputDir, encodeName(shareName)) : outputDir;
|
|
12071
|
+
class IndependentSharedPlugin {
|
|
12072
|
+
mfName;
|
|
12073
|
+
shared;
|
|
12074
|
+
library;
|
|
12075
|
+
sharedOptions;
|
|
12076
|
+
outputDir;
|
|
12077
|
+
plugins;
|
|
12078
|
+
treeshake;
|
|
12079
|
+
manifest;
|
|
12080
|
+
buildAssets = {};
|
|
12081
|
+
injectUsedExports;
|
|
12082
|
+
name = "IndependentSharedPlugin";
|
|
12083
|
+
constructor(options){
|
|
12084
|
+
const { outputDir, plugins, treeshake, shared, name, manifest, injectUsedExports, library } = options;
|
|
12085
|
+
this.shared = shared, this.mfName = name, this.outputDir = outputDir || "independent-packages", this.plugins = plugins || [], this.treeshake = treeshake, this.manifest = manifest, this.injectUsedExports = injectUsedExports ?? !0, this.library = library, this.sharedOptions = parseOptions(shared, (item, key)=>{
|
|
12086
|
+
if ("string" != typeof item) throw Error(`Unexpected array in shared configuration for key "${key}"`);
|
|
12087
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12088
|
+
import: key,
|
|
12089
|
+
requiredVersion: item
|
|
12090
|
+
} : {
|
|
12091
|
+
import: item
|
|
12092
|
+
};
|
|
12093
|
+
}, (item)=>item);
|
|
12094
|
+
}
|
|
12095
|
+
apply(compiler) {
|
|
12096
|
+
let { manifest } = this, runCount = 0;
|
|
12097
|
+
compiler.hooks.beforeRun.tapPromise("IndependentSharedPlugin", async ()=>{
|
|
12098
|
+
!runCount && (await this.createIndependentCompilers(compiler), runCount++);
|
|
12099
|
+
}), compiler.hooks.watchRun.tapPromise("IndependentSharedPlugin", async ()=>{
|
|
12100
|
+
!runCount && (await this.createIndependentCompilers(compiler), runCount++);
|
|
12101
|
+
}), compiler.hooks.shutdown.tapAsync("IndependentSharedPlugin", (callback)=>{
|
|
12102
|
+
callback();
|
|
12103
|
+
}), manifest && compiler.hooks.compilation.tap("IndependentSharedPlugin", (compilation)=>{
|
|
12104
|
+
compilation.hooks.processAssets.tapPromise({
|
|
12105
|
+
name: "injectBuildAssets",
|
|
12106
|
+
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
12107
|
+
}, async ()=>{
|
|
12108
|
+
let { statsFileName, manifestFileName } = getFileName(manifest), injectBuildAssetsIntoStatsOrManifest = (filename)=>{
|
|
12109
|
+
let stats = compilation.getAsset(filename);
|
|
12110
|
+
if (!stats) return;
|
|
12111
|
+
let statsContent = JSON.parse(stats.source.source().toString()), { shared } = statsContent;
|
|
12112
|
+
Object.entries(this.buildAssets).forEach(([key, item])=>{
|
|
12113
|
+
let targetShared = shared.find((s)=>s.name === key);
|
|
12114
|
+
targetShared && item.forEach(([entry, version, globalName])=>{
|
|
12115
|
+
version === targetShared.version && (targetShared.fallback = entry, targetShared.fallbackName = globalName);
|
|
12116
|
+
});
|
|
12117
|
+
}), compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
|
|
12118
|
+
};
|
|
12119
|
+
injectBuildAssetsIntoStatsOrManifest(statsFileName), injectBuildAssetsIntoStatsOrManifest(manifestFileName);
|
|
12120
|
+
});
|
|
12121
|
+
});
|
|
12122
|
+
}
|
|
12123
|
+
async createIndependentCompilers(parentCompiler) {
|
|
12124
|
+
let { sharedOptions, buildAssets, outputDir } = this;
|
|
12125
|
+
console.log("🚀 Start creating a standalone compiler...");
|
|
12126
|
+
let shareRequestsMap = await this.createIndependentCompiler(parentCompiler);
|
|
12127
|
+
await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
|
|
12128
|
+
if (!shareConfig.treeshake || !1 === shareConfig.import) return;
|
|
12129
|
+
let shareRequests = shareRequestsMap[shareName].requests;
|
|
12130
|
+
await Promise.all(shareRequests.map(async ([request, version])=>{
|
|
12131
|
+
let sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1], [shareFileName, globalName, sharedVersion] = await this.createIndependentCompiler(parentCompiler, {
|
|
12132
|
+
shareRequestsMap,
|
|
12133
|
+
currentShare: {
|
|
12134
|
+
shareName,
|
|
12135
|
+
version,
|
|
12136
|
+
request,
|
|
12137
|
+
independentShareFileName: sharedConfig?.treeshake?.filename
|
|
12138
|
+
}
|
|
12139
|
+
});
|
|
12140
|
+
"string" == typeof shareFileName && (buildAssets[shareName] ||= [], buildAssets[shareName].push([
|
|
12141
|
+
(0, external_node_path_namespaceObject.join)(resolveOutputDir(outputDir, shareName), shareFileName),
|
|
12142
|
+
sharedVersion,
|
|
12143
|
+
globalName
|
|
12144
|
+
]));
|
|
12145
|
+
}));
|
|
12146
|
+
})), console.log("✅ All independent packages have been compiled successfully");
|
|
12147
|
+
}
|
|
12148
|
+
async createIndependentCompiler(parentCompiler, extraOptions) {
|
|
12149
|
+
let extraPlugin, { mfName, plugins, outputDir, sharedOptions, treeshake, library } = this, outputDirWithShareName = resolveOutputDir(outputDir, extraOptions?.currentShare?.shareName || ""), parentConfig = parentCompiler.options, finalPlugins = [], rspack = parentCompiler.rspack;
|
|
12150
|
+
extraPlugin = extraOptions ? new SharedContainerPlugin({
|
|
12151
|
+
mfName,
|
|
12152
|
+
library,
|
|
12153
|
+
...extraOptions.currentShare
|
|
12154
|
+
}) : new CollectSharedEntryPlugin({
|
|
12155
|
+
sharedOptions,
|
|
12156
|
+
shareScope: "default"
|
|
12157
|
+
}), (parentConfig.plugins || []).forEach((plugin)=>{
|
|
12158
|
+
void 0 !== plugin && "string" != typeof plugin && ((plugin)=>{
|
|
12159
|
+
if (!plugin) return !0;
|
|
12160
|
+
let pluginName = plugin.name || plugin.constructor?.name;
|
|
12161
|
+
return !pluginName || ![
|
|
12162
|
+
"TreeShakeSharedPlugin",
|
|
12163
|
+
"IndependentSharedPlugin",
|
|
12164
|
+
"ModuleFederationPlugin",
|
|
12165
|
+
"SharedUsedExportsOptimizerPlugin",
|
|
12166
|
+
"HtmlWebpackPlugin"
|
|
12167
|
+
].includes(pluginName);
|
|
12168
|
+
})(plugin) && finalPlugins.push(plugin);
|
|
12169
|
+
}), plugins.forEach((plugin)=>{
|
|
12170
|
+
finalPlugins.push(plugin);
|
|
12171
|
+
}), finalPlugins.push(extraPlugin), finalPlugins.push(new ConsumeSharedPlugin({
|
|
12172
|
+
consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
|
|
12173
|
+
[key]: {
|
|
12174
|
+
import: !extraOptions && options.import,
|
|
12175
|
+
shareKey: options.shareKey || key,
|
|
12176
|
+
shareScope: options.shareScope,
|
|
12177
|
+
requiredVersion: options.requiredVersion,
|
|
12178
|
+
strictVersion: options.strictVersion,
|
|
12179
|
+
singleton: options.singleton,
|
|
12180
|
+
packageName: options.packageName,
|
|
12181
|
+
eager: options.eager
|
|
12182
|
+
}
|
|
12183
|
+
})),
|
|
12184
|
+
enhanced: !0
|
|
12185
|
+
})), treeshake && finalPlugins.push(new SharedUsedExportsOptimizerPlugin(sharedOptions, this.injectUsedExports)), finalPlugins.push(new VirtualEntryPlugin(sharedOptions));
|
|
12186
|
+
let fullOutputDir = (0, external_node_path_namespaceObject.resolve)(parentCompiler.outputPath, outputDirWithShareName), compilerConfig = {
|
|
12187
|
+
...parentConfig,
|
|
12188
|
+
mode: parentConfig.mode || "development",
|
|
12189
|
+
entry: VirtualEntryPlugin.entry,
|
|
12190
|
+
output: {
|
|
12191
|
+
path: fullOutputDir,
|
|
12192
|
+
clean: !0,
|
|
12193
|
+
publicPath: parentConfig.output?.publicPath || "auto"
|
|
12194
|
+
},
|
|
12195
|
+
plugins: finalPlugins,
|
|
12196
|
+
optimization: {
|
|
12197
|
+
...parentConfig.optimization,
|
|
12198
|
+
splitChunks: !1
|
|
12199
|
+
}
|
|
12200
|
+
}, compiler = rspack.rspack(compilerConfig);
|
|
12201
|
+
compiler.inputFileSystem = parentCompiler.inputFileSystem, compiler.outputFileSystem = parentCompiler.outputFileSystem, compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
|
|
12202
|
+
let { currentShare } = extraOptions || {};
|
|
12203
|
+
return new Promise((resolve, reject)=>{
|
|
12204
|
+
compiler.run((err, stats)=>{
|
|
12205
|
+
if (err || stats?.hasErrors()) {
|
|
12206
|
+
let target = currentShare ? currentShare.shareName : "收集依赖";
|
|
12207
|
+
console.error(`❌ ${target} 编译失败:`, err || stats.toJson().errors.map((e)=>e.message).join("\n")), reject(err || Error(`${target} 编译失败`));
|
|
12208
|
+
return;
|
|
12209
|
+
}
|
|
12210
|
+
currentShare && console.log(`✅ 独立包 ${currentShare.shareName} 编译成功`), stats && (currentShare && console.log(`📊 ${currentShare.shareName} 编译统计:`), console.log(stats.toString({
|
|
12211
|
+
colors: !0,
|
|
12212
|
+
chunks: !1,
|
|
12213
|
+
modules: !1
|
|
12214
|
+
}))), resolve(extraPlugin.getData());
|
|
12215
|
+
});
|
|
12216
|
+
});
|
|
12217
|
+
}
|
|
12218
|
+
}
|
|
12219
|
+
class TreeShakeSharedPlugin {
|
|
12220
|
+
mfConfig;
|
|
12221
|
+
outputDir;
|
|
12222
|
+
plugins;
|
|
12223
|
+
reshake;
|
|
12224
|
+
_independentSharePlugin;
|
|
12225
|
+
name = "TreeShakeSharedPlugin";
|
|
12226
|
+
constructor(options){
|
|
12227
|
+
const { mfConfig, plugins, reshake } = options;
|
|
12228
|
+
this.mfConfig = mfConfig, this.outputDir = mfConfig.independentShareDir || "independent-packages", this.plugins = plugins, this.reshake = !!reshake;
|
|
12229
|
+
}
|
|
12230
|
+
apply(compiler) {
|
|
12231
|
+
let { mfConfig, outputDir, plugins, reshake } = this, { name, shared, library } = mfConfig;
|
|
12232
|
+
if (!shared) return;
|
|
12233
|
+
let sharedOptions = normalizeSharedOptions(shared);
|
|
12234
|
+
sharedOptions.length && sharedOptions.some(([_, config])=>config.treeshake && !1 !== config.import) && (reshake || new SharedUsedExportsOptimizerPlugin(sharedOptions, mfConfig.injectUsedExports, mfConfig.manifest).apply(compiler), this._independentSharePlugin = new IndependentSharedPlugin({
|
|
12235
|
+
name: name,
|
|
12236
|
+
shared: shared,
|
|
12237
|
+
outputDir,
|
|
12238
|
+
plugins,
|
|
12239
|
+
treeshake: reshake,
|
|
12240
|
+
library,
|
|
12241
|
+
manifest: mfConfig.manifest
|
|
12242
|
+
}), this._independentSharePlugin.apply(compiler));
|
|
12243
|
+
}
|
|
12244
|
+
get buildAssets() {
|
|
12245
|
+
return this._independentSharePlugin?.buildAssets || {};
|
|
12246
|
+
}
|
|
12247
|
+
}
|
|
12248
|
+
let ModuleFederationRuntimePlugin = base_create(binding_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
|
|
12249
|
+
function getRemoteInfos(options) {
|
|
12250
|
+
if (!options.remotes) return {};
|
|
12251
|
+
let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
|
|
12252
|
+
external: Array.isArray(item) ? item : [
|
|
12253
|
+
item
|
|
12254
|
+
],
|
|
12255
|
+
shareScope: options.shareScope || "default"
|
|
12256
|
+
}), (item)=>({
|
|
12257
|
+
external: Array.isArray(item.external) ? item.external : [
|
|
12258
|
+
item.external
|
|
12259
|
+
],
|
|
12260
|
+
shareScope: item.shareScope || options.shareScope || "default"
|
|
12261
|
+
})), remoteInfos = {};
|
|
12262
|
+
for (let [key, config] of remotes)for (let external of config.external){
|
|
12263
|
+
let [externalType, externalRequest] = function(external) {
|
|
12264
|
+
let result = function(external) {
|
|
12265
|
+
if (/^[a-z0-9-]+ /.test(external)) {
|
|
12266
|
+
let idx = external.indexOf(" ");
|
|
12267
|
+
return [
|
|
12268
|
+
external.slice(0, idx),
|
|
12269
|
+
external.slice(idx + 1)
|
|
12270
|
+
];
|
|
12271
|
+
}
|
|
12272
|
+
return null;
|
|
12273
|
+
}(external);
|
|
12274
|
+
return null === result ? [
|
|
12275
|
+
remoteType,
|
|
12276
|
+
external
|
|
12277
|
+
] : result;
|
|
12278
|
+
}(external);
|
|
12279
|
+
if (remoteInfos[key] ??= [], "script" === externalType) {
|
|
12280
|
+
let [url, global] = function(urlAndGlobal) {
|
|
12281
|
+
let index = urlAndGlobal.indexOf("@");
|
|
12282
|
+
return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
|
|
12283
|
+
urlAndGlobal.substring(index + 1),
|
|
12284
|
+
urlAndGlobal.substring(0, index)
|
|
12285
|
+
];
|
|
12286
|
+
}(externalRequest);
|
|
12287
|
+
remoteInfos[key].push({
|
|
12288
|
+
alias: key,
|
|
12289
|
+
name: global,
|
|
12290
|
+
entry: url,
|
|
12291
|
+
externalType,
|
|
12292
|
+
shareScope: config.shareScope
|
|
12293
|
+
});
|
|
12294
|
+
} else remoteInfos[key].push({
|
|
12295
|
+
alias: key,
|
|
12296
|
+
name: void 0,
|
|
12297
|
+
entry: void 0,
|
|
12298
|
+
externalType,
|
|
12299
|
+
shareScope: config.shareScope
|
|
12300
|
+
});
|
|
12301
|
+
}
|
|
12302
|
+
return remoteInfos;
|
|
12303
|
+
}
|
|
11884
12304
|
class ContainerPlugin extends RspackBuiltinPlugin {
|
|
11885
12305
|
name = binding_.BuiltinPluginName.ContainerPlugin;
|
|
11886
12306
|
_options;
|
|
@@ -11889,7 +12309,7 @@ Help:
|
|
|
11889
12309
|
name: options.name,
|
|
11890
12310
|
shareScope: options.shareScope || "default",
|
|
11891
12311
|
library: options.library || {
|
|
11892
|
-
type: "
|
|
12312
|
+
type: "global",
|
|
11893
12313
|
name: options.name
|
|
11894
12314
|
},
|
|
11895
12315
|
runtime: options.runtime,
|
|
@@ -11972,7 +12392,7 @@ Help:
|
|
|
11972
12392
|
let _options = JSON.stringify(options || {});
|
|
11973
12393
|
return binding_default().transform(source, _options);
|
|
11974
12394
|
}
|
|
11975
|
-
let exports_rspackVersion = "1.6.7-canary-
|
|
12395
|
+
let exports_rspackVersion = "1.6.7-canary-e27a87e9-20251209100543", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
|
|
11976
12396
|
getNormalizedRspackOptions: getNormalizedRspackOptions,
|
|
11977
12397
|
applyRspackOptionsDefaults: applyRspackOptionsDefaults,
|
|
11978
12398
|
getNormalizedWebpackOptions: getNormalizedRspackOptions,
|
|
@@ -12015,11 +12435,12 @@ Help:
|
|
|
12015
12435
|
ContainerReferencePlugin: ContainerReferencePlugin,
|
|
12016
12436
|
ModuleFederationPlugin: class {
|
|
12017
12437
|
_options;
|
|
12438
|
+
_treeShakeSharedPlugin;
|
|
12018
12439
|
constructor(_options){
|
|
12019
12440
|
this._options = _options;
|
|
12020
12441
|
}
|
|
12021
12442
|
apply(compiler) {
|
|
12022
|
-
var options;
|
|
12443
|
+
var options, options1;
|
|
12023
12444
|
let runtimeToolsPath, bundlerRuntimePath, runtimePath, { webpack } = compiler, paths = (runtimeToolsPath = (options = this._options).implementation ?? require.resolve("@module-federation/runtime-tools"), bundlerRuntimePath = require.resolve("@module-federation/webpack-bundler-runtime", {
|
|
12024
12445
|
paths: [
|
|
12025
12446
|
runtimeToolsPath
|
|
@@ -12033,101 +12454,54 @@ Help:
|
|
|
12033
12454
|
bundlerRuntime: bundlerRuntimePath,
|
|
12034
12455
|
runtime: runtimePath
|
|
12035
12456
|
});
|
|
12036
|
-
|
|
12457
|
+
compiler.options.resolve.alias = {
|
|
12037
12458
|
"@module-federation/runtime-tools": paths.runtimeTools,
|
|
12038
12459
|
"@module-federation/runtime": paths.runtime,
|
|
12039
12460
|
...compiler.options.resolve.alias
|
|
12040
|
-
},
|
|
12041
|
-
|
|
12042
|
-
|
|
12043
|
-
|
|
12044
|
-
|
|
12045
|
-
|
|
12046
|
-
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
|
|
12051
|
-
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
|
|
12055
|
-
|
|
12056
|
-
|
|
12057
|
-
|
|
12058
|
-
|
|
12059
|
-
|
|
12060
|
-
|
|
12461
|
+
}, ((options1 = this._options).shared ? parseOptions(options1.shared, (item, key)=>{
|
|
12462
|
+
if ("string" != typeof item) throw Error("Unexpected array in shared");
|
|
12463
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12464
|
+
import: key,
|
|
12465
|
+
requiredVersion: item
|
|
12466
|
+
} : {
|
|
12467
|
+
import: item
|
|
12468
|
+
};
|
|
12469
|
+
}, (item)=>item) : []).filter(([, config])=>config.treeshake).length > 0 && (this._treeShakeSharedPlugin = new TreeShakeSharedPlugin({
|
|
12470
|
+
mfConfig: this._options,
|
|
12471
|
+
reshake: !1
|
|
12472
|
+
}), this._treeShakeSharedPlugin.apply(compiler));
|
|
12473
|
+
let runtimePluginApplied = !1;
|
|
12474
|
+
compiler.hooks.beforeRun.tapPromise({
|
|
12475
|
+
name: "ModuleFederationPlugin",
|
|
12476
|
+
stage: 100
|
|
12477
|
+
}, async ()=>{
|
|
12478
|
+
runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
|
|
12479
|
+
entryRuntime: function(paths, options, compiler, treeshakeShareFallbacks) {
|
|
12480
|
+
let runtimePlugins = options.runtimePlugins ?? [], remoteInfos = getRemoteInfos(options), runtimePluginImports = [], runtimePluginVars = [], libraryType = options.library?.type || "var";
|
|
12481
|
+
for(let i = 0; i < runtimePlugins.length; i++){
|
|
12482
|
+
let runtimePluginVar = `__module_federation_runtime_plugin_${i}__`, pluginSpec = runtimePlugins[i], pluginPath = Array.isArray(pluginSpec) ? pluginSpec[0] : pluginSpec, pluginParams = Array.isArray(pluginSpec) ? pluginSpec[1] : void 0;
|
|
12483
|
+
runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
|
|
12484
|
+
let paramsCode = void 0 === pluginParams ? "undefined" : JSON.stringify(pluginParams);
|
|
12485
|
+
runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
|
|
12486
|
+
}
|
|
12487
|
+
let content = [
|
|
12488
|
+
`import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
|
|
12489
|
+
...runtimePluginImports,
|
|
12490
|
+
`const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(", ")}]`,
|
|
12491
|
+
`const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
|
|
12492
|
+
`const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
|
|
12493
|
+
`const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? "version-first")}`,
|
|
12494
|
+
`const __module_federation_share_fallbacks__ = ${JSON.stringify(treeshakeShareFallbacks)}`,
|
|
12495
|
+
`const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
|
|
12496
|
+
compiler.webpack.Template.getFunctionContent(__webpack_require__("./moduleFederationDefaultRuntime.js"))
|
|
12497
|
+
].join(";");
|
|
12498
|
+
return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
|
|
12499
|
+
}(paths, this._options, compiler, this._treeShakeSharedPlugin?.buildAssets || {})
|
|
12500
|
+
}).apply(compiler));
|
|
12501
|
+
}), new webpack.container.ModuleFederationPluginV1({
|
|
12061
12502
|
...this._options,
|
|
12062
12503
|
enhanced: !0
|
|
12063
|
-
}).apply(compiler), this._options.manifest)
|
|
12064
|
-
let manifestOptions = !0 === this._options.manifest ? {} : {
|
|
12065
|
-
...this._options.manifest
|
|
12066
|
-
}, containerName = manifestOptions.name ?? this._options.name, globalName = manifestOptions.globalName ?? function(library) {
|
|
12067
|
-
if (!library) return;
|
|
12068
|
-
let libName = library.name;
|
|
12069
|
-
if (libName) {
|
|
12070
|
-
if ("string" == typeof libName) return libName;
|
|
12071
|
-
if (Array.isArray(libName)) return libName[0];
|
|
12072
|
-
if ("object" == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
12073
|
-
}
|
|
12074
|
-
}(this._options.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
|
|
12075
|
-
if (cur[1].length > 1) return sum;
|
|
12076
|
-
let { entry, alias, name } = cur[1][0];
|
|
12077
|
-
return entry && name && (sum[alias] = {
|
|
12078
|
-
name,
|
|
12079
|
-
entry
|
|
12080
|
-
}), sum;
|
|
12081
|
-
}, {}), manifestExposes = function(exposes) {
|
|
12082
|
-
if (!exposes) return;
|
|
12083
|
-
let result = parseOptions(exposes, (value, key)=>({
|
|
12084
|
-
import: Array.isArray(value) ? value : [
|
|
12085
|
-
value
|
|
12086
|
-
],
|
|
12087
|
-
name: void 0
|
|
12088
|
-
}), (value)=>({
|
|
12089
|
-
import: Array.isArray(value.import) ? value.import : [
|
|
12090
|
-
value.import
|
|
12091
|
-
],
|
|
12092
|
-
name: value.name ?? void 0
|
|
12093
|
-
})).map(([exposeKey, info])=>{
|
|
12094
|
-
let exposeName = info.name ?? exposeKey.replace(/^\.\//, "");
|
|
12095
|
-
return {
|
|
12096
|
-
path: exposeKey,
|
|
12097
|
-
name: exposeName
|
|
12098
|
-
};
|
|
12099
|
-
});
|
|
12100
|
-
return result.length > 0 ? result : void 0;
|
|
12101
|
-
}(this._options.exposes);
|
|
12102
|
-
void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes);
|
|
12103
|
-
let manifestShared = function(shared) {
|
|
12104
|
-
if (!shared) return;
|
|
12105
|
-
let result = parseOptions(shared, (item, key)=>{
|
|
12106
|
-
if ("string" != typeof item) throw Error("Unexpected array in shared");
|
|
12107
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
12108
|
-
import: key,
|
|
12109
|
-
requiredVersion: item
|
|
12110
|
-
} : {
|
|
12111
|
-
import: item
|
|
12112
|
-
};
|
|
12113
|
-
}, (item)=>item).map(([key, config])=>{
|
|
12114
|
-
let name = config.shareKey || key, version = "string" == typeof config.version ? config.version : void 0;
|
|
12115
|
-
return {
|
|
12116
|
-
name,
|
|
12117
|
-
version,
|
|
12118
|
-
requiredVersion: "string" == typeof config.requiredVersion ? config.requiredVersion : void 0,
|
|
12119
|
-
singleton: config.singleton
|
|
12120
|
-
};
|
|
12121
|
-
});
|
|
12122
|
-
return result.length > 0 ? result : void 0;
|
|
12123
|
-
}(this._options.shared);
|
|
12124
|
-
void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), new ModuleFederationManifestPlugin({
|
|
12125
|
-
...manifestOptions,
|
|
12126
|
-
name: containerName,
|
|
12127
|
-
globalName,
|
|
12128
|
-
remoteAliasMap
|
|
12129
|
-
}).apply(compiler);
|
|
12130
|
-
}
|
|
12504
|
+
}).apply(compiler), this._options.manifest && new ModuleFederationManifestPlugin(this._options).apply(compiler);
|
|
12131
12505
|
}
|
|
12132
12506
|
},
|
|
12133
12507
|
ModuleFederationPluginV1: class {
|
|
@@ -12164,6 +12538,7 @@ Help:
|
|
|
12164
12538
|
}
|
|
12165
12539
|
}, sharing = {
|
|
12166
12540
|
ProvideSharedPlugin: ProvideSharedPlugin,
|
|
12541
|
+
TreeShakeSharedPlugin: TreeShakeSharedPlugin,
|
|
12167
12542
|
ConsumeSharedPlugin: ConsumeSharedPlugin,
|
|
12168
12543
|
SharePlugin: SharePlugin
|
|
12169
12544
|
}, exports_experiments = {
|