@rspack-canary/core 1.7.3-canary-785c0f6f-20260114175124 → 1.7.3-canary-1138ed18-20260115124957
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/container/ModuleFederationManifestPlugin.d.ts +10 -3
- package/dist/container/ModuleFederationPlugin.d.ts +17 -1
- package/dist/exports.d.ts +3 -0
- package/dist/index.js +716 -286
- package/dist/moduleFederationDefaultRuntime.js +1 -1
- package/dist/sharing/CollectSharedEntryPlugin.d.ts +22 -0
- package/dist/sharing/ConsumeSharedPlugin.d.ts +13 -0
- package/dist/sharing/IndependentSharedPlugin.d.ts +35 -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/TreeShakingSharedPlugin.d.ts +16 -0
- package/dist/sharing/utils.d.ts +1 -0
- package/hot/lazy-compilation-node.js +90 -34
- package/hot/lazy-compilation-web.js +61 -35
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -4510,16 +4510,44 @@ Plugins which provide custom chunk loading types must call EnableChunkLoadingPlu
|
|
|
4510
4510
|
}
|
|
4511
4511
|
let lazyCompilationMiddlewareInternal = (compiler, activeModules, lazyCompilationPrefix)=>{
|
|
4512
4512
|
let logger = compiler.getInfrastructureLogger('LazyCompilation');
|
|
4513
|
-
return (req, res, next)=>{
|
|
4514
|
-
if (!req.url?.startsWith(lazyCompilationPrefix)) return next?.();
|
|
4515
|
-
let modules =
|
|
4516
|
-
|
|
4513
|
+
return async (req, res, next)=>{
|
|
4514
|
+
if (!req.url?.startsWith(lazyCompilationPrefix) || 'POST' !== req.method) return next?.();
|
|
4515
|
+
let modules = [];
|
|
4516
|
+
try {
|
|
4517
|
+
modules = await function(req) {
|
|
4518
|
+
if (void 0 !== req.body) {
|
|
4519
|
+
if (Array.isArray(req.body)) return Promise.resolve(req.body);
|
|
4520
|
+
if ('string' == typeof req.body) return Promise.resolve(req.body.split('\n').filter(Boolean));
|
|
4521
|
+
throw Error('Invalid body type');
|
|
4522
|
+
}
|
|
4523
|
+
return new Promise((resolve, reject)=>{
|
|
4524
|
+
if (req.aborted || req.destroyed) return void reject(Error('Request was aborted before body could be read'));
|
|
4525
|
+
let cleanup = ()=>{
|
|
4526
|
+
req.removeListener('data', onData), req.removeListener('end', onEnd), req.removeListener('error', onError), req.removeListener('close', onClose), req.removeListener('aborted', onAborted);
|
|
4527
|
+
}, chunks = [], onData = (chunk)=>{
|
|
4528
|
+
chunks.push(chunk);
|
|
4529
|
+
}, onEnd = ()=>{
|
|
4530
|
+
cleanup(), resolve(Buffer.concat(chunks).toString('utf8').split('\n').filter(Boolean));
|
|
4531
|
+
}, onError = (err)=>{
|
|
4532
|
+
cleanup(), reject(err);
|
|
4533
|
+
}, onClose = ()=>{
|
|
4534
|
+
cleanup(), reject(Error('Request was closed before body could be read'));
|
|
4535
|
+
}, onAborted = ()=>{
|
|
4536
|
+
cleanup(), reject(Error('Request was aborted before body could be read'));
|
|
4537
|
+
};
|
|
4538
|
+
req.on('data', onData), req.on('end', onEnd), req.on('error', onError), req.on('close', onClose), req.on('aborted', onAborted);
|
|
4539
|
+
});
|
|
4540
|
+
}(req);
|
|
4541
|
+
} catch (err) {
|
|
4542
|
+
logger.error('Failed to parse request body: ' + err), res.writeHead(400), res.end('Bad Request');
|
|
4543
|
+
return;
|
|
4544
|
+
}
|
|
4517
4545
|
let moduleActivated = [];
|
|
4518
4546
|
for (let key of modules){
|
|
4519
4547
|
let activated = activeModules.has(key);
|
|
4520
4548
|
activeModules.add(key), activated || (logger.log(`${key} is now in use and will be compiled.`), moduleActivated.push(key));
|
|
4521
4549
|
}
|
|
4522
|
-
moduleActivated.length && compiler.watching && compiler.watching.invalidate();
|
|
4550
|
+
moduleActivated.length && compiler.watching && compiler.watching.invalidate(), res.writeHead(200), res.write('\n'), res.end();
|
|
4523
4551
|
};
|
|
4524
4552
|
};
|
|
4525
4553
|
class MangleExportsPlugin extends RspackBuiltinPlugin {
|
|
@@ -5854,7 +5882,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
5854
5882
|
}, applyExperimentsDefaults = (experiments, { development })=>{
|
|
5855
5883
|
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, 'parallelLoader', !1), D(experiments, 'useInputFileSystem', !1), D(experiments, 'inlineConst', !0), D(experiments, 'inlineEnum', !1), D(experiments, 'typeReexportsPresence', !1), D(experiments, 'lazyBarrel', !0);
|
|
5856
5884
|
}, applybundlerInfoDefaults = (rspackFuture, library)=>{
|
|
5857
|
-
'object' == typeof rspackFuture && (D(rspackFuture, 'bundlerInfo', {}), 'object' == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, 'version', "1.7.3-canary-
|
|
5885
|
+
'object' == typeof rspackFuture && (D(rspackFuture, 'bundlerInfo', {}), 'object' == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, 'version', "1.7.3-canary-1138ed18-20260115124957"), D(rspackFuture.bundlerInfo, 'bundler', 'rspack'), D(rspackFuture.bundlerInfo, 'force', !library)));
|
|
5858
5886
|
}, applySnapshotDefaults = (_snapshot, _env)=>{}, applyCssGeneratorOptionsDefaults = (generatorOptions, { targetProperties })=>{
|
|
5859
5887
|
D(generatorOptions, 'exportsOnly', !targetProperties || !1 === targetProperties.document), D(generatorOptions, 'esModule', !0);
|
|
5860
5888
|
}, applyModuleDefaults = (module1, { cache, asyncWebAssembly, css, targetProperties, mode, uniqueName, deferImport })=>{
|
|
@@ -7392,10 +7420,10 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
7392
7420
|
hasWarnings() {
|
|
7393
7421
|
return this.stats.some((stat)=>stat.hasWarnings());
|
|
7394
7422
|
}
|
|
7395
|
-
#createChildOptions(options
|
|
7423
|
+
#createChildOptions(options, context) {
|
|
7396
7424
|
let { children: childrenOptions, ...baseOptions } = 'string' == typeof options || 'boolean' == typeof options ? {
|
|
7397
7425
|
preset: options
|
|
7398
|
-
} : options, children = this.stats.map((stat, idx)=>{
|
|
7426
|
+
} : options ?? {}, children = this.stats.map((stat, idx)=>{
|
|
7399
7427
|
let childOptions = Array.isArray(childrenOptions) ? childrenOptions[idx] : childrenOptions;
|
|
7400
7428
|
return stat.compilation.createStatsOptions({
|
|
7401
7429
|
...baseOptions,
|
|
@@ -7422,7 +7450,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
7422
7450
|
obj.children = this.stats.map((stat, idx)=>{
|
|
7423
7451
|
let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
|
|
7424
7452
|
return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
|
|
7425
|
-
}), childOptions.version && (obj.rspackVersion = "1.7.3-canary-
|
|
7453
|
+
}), childOptions.version && (obj.rspackVersion = "1.7.3-canary-1138ed18-20260115124957", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
|
|
7426
7454
|
let mapError = (j, obj)=>({
|
|
7427
7455
|
...obj,
|
|
7428
7456
|
compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
|
|
@@ -8678,7 +8706,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
8678
8706
|
object.hash = context.getStatsCompilation(compilation).hash;
|
|
8679
8707
|
},
|
|
8680
8708
|
version: (object)=>{
|
|
8681
|
-
object.version = "5.75.0", object.rspackVersion = "1.7.3-canary-
|
|
8709
|
+
object.version = "5.75.0", object.rspackVersion = "1.7.3-canary-1138ed18-20260115124957";
|
|
8682
8710
|
},
|
|
8683
8711
|
env: (object, _compilation, _context, { _env })=>{
|
|
8684
8712
|
object.env = _env;
|
|
@@ -10107,7 +10135,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
10107
10135
|
function isMultiRspackOptions(o) {
|
|
10108
10136
|
return Array.isArray(o);
|
|
10109
10137
|
}
|
|
10110
|
-
function
|
|
10138
|
+
function rspack_rspack(options, callback) {
|
|
10111
10139
|
try {
|
|
10112
10140
|
if (isMultiRspackOptions(options)) for (let option of options)validateRspackConfig(option);
|
|
10113
10141
|
else validateRspackConfig(options);
|
|
@@ -10403,7 +10431,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
|
|
|
10403
10431
|
});
|
|
10404
10432
|
}
|
|
10405
10433
|
}
|
|
10406
|
-
let CORE_VERSION = "1.7.3-canary-
|
|
10434
|
+
let CORE_VERSION = "1.7.3-canary-1138ed18-20260115124957", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
|
|
10407
10435
|
|
|
10408
10436
|
Help:
|
|
10409
10437
|
Looks like you are using a custom binding (via environment variable 'RSPACK_BINDING=${process.env.RSPACK_BINDING}').
|
|
@@ -10724,7 +10752,7 @@ Help:
|
|
|
10724
10752
|
additionalPass: new lite_tapable_namespaceObject.AsyncSeriesHook([])
|
|
10725
10753
|
};
|
|
10726
10754
|
const compilerRuntimeGlobals = createCompilerRuntimeGlobals(options), compilerRspack = Object.assign(function(...params) {
|
|
10727
|
-
return
|
|
10755
|
+
return rspack_rspack(...params);
|
|
10728
10756
|
}, exports_namespaceObject, {
|
|
10729
10757
|
RuntimeGlobals: compilerRuntimeGlobals
|
|
10730
10758
|
});
|
|
@@ -11819,69 +11847,7 @@ Help:
|
|
|
11819
11847
|
});
|
|
11820
11848
|
}
|
|
11821
11849
|
}
|
|
11822
|
-
let
|
|
11823
|
-
function isRequiredVersion(str) {
|
|
11824
|
-
return VERSION_PATTERN_REGEXP.test(str);
|
|
11825
|
-
}
|
|
11826
|
-
let MANIFEST_FILE_NAME = 'mf-manifest.json', STATS_FILE_NAME = 'mf-stats.json', JSON_EXT = '.json';
|
|
11827
|
-
function isPlainObject(value) {
|
|
11828
|
-
return !!value && 'object' == typeof value && !Array.isArray(value);
|
|
11829
|
-
}
|
|
11830
|
-
class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
11831
|
-
name = binding_.BuiltinPluginName.ModuleFederationManifestPlugin;
|
|
11832
|
-
opts;
|
|
11833
|
-
constructor(opts){
|
|
11834
|
-
super(), this.opts = opts;
|
|
11835
|
-
}
|
|
11836
|
-
raw(compiler) {
|
|
11837
|
-
var isDev;
|
|
11838
|
-
let pkg, buildVersion, { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts, { statsFileName, manifestFileName } = function(manifestOptions) {
|
|
11839
|
-
var name;
|
|
11840
|
-
if (!manifestOptions) return {
|
|
11841
|
-
statsFileName: STATS_FILE_NAME,
|
|
11842
|
-
manifestFileName: MANIFEST_FILE_NAME
|
|
11843
|
-
};
|
|
11844
|
-
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;
|
|
11845
|
-
return {
|
|
11846
|
-
statsFileName: (0, external_node_path_namespaceObject.join)(filePath, statsFileName),
|
|
11847
|
-
manifestFileName: (0, external_node_path_namespaceObject.join)(filePath, manifestFileName)
|
|
11848
|
-
};
|
|
11849
|
-
}(this.opts), rawOptions = {
|
|
11850
|
-
name: this.opts.name,
|
|
11851
|
-
globalName: this.opts.globalName,
|
|
11852
|
-
fileName,
|
|
11853
|
-
filePath,
|
|
11854
|
-
manifestFileName,
|
|
11855
|
-
statsFileName,
|
|
11856
|
-
disableAssetsAnalyze,
|
|
11857
|
-
remoteAliasMap,
|
|
11858
|
-
exposes,
|
|
11859
|
-
shared,
|
|
11860
|
-
buildInfo: (isDev = 'development' === compiler.options.mode, pkg = function(root) {
|
|
11861
|
-
let base = root ? (0, external_node_path_namespaceObject.resolve)(root) : process.cwd(), pkgPath = (0, external_node_path_namespaceObject.join)(base, 'package.json');
|
|
11862
|
-
try {
|
|
11863
|
-
let content = (0, external_node_fs_namespaceObject.readFileSync)(pkgPath, 'utf-8'), parsed = function(input, guard) {
|
|
11864
|
-
try {
|
|
11865
|
-
let parsed = JSON.parse(input);
|
|
11866
|
-
if (guard(parsed)) return parsed;
|
|
11867
|
-
} catch {}
|
|
11868
|
-
}(content, isPlainObject);
|
|
11869
|
-
if (parsed) {
|
|
11870
|
-
let filtered = {};
|
|
11871
|
-
for (let [key, value] of Object.entries(parsed))'string' == typeof value && (filtered[key] = value);
|
|
11872
|
-
if (Object.keys(filtered).length > 0) return filtered;
|
|
11873
|
-
}
|
|
11874
|
-
} catch {}
|
|
11875
|
-
return {};
|
|
11876
|
-
}(compiler.context || process.cwd()), buildVersion = isDev ? 'local' : pkg?.version, {
|
|
11877
|
-
buildVersion: process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
|
|
11878
|
-
buildName: process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
|
|
11879
|
-
})
|
|
11880
|
-
};
|
|
11881
|
-
return createBuiltinPlugin(this.name, rawOptions);
|
|
11882
|
-
}
|
|
11883
|
-
}
|
|
11884
|
-
let ModuleFederationRuntimePlugin = base_create(binding_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options), parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
11850
|
+
let parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
11885
11851
|
let items = [];
|
|
11886
11852
|
var options1 = options, normalizeSimple1 = normalizeSimple, normalizeOptions1 = normalizeOptions, fn = (key, value)=>{
|
|
11887
11853
|
items.push([
|
|
@@ -11900,63 +11866,7 @@ Help:
|
|
|
11900
11866
|
} else if ('object' == typeof options1) object(options1);
|
|
11901
11867
|
else throw Error('Unexpected options format');
|
|
11902
11868
|
return items;
|
|
11903
|
-
};
|
|
11904
|
-
function getRemoteInfos(options) {
|
|
11905
|
-
if (!options.remotes) return {};
|
|
11906
|
-
let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
|
|
11907
|
-
external: Array.isArray(item) ? item : [
|
|
11908
|
-
item
|
|
11909
|
-
],
|
|
11910
|
-
shareScope: options.shareScope || 'default'
|
|
11911
|
-
}), (item)=>({
|
|
11912
|
-
external: Array.isArray(item.external) ? item.external : [
|
|
11913
|
-
item.external
|
|
11914
|
-
],
|
|
11915
|
-
shareScope: item.shareScope || options.shareScope || 'default'
|
|
11916
|
-
})), remoteInfos = {};
|
|
11917
|
-
for (let [key, config] of remotes)for (let external of config.external){
|
|
11918
|
-
let [externalType, externalRequest] = function(external) {
|
|
11919
|
-
let result = function(external) {
|
|
11920
|
-
if (/^[a-z0-9-]+ /.test(external)) {
|
|
11921
|
-
let idx = external.indexOf(' ');
|
|
11922
|
-
return [
|
|
11923
|
-
external.slice(0, idx),
|
|
11924
|
-
external.slice(idx + 1)
|
|
11925
|
-
];
|
|
11926
|
-
}
|
|
11927
|
-
return null;
|
|
11928
|
-
}(external);
|
|
11929
|
-
return null === result ? [
|
|
11930
|
-
remoteType,
|
|
11931
|
-
external
|
|
11932
|
-
] : result;
|
|
11933
|
-
}(external);
|
|
11934
|
-
if (remoteInfos[key] ??= [], "script" === externalType) {
|
|
11935
|
-
let [url, global] = function(urlAndGlobal) {
|
|
11936
|
-
let index = urlAndGlobal.indexOf('@');
|
|
11937
|
-
return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
|
|
11938
|
-
urlAndGlobal.substring(index + 1),
|
|
11939
|
-
urlAndGlobal.substring(0, index)
|
|
11940
|
-
];
|
|
11941
|
-
}(externalRequest);
|
|
11942
|
-
remoteInfos[key].push({
|
|
11943
|
-
alias: key,
|
|
11944
|
-
name: global,
|
|
11945
|
-
entry: url,
|
|
11946
|
-
externalType,
|
|
11947
|
-
shareScope: config.shareScope
|
|
11948
|
-
});
|
|
11949
|
-
} else remoteInfos[key].push({
|
|
11950
|
-
alias: key,
|
|
11951
|
-
name: void 0,
|
|
11952
|
-
entry: void 0,
|
|
11953
|
-
externalType,
|
|
11954
|
-
shareScope: config.shareScope
|
|
11955
|
-
});
|
|
11956
|
-
}
|
|
11957
|
-
return remoteInfos;
|
|
11958
|
-
}
|
|
11959
|
-
let compilerSet = new WeakSet();
|
|
11869
|
+
}, compilerSet = new WeakSet();
|
|
11960
11870
|
class ShareRuntimePlugin extends RspackBuiltinPlugin {
|
|
11961
11871
|
enhanced;
|
|
11962
11872
|
name = binding_.BuiltinPluginName.ShareRuntimePlugin;
|
|
@@ -11968,42 +11878,55 @@ Help:
|
|
|
11968
11878
|
if (compiler1 = compiler, !compilerSet.has(compiler1)) return compiler2 = compiler, compilerSet.add(compiler2), createBuiltinPlugin(this.name, this.enhanced);
|
|
11969
11879
|
}
|
|
11970
11880
|
}
|
|
11881
|
+
let VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
|
|
11882
|
+
function isRequiredVersion(str) {
|
|
11883
|
+
return VERSION_PATTERN_REGEXP.test(str);
|
|
11884
|
+
}
|
|
11885
|
+
let encodeName = function(name, prefix = '', withExt = !1) {
|
|
11886
|
+
return `${prefix}${name.replace(/@/g, 'scope_').replace(/-/g, '_').replace(/\//g, '__').replace(/\./g, '')}${withExt ? '.js' : ''}`;
|
|
11887
|
+
};
|
|
11888
|
+
function normalizeConsumeShareOptions(consumes, shareScope) {
|
|
11889
|
+
return parseOptions(consumes, (item, key)=>{
|
|
11890
|
+
if (Array.isArray(item)) throw Error('Unexpected array in options');
|
|
11891
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
11892
|
+
import: key,
|
|
11893
|
+
shareScope: shareScope || 'default',
|
|
11894
|
+
shareKey: key,
|
|
11895
|
+
requiredVersion: item,
|
|
11896
|
+
strictVersion: !0,
|
|
11897
|
+
packageName: void 0,
|
|
11898
|
+
singleton: !1,
|
|
11899
|
+
eager: !1,
|
|
11900
|
+
treeShakingMode: void 0
|
|
11901
|
+
} : {
|
|
11902
|
+
import: key,
|
|
11903
|
+
shareScope: shareScope || 'default',
|
|
11904
|
+
shareKey: key,
|
|
11905
|
+
requiredVersion: void 0,
|
|
11906
|
+
packageName: void 0,
|
|
11907
|
+
strictVersion: !1,
|
|
11908
|
+
singleton: !1,
|
|
11909
|
+
eager: !1,
|
|
11910
|
+
treeShakingMode: void 0
|
|
11911
|
+
};
|
|
11912
|
+
}, (item, key)=>({
|
|
11913
|
+
import: !1 === item.import ? void 0 : item.import || key,
|
|
11914
|
+
shareScope: item.shareScope || shareScope || 'default',
|
|
11915
|
+
shareKey: item.shareKey || key,
|
|
11916
|
+
requiredVersion: item.requiredVersion,
|
|
11917
|
+
strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
|
|
11918
|
+
packageName: item.packageName,
|
|
11919
|
+
singleton: !!item.singleton,
|
|
11920
|
+
eager: !!item.eager,
|
|
11921
|
+
treeShakingMode: item.treeShakingMode
|
|
11922
|
+
}));
|
|
11923
|
+
}
|
|
11971
11924
|
class ConsumeSharedPlugin extends RspackBuiltinPlugin {
|
|
11972
11925
|
name = binding_.BuiltinPluginName.ConsumeSharedPlugin;
|
|
11973
11926
|
_options;
|
|
11974
11927
|
constructor(options){
|
|
11975
11928
|
super(), this._options = {
|
|
11976
|
-
consumes:
|
|
11977
|
-
if (Array.isArray(item)) throw Error('Unexpected array in options');
|
|
11978
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
11979
|
-
import: key,
|
|
11980
|
-
shareScope: options.shareScope || 'default',
|
|
11981
|
-
shareKey: key,
|
|
11982
|
-
requiredVersion: item,
|
|
11983
|
-
strictVersion: !0,
|
|
11984
|
-
packageName: void 0,
|
|
11985
|
-
singleton: !1,
|
|
11986
|
-
eager: !1
|
|
11987
|
-
} : {
|
|
11988
|
-
import: key,
|
|
11989
|
-
shareScope: options.shareScope || 'default',
|
|
11990
|
-
shareKey: key,
|
|
11991
|
-
requiredVersion: void 0,
|
|
11992
|
-
packageName: void 0,
|
|
11993
|
-
strictVersion: !1,
|
|
11994
|
-
singleton: !1,
|
|
11995
|
-
eager: !1
|
|
11996
|
-
};
|
|
11997
|
-
}, (item, key)=>({
|
|
11998
|
-
import: !1 === item.import ? void 0 : item.import || key,
|
|
11999
|
-
shareScope: item.shareScope || options.shareScope || 'default',
|
|
12000
|
-
shareKey: item.shareKey || key,
|
|
12001
|
-
requiredVersion: item.requiredVersion,
|
|
12002
|
-
strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
|
|
12003
|
-
packageName: item.packageName,
|
|
12004
|
-
singleton: !!item.singleton,
|
|
12005
|
-
eager: !!item.eager
|
|
12006
|
-
})),
|
|
11929
|
+
consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
|
|
12007
11930
|
enhanced: options.enhanced ?? !1
|
|
12008
11931
|
};
|
|
12009
11932
|
}
|
|
@@ -12024,28 +11947,30 @@ Help:
|
|
|
12024
11947
|
_provides;
|
|
12025
11948
|
_enhanced;
|
|
12026
11949
|
constructor(options){
|
|
12027
|
-
|
|
11950
|
+
var options1, shareScope, enhanced;
|
|
11951
|
+
super(), this._provides = (options1 = options.provides, shareScope = options.shareScope, enhanced = options.enhanced, parseOptions(options1, (item)=>{
|
|
12028
11952
|
if (Array.isArray(item)) throw Error('Unexpected array of provides');
|
|
12029
11953
|
return {
|
|
12030
11954
|
shareKey: item,
|
|
12031
11955
|
version: void 0,
|
|
12032
|
-
shareScope:
|
|
11956
|
+
shareScope: shareScope || 'default',
|
|
12033
11957
|
eager: !1
|
|
12034
11958
|
};
|
|
12035
11959
|
}, (item)=>{
|
|
12036
11960
|
let raw = {
|
|
12037
11961
|
shareKey: item.shareKey,
|
|
12038
11962
|
version: item.version,
|
|
12039
|
-
shareScope: item.shareScope ||
|
|
11963
|
+
shareScope: item.shareScope || shareScope || 'default',
|
|
12040
11964
|
eager: !!item.eager
|
|
12041
11965
|
};
|
|
12042
|
-
return
|
|
11966
|
+
return enhanced ? {
|
|
12043
11967
|
...raw,
|
|
12044
11968
|
singleton: item.singleton,
|
|
12045
11969
|
requiredVersion: item.requiredVersion,
|
|
12046
|
-
strictVersion: item.strictVersion
|
|
11970
|
+
strictVersion: item.strictVersion,
|
|
11971
|
+
treeShakingMode: item.treeShakingMode
|
|
12047
11972
|
} : raw;
|
|
12048
|
-
}), this._enhanced = options.enhanced;
|
|
11973
|
+
})), this._enhanced = options.enhanced;
|
|
12049
11974
|
}
|
|
12050
11975
|
raw(compiler) {
|
|
12051
11976
|
new ShareRuntimePlugin(this._enhanced ?? !1).apply(compiler);
|
|
@@ -12056,32 +11981,40 @@ Help:
|
|
|
12056
11981
|
return createBuiltinPlugin(this.name, rawOptions);
|
|
12057
11982
|
}
|
|
12058
11983
|
}
|
|
11984
|
+
function normalizeSharedOptions(shared) {
|
|
11985
|
+
return parseOptions(shared, (item, key)=>{
|
|
11986
|
+
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
11987
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
11988
|
+
import: key,
|
|
11989
|
+
requiredVersion: item
|
|
11990
|
+
} : {
|
|
11991
|
+
import: item
|
|
11992
|
+
};
|
|
11993
|
+
}, (item)=>item);
|
|
11994
|
+
}
|
|
11995
|
+
function createConsumeShareOptions(normalizedSharedOptions) {
|
|
11996
|
+
return normalizedSharedOptions.map(([key, options])=>({
|
|
11997
|
+
[key]: {
|
|
11998
|
+
import: options.import,
|
|
11999
|
+
shareKey: options.shareKey || key,
|
|
12000
|
+
shareScope: options.shareScope,
|
|
12001
|
+
requiredVersion: options.requiredVersion,
|
|
12002
|
+
strictVersion: options.strictVersion,
|
|
12003
|
+
singleton: options.singleton,
|
|
12004
|
+
packageName: options.packageName,
|
|
12005
|
+
eager: options.eager,
|
|
12006
|
+
treeShakingMode: options.treeShaking?.mode
|
|
12007
|
+
}
|
|
12008
|
+
}));
|
|
12009
|
+
}
|
|
12059
12010
|
class SharePlugin {
|
|
12060
12011
|
_shareScope;
|
|
12061
12012
|
_consumes;
|
|
12062
12013
|
_provides;
|
|
12063
12014
|
_enhanced;
|
|
12015
|
+
_sharedOptions;
|
|
12064
12016
|
constructor(options){
|
|
12065
|
-
const sharedOptions =
|
|
12066
|
-
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12067
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
12068
|
-
import: key,
|
|
12069
|
-
requiredVersion: item
|
|
12070
|
-
} : {
|
|
12071
|
-
import: item
|
|
12072
|
-
};
|
|
12073
|
-
}, (item)=>item), consumes = sharedOptions.map(([key, options])=>({
|
|
12074
|
-
[key]: {
|
|
12075
|
-
import: options.import,
|
|
12076
|
-
shareKey: options.shareKey || key,
|
|
12077
|
-
shareScope: options.shareScope,
|
|
12078
|
-
requiredVersion: options.requiredVersion,
|
|
12079
|
-
strictVersion: options.strictVersion,
|
|
12080
|
-
singleton: options.singleton,
|
|
12081
|
-
packageName: options.packageName,
|
|
12082
|
-
eager: options.eager
|
|
12083
|
-
}
|
|
12084
|
-
})), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
|
|
12017
|
+
const sharedOptions = normalizeSharedOptions(options.shared), consumes = createConsumeShareOptions(sharedOptions), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
|
|
12085
12018
|
[options.import || key]: {
|
|
12086
12019
|
shareKey: options.shareKey || key,
|
|
12087
12020
|
shareScope: options.shareScope,
|
|
@@ -12089,10 +12022,11 @@ Help:
|
|
|
12089
12022
|
eager: options.eager,
|
|
12090
12023
|
singleton: options.singleton,
|
|
12091
12024
|
requiredVersion: options.requiredVersion,
|
|
12092
|
-
strictVersion: options.strictVersion
|
|
12025
|
+
strictVersion: options.strictVersion,
|
|
12026
|
+
treeShakingMode: options.treeShaking?.mode
|
|
12093
12027
|
}
|
|
12094
12028
|
}));
|
|
12095
|
-
this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1;
|
|
12029
|
+
this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1, this._sharedOptions = sharedOptions;
|
|
12096
12030
|
}
|
|
12097
12031
|
apply(compiler) {
|
|
12098
12032
|
new ConsumeSharedPlugin({
|
|
@@ -12106,6 +12040,560 @@ Help:
|
|
|
12106
12040
|
}).apply(compiler);
|
|
12107
12041
|
}
|
|
12108
12042
|
}
|
|
12043
|
+
let MANIFEST_FILE_NAME = 'mf-manifest.json', STATS_FILE_NAME = 'mf-stats.json', JSON_EXT = '.json';
|
|
12044
|
+
function isPlainObject(value) {
|
|
12045
|
+
return !!value && 'object' == typeof value && !Array.isArray(value);
|
|
12046
|
+
}
|
|
12047
|
+
function getFileName(manifestOptions) {
|
|
12048
|
+
var name;
|
|
12049
|
+
if (!manifestOptions) return {
|
|
12050
|
+
statsFileName: '',
|
|
12051
|
+
manifestFileName: ''
|
|
12052
|
+
};
|
|
12053
|
+
if ('boolean' == typeof manifestOptions) return {
|
|
12054
|
+
statsFileName: STATS_FILE_NAME,
|
|
12055
|
+
manifestFileName: MANIFEST_FILE_NAME
|
|
12056
|
+
};
|
|
12057
|
+
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;
|
|
12058
|
+
return {
|
|
12059
|
+
statsFileName: (0, external_node_path_namespaceObject.join)(filePath, statsFileName),
|
|
12060
|
+
manifestFileName: (0, external_node_path_namespaceObject.join)(filePath, manifestFileName)
|
|
12061
|
+
};
|
|
12062
|
+
}
|
|
12063
|
+
class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
12064
|
+
name = binding_.BuiltinPluginName.ModuleFederationManifestPlugin;
|
|
12065
|
+
rawOpts;
|
|
12066
|
+
constructor(opts){
|
|
12067
|
+
super(), this.rawOpts = opts;
|
|
12068
|
+
}
|
|
12069
|
+
raw(compiler) {
|
|
12070
|
+
var mfConfig, isDev, compiler1, mfConfig1;
|
|
12071
|
+
let manifestOptions, containerName, globalName, remoteAliasMap, manifestExposes, manifestShared, pkg, buildVersion, statsBuildInfo, opts = (manifestOptions = !0 === (mfConfig = this.rawOpts).manifest ? {} : {
|
|
12072
|
+
...mfConfig.manifest
|
|
12073
|
+
}, containerName = mfConfig.name, globalName = function(library) {
|
|
12074
|
+
if (!library) return;
|
|
12075
|
+
let libName = library.name;
|
|
12076
|
+
if (libName) {
|
|
12077
|
+
if ('string' == typeof libName) return libName;
|
|
12078
|
+
if (Array.isArray(libName)) return libName[0];
|
|
12079
|
+
if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
12080
|
+
}
|
|
12081
|
+
}(mfConfig.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(mfConfig)).reduce((sum, cur)=>{
|
|
12082
|
+
if (cur[1].length > 1) return sum;
|
|
12083
|
+
let { entry, alias, name } = cur[1][0];
|
|
12084
|
+
return entry && name && (sum[alias] = {
|
|
12085
|
+
name,
|
|
12086
|
+
entry
|
|
12087
|
+
}), sum;
|
|
12088
|
+
}, {}), manifestExposes = function(exposes) {
|
|
12089
|
+
if (!exposes) return;
|
|
12090
|
+
let result = parseOptions(exposes, (value)=>({
|
|
12091
|
+
import: Array.isArray(value) ? value : [
|
|
12092
|
+
value
|
|
12093
|
+
],
|
|
12094
|
+
name: void 0
|
|
12095
|
+
}), (value)=>({
|
|
12096
|
+
import: Array.isArray(value.import) ? value.import : [
|
|
12097
|
+
value.import
|
|
12098
|
+
],
|
|
12099
|
+
name: value.name ?? void 0
|
|
12100
|
+
})).map(([exposeKey, info])=>{
|
|
12101
|
+
let exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
|
|
12102
|
+
return {
|
|
12103
|
+
path: exposeKey,
|
|
12104
|
+
name: exposeName
|
|
12105
|
+
};
|
|
12106
|
+
});
|
|
12107
|
+
return result.length > 0 ? result : void 0;
|
|
12108
|
+
}(mfConfig.exposes), void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes), manifestShared = function(shared) {
|
|
12109
|
+
if (!shared) return;
|
|
12110
|
+
let result = parseOptions(shared, (item, key)=>{
|
|
12111
|
+
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12112
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12113
|
+
import: key,
|
|
12114
|
+
requiredVersion: item
|
|
12115
|
+
} : {
|
|
12116
|
+
import: item
|
|
12117
|
+
};
|
|
12118
|
+
}, (item)=>item).map(([key, config])=>{
|
|
12119
|
+
let name = config.shareKey || key, version = 'string' == typeof config.version ? config.version : void 0;
|
|
12120
|
+
return {
|
|
12121
|
+
name,
|
|
12122
|
+
version,
|
|
12123
|
+
requiredVersion: 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0,
|
|
12124
|
+
singleton: config.singleton
|
|
12125
|
+
};
|
|
12126
|
+
});
|
|
12127
|
+
return result.length > 0 ? result : void 0;
|
|
12128
|
+
}(mfConfig.shared), void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), {
|
|
12129
|
+
...manifestOptions,
|
|
12130
|
+
remoteAliasMap,
|
|
12131
|
+
globalName,
|
|
12132
|
+
name: containerName
|
|
12133
|
+
}), { fileName, filePath, disableAssetsAnalyze, remoteAliasMap: remoteAliasMap1, exposes, shared } = opts, { statsFileName, manifestFileName } = getFileName(opts), rawOptions = {
|
|
12134
|
+
name: opts.name,
|
|
12135
|
+
globalName: opts.globalName,
|
|
12136
|
+
fileName,
|
|
12137
|
+
filePath,
|
|
12138
|
+
manifestFileName,
|
|
12139
|
+
statsFileName,
|
|
12140
|
+
disableAssetsAnalyze,
|
|
12141
|
+
remoteAliasMap: remoteAliasMap1,
|
|
12142
|
+
exposes,
|
|
12143
|
+
shared,
|
|
12144
|
+
buildInfo: (isDev = 'development' === compiler.options.mode, compiler1 = compiler, mfConfig1 = this.rawOpts, pkg = function(root) {
|
|
12145
|
+
let base = root ? (0, external_node_path_namespaceObject.resolve)(root) : process.cwd(), pkgPath = (0, external_node_path_namespaceObject.join)(base, 'package.json');
|
|
12146
|
+
try {
|
|
12147
|
+
let content = (0, external_node_fs_namespaceObject.readFileSync)(pkgPath, 'utf-8'), parsed = function(input, guard) {
|
|
12148
|
+
try {
|
|
12149
|
+
let parsed = JSON.parse(input);
|
|
12150
|
+
if (guard(parsed)) return parsed;
|
|
12151
|
+
} catch {}
|
|
12152
|
+
}(content, isPlainObject);
|
|
12153
|
+
if (parsed) {
|
|
12154
|
+
let filtered = {};
|
|
12155
|
+
for (let [key, value] of Object.entries(parsed))'string' == typeof value && (filtered[key] = value);
|
|
12156
|
+
if (Object.keys(filtered).length > 0) return filtered;
|
|
12157
|
+
}
|
|
12158
|
+
} catch {}
|
|
12159
|
+
return {};
|
|
12160
|
+
}(compiler1.options.context || process.cwd()), buildVersion = isDev ? 'local' : pkg?.version, statsBuildInfo = {
|
|
12161
|
+
buildVersion: process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
|
|
12162
|
+
buildName: process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
|
|
12163
|
+
}, Object.values(normalizeSharedOptions(mfConfig1.shared || {})).some((config)=>config[1].treeShaking) && (statsBuildInfo.target = Array.isArray(compiler1.options.target) ? compiler1.options.target : [], statsBuildInfo.plugins = mfConfig1.treeShakingSharedPlugins || [], statsBuildInfo.excludePlugins = mfConfig1.treeShakingSharedExcludePlugins || []), statsBuildInfo)
|
|
12164
|
+
};
|
|
12165
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
12166
|
+
}
|
|
12167
|
+
}
|
|
12168
|
+
let SHARE_ENTRY_ASSET = 'collect-shared-entries.json';
|
|
12169
|
+
class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
|
|
12170
|
+
name = binding_.BuiltinPluginName.CollectSharedEntryPlugin;
|
|
12171
|
+
sharedOptions;
|
|
12172
|
+
_collectedEntries;
|
|
12173
|
+
constructor(options){
|
|
12174
|
+
super();
|
|
12175
|
+
const { sharedOptions } = options;
|
|
12176
|
+
this.sharedOptions = sharedOptions, this._collectedEntries = {};
|
|
12177
|
+
}
|
|
12178
|
+
getData() {
|
|
12179
|
+
return this._collectedEntries;
|
|
12180
|
+
}
|
|
12181
|
+
getFilename() {
|
|
12182
|
+
return SHARE_ENTRY_ASSET;
|
|
12183
|
+
}
|
|
12184
|
+
apply(compiler) {
|
|
12185
|
+
super.apply(compiler), compiler.hooks.thisCompilation.tap('Collect shared entry', (compilation)=>{
|
|
12186
|
+
compilation.hooks.processAssets.tap({
|
|
12187
|
+
name: 'CollectSharedEntry',
|
|
12188
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
|
|
12189
|
+
}, ()=>{
|
|
12190
|
+
compilation.getAssets().forEach((asset)=>{
|
|
12191
|
+
asset.name === SHARE_ENTRY_ASSET && (this._collectedEntries = JSON.parse(asset.source.source().toString())), compilation.deleteAsset(asset.name);
|
|
12192
|
+
});
|
|
12193
|
+
});
|
|
12194
|
+
});
|
|
12195
|
+
}
|
|
12196
|
+
raw() {
|
|
12197
|
+
let rawOptions = {
|
|
12198
|
+
consumes: normalizeConsumeShareOptions(createConsumeShareOptions(this.sharedOptions)).map(([key, v])=>({
|
|
12199
|
+
key,
|
|
12200
|
+
...v
|
|
12201
|
+
})),
|
|
12202
|
+
filename: this.getFilename()
|
|
12203
|
+
};
|
|
12204
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
12205
|
+
}
|
|
12206
|
+
}
|
|
12207
|
+
function assert(condition, msg) {
|
|
12208
|
+
if (!condition) throw Error(msg);
|
|
12209
|
+
}
|
|
12210
|
+
class SharedContainerPlugin extends RspackBuiltinPlugin {
|
|
12211
|
+
name = binding_.BuiltinPluginName.SharedContainerPlugin;
|
|
12212
|
+
filename = '';
|
|
12213
|
+
_options;
|
|
12214
|
+
_shareName;
|
|
12215
|
+
_globalName;
|
|
12216
|
+
constructor(options){
|
|
12217
|
+
super();
|
|
12218
|
+
const { shareName, library, request, independentShareFileName, mfName } = options, version = options.version || '0.0.0';
|
|
12219
|
+
this._globalName = encodeName(`${mfName}_${shareName}_${version}`);
|
|
12220
|
+
const fileName = independentShareFileName || `${version}/share-entry.js`;
|
|
12221
|
+
this._shareName = shareName, this._options = {
|
|
12222
|
+
name: shareName,
|
|
12223
|
+
request: request,
|
|
12224
|
+
library: (library ? {
|
|
12225
|
+
...library,
|
|
12226
|
+
name: this._globalName
|
|
12227
|
+
} : void 0) || {
|
|
12228
|
+
type: 'global',
|
|
12229
|
+
name: this._globalName
|
|
12230
|
+
},
|
|
12231
|
+
version,
|
|
12232
|
+
fileName
|
|
12233
|
+
};
|
|
12234
|
+
}
|
|
12235
|
+
getData() {
|
|
12236
|
+
return [
|
|
12237
|
+
this._options.fileName,
|
|
12238
|
+
this._globalName,
|
|
12239
|
+
this._options.version
|
|
12240
|
+
];
|
|
12241
|
+
}
|
|
12242
|
+
raw(compiler) {
|
|
12243
|
+
let { library } = this._options;
|
|
12244
|
+
return compiler.options.output.enabledLibraryTypes.includes(library.type) || compiler.options.output.enabledLibraryTypes.push(library.type), createBuiltinPlugin(this.name, this._options);
|
|
12245
|
+
}
|
|
12246
|
+
apply(compiler) {
|
|
12247
|
+
super.apply(compiler);
|
|
12248
|
+
let shareName = this._shareName;
|
|
12249
|
+
compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
|
|
12250
|
+
compilation.hooks.processAssets.tap({
|
|
12251
|
+
name: 'getShareContainerFile'
|
|
12252
|
+
}, ()=>{
|
|
12253
|
+
assert(compilation.entrypoints.get(shareName), `Can not get shared ${shareName} entryPoint!`);
|
|
12254
|
+
let remoteEntryNameChunk = compilation.namedChunks.get(shareName);
|
|
12255
|
+
assert(remoteEntryNameChunk, `Can not get shared ${shareName} chunk!`);
|
|
12256
|
+
let files = Array.from(remoteEntryNameChunk.files).filter((f)=>!f.includes('.hot-update') && !f.endsWith('.css'));
|
|
12257
|
+
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];
|
|
12258
|
+
});
|
|
12259
|
+
});
|
|
12260
|
+
}
|
|
12261
|
+
}
|
|
12262
|
+
class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
|
|
12263
|
+
name = binding_.BuiltinPluginName.SharedUsedExportsOptimizerPlugin;
|
|
12264
|
+
sharedOptions;
|
|
12265
|
+
injectTreeShakingUsedExports;
|
|
12266
|
+
manifestOptions;
|
|
12267
|
+
constructor(sharedOptions, injectTreeShakingUsedExports, manifestOptions){
|
|
12268
|
+
super(), this.sharedOptions = sharedOptions, this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? !0, this.manifestOptions = manifestOptions ?? {};
|
|
12269
|
+
}
|
|
12270
|
+
buildOptions() {
|
|
12271
|
+
let shared = this.sharedOptions.map(([shareKey, config])=>({
|
|
12272
|
+
shareKey,
|
|
12273
|
+
treeShaking: !!config.treeShaking,
|
|
12274
|
+
usedExports: config.treeShaking?.usedExports
|
|
12275
|
+
})), { manifestFileName, statsFileName } = getFileName(this.manifestOptions);
|
|
12276
|
+
return {
|
|
12277
|
+
shared,
|
|
12278
|
+
injectTreeShakingUsedExports: this.injectTreeShakingUsedExports,
|
|
12279
|
+
manifestFileName,
|
|
12280
|
+
statsFileName
|
|
12281
|
+
};
|
|
12282
|
+
}
|
|
12283
|
+
raw() {
|
|
12284
|
+
if (this.sharedOptions.length) return createBuiltinPlugin(this.name, this.buildOptions());
|
|
12285
|
+
}
|
|
12286
|
+
}
|
|
12287
|
+
let VIRTUAL_ENTRY = './virtual-entry.js', VIRTUAL_ENTRY_NAME = 'virtual-entry';
|
|
12288
|
+
class VirtualEntryPlugin {
|
|
12289
|
+
sharedOptions;
|
|
12290
|
+
collectShared = !1;
|
|
12291
|
+
constructor(sharedOptions, collectShared){
|
|
12292
|
+
this.sharedOptions = sharedOptions, this.collectShared = collectShared;
|
|
12293
|
+
}
|
|
12294
|
+
createEntry() {
|
|
12295
|
+
let { sharedOptions, collectShared } = this;
|
|
12296
|
+
return sharedOptions.reduce((acc, cur, index)=>{
|
|
12297
|
+
let importLine = `import shared_${index} from '${cur[0]}';\n`;
|
|
12298
|
+
return acc + importLine + (collectShared ? `console.log(shared_${index});\n` : '');
|
|
12299
|
+
}, '');
|
|
12300
|
+
}
|
|
12301
|
+
static entry() {
|
|
12302
|
+
return {
|
|
12303
|
+
[VIRTUAL_ENTRY_NAME]: VIRTUAL_ENTRY
|
|
12304
|
+
};
|
|
12305
|
+
}
|
|
12306
|
+
apply(compiler) {
|
|
12307
|
+
new compiler.rspack.experiments.VirtualModulesPlugin({
|
|
12308
|
+
[VIRTUAL_ENTRY]: this.createEntry()
|
|
12309
|
+
}).apply(compiler), compiler.hooks.thisCompilation.tap('RemoveVirtualEntryAsset', (compilation)=>{
|
|
12310
|
+
compilation.hooks.processAssets.tap({
|
|
12311
|
+
name: 'RemoveVirtualEntryAsset',
|
|
12312
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
|
|
12313
|
+
}, ()=>{
|
|
12314
|
+
try {
|
|
12315
|
+
let chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
|
|
12316
|
+
chunk?.files.forEach((f)=>{
|
|
12317
|
+
compilation.deleteAsset(f);
|
|
12318
|
+
});
|
|
12319
|
+
} catch (_e) {
|
|
12320
|
+
console.error('Failed to remove virtual entry file!');
|
|
12321
|
+
}
|
|
12322
|
+
});
|
|
12323
|
+
});
|
|
12324
|
+
}
|
|
12325
|
+
}
|
|
12326
|
+
let resolveOutputDir = (outputDir, shareName)=>shareName ? (0, external_node_path_namespaceObject.join)(outputDir, encodeName(shareName)) : outputDir;
|
|
12327
|
+
class IndependentSharedPlugin {
|
|
12328
|
+
mfName;
|
|
12329
|
+
shared;
|
|
12330
|
+
library;
|
|
12331
|
+
sharedOptions;
|
|
12332
|
+
outputDir;
|
|
12333
|
+
plugins;
|
|
12334
|
+
treeShaking;
|
|
12335
|
+
manifest;
|
|
12336
|
+
buildAssets = {};
|
|
12337
|
+
injectTreeShakingUsedExports;
|
|
12338
|
+
treeShakingSharedExcludePlugins;
|
|
12339
|
+
name = 'IndependentSharedPlugin';
|
|
12340
|
+
constructor(options){
|
|
12341
|
+
const { outputDir, plugins, treeShaking, shared, name, manifest, injectTreeShakingUsedExports, library, treeShakingSharedExcludePlugins } = options;
|
|
12342
|
+
this.shared = shared, this.mfName = name, this.outputDir = outputDir || 'independent-packages', this.plugins = plugins || [], this.treeShaking = treeShaking, this.manifest = manifest, this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? !0, this.library = library, this.treeShakingSharedExcludePlugins = treeShakingSharedExcludePlugins || [], this.sharedOptions = parseOptions(shared, (item, key)=>{
|
|
12343
|
+
if ('string' != typeof item) throw Error(`Unexpected array in shared configuration for key "${key}"`);
|
|
12344
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12345
|
+
import: key,
|
|
12346
|
+
requiredVersion: item
|
|
12347
|
+
} : {
|
|
12348
|
+
import: item
|
|
12349
|
+
};
|
|
12350
|
+
}, (item)=>item);
|
|
12351
|
+
}
|
|
12352
|
+
apply(compiler) {
|
|
12353
|
+
let { manifest } = this, runCount = 0;
|
|
12354
|
+
compiler.hooks.beforeRun.tapPromise('IndependentSharedPlugin', async ()=>{
|
|
12355
|
+
!runCount && (await this.createIndependentCompilers(compiler), runCount++);
|
|
12356
|
+
}), compiler.hooks.watchRun.tapPromise('IndependentSharedPlugin', async ()=>{
|
|
12357
|
+
!runCount && (await this.createIndependentCompilers(compiler), runCount++);
|
|
12358
|
+
}), compiler.hooks.shutdown.tapAsync('IndependentSharedPlugin', (callback)=>{
|
|
12359
|
+
callback();
|
|
12360
|
+
}), manifest && compiler.hooks.compilation.tap('IndependentSharedPlugin', (compilation)=>{
|
|
12361
|
+
compilation.hooks.processAssets.tap({
|
|
12362
|
+
name: 'injectBuildAssets',
|
|
12363
|
+
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
12364
|
+
}, ()=>{
|
|
12365
|
+
let { statsFileName, manifestFileName } = getFileName(manifest), injectBuildAssetsIntoStatsOrManifest = (filename)=>{
|
|
12366
|
+
let stats = compilation.getAsset(filename);
|
|
12367
|
+
if (!stats) return;
|
|
12368
|
+
let statsContent = JSON.parse(stats.source.source().toString()), { shared } = statsContent;
|
|
12369
|
+
Object.entries(this.buildAssets).forEach(([key, item])=>{
|
|
12370
|
+
let targetShared = shared.find((s)=>s.name === key);
|
|
12371
|
+
targetShared && item.forEach(([entry, version, globalName])=>{
|
|
12372
|
+
version === targetShared.version && (targetShared.fallback = entry, targetShared.fallbackName = globalName);
|
|
12373
|
+
});
|
|
12374
|
+
}), compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
|
|
12375
|
+
};
|
|
12376
|
+
injectBuildAssetsIntoStatsOrManifest(statsFileName), injectBuildAssetsIntoStatsOrManifest(manifestFileName);
|
|
12377
|
+
});
|
|
12378
|
+
});
|
|
12379
|
+
}
|
|
12380
|
+
async createIndependentCompilers(parentCompiler) {
|
|
12381
|
+
let { sharedOptions, buildAssets, outputDir } = this;
|
|
12382
|
+
console.log('Start building shared fallback resources ...');
|
|
12383
|
+
let shareRequestsMap = await this.createIndependentCompiler(parentCompiler);
|
|
12384
|
+
await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
|
|
12385
|
+
if (!shareConfig.treeShaking || !1 === shareConfig.import) return;
|
|
12386
|
+
let shareRequests = shareRequestsMap[shareName].requests;
|
|
12387
|
+
await Promise.all(shareRequests.map(async ([request, version])=>{
|
|
12388
|
+
let sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1], [shareFileName, globalName, sharedVersion] = await this.createIndependentCompiler(parentCompiler, {
|
|
12389
|
+
shareRequestsMap,
|
|
12390
|
+
currentShare: {
|
|
12391
|
+
shareName,
|
|
12392
|
+
version,
|
|
12393
|
+
request,
|
|
12394
|
+
independentShareFileName: sharedConfig?.treeShaking?.filename
|
|
12395
|
+
}
|
|
12396
|
+
});
|
|
12397
|
+
'string' == typeof shareFileName && (buildAssets[shareName] ||= [], buildAssets[shareName].push([
|
|
12398
|
+
(0, external_node_path_namespaceObject.join)(resolveOutputDir(outputDir, shareName), shareFileName),
|
|
12399
|
+
sharedVersion,
|
|
12400
|
+
globalName
|
|
12401
|
+
]));
|
|
12402
|
+
}));
|
|
12403
|
+
})), console.log('All shared fallback have been compiled successfully!');
|
|
12404
|
+
}
|
|
12405
|
+
async createIndependentCompiler(parentCompiler, extraOptions) {
|
|
12406
|
+
let extraPlugin, { mfName, plugins, outputDir, sharedOptions, treeShaking, library, treeShakingSharedExcludePlugins } = this, outputDirWithShareName = resolveOutputDir(outputDir, extraOptions?.currentShare?.shareName || ''), parentConfig = parentCompiler.options, finalPlugins = [], rspack = parentCompiler.rspack;
|
|
12407
|
+
extraPlugin = extraOptions ? new SharedContainerPlugin({
|
|
12408
|
+
mfName,
|
|
12409
|
+
library,
|
|
12410
|
+
...extraOptions.currentShare
|
|
12411
|
+
}) : new CollectSharedEntryPlugin({
|
|
12412
|
+
sharedOptions,
|
|
12413
|
+
shareScope: 'default'
|
|
12414
|
+
}), (parentConfig.plugins || []).forEach((plugin)=>{
|
|
12415
|
+
void 0 !== plugin && 'string' != typeof plugin && ((plugin, excludedPlugins = [])=>{
|
|
12416
|
+
if (!plugin) return !0;
|
|
12417
|
+
let pluginName = plugin.name || plugin.constructor?.name;
|
|
12418
|
+
return !pluginName || ![
|
|
12419
|
+
'TreeShakingSharedPlugin',
|
|
12420
|
+
'IndependentSharedPlugin',
|
|
12421
|
+
'ModuleFederationPlugin',
|
|
12422
|
+
'SharedUsedExportsOptimizerPlugin',
|
|
12423
|
+
'HtmlWebpackPlugin',
|
|
12424
|
+
'HtmlRspackPlugin',
|
|
12425
|
+
'RsbuildHtmlPlugin',
|
|
12426
|
+
...excludedPlugins
|
|
12427
|
+
].includes(pluginName);
|
|
12428
|
+
})(plugin, treeShakingSharedExcludePlugins) && finalPlugins.push(plugin);
|
|
12429
|
+
}), plugins.forEach((plugin)=>{
|
|
12430
|
+
finalPlugins.push(plugin);
|
|
12431
|
+
}), finalPlugins.push(extraPlugin), finalPlugins.push(new ConsumeSharedPlugin({
|
|
12432
|
+
consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
|
|
12433
|
+
[key]: {
|
|
12434
|
+
import: !extraOptions && options.import,
|
|
12435
|
+
shareKey: options.shareKey || key,
|
|
12436
|
+
shareScope: options.shareScope,
|
|
12437
|
+
requiredVersion: options.requiredVersion,
|
|
12438
|
+
strictVersion: options.strictVersion,
|
|
12439
|
+
singleton: options.singleton,
|
|
12440
|
+
packageName: options.packageName,
|
|
12441
|
+
eager: options.eager
|
|
12442
|
+
}
|
|
12443
|
+
})),
|
|
12444
|
+
enhanced: !0
|
|
12445
|
+
})), treeShaking && finalPlugins.push(new SharedUsedExportsOptimizerPlugin(sharedOptions, this.injectTreeShakingUsedExports)), finalPlugins.push(new VirtualEntryPlugin(sharedOptions, !extraOptions));
|
|
12446
|
+
let fullOutputDir = (0, external_node_path_namespaceObject.resolve)(parentCompiler.outputPath, outputDirWithShareName), compilerConfig = {
|
|
12447
|
+
...parentConfig,
|
|
12448
|
+
module: {
|
|
12449
|
+
...parentConfig.module,
|
|
12450
|
+
rules: [
|
|
12451
|
+
{
|
|
12452
|
+
test: /virtual-entry\.js$/,
|
|
12453
|
+
type: "javascript/auto",
|
|
12454
|
+
resolve: {
|
|
12455
|
+
fullySpecified: !1
|
|
12456
|
+
},
|
|
12457
|
+
use: {
|
|
12458
|
+
loader: 'builtin:swc-loader'
|
|
12459
|
+
}
|
|
12460
|
+
},
|
|
12461
|
+
...parentConfig.module?.rules || []
|
|
12462
|
+
]
|
|
12463
|
+
},
|
|
12464
|
+
mode: parentConfig.mode || 'development',
|
|
12465
|
+
entry: VirtualEntryPlugin.entry,
|
|
12466
|
+
output: {
|
|
12467
|
+
path: fullOutputDir,
|
|
12468
|
+
clean: !0,
|
|
12469
|
+
publicPath: parentConfig.output?.publicPath || 'auto'
|
|
12470
|
+
},
|
|
12471
|
+
plugins: finalPlugins,
|
|
12472
|
+
optimization: {
|
|
12473
|
+
...parentConfig.optimization,
|
|
12474
|
+
splitChunks: !1
|
|
12475
|
+
}
|
|
12476
|
+
}, compiler = rspack.rspack(compilerConfig);
|
|
12477
|
+
compiler.inputFileSystem = parentCompiler.inputFileSystem, compiler.outputFileSystem = parentCompiler.outputFileSystem, compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
|
|
12478
|
+
let { currentShare } = extraOptions || {};
|
|
12479
|
+
return new Promise((resolve, reject)=>{
|
|
12480
|
+
compiler.run((err, stats)=>{
|
|
12481
|
+
if (err || stats?.hasErrors()) {
|
|
12482
|
+
let target = currentShare ? currentShare.shareName : 'Collect deps';
|
|
12483
|
+
console.error(`${target} Compile failed:`, err || stats.toJson().errors.map((e)=>e.message).join('\n')), reject(err || Error(`${target} Compile failed`));
|
|
12484
|
+
return;
|
|
12485
|
+
}
|
|
12486
|
+
currentShare && console.log(`${currentShare.shareName} Compile success`), resolve(extraPlugin.getData());
|
|
12487
|
+
});
|
|
12488
|
+
});
|
|
12489
|
+
}
|
|
12490
|
+
}
|
|
12491
|
+
class TreeShakingSharedPlugin {
|
|
12492
|
+
mfConfig;
|
|
12493
|
+
outputDir;
|
|
12494
|
+
secondary;
|
|
12495
|
+
_independentSharePlugin;
|
|
12496
|
+
name = 'TreeShakingSharedPlugin';
|
|
12497
|
+
constructor(options){
|
|
12498
|
+
const { mfConfig, secondary } = options;
|
|
12499
|
+
this.mfConfig = mfConfig, this.outputDir = mfConfig.treeShakingSharedDir || 'independent-packages', this.secondary = !!secondary;
|
|
12500
|
+
}
|
|
12501
|
+
apply(compiler) {
|
|
12502
|
+
let { mfConfig, outputDir, secondary } = this, { name, shared, library, treeShakingSharedPlugins } = mfConfig;
|
|
12503
|
+
if (!shared) return;
|
|
12504
|
+
let sharedOptions = normalizeSharedOptions(shared);
|
|
12505
|
+
sharedOptions.length && sharedOptions.some(([_, config])=>config.treeShaking && !1 !== config.import) && (secondary || new SharedUsedExportsOptimizerPlugin(sharedOptions, mfConfig.injectTreeShakingUsedExports, mfConfig.manifest).apply(compiler), this._independentSharePlugin = new IndependentSharedPlugin({
|
|
12506
|
+
name: name,
|
|
12507
|
+
shared: shared,
|
|
12508
|
+
outputDir,
|
|
12509
|
+
plugins: treeShakingSharedPlugins?.map((p)=>new (require(p))()) || [],
|
|
12510
|
+
treeShaking: secondary,
|
|
12511
|
+
library,
|
|
12512
|
+
manifest: mfConfig.manifest,
|
|
12513
|
+
treeShakingSharedExcludePlugins: mfConfig.treeShakingSharedExcludePlugins
|
|
12514
|
+
}), this._independentSharePlugin.apply(compiler));
|
|
12515
|
+
}
|
|
12516
|
+
get buildAssets() {
|
|
12517
|
+
return this._independentSharePlugin?.buildAssets || {};
|
|
12518
|
+
}
|
|
12519
|
+
}
|
|
12520
|
+
let ModuleFederationRuntimePlugin = base_create(binding_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
|
|
12521
|
+
function getRemoteInfos(options) {
|
|
12522
|
+
if (!options.remotes) return {};
|
|
12523
|
+
let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
|
|
12524
|
+
external: Array.isArray(item) ? item : [
|
|
12525
|
+
item
|
|
12526
|
+
],
|
|
12527
|
+
shareScope: options.shareScope || 'default'
|
|
12528
|
+
}), (item)=>({
|
|
12529
|
+
external: Array.isArray(item.external) ? item.external : [
|
|
12530
|
+
item.external
|
|
12531
|
+
],
|
|
12532
|
+
shareScope: item.shareScope || options.shareScope || 'default'
|
|
12533
|
+
})), remoteInfos = {};
|
|
12534
|
+
for (let [key, config] of remotes)for (let external of config.external){
|
|
12535
|
+
let [externalType, externalRequest] = function(external) {
|
|
12536
|
+
let result = function(external) {
|
|
12537
|
+
if (/^[a-z0-9-]+ /.test(external)) {
|
|
12538
|
+
let idx = external.indexOf(' ');
|
|
12539
|
+
return [
|
|
12540
|
+
external.slice(0, idx),
|
|
12541
|
+
external.slice(idx + 1)
|
|
12542
|
+
];
|
|
12543
|
+
}
|
|
12544
|
+
return null;
|
|
12545
|
+
}(external);
|
|
12546
|
+
return null === result ? [
|
|
12547
|
+
remoteType,
|
|
12548
|
+
external
|
|
12549
|
+
] : result;
|
|
12550
|
+
}(external);
|
|
12551
|
+
if (remoteInfos[key] ??= [], "script" === externalType) {
|
|
12552
|
+
let [url, global] = function(urlAndGlobal) {
|
|
12553
|
+
let index = urlAndGlobal.indexOf('@');
|
|
12554
|
+
return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
|
|
12555
|
+
urlAndGlobal.substring(index + 1),
|
|
12556
|
+
urlAndGlobal.substring(0, index)
|
|
12557
|
+
];
|
|
12558
|
+
}(externalRequest);
|
|
12559
|
+
remoteInfos[key].push({
|
|
12560
|
+
alias: key,
|
|
12561
|
+
name: global,
|
|
12562
|
+
entry: url,
|
|
12563
|
+
externalType,
|
|
12564
|
+
shareScope: config.shareScope
|
|
12565
|
+
});
|
|
12566
|
+
} else remoteInfos[key].push({
|
|
12567
|
+
alias: key,
|
|
12568
|
+
name: void 0,
|
|
12569
|
+
entry: void 0,
|
|
12570
|
+
externalType,
|
|
12571
|
+
shareScope: config.shareScope
|
|
12572
|
+
});
|
|
12573
|
+
}
|
|
12574
|
+
return remoteInfos;
|
|
12575
|
+
}
|
|
12576
|
+
function getDefaultEntryRuntime(paths, options, compiler, treeShakingShareFallbacks) {
|
|
12577
|
+
let runtimePlugins = options.runtimePlugins ?? [], remoteInfos = getRemoteInfos(options), runtimePluginImports = [], runtimePluginVars = [], libraryType = options.library?.type || 'var';
|
|
12578
|
+
for(let i = 0; i < runtimePlugins.length; i++){
|
|
12579
|
+
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;
|
|
12580
|
+
runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
|
|
12581
|
+
let paramsCode = void 0 === pluginParams ? 'undefined' : JSON.stringify(pluginParams);
|
|
12582
|
+
runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
|
|
12583
|
+
}
|
|
12584
|
+
let content = [
|
|
12585
|
+
`import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
|
|
12586
|
+
...runtimePluginImports,
|
|
12587
|
+
`const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(', ')}]`,
|
|
12588
|
+
`const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
|
|
12589
|
+
`const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
|
|
12590
|
+
`const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? 'version-first')}`,
|
|
12591
|
+
`const __module_federation_share_fallbacks__ = ${JSON.stringify(treeShakingShareFallbacks)}`,
|
|
12592
|
+
`const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
|
|
12593
|
+
compiler.webpack.Template.getFunctionContent(__webpack_require__("./moduleFederationDefaultRuntime.js"))
|
|
12594
|
+
].join(';');
|
|
12595
|
+
return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
|
|
12596
|
+
}
|
|
12109
12597
|
class ContainerPlugin extends RspackBuiltinPlugin {
|
|
12110
12598
|
name = binding_.BuiltinPluginName.ContainerPlugin;
|
|
12111
12599
|
_options;
|
|
@@ -12114,7 +12602,7 @@ Help:
|
|
|
12114
12602
|
name: options.name,
|
|
12115
12603
|
shareScope: options.shareScope || 'default',
|
|
12116
12604
|
library: options.library || {
|
|
12117
|
-
type: '
|
|
12605
|
+
type: 'global',
|
|
12118
12606
|
name: options.name
|
|
12119
12607
|
},
|
|
12120
12608
|
runtime: options.runtime,
|
|
@@ -12197,7 +12685,7 @@ Help:
|
|
|
12197
12685
|
let _options = JSON.stringify(options || {});
|
|
12198
12686
|
return binding_default().transform(source, _options);
|
|
12199
12687
|
}
|
|
12200
|
-
let exports_rspackVersion = "1.7.3-canary-
|
|
12688
|
+
let exports_rspackVersion = "1.7.3-canary-1138ed18-20260115124957", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
|
|
12201
12689
|
getNormalizedRspackOptions: getNormalizedRspackOptions,
|
|
12202
12690
|
applyRspackOptionsDefaults: applyRspackOptionsDefaults,
|
|
12203
12691
|
getNormalizedWebpackOptions: getNormalizedRspackOptions,
|
|
@@ -12240,11 +12728,12 @@ Help:
|
|
|
12240
12728
|
ContainerReferencePlugin: ContainerReferencePlugin,
|
|
12241
12729
|
ModuleFederationPlugin: class {
|
|
12242
12730
|
_options;
|
|
12731
|
+
_treeShakingSharedPlugin;
|
|
12243
12732
|
constructor(_options){
|
|
12244
12733
|
this._options = _options;
|
|
12245
12734
|
}
|
|
12246
12735
|
apply(compiler) {
|
|
12247
|
-
var options;
|
|
12736
|
+
var options, options1;
|
|
12248
12737
|
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', {
|
|
12249
12738
|
paths: [
|
|
12250
12739
|
runtimeToolsPath
|
|
@@ -12258,101 +12747,41 @@ Help:
|
|
|
12258
12747
|
bundlerRuntime: bundlerRuntimePath,
|
|
12259
12748
|
runtime: runtimePath
|
|
12260
12749
|
});
|
|
12261
|
-
|
|
12750
|
+
compiler.options.resolve.alias = {
|
|
12262
12751
|
'@module-federation/runtime-tools': paths.runtimeTools,
|
|
12263
12752
|
'@module-federation/runtime': paths.runtime,
|
|
12264
12753
|
...compiler.options.resolve.alias
|
|
12265
|
-
},
|
|
12266
|
-
|
|
12267
|
-
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
|
|
12271
|
-
|
|
12272
|
-
|
|
12273
|
-
|
|
12274
|
-
|
|
12275
|
-
|
|
12276
|
-
|
|
12277
|
-
|
|
12278
|
-
|
|
12279
|
-
|
|
12280
|
-
|
|
12281
|
-
|
|
12282
|
-
|
|
12283
|
-
|
|
12284
|
-
}(
|
|
12285
|
-
})
|
|
12754
|
+
}, ((options1 = this._options).shared ? parseOptions(options1.shared, (item, key)=>{
|
|
12755
|
+
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12756
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12757
|
+
import: key,
|
|
12758
|
+
requiredVersion: item
|
|
12759
|
+
} : {
|
|
12760
|
+
import: item
|
|
12761
|
+
};
|
|
12762
|
+
}, (item)=>item) : []).filter(([, config])=>config.treeShaking).length > 0 && (this._treeShakingSharedPlugin = new TreeShakingSharedPlugin({
|
|
12763
|
+
mfConfig: this._options,
|
|
12764
|
+
secondary: !1
|
|
12765
|
+
}), this._treeShakingSharedPlugin.apply(compiler));
|
|
12766
|
+
let runtimePluginApplied = !1;
|
|
12767
|
+
compiler.hooks.beforeRun.tap({
|
|
12768
|
+
name: 'ModuleFederationPlugin',
|
|
12769
|
+
stage: 100
|
|
12770
|
+
}, ()=>{
|
|
12771
|
+
runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
|
|
12772
|
+
entryRuntime: getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets)
|
|
12773
|
+
}).apply(compiler));
|
|
12774
|
+
}), compiler.hooks.watchRun.tap({
|
|
12775
|
+
name: 'ModuleFederationPlugin',
|
|
12776
|
+
stage: 100
|
|
12777
|
+
}, ()=>{
|
|
12778
|
+
runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
|
|
12779
|
+
entryRuntime: getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets || {})
|
|
12780
|
+
}).apply(compiler));
|
|
12781
|
+
}), new webpack.container.ModuleFederationPluginV1({
|
|
12286
12782
|
...this._options,
|
|
12287
12783
|
enhanced: !0
|
|
12288
|
-
}).apply(compiler), this._options.manifest)
|
|
12289
|
-
let manifestOptions = !0 === this._options.manifest ? {} : {
|
|
12290
|
-
...this._options.manifest
|
|
12291
|
-
}, containerName = manifestOptions.name ?? this._options.name, globalName = manifestOptions.globalName ?? function(library) {
|
|
12292
|
-
if (!library) return;
|
|
12293
|
-
let libName = library.name;
|
|
12294
|
-
if (libName) {
|
|
12295
|
-
if ('string' == typeof libName) return libName;
|
|
12296
|
-
if (Array.isArray(libName)) return libName[0];
|
|
12297
|
-
if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
12298
|
-
}
|
|
12299
|
-
}(this._options.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
|
|
12300
|
-
if (cur[1].length > 1) return sum;
|
|
12301
|
-
let { entry, alias, name } = cur[1][0];
|
|
12302
|
-
return entry && name && (sum[alias] = {
|
|
12303
|
-
name,
|
|
12304
|
-
entry
|
|
12305
|
-
}), sum;
|
|
12306
|
-
}, {}), manifestExposes = function(exposes) {
|
|
12307
|
-
if (!exposes) return;
|
|
12308
|
-
let result = parseOptions(exposes, (value)=>({
|
|
12309
|
-
import: Array.isArray(value) ? value : [
|
|
12310
|
-
value
|
|
12311
|
-
],
|
|
12312
|
-
name: void 0
|
|
12313
|
-
}), (value)=>({
|
|
12314
|
-
import: Array.isArray(value.import) ? value.import : [
|
|
12315
|
-
value.import
|
|
12316
|
-
],
|
|
12317
|
-
name: value.name ?? void 0
|
|
12318
|
-
})).map(([exposeKey, info])=>{
|
|
12319
|
-
let exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
|
|
12320
|
-
return {
|
|
12321
|
-
path: exposeKey,
|
|
12322
|
-
name: exposeName
|
|
12323
|
-
};
|
|
12324
|
-
});
|
|
12325
|
-
return result.length > 0 ? result : void 0;
|
|
12326
|
-
}(this._options.exposes);
|
|
12327
|
-
void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes);
|
|
12328
|
-
let manifestShared = function(shared) {
|
|
12329
|
-
if (!shared) return;
|
|
12330
|
-
let result = parseOptions(shared, (item, key)=>{
|
|
12331
|
-
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12332
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
12333
|
-
import: key,
|
|
12334
|
-
requiredVersion: item
|
|
12335
|
-
} : {
|
|
12336
|
-
import: item
|
|
12337
|
-
};
|
|
12338
|
-
}, (item)=>item).map(([key, config])=>{
|
|
12339
|
-
let name = config.shareKey || key, version = 'string' == typeof config.version ? config.version : void 0;
|
|
12340
|
-
return {
|
|
12341
|
-
name,
|
|
12342
|
-
version,
|
|
12343
|
-
requiredVersion: 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0,
|
|
12344
|
-
singleton: config.singleton
|
|
12345
|
-
};
|
|
12346
|
-
});
|
|
12347
|
-
return result.length > 0 ? result : void 0;
|
|
12348
|
-
}(this._options.shared);
|
|
12349
|
-
void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), new ModuleFederationManifestPlugin({
|
|
12350
|
-
...manifestOptions,
|
|
12351
|
-
name: containerName,
|
|
12352
|
-
globalName,
|
|
12353
|
-
remoteAliasMap
|
|
12354
|
-
}).apply(compiler);
|
|
12355
|
-
}
|
|
12784
|
+
}).apply(compiler), this._options.manifest && new ModuleFederationManifestPlugin(this._options).apply(compiler);
|
|
12356
12785
|
}
|
|
12357
12786
|
},
|
|
12358
12787
|
ModuleFederationPluginV1: class {
|
|
@@ -12389,6 +12818,7 @@ Help:
|
|
|
12389
12818
|
}
|
|
12390
12819
|
}, sharing = {
|
|
12391
12820
|
ProvideSharedPlugin: ProvideSharedPlugin,
|
|
12821
|
+
TreeShakingSharedPlugin: TreeShakingSharedPlugin,
|
|
12392
12822
|
ConsumeSharedPlugin: ConsumeSharedPlugin,
|
|
12393
12823
|
SharePlugin: SharePlugin
|
|
12394
12824
|
}, exports_experiments = {
|
|
@@ -12431,7 +12861,7 @@ Help:
|
|
|
12431
12861
|
return base_create(name, resolve, affectedHooks);
|
|
12432
12862
|
},
|
|
12433
12863
|
VirtualModulesPlugin: VirtualModulesPlugin
|
|
12434
|
-
}, src_fn = Object.assign(
|
|
12864
|
+
}, src_fn = Object.assign(rspack_rspack, exports_namespaceObject);
|
|
12435
12865
|
src_fn.rspack = src_fn, src_fn.webpack = src_fn;
|
|
12436
12866
|
let src_rspack_0 = src_fn, src_0 = src_rspack_0;
|
|
12437
12867
|
})(), exports.AsyncDependenciesBlock = __webpack_exports__.AsyncDependenciesBlock, exports.BannerPlugin = __webpack_exports__.BannerPlugin, exports.CaseSensitivePlugin = __webpack_exports__.CaseSensitivePlugin, exports.CircularDependencyRspackPlugin = __webpack_exports__.CircularDependencyRspackPlugin, exports.Compilation = __webpack_exports__.Compilation, exports.Compiler = __webpack_exports__.Compiler, exports.ConcatenatedModule = __webpack_exports__.ConcatenatedModule, exports.ContextModule = __webpack_exports__.ContextModule, exports.ContextReplacementPlugin = __webpack_exports__.ContextReplacementPlugin, exports.CopyRspackPlugin = __webpack_exports__.CopyRspackPlugin, exports.CssExtractRspackPlugin = __webpack_exports__.CssExtractRspackPlugin, exports.DefinePlugin = __webpack_exports__.DefinePlugin, exports.Dependency = __webpack_exports__.Dependency, exports.DllPlugin = __webpack_exports__.DllPlugin, exports.DllReferencePlugin = __webpack_exports__.DllReferencePlugin, exports.DynamicEntryPlugin = __webpack_exports__.DynamicEntryPlugin, exports.EntryDependency = __webpack_exports__.EntryDependency, exports.EntryOptionPlugin = __webpack_exports__.EntryOptionPlugin, exports.EntryPlugin = __webpack_exports__.EntryPlugin, exports.EnvironmentPlugin = __webpack_exports__.EnvironmentPlugin, exports.EvalDevToolModulePlugin = __webpack_exports__.EvalDevToolModulePlugin, exports.EvalSourceMapDevToolPlugin = __webpack_exports__.EvalSourceMapDevToolPlugin, exports.ExternalModule = __webpack_exports__.ExternalModule, exports.ExternalsPlugin = __webpack_exports__.ExternalsPlugin, exports.HotModuleReplacementPlugin = __webpack_exports__.HotModuleReplacementPlugin, exports.HtmlRspackPlugin = __webpack_exports__.HtmlRspackPlugin, exports.IgnorePlugin = __webpack_exports__.IgnorePlugin, exports.LightningCssMinimizerRspackPlugin = __webpack_exports__.LightningCssMinimizerRspackPlugin, exports.LoaderOptionsPlugin = __webpack_exports__.LoaderOptionsPlugin, exports.LoaderTargetPlugin = __webpack_exports__.LoaderTargetPlugin, exports.Module = __webpack_exports__.Module, exports.ModuleFilenameHelpers = __webpack_exports__.ModuleFilenameHelpers, exports.MultiCompiler = __webpack_exports__.MultiCompiler, exports.MultiStats = __webpack_exports__.MultiStats, exports.NoEmitOnErrorsPlugin = __webpack_exports__.NoEmitOnErrorsPlugin, exports.NormalModule = __webpack_exports__.NormalModule, exports.NormalModuleReplacementPlugin = __webpack_exports__.NormalModuleReplacementPlugin, exports.ProgressPlugin = __webpack_exports__.ProgressPlugin, exports.ProvidePlugin = __webpack_exports__.ProvidePlugin, exports.RspackOptionsApply = __webpack_exports__.RspackOptionsApply, exports.RuntimeGlobals = __webpack_exports__.RuntimeGlobals, exports.RuntimeModule = __webpack_exports__.RuntimeModule, exports.RuntimePlugin = __webpack_exports__.RuntimePlugin, exports.SourceMapDevToolPlugin = __webpack_exports__.SourceMapDevToolPlugin, exports.Stats = __webpack_exports__.Stats, exports.StatsErrorCode = __webpack_exports__.StatsErrorCode, exports.SubresourceIntegrityPlugin = __webpack_exports__.SubresourceIntegrityPlugin, exports.SwcJsMinimizerRspackPlugin = __webpack_exports__.SwcJsMinimizerRspackPlugin, exports.Template = __webpack_exports__.Template, exports.ValidationError = __webpack_exports__.ValidationError, exports.WarnCaseSensitiveModulesPlugin = __webpack_exports__.WarnCaseSensitiveModulesPlugin, exports.WebpackError = __webpack_exports__.WebpackError, exports.WebpackOptionsApply = __webpack_exports__.WebpackOptionsApply, exports.config = __webpack_exports__.config, exports.container = __webpack_exports__.container, exports.default = __webpack_exports__.default, exports.electron = __webpack_exports__.electron, exports.experiments = __webpack_exports__.experiments, exports.javascript = __webpack_exports__.javascript, exports.lazyCompilationMiddleware = __webpack_exports__.lazyCompilationMiddleware, exports.library = __webpack_exports__.library, exports.node = __webpack_exports__.node, exports.optimize = __webpack_exports__.optimize, exports.rspack = __webpack_exports__.rspack, exports.rspackVersion = __webpack_exports__.rspackVersion, exports.sharing = __webpack_exports__.sharing, exports.sources = __webpack_exports__.sources, exports.util = __webpack_exports__.util, exports.version = __webpack_exports__.version, exports.wasm = __webpack_exports__.wasm, exports.web = __webpack_exports__.web, exports.webworker = __webpack_exports__.webworker, __webpack_exports__)-1 === [
|