@rspack-canary/core 1.7.3-canary-58d41d16-20260115035302 → 1.7.3-canary-ef467b46-20260115180501
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 +3 -10
- package/dist/container/ModuleFederationPlugin.d.ts +1 -17
- package/dist/exports.d.ts +0 -3
- package/dist/index.js +314 -688
- package/dist/moduleFederationDefaultRuntime.js +1 -1
- package/dist/sharing/ConsumeSharedPlugin.d.ts +0 -13
- package/dist/sharing/ProvideSharedPlugin.d.ts +0 -19
- package/dist/sharing/SharePlugin.d.ts +0 -36
- package/dist/sharing/utils.d.ts +0 -1
- package/hot/lazy-compilation-node.js +90 -34
- package/hot/lazy-compilation-web.js +61 -35
- package/package.json +6 -6
- package/dist/sharing/CollectSharedEntryPlugin.d.ts +0 -22
- package/dist/sharing/IndependentSharedPlugin.d.ts +0 -35
- package/dist/sharing/SharedContainerPlugin.d.ts +0 -23
- package/dist/sharing/SharedUsedExportsOptimizerPlugin.d.ts +0 -14
- package/dist/sharing/TreeShakingSharedPlugin.d.ts +0 -16
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-ef467b46-20260115180501"), 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-ef467b46-20260115180501", 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-ef467b46-20260115180501";
|
|
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(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-ef467b46-20260115180501", 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(...params);
|
|
10728
10756
|
}, exports_namespaceObject, {
|
|
10729
10757
|
RuntimeGlobals: compilerRuntimeGlobals
|
|
10730
10758
|
});
|
|
@@ -11819,7 +11847,69 @@ Help:
|
|
|
11819
11847
|
});
|
|
11820
11848
|
}
|
|
11821
11849
|
}
|
|
11822
|
-
let
|
|
11850
|
+
let VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
|
|
11851
|
+
function isRequiredVersion(str) {
|
|
11852
|
+
return VERSION_PATTERN_REGEXP.test(str);
|
|
11853
|
+
}
|
|
11854
|
+
let MANIFEST_FILE_NAME = 'mf-manifest.json', STATS_FILE_NAME = 'mf-stats.json', JSON_EXT = '.json';
|
|
11855
|
+
function isPlainObject(value) {
|
|
11856
|
+
return !!value && 'object' == typeof value && !Array.isArray(value);
|
|
11857
|
+
}
|
|
11858
|
+
class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
11859
|
+
name = binding_.BuiltinPluginName.ModuleFederationManifestPlugin;
|
|
11860
|
+
opts;
|
|
11861
|
+
constructor(opts){
|
|
11862
|
+
super(), this.opts = opts;
|
|
11863
|
+
}
|
|
11864
|
+
raw(compiler) {
|
|
11865
|
+
var isDev;
|
|
11866
|
+
let pkg, buildVersion, { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts, { statsFileName, manifestFileName } = function(manifestOptions) {
|
|
11867
|
+
var name;
|
|
11868
|
+
if (!manifestOptions) return {
|
|
11869
|
+
statsFileName: STATS_FILE_NAME,
|
|
11870
|
+
manifestFileName: MANIFEST_FILE_NAME
|
|
11871
|
+
};
|
|
11872
|
+
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;
|
|
11873
|
+
return {
|
|
11874
|
+
statsFileName: (0, external_node_path_namespaceObject.join)(filePath, statsFileName),
|
|
11875
|
+
manifestFileName: (0, external_node_path_namespaceObject.join)(filePath, manifestFileName)
|
|
11876
|
+
};
|
|
11877
|
+
}(this.opts), rawOptions = {
|
|
11878
|
+
name: this.opts.name,
|
|
11879
|
+
globalName: this.opts.globalName,
|
|
11880
|
+
fileName,
|
|
11881
|
+
filePath,
|
|
11882
|
+
manifestFileName,
|
|
11883
|
+
statsFileName,
|
|
11884
|
+
disableAssetsAnalyze,
|
|
11885
|
+
remoteAliasMap,
|
|
11886
|
+
exposes,
|
|
11887
|
+
shared,
|
|
11888
|
+
buildInfo: (isDev = 'development' === compiler.options.mode, pkg = function(root) {
|
|
11889
|
+
let base = root ? (0, external_node_path_namespaceObject.resolve)(root) : process.cwd(), pkgPath = (0, external_node_path_namespaceObject.join)(base, 'package.json');
|
|
11890
|
+
try {
|
|
11891
|
+
let content = (0, external_node_fs_namespaceObject.readFileSync)(pkgPath, 'utf-8'), parsed = function(input, guard) {
|
|
11892
|
+
try {
|
|
11893
|
+
let parsed = JSON.parse(input);
|
|
11894
|
+
if (guard(parsed)) return parsed;
|
|
11895
|
+
} catch {}
|
|
11896
|
+
}(content, isPlainObject);
|
|
11897
|
+
if (parsed) {
|
|
11898
|
+
let filtered = {};
|
|
11899
|
+
for (let [key, value] of Object.entries(parsed))'string' == typeof value && (filtered[key] = value);
|
|
11900
|
+
if (Object.keys(filtered).length > 0) return filtered;
|
|
11901
|
+
}
|
|
11902
|
+
} catch {}
|
|
11903
|
+
return {};
|
|
11904
|
+
}(compiler.context || process.cwd()), buildVersion = isDev ? 'local' : pkg?.version, {
|
|
11905
|
+
buildVersion: process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
|
|
11906
|
+
buildName: process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
|
|
11907
|
+
})
|
|
11908
|
+
};
|
|
11909
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
11910
|
+
}
|
|
11911
|
+
}
|
|
11912
|
+
let ModuleFederationRuntimePlugin = base_create(binding_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options), parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
11823
11913
|
let items = [];
|
|
11824
11914
|
var options1 = options, normalizeSimple1 = normalizeSimple, normalizeOptions1 = normalizeOptions, fn = (key, value)=>{
|
|
11825
11915
|
items.push([
|
|
@@ -11838,7 +11928,63 @@ Help:
|
|
|
11838
11928
|
} else if ('object' == typeof options1) object(options1);
|
|
11839
11929
|
else throw Error('Unexpected options format');
|
|
11840
11930
|
return items;
|
|
11841
|
-
}
|
|
11931
|
+
};
|
|
11932
|
+
function getRemoteInfos(options) {
|
|
11933
|
+
if (!options.remotes) return {};
|
|
11934
|
+
let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
|
|
11935
|
+
external: Array.isArray(item) ? item : [
|
|
11936
|
+
item
|
|
11937
|
+
],
|
|
11938
|
+
shareScope: options.shareScope || 'default'
|
|
11939
|
+
}), (item)=>({
|
|
11940
|
+
external: Array.isArray(item.external) ? item.external : [
|
|
11941
|
+
item.external
|
|
11942
|
+
],
|
|
11943
|
+
shareScope: item.shareScope || options.shareScope || 'default'
|
|
11944
|
+
})), remoteInfos = {};
|
|
11945
|
+
for (let [key, config] of remotes)for (let external of config.external){
|
|
11946
|
+
let [externalType, externalRequest] = function(external) {
|
|
11947
|
+
let result = function(external) {
|
|
11948
|
+
if (/^[a-z0-9-]+ /.test(external)) {
|
|
11949
|
+
let idx = external.indexOf(' ');
|
|
11950
|
+
return [
|
|
11951
|
+
external.slice(0, idx),
|
|
11952
|
+
external.slice(idx + 1)
|
|
11953
|
+
];
|
|
11954
|
+
}
|
|
11955
|
+
return null;
|
|
11956
|
+
}(external);
|
|
11957
|
+
return null === result ? [
|
|
11958
|
+
remoteType,
|
|
11959
|
+
external
|
|
11960
|
+
] : result;
|
|
11961
|
+
}(external);
|
|
11962
|
+
if (remoteInfos[key] ??= [], "script" === externalType) {
|
|
11963
|
+
let [url, global] = function(urlAndGlobal) {
|
|
11964
|
+
let index = urlAndGlobal.indexOf('@');
|
|
11965
|
+
return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
|
|
11966
|
+
urlAndGlobal.substring(index + 1),
|
|
11967
|
+
urlAndGlobal.substring(0, index)
|
|
11968
|
+
];
|
|
11969
|
+
}(externalRequest);
|
|
11970
|
+
remoteInfos[key].push({
|
|
11971
|
+
alias: key,
|
|
11972
|
+
name: global,
|
|
11973
|
+
entry: url,
|
|
11974
|
+
externalType,
|
|
11975
|
+
shareScope: config.shareScope
|
|
11976
|
+
});
|
|
11977
|
+
} else remoteInfos[key].push({
|
|
11978
|
+
alias: key,
|
|
11979
|
+
name: void 0,
|
|
11980
|
+
entry: void 0,
|
|
11981
|
+
externalType,
|
|
11982
|
+
shareScope: config.shareScope
|
|
11983
|
+
});
|
|
11984
|
+
}
|
|
11985
|
+
return remoteInfos;
|
|
11986
|
+
}
|
|
11987
|
+
let compilerSet = new WeakSet();
|
|
11842
11988
|
class ShareRuntimePlugin extends RspackBuiltinPlugin {
|
|
11843
11989
|
enhanced;
|
|
11844
11990
|
name = binding_.BuiltinPluginName.ShareRuntimePlugin;
|
|
@@ -11850,55 +11996,42 @@ Help:
|
|
|
11850
11996
|
if (compiler1 = compiler, !compilerSet.has(compiler1)) return compiler2 = compiler, compilerSet.add(compiler2), createBuiltinPlugin(this.name, this.enhanced);
|
|
11851
11997
|
}
|
|
11852
11998
|
}
|
|
11853
|
-
let VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
|
|
11854
|
-
function isRequiredVersion(str) {
|
|
11855
|
-
return VERSION_PATTERN_REGEXP.test(str);
|
|
11856
|
-
}
|
|
11857
|
-
let encodeName = function(name, prefix = '', withExt = !1) {
|
|
11858
|
-
return `${prefix}${name.replace(/@/g, 'scope_').replace(/-/g, '_').replace(/\//g, '__').replace(/\./g, '')}${withExt ? '.js' : ''}`;
|
|
11859
|
-
};
|
|
11860
|
-
function normalizeConsumeShareOptions(consumes, shareScope) {
|
|
11861
|
-
return parseOptions(consumes, (item, key)=>{
|
|
11862
|
-
if (Array.isArray(item)) throw Error('Unexpected array in options');
|
|
11863
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
11864
|
-
import: key,
|
|
11865
|
-
shareScope: shareScope || 'default',
|
|
11866
|
-
shareKey: key,
|
|
11867
|
-
requiredVersion: item,
|
|
11868
|
-
strictVersion: !0,
|
|
11869
|
-
packageName: void 0,
|
|
11870
|
-
singleton: !1,
|
|
11871
|
-
eager: !1,
|
|
11872
|
-
treeShakingMode: void 0
|
|
11873
|
-
} : {
|
|
11874
|
-
import: key,
|
|
11875
|
-
shareScope: shareScope || 'default',
|
|
11876
|
-
shareKey: key,
|
|
11877
|
-
requiredVersion: void 0,
|
|
11878
|
-
packageName: void 0,
|
|
11879
|
-
strictVersion: !1,
|
|
11880
|
-
singleton: !1,
|
|
11881
|
-
eager: !1,
|
|
11882
|
-
treeShakingMode: void 0
|
|
11883
|
-
};
|
|
11884
|
-
}, (item, key)=>({
|
|
11885
|
-
import: !1 === item.import ? void 0 : item.import || key,
|
|
11886
|
-
shareScope: item.shareScope || shareScope || 'default',
|
|
11887
|
-
shareKey: item.shareKey || key,
|
|
11888
|
-
requiredVersion: item.requiredVersion,
|
|
11889
|
-
strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
|
|
11890
|
-
packageName: item.packageName,
|
|
11891
|
-
singleton: !!item.singleton,
|
|
11892
|
-
eager: !!item.eager,
|
|
11893
|
-
treeShakingMode: item.treeShakingMode
|
|
11894
|
-
}));
|
|
11895
|
-
}
|
|
11896
11999
|
class ConsumeSharedPlugin extends RspackBuiltinPlugin {
|
|
11897
12000
|
name = binding_.BuiltinPluginName.ConsumeSharedPlugin;
|
|
11898
12001
|
_options;
|
|
11899
12002
|
constructor(options){
|
|
11900
12003
|
super(), this._options = {
|
|
11901
|
-
consumes:
|
|
12004
|
+
consumes: parseOptions(options.consumes, (item, key)=>{
|
|
12005
|
+
if (Array.isArray(item)) throw Error('Unexpected array in options');
|
|
12006
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12007
|
+
import: key,
|
|
12008
|
+
shareScope: options.shareScope || 'default',
|
|
12009
|
+
shareKey: key,
|
|
12010
|
+
requiredVersion: item,
|
|
12011
|
+
strictVersion: !0,
|
|
12012
|
+
packageName: void 0,
|
|
12013
|
+
singleton: !1,
|
|
12014
|
+
eager: !1
|
|
12015
|
+
} : {
|
|
12016
|
+
import: key,
|
|
12017
|
+
shareScope: options.shareScope || 'default',
|
|
12018
|
+
shareKey: key,
|
|
12019
|
+
requiredVersion: void 0,
|
|
12020
|
+
packageName: void 0,
|
|
12021
|
+
strictVersion: !1,
|
|
12022
|
+
singleton: !1,
|
|
12023
|
+
eager: !1
|
|
12024
|
+
};
|
|
12025
|
+
}, (item, key)=>({
|
|
12026
|
+
import: !1 === item.import ? void 0 : item.import || key,
|
|
12027
|
+
shareScope: item.shareScope || options.shareScope || 'default',
|
|
12028
|
+
shareKey: item.shareKey || key,
|
|
12029
|
+
requiredVersion: item.requiredVersion,
|
|
12030
|
+
strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
|
|
12031
|
+
packageName: item.packageName,
|
|
12032
|
+
singleton: !!item.singleton,
|
|
12033
|
+
eager: !!item.eager
|
|
12034
|
+
})),
|
|
11902
12035
|
enhanced: options.enhanced ?? !1
|
|
11903
12036
|
};
|
|
11904
12037
|
}
|
|
@@ -11919,30 +12052,28 @@ Help:
|
|
|
11919
12052
|
_provides;
|
|
11920
12053
|
_enhanced;
|
|
11921
12054
|
constructor(options){
|
|
11922
|
-
|
|
11923
|
-
super(), this._provides = (options1 = options.provides, shareScope = options.shareScope, enhanced = options.enhanced, parseOptions(options1, (item)=>{
|
|
12055
|
+
super(), this._provides = parseOptions(options.provides, (item)=>{
|
|
11924
12056
|
if (Array.isArray(item)) throw Error('Unexpected array of provides');
|
|
11925
12057
|
return {
|
|
11926
12058
|
shareKey: item,
|
|
11927
12059
|
version: void 0,
|
|
11928
|
-
shareScope: shareScope || 'default',
|
|
12060
|
+
shareScope: options.shareScope || 'default',
|
|
11929
12061
|
eager: !1
|
|
11930
12062
|
};
|
|
11931
12063
|
}, (item)=>{
|
|
11932
12064
|
let raw = {
|
|
11933
12065
|
shareKey: item.shareKey,
|
|
11934
12066
|
version: item.version,
|
|
11935
|
-
shareScope: item.shareScope || shareScope || 'default',
|
|
12067
|
+
shareScope: item.shareScope || options.shareScope || 'default',
|
|
11936
12068
|
eager: !!item.eager
|
|
11937
12069
|
};
|
|
11938
|
-
return enhanced ? {
|
|
12070
|
+
return options.enhanced ? {
|
|
11939
12071
|
...raw,
|
|
11940
12072
|
singleton: item.singleton,
|
|
11941
12073
|
requiredVersion: item.requiredVersion,
|
|
11942
|
-
strictVersion: item.strictVersion
|
|
11943
|
-
treeShakingMode: item.treeShakingMode
|
|
12074
|
+
strictVersion: item.strictVersion
|
|
11944
12075
|
} : raw;
|
|
11945
|
-
})
|
|
12076
|
+
}), this._enhanced = options.enhanced;
|
|
11946
12077
|
}
|
|
11947
12078
|
raw(compiler) {
|
|
11948
12079
|
new ShareRuntimePlugin(this._enhanced ?? !1).apply(compiler);
|
|
@@ -11953,40 +12084,32 @@ Help:
|
|
|
11953
12084
|
return createBuiltinPlugin(this.name, rawOptions);
|
|
11954
12085
|
}
|
|
11955
12086
|
}
|
|
11956
|
-
function normalizeSharedOptions(shared) {
|
|
11957
|
-
return parseOptions(shared, (item, key)=>{
|
|
11958
|
-
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
11959
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
11960
|
-
import: key,
|
|
11961
|
-
requiredVersion: item
|
|
11962
|
-
} : {
|
|
11963
|
-
import: item
|
|
11964
|
-
};
|
|
11965
|
-
}, (item)=>item);
|
|
11966
|
-
}
|
|
11967
|
-
function createConsumeShareOptions(normalizedSharedOptions) {
|
|
11968
|
-
return normalizedSharedOptions.map(([key, options])=>({
|
|
11969
|
-
[key]: {
|
|
11970
|
-
import: options.import,
|
|
11971
|
-
shareKey: options.shareKey || key,
|
|
11972
|
-
shareScope: options.shareScope,
|
|
11973
|
-
requiredVersion: options.requiredVersion,
|
|
11974
|
-
strictVersion: options.strictVersion,
|
|
11975
|
-
singleton: options.singleton,
|
|
11976
|
-
packageName: options.packageName,
|
|
11977
|
-
eager: options.eager,
|
|
11978
|
-
treeShakingMode: options.treeShaking?.mode
|
|
11979
|
-
}
|
|
11980
|
-
}));
|
|
11981
|
-
}
|
|
11982
12087
|
class SharePlugin {
|
|
11983
12088
|
_shareScope;
|
|
11984
12089
|
_consumes;
|
|
11985
12090
|
_provides;
|
|
11986
12091
|
_enhanced;
|
|
11987
|
-
_sharedOptions;
|
|
11988
12092
|
constructor(options){
|
|
11989
|
-
const sharedOptions =
|
|
12093
|
+
const sharedOptions = parseOptions(options.shared, (item, key)=>{
|
|
12094
|
+
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12095
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12096
|
+
import: key,
|
|
12097
|
+
requiredVersion: item
|
|
12098
|
+
} : {
|
|
12099
|
+
import: item
|
|
12100
|
+
};
|
|
12101
|
+
}, (item)=>item), consumes = sharedOptions.map(([key, options])=>({
|
|
12102
|
+
[key]: {
|
|
12103
|
+
import: options.import,
|
|
12104
|
+
shareKey: options.shareKey || key,
|
|
12105
|
+
shareScope: options.shareScope,
|
|
12106
|
+
requiredVersion: options.requiredVersion,
|
|
12107
|
+
strictVersion: options.strictVersion,
|
|
12108
|
+
singleton: options.singleton,
|
|
12109
|
+
packageName: options.packageName,
|
|
12110
|
+
eager: options.eager
|
|
12111
|
+
}
|
|
12112
|
+
})), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
|
|
11990
12113
|
[options.import || key]: {
|
|
11991
12114
|
shareKey: options.shareKey || key,
|
|
11992
12115
|
shareScope: options.shareScope,
|
|
@@ -11994,11 +12117,10 @@ Help:
|
|
|
11994
12117
|
eager: options.eager,
|
|
11995
12118
|
singleton: options.singleton,
|
|
11996
12119
|
requiredVersion: options.requiredVersion,
|
|
11997
|
-
strictVersion: options.strictVersion
|
|
11998
|
-
treeShakingMode: options.treeShaking?.mode
|
|
12120
|
+
strictVersion: options.strictVersion
|
|
11999
12121
|
}
|
|
12000
12122
|
}));
|
|
12001
|
-
this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1
|
|
12123
|
+
this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1;
|
|
12002
12124
|
}
|
|
12003
12125
|
apply(compiler) {
|
|
12004
12126
|
new ConsumeSharedPlugin({
|
|
@@ -12012,560 +12134,6 @@ Help:
|
|
|
12012
12134
|
}).apply(compiler);
|
|
12013
12135
|
}
|
|
12014
12136
|
}
|
|
12015
|
-
let MANIFEST_FILE_NAME = 'mf-manifest.json', STATS_FILE_NAME = 'mf-stats.json', JSON_EXT = '.json';
|
|
12016
|
-
function isPlainObject(value) {
|
|
12017
|
-
return !!value && 'object' == typeof value && !Array.isArray(value);
|
|
12018
|
-
}
|
|
12019
|
-
function getFileName(manifestOptions) {
|
|
12020
|
-
var name;
|
|
12021
|
-
if (!manifestOptions) return {
|
|
12022
|
-
statsFileName: '',
|
|
12023
|
-
manifestFileName: ''
|
|
12024
|
-
};
|
|
12025
|
-
if ('boolean' == typeof manifestOptions) return {
|
|
12026
|
-
statsFileName: STATS_FILE_NAME,
|
|
12027
|
-
manifestFileName: MANIFEST_FILE_NAME
|
|
12028
|
-
};
|
|
12029
|
-
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;
|
|
12030
|
-
return {
|
|
12031
|
-
statsFileName: (0, external_node_path_namespaceObject.join)(filePath, statsFileName),
|
|
12032
|
-
manifestFileName: (0, external_node_path_namespaceObject.join)(filePath, manifestFileName)
|
|
12033
|
-
};
|
|
12034
|
-
}
|
|
12035
|
-
class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
12036
|
-
name = binding_.BuiltinPluginName.ModuleFederationManifestPlugin;
|
|
12037
|
-
rawOpts;
|
|
12038
|
-
constructor(opts){
|
|
12039
|
-
super(), this.rawOpts = opts;
|
|
12040
|
-
}
|
|
12041
|
-
raw(compiler) {
|
|
12042
|
-
var mfConfig, isDev, compiler1, mfConfig1;
|
|
12043
|
-
let manifestOptions, containerName, globalName, remoteAliasMap, manifestExposes, manifestShared, pkg, buildVersion, statsBuildInfo, opts = (manifestOptions = !0 === (mfConfig = this.rawOpts).manifest ? {} : {
|
|
12044
|
-
...mfConfig.manifest
|
|
12045
|
-
}, containerName = mfConfig.name, globalName = function(library) {
|
|
12046
|
-
if (!library) return;
|
|
12047
|
-
let libName = library.name;
|
|
12048
|
-
if (libName) {
|
|
12049
|
-
if ('string' == typeof libName) return libName;
|
|
12050
|
-
if (Array.isArray(libName)) return libName[0];
|
|
12051
|
-
if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
12052
|
-
}
|
|
12053
|
-
}(mfConfig.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(mfConfig)).reduce((sum, cur)=>{
|
|
12054
|
-
if (cur[1].length > 1) return sum;
|
|
12055
|
-
let { entry, alias, name } = cur[1][0];
|
|
12056
|
-
return entry && name && (sum[alias] = {
|
|
12057
|
-
name,
|
|
12058
|
-
entry
|
|
12059
|
-
}), sum;
|
|
12060
|
-
}, {}), manifestExposes = function(exposes) {
|
|
12061
|
-
if (!exposes) return;
|
|
12062
|
-
let result = parseOptions(exposes, (value)=>({
|
|
12063
|
-
import: Array.isArray(value) ? value : [
|
|
12064
|
-
value
|
|
12065
|
-
],
|
|
12066
|
-
name: void 0
|
|
12067
|
-
}), (value)=>({
|
|
12068
|
-
import: Array.isArray(value.import) ? value.import : [
|
|
12069
|
-
value.import
|
|
12070
|
-
],
|
|
12071
|
-
name: value.name ?? void 0
|
|
12072
|
-
})).map(([exposeKey, info])=>{
|
|
12073
|
-
let exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
|
|
12074
|
-
return {
|
|
12075
|
-
path: exposeKey,
|
|
12076
|
-
name: exposeName
|
|
12077
|
-
};
|
|
12078
|
-
});
|
|
12079
|
-
return result.length > 0 ? result : void 0;
|
|
12080
|
-
}(mfConfig.exposes), void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes), manifestShared = function(shared) {
|
|
12081
|
-
if (!shared) return;
|
|
12082
|
-
let result = parseOptions(shared, (item, key)=>{
|
|
12083
|
-
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12084
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
12085
|
-
import: key,
|
|
12086
|
-
requiredVersion: item
|
|
12087
|
-
} : {
|
|
12088
|
-
import: item
|
|
12089
|
-
};
|
|
12090
|
-
}, (item)=>item).map(([key, config])=>{
|
|
12091
|
-
let name = config.shareKey || key, version = 'string' == typeof config.version ? config.version : void 0;
|
|
12092
|
-
return {
|
|
12093
|
-
name,
|
|
12094
|
-
version,
|
|
12095
|
-
requiredVersion: 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0,
|
|
12096
|
-
singleton: config.singleton
|
|
12097
|
-
};
|
|
12098
|
-
});
|
|
12099
|
-
return result.length > 0 ? result : void 0;
|
|
12100
|
-
}(mfConfig.shared), void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), {
|
|
12101
|
-
...manifestOptions,
|
|
12102
|
-
remoteAliasMap,
|
|
12103
|
-
globalName,
|
|
12104
|
-
name: containerName
|
|
12105
|
-
}), { fileName, filePath, disableAssetsAnalyze, remoteAliasMap: remoteAliasMap1, exposes, shared } = opts, { statsFileName, manifestFileName } = getFileName(opts), rawOptions = {
|
|
12106
|
-
name: opts.name,
|
|
12107
|
-
globalName: opts.globalName,
|
|
12108
|
-
fileName,
|
|
12109
|
-
filePath,
|
|
12110
|
-
manifestFileName,
|
|
12111
|
-
statsFileName,
|
|
12112
|
-
disableAssetsAnalyze,
|
|
12113
|
-
remoteAliasMap: remoteAliasMap1,
|
|
12114
|
-
exposes,
|
|
12115
|
-
shared,
|
|
12116
|
-
buildInfo: (isDev = 'development' === compiler.options.mode, compiler1 = compiler, mfConfig1 = this.rawOpts, pkg = function(root) {
|
|
12117
|
-
let base = root ? (0, external_node_path_namespaceObject.resolve)(root) : process.cwd(), pkgPath = (0, external_node_path_namespaceObject.join)(base, 'package.json');
|
|
12118
|
-
try {
|
|
12119
|
-
let content = (0, external_node_fs_namespaceObject.readFileSync)(pkgPath, 'utf-8'), parsed = function(input, guard) {
|
|
12120
|
-
try {
|
|
12121
|
-
let parsed = JSON.parse(input);
|
|
12122
|
-
if (guard(parsed)) return parsed;
|
|
12123
|
-
} catch {}
|
|
12124
|
-
}(content, isPlainObject);
|
|
12125
|
-
if (parsed) {
|
|
12126
|
-
let filtered = {};
|
|
12127
|
-
for (let [key, value] of Object.entries(parsed))'string' == typeof value && (filtered[key] = value);
|
|
12128
|
-
if (Object.keys(filtered).length > 0) return filtered;
|
|
12129
|
-
}
|
|
12130
|
-
} catch {}
|
|
12131
|
-
return {};
|
|
12132
|
-
}(compiler1.options.context || process.cwd()), buildVersion = isDev ? 'local' : pkg?.version, statsBuildInfo = {
|
|
12133
|
-
buildVersion: process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
|
|
12134
|
-
buildName: process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
|
|
12135
|
-
}, 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)
|
|
12136
|
-
};
|
|
12137
|
-
return createBuiltinPlugin(this.name, rawOptions);
|
|
12138
|
-
}
|
|
12139
|
-
}
|
|
12140
|
-
let SHARE_ENTRY_ASSET = 'collect-shared-entries.json';
|
|
12141
|
-
class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
|
|
12142
|
-
name = binding_.BuiltinPluginName.CollectSharedEntryPlugin;
|
|
12143
|
-
sharedOptions;
|
|
12144
|
-
_collectedEntries;
|
|
12145
|
-
constructor(options){
|
|
12146
|
-
super();
|
|
12147
|
-
const { sharedOptions } = options;
|
|
12148
|
-
this.sharedOptions = sharedOptions, this._collectedEntries = {};
|
|
12149
|
-
}
|
|
12150
|
-
getData() {
|
|
12151
|
-
return this._collectedEntries;
|
|
12152
|
-
}
|
|
12153
|
-
getFilename() {
|
|
12154
|
-
return SHARE_ENTRY_ASSET;
|
|
12155
|
-
}
|
|
12156
|
-
apply(compiler) {
|
|
12157
|
-
super.apply(compiler), compiler.hooks.thisCompilation.tap('Collect shared entry', (compilation)=>{
|
|
12158
|
-
compilation.hooks.processAssets.tap({
|
|
12159
|
-
name: 'CollectSharedEntry',
|
|
12160
|
-
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
|
|
12161
|
-
}, ()=>{
|
|
12162
|
-
compilation.getAssets().forEach((asset)=>{
|
|
12163
|
-
asset.name === SHARE_ENTRY_ASSET && (this._collectedEntries = JSON.parse(asset.source.source().toString())), compilation.deleteAsset(asset.name);
|
|
12164
|
-
});
|
|
12165
|
-
});
|
|
12166
|
-
});
|
|
12167
|
-
}
|
|
12168
|
-
raw() {
|
|
12169
|
-
let rawOptions = {
|
|
12170
|
-
consumes: normalizeConsumeShareOptions(createConsumeShareOptions(this.sharedOptions)).map(([key, v])=>({
|
|
12171
|
-
key,
|
|
12172
|
-
...v
|
|
12173
|
-
})),
|
|
12174
|
-
filename: this.getFilename()
|
|
12175
|
-
};
|
|
12176
|
-
return createBuiltinPlugin(this.name, rawOptions);
|
|
12177
|
-
}
|
|
12178
|
-
}
|
|
12179
|
-
function assert(condition, msg) {
|
|
12180
|
-
if (!condition) throw Error(msg);
|
|
12181
|
-
}
|
|
12182
|
-
class SharedContainerPlugin extends RspackBuiltinPlugin {
|
|
12183
|
-
name = binding_.BuiltinPluginName.SharedContainerPlugin;
|
|
12184
|
-
filename = '';
|
|
12185
|
-
_options;
|
|
12186
|
-
_shareName;
|
|
12187
|
-
_globalName;
|
|
12188
|
-
constructor(options){
|
|
12189
|
-
super();
|
|
12190
|
-
const { shareName, library, request, independentShareFileName, mfName } = options, version = options.version || '0.0.0';
|
|
12191
|
-
this._globalName = encodeName(`${mfName}_${shareName}_${version}`);
|
|
12192
|
-
const fileName = independentShareFileName || `${version}/share-entry.js`;
|
|
12193
|
-
this._shareName = shareName, this._options = {
|
|
12194
|
-
name: shareName,
|
|
12195
|
-
request: request,
|
|
12196
|
-
library: (library ? {
|
|
12197
|
-
...library,
|
|
12198
|
-
name: this._globalName
|
|
12199
|
-
} : void 0) || {
|
|
12200
|
-
type: 'global',
|
|
12201
|
-
name: this._globalName
|
|
12202
|
-
},
|
|
12203
|
-
version,
|
|
12204
|
-
fileName
|
|
12205
|
-
};
|
|
12206
|
-
}
|
|
12207
|
-
getData() {
|
|
12208
|
-
return [
|
|
12209
|
-
this._options.fileName,
|
|
12210
|
-
this._globalName,
|
|
12211
|
-
this._options.version
|
|
12212
|
-
];
|
|
12213
|
-
}
|
|
12214
|
-
raw(compiler) {
|
|
12215
|
-
let { library } = this._options;
|
|
12216
|
-
return compiler.options.output.enabledLibraryTypes.includes(library.type) || compiler.options.output.enabledLibraryTypes.push(library.type), createBuiltinPlugin(this.name, this._options);
|
|
12217
|
-
}
|
|
12218
|
-
apply(compiler) {
|
|
12219
|
-
super.apply(compiler);
|
|
12220
|
-
let shareName = this._shareName;
|
|
12221
|
-
compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
|
|
12222
|
-
compilation.hooks.processAssets.tap({
|
|
12223
|
-
name: 'getShareContainerFile'
|
|
12224
|
-
}, ()=>{
|
|
12225
|
-
assert(compilation.entrypoints.get(shareName), `Can not get shared ${shareName} entryPoint!`);
|
|
12226
|
-
let remoteEntryNameChunk = compilation.namedChunks.get(shareName);
|
|
12227
|
-
assert(remoteEntryNameChunk, `Can not get shared ${shareName} chunk!`);
|
|
12228
|
-
let files = Array.from(remoteEntryNameChunk.files).filter((f)=>!f.includes('.hot-update') && !f.endsWith('.css'));
|
|
12229
|
-
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];
|
|
12230
|
-
});
|
|
12231
|
-
});
|
|
12232
|
-
}
|
|
12233
|
-
}
|
|
12234
|
-
class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
|
|
12235
|
-
name = binding_.BuiltinPluginName.SharedUsedExportsOptimizerPlugin;
|
|
12236
|
-
sharedOptions;
|
|
12237
|
-
injectTreeShakingUsedExports;
|
|
12238
|
-
manifestOptions;
|
|
12239
|
-
constructor(sharedOptions, injectTreeShakingUsedExports, manifestOptions){
|
|
12240
|
-
super(), this.sharedOptions = sharedOptions, this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? !0, this.manifestOptions = manifestOptions ?? {};
|
|
12241
|
-
}
|
|
12242
|
-
buildOptions() {
|
|
12243
|
-
let shared = this.sharedOptions.map(([shareKey, config])=>({
|
|
12244
|
-
shareKey,
|
|
12245
|
-
treeShaking: !!config.treeShaking,
|
|
12246
|
-
usedExports: config.treeShaking?.usedExports
|
|
12247
|
-
})), { manifestFileName, statsFileName } = getFileName(this.manifestOptions);
|
|
12248
|
-
return {
|
|
12249
|
-
shared,
|
|
12250
|
-
injectTreeShakingUsedExports: this.injectTreeShakingUsedExports,
|
|
12251
|
-
manifestFileName,
|
|
12252
|
-
statsFileName
|
|
12253
|
-
};
|
|
12254
|
-
}
|
|
12255
|
-
raw() {
|
|
12256
|
-
if (this.sharedOptions.length) return createBuiltinPlugin(this.name, this.buildOptions());
|
|
12257
|
-
}
|
|
12258
|
-
}
|
|
12259
|
-
let VIRTUAL_ENTRY = './virtual-entry.js', VIRTUAL_ENTRY_NAME = 'virtual-entry';
|
|
12260
|
-
class VirtualEntryPlugin {
|
|
12261
|
-
sharedOptions;
|
|
12262
|
-
collectShared = !1;
|
|
12263
|
-
constructor(sharedOptions, collectShared){
|
|
12264
|
-
this.sharedOptions = sharedOptions, this.collectShared = collectShared;
|
|
12265
|
-
}
|
|
12266
|
-
createEntry() {
|
|
12267
|
-
let { sharedOptions, collectShared } = this;
|
|
12268
|
-
return sharedOptions.reduce((acc, cur, index)=>{
|
|
12269
|
-
let importLine = `import shared_${index} from '${cur[0]}';\n`;
|
|
12270
|
-
return acc + importLine + (collectShared ? `console.log(shared_${index});\n` : '');
|
|
12271
|
-
}, '');
|
|
12272
|
-
}
|
|
12273
|
-
static entry() {
|
|
12274
|
-
return {
|
|
12275
|
-
[VIRTUAL_ENTRY_NAME]: VIRTUAL_ENTRY
|
|
12276
|
-
};
|
|
12277
|
-
}
|
|
12278
|
-
apply(compiler) {
|
|
12279
|
-
new compiler.rspack.experiments.VirtualModulesPlugin({
|
|
12280
|
-
[VIRTUAL_ENTRY]: this.createEntry()
|
|
12281
|
-
}).apply(compiler), compiler.hooks.thisCompilation.tap('RemoveVirtualEntryAsset', (compilation)=>{
|
|
12282
|
-
compilation.hooks.processAssets.tap({
|
|
12283
|
-
name: 'RemoveVirtualEntryAsset',
|
|
12284
|
-
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
|
|
12285
|
-
}, ()=>{
|
|
12286
|
-
try {
|
|
12287
|
-
let chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
|
|
12288
|
-
chunk?.files.forEach((f)=>{
|
|
12289
|
-
compilation.deleteAsset(f);
|
|
12290
|
-
});
|
|
12291
|
-
} catch (_e) {
|
|
12292
|
-
console.error('Failed to remove virtual entry file!');
|
|
12293
|
-
}
|
|
12294
|
-
});
|
|
12295
|
-
});
|
|
12296
|
-
}
|
|
12297
|
-
}
|
|
12298
|
-
let resolveOutputDir = (outputDir, shareName)=>shareName ? (0, external_node_path_namespaceObject.join)(outputDir, encodeName(shareName)) : outputDir;
|
|
12299
|
-
class IndependentSharedPlugin {
|
|
12300
|
-
mfName;
|
|
12301
|
-
shared;
|
|
12302
|
-
library;
|
|
12303
|
-
sharedOptions;
|
|
12304
|
-
outputDir;
|
|
12305
|
-
plugins;
|
|
12306
|
-
treeShaking;
|
|
12307
|
-
manifest;
|
|
12308
|
-
buildAssets = {};
|
|
12309
|
-
injectTreeShakingUsedExports;
|
|
12310
|
-
treeShakingSharedExcludePlugins;
|
|
12311
|
-
name = 'IndependentSharedPlugin';
|
|
12312
|
-
constructor(options){
|
|
12313
|
-
const { outputDir, plugins, treeShaking, shared, name, manifest, injectTreeShakingUsedExports, library, treeShakingSharedExcludePlugins } = options;
|
|
12314
|
-
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)=>{
|
|
12315
|
-
if ('string' != typeof item) throw Error(`Unexpected array in shared configuration for key "${key}"`);
|
|
12316
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
12317
|
-
import: key,
|
|
12318
|
-
requiredVersion: item
|
|
12319
|
-
} : {
|
|
12320
|
-
import: item
|
|
12321
|
-
};
|
|
12322
|
-
}, (item)=>item);
|
|
12323
|
-
}
|
|
12324
|
-
apply(compiler) {
|
|
12325
|
-
let { manifest } = this, runCount = 0;
|
|
12326
|
-
compiler.hooks.beforeRun.tapPromise('IndependentSharedPlugin', async ()=>{
|
|
12327
|
-
!runCount && (await this.createIndependentCompilers(compiler), runCount++);
|
|
12328
|
-
}), compiler.hooks.watchRun.tapPromise('IndependentSharedPlugin', async ()=>{
|
|
12329
|
-
!runCount && (await this.createIndependentCompilers(compiler), runCount++);
|
|
12330
|
-
}), compiler.hooks.shutdown.tapAsync('IndependentSharedPlugin', (callback)=>{
|
|
12331
|
-
callback();
|
|
12332
|
-
}), manifest && compiler.hooks.compilation.tap('IndependentSharedPlugin', (compilation)=>{
|
|
12333
|
-
compilation.hooks.processAssets.tap({
|
|
12334
|
-
name: 'injectBuildAssets',
|
|
12335
|
-
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
12336
|
-
}, ()=>{
|
|
12337
|
-
let { statsFileName, manifestFileName } = getFileName(manifest), injectBuildAssetsIntoStatsOrManifest = (filename)=>{
|
|
12338
|
-
let stats = compilation.getAsset(filename);
|
|
12339
|
-
if (!stats) return;
|
|
12340
|
-
let statsContent = JSON.parse(stats.source.source().toString()), { shared } = statsContent;
|
|
12341
|
-
Object.entries(this.buildAssets).forEach(([key, item])=>{
|
|
12342
|
-
let targetShared = shared.find((s)=>s.name === key);
|
|
12343
|
-
targetShared && item.forEach(([entry, version, globalName])=>{
|
|
12344
|
-
version === targetShared.version && (targetShared.fallback = entry, targetShared.fallbackName = globalName);
|
|
12345
|
-
});
|
|
12346
|
-
}), compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
|
|
12347
|
-
};
|
|
12348
|
-
injectBuildAssetsIntoStatsOrManifest(statsFileName), injectBuildAssetsIntoStatsOrManifest(manifestFileName);
|
|
12349
|
-
});
|
|
12350
|
-
});
|
|
12351
|
-
}
|
|
12352
|
-
async createIndependentCompilers(parentCompiler) {
|
|
12353
|
-
let { sharedOptions, buildAssets, outputDir } = this;
|
|
12354
|
-
console.log('Start building shared fallback resources ...');
|
|
12355
|
-
let shareRequestsMap = await this.createIndependentCompiler(parentCompiler);
|
|
12356
|
-
await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
|
|
12357
|
-
if (!shareConfig.treeShaking || !1 === shareConfig.import) return;
|
|
12358
|
-
let shareRequests = shareRequestsMap[shareName].requests;
|
|
12359
|
-
await Promise.all(shareRequests.map(async ([request, version])=>{
|
|
12360
|
-
let sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1], [shareFileName, globalName, sharedVersion] = await this.createIndependentCompiler(parentCompiler, {
|
|
12361
|
-
shareRequestsMap,
|
|
12362
|
-
currentShare: {
|
|
12363
|
-
shareName,
|
|
12364
|
-
version,
|
|
12365
|
-
request,
|
|
12366
|
-
independentShareFileName: sharedConfig?.treeShaking?.filename
|
|
12367
|
-
}
|
|
12368
|
-
});
|
|
12369
|
-
'string' == typeof shareFileName && (buildAssets[shareName] ||= [], buildAssets[shareName].push([
|
|
12370
|
-
(0, external_node_path_namespaceObject.join)(resolveOutputDir(outputDir, shareName), shareFileName),
|
|
12371
|
-
sharedVersion,
|
|
12372
|
-
globalName
|
|
12373
|
-
]));
|
|
12374
|
-
}));
|
|
12375
|
-
})), console.log('All shared fallback have been compiled successfully!');
|
|
12376
|
-
}
|
|
12377
|
-
async createIndependentCompiler(parentCompiler, extraOptions) {
|
|
12378
|
-
let extraPlugin, { mfName, plugins, outputDir, sharedOptions, treeShaking, library, treeShakingSharedExcludePlugins } = this, outputDirWithShareName = resolveOutputDir(outputDir, extraOptions?.currentShare?.shareName || ''), parentConfig = parentCompiler.options, finalPlugins = [], rspack = parentCompiler.rspack;
|
|
12379
|
-
extraPlugin = extraOptions ? new SharedContainerPlugin({
|
|
12380
|
-
mfName,
|
|
12381
|
-
library,
|
|
12382
|
-
...extraOptions.currentShare
|
|
12383
|
-
}) : new CollectSharedEntryPlugin({
|
|
12384
|
-
sharedOptions,
|
|
12385
|
-
shareScope: 'default'
|
|
12386
|
-
}), (parentConfig.plugins || []).forEach((plugin)=>{
|
|
12387
|
-
void 0 !== plugin && 'string' != typeof plugin && ((plugin, excludedPlugins = [])=>{
|
|
12388
|
-
if (!plugin) return !0;
|
|
12389
|
-
let pluginName = plugin.name || plugin.constructor?.name;
|
|
12390
|
-
return !pluginName || ![
|
|
12391
|
-
'TreeShakingSharedPlugin',
|
|
12392
|
-
'IndependentSharedPlugin',
|
|
12393
|
-
'ModuleFederationPlugin',
|
|
12394
|
-
'SharedUsedExportsOptimizerPlugin',
|
|
12395
|
-
'HtmlWebpackPlugin',
|
|
12396
|
-
'HtmlRspackPlugin',
|
|
12397
|
-
'RsbuildHtmlPlugin',
|
|
12398
|
-
...excludedPlugins
|
|
12399
|
-
].includes(pluginName);
|
|
12400
|
-
})(plugin, treeShakingSharedExcludePlugins) && finalPlugins.push(plugin);
|
|
12401
|
-
}), plugins.forEach((plugin)=>{
|
|
12402
|
-
finalPlugins.push(plugin);
|
|
12403
|
-
}), finalPlugins.push(extraPlugin), finalPlugins.push(new ConsumeSharedPlugin({
|
|
12404
|
-
consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
|
|
12405
|
-
[key]: {
|
|
12406
|
-
import: !extraOptions && options.import,
|
|
12407
|
-
shareKey: options.shareKey || key,
|
|
12408
|
-
shareScope: options.shareScope,
|
|
12409
|
-
requiredVersion: options.requiredVersion,
|
|
12410
|
-
strictVersion: options.strictVersion,
|
|
12411
|
-
singleton: options.singleton,
|
|
12412
|
-
packageName: options.packageName,
|
|
12413
|
-
eager: options.eager
|
|
12414
|
-
}
|
|
12415
|
-
})),
|
|
12416
|
-
enhanced: !0
|
|
12417
|
-
})), treeShaking && finalPlugins.push(new SharedUsedExportsOptimizerPlugin(sharedOptions, this.injectTreeShakingUsedExports)), finalPlugins.push(new VirtualEntryPlugin(sharedOptions, !extraOptions));
|
|
12418
|
-
let fullOutputDir = (0, external_node_path_namespaceObject.resolve)(parentCompiler.outputPath, outputDirWithShareName), compilerConfig = {
|
|
12419
|
-
...parentConfig,
|
|
12420
|
-
module: {
|
|
12421
|
-
...parentConfig.module,
|
|
12422
|
-
rules: [
|
|
12423
|
-
{
|
|
12424
|
-
test: /virtual-entry\.js$/,
|
|
12425
|
-
type: "javascript/auto",
|
|
12426
|
-
resolve: {
|
|
12427
|
-
fullySpecified: !1
|
|
12428
|
-
},
|
|
12429
|
-
use: {
|
|
12430
|
-
loader: 'builtin:swc-loader'
|
|
12431
|
-
}
|
|
12432
|
-
},
|
|
12433
|
-
...parentConfig.module?.rules || []
|
|
12434
|
-
]
|
|
12435
|
-
},
|
|
12436
|
-
mode: parentConfig.mode || 'development',
|
|
12437
|
-
entry: VirtualEntryPlugin.entry,
|
|
12438
|
-
output: {
|
|
12439
|
-
path: fullOutputDir,
|
|
12440
|
-
clean: !0,
|
|
12441
|
-
publicPath: parentConfig.output?.publicPath || 'auto'
|
|
12442
|
-
},
|
|
12443
|
-
plugins: finalPlugins,
|
|
12444
|
-
optimization: {
|
|
12445
|
-
...parentConfig.optimization,
|
|
12446
|
-
splitChunks: !1
|
|
12447
|
-
}
|
|
12448
|
-
}, compiler = rspack.rspack(compilerConfig);
|
|
12449
|
-
compiler.inputFileSystem = parentCompiler.inputFileSystem, compiler.outputFileSystem = parentCompiler.outputFileSystem, compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
|
|
12450
|
-
let { currentShare } = extraOptions || {};
|
|
12451
|
-
return new Promise((resolve, reject)=>{
|
|
12452
|
-
compiler.run((err, stats)=>{
|
|
12453
|
-
if (err || stats?.hasErrors()) {
|
|
12454
|
-
let target = currentShare ? currentShare.shareName : 'Collect deps';
|
|
12455
|
-
console.error(`${target} Compile failed:`, err || stats.toJson().errors.map((e)=>e.message).join('\n')), reject(err || Error(`${target} Compile failed`));
|
|
12456
|
-
return;
|
|
12457
|
-
}
|
|
12458
|
-
currentShare && console.log(`${currentShare.shareName} Compile success`), resolve(extraPlugin.getData());
|
|
12459
|
-
});
|
|
12460
|
-
});
|
|
12461
|
-
}
|
|
12462
|
-
}
|
|
12463
|
-
class TreeShakingSharedPlugin {
|
|
12464
|
-
mfConfig;
|
|
12465
|
-
outputDir;
|
|
12466
|
-
secondary;
|
|
12467
|
-
_independentSharePlugin;
|
|
12468
|
-
name = 'TreeShakingSharedPlugin';
|
|
12469
|
-
constructor(options){
|
|
12470
|
-
const { mfConfig, secondary } = options;
|
|
12471
|
-
this.mfConfig = mfConfig, this.outputDir = mfConfig.treeShakingSharedDir || 'independent-packages', this.secondary = !!secondary;
|
|
12472
|
-
}
|
|
12473
|
-
apply(compiler) {
|
|
12474
|
-
let { mfConfig, outputDir, secondary } = this, { name, shared, library, treeShakingSharedPlugins } = mfConfig;
|
|
12475
|
-
if (!shared) return;
|
|
12476
|
-
let sharedOptions = normalizeSharedOptions(shared);
|
|
12477
|
-
sharedOptions.length && sharedOptions.some(([_, config])=>config.treeShaking && !1 !== config.import) && (secondary || new SharedUsedExportsOptimizerPlugin(sharedOptions, mfConfig.injectTreeShakingUsedExports, mfConfig.manifest).apply(compiler), this._independentSharePlugin = new IndependentSharedPlugin({
|
|
12478
|
-
name: name,
|
|
12479
|
-
shared: shared,
|
|
12480
|
-
outputDir,
|
|
12481
|
-
plugins: treeShakingSharedPlugins?.map((p)=>new (require(p))()) || [],
|
|
12482
|
-
treeShaking: secondary,
|
|
12483
|
-
library,
|
|
12484
|
-
manifest: mfConfig.manifest,
|
|
12485
|
-
treeShakingSharedExcludePlugins: mfConfig.treeShakingSharedExcludePlugins
|
|
12486
|
-
}), this._independentSharePlugin.apply(compiler));
|
|
12487
|
-
}
|
|
12488
|
-
get buildAssets() {
|
|
12489
|
-
return this._independentSharePlugin?.buildAssets || {};
|
|
12490
|
-
}
|
|
12491
|
-
}
|
|
12492
|
-
let ModuleFederationRuntimePlugin = base_create(binding_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
|
|
12493
|
-
function getRemoteInfos(options) {
|
|
12494
|
-
if (!options.remotes) return {};
|
|
12495
|
-
let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
|
|
12496
|
-
external: Array.isArray(item) ? item : [
|
|
12497
|
-
item
|
|
12498
|
-
],
|
|
12499
|
-
shareScope: options.shareScope || 'default'
|
|
12500
|
-
}), (item)=>({
|
|
12501
|
-
external: Array.isArray(item.external) ? item.external : [
|
|
12502
|
-
item.external
|
|
12503
|
-
],
|
|
12504
|
-
shareScope: item.shareScope || options.shareScope || 'default'
|
|
12505
|
-
})), remoteInfos = {};
|
|
12506
|
-
for (let [key, config] of remotes)for (let external of config.external){
|
|
12507
|
-
let [externalType, externalRequest] = function(external) {
|
|
12508
|
-
let result = function(external) {
|
|
12509
|
-
if (/^[a-z0-9-]+ /.test(external)) {
|
|
12510
|
-
let idx = external.indexOf(' ');
|
|
12511
|
-
return [
|
|
12512
|
-
external.slice(0, idx),
|
|
12513
|
-
external.slice(idx + 1)
|
|
12514
|
-
];
|
|
12515
|
-
}
|
|
12516
|
-
return null;
|
|
12517
|
-
}(external);
|
|
12518
|
-
return null === result ? [
|
|
12519
|
-
remoteType,
|
|
12520
|
-
external
|
|
12521
|
-
] : result;
|
|
12522
|
-
}(external);
|
|
12523
|
-
if (remoteInfos[key] ??= [], "script" === externalType) {
|
|
12524
|
-
let [url, global] = function(urlAndGlobal) {
|
|
12525
|
-
let index = urlAndGlobal.indexOf('@');
|
|
12526
|
-
return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
|
|
12527
|
-
urlAndGlobal.substring(index + 1),
|
|
12528
|
-
urlAndGlobal.substring(0, index)
|
|
12529
|
-
];
|
|
12530
|
-
}(externalRequest);
|
|
12531
|
-
remoteInfos[key].push({
|
|
12532
|
-
alias: key,
|
|
12533
|
-
name: global,
|
|
12534
|
-
entry: url,
|
|
12535
|
-
externalType,
|
|
12536
|
-
shareScope: config.shareScope
|
|
12537
|
-
});
|
|
12538
|
-
} else remoteInfos[key].push({
|
|
12539
|
-
alias: key,
|
|
12540
|
-
name: void 0,
|
|
12541
|
-
entry: void 0,
|
|
12542
|
-
externalType,
|
|
12543
|
-
shareScope: config.shareScope
|
|
12544
|
-
});
|
|
12545
|
-
}
|
|
12546
|
-
return remoteInfos;
|
|
12547
|
-
}
|
|
12548
|
-
function getDefaultEntryRuntime(paths, options, compiler, treeShakingShareFallbacks) {
|
|
12549
|
-
let runtimePlugins = options.runtimePlugins ?? [], remoteInfos = getRemoteInfos(options), runtimePluginImports = [], runtimePluginVars = [], libraryType = options.library?.type || 'var';
|
|
12550
|
-
for(let i = 0; i < runtimePlugins.length; i++){
|
|
12551
|
-
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;
|
|
12552
|
-
runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
|
|
12553
|
-
let paramsCode = void 0 === pluginParams ? 'undefined' : JSON.stringify(pluginParams);
|
|
12554
|
-
runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
|
|
12555
|
-
}
|
|
12556
|
-
let content = [
|
|
12557
|
-
`import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
|
|
12558
|
-
...runtimePluginImports,
|
|
12559
|
-
`const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(', ')}]`,
|
|
12560
|
-
`const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
|
|
12561
|
-
`const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
|
|
12562
|
-
`const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? 'version-first')}`,
|
|
12563
|
-
`const __module_federation_share_fallbacks__ = ${JSON.stringify(treeShakingShareFallbacks)}`,
|
|
12564
|
-
`const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
|
|
12565
|
-
compiler.webpack.Template.getFunctionContent(__webpack_require__("./moduleFederationDefaultRuntime.js"))
|
|
12566
|
-
].join(';');
|
|
12567
|
-
return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
|
|
12568
|
-
}
|
|
12569
12137
|
class ContainerPlugin extends RspackBuiltinPlugin {
|
|
12570
12138
|
name = binding_.BuiltinPluginName.ContainerPlugin;
|
|
12571
12139
|
_options;
|
|
@@ -12574,7 +12142,7 @@ Help:
|
|
|
12574
12142
|
name: options.name,
|
|
12575
12143
|
shareScope: options.shareScope || 'default',
|
|
12576
12144
|
library: options.library || {
|
|
12577
|
-
type: '
|
|
12145
|
+
type: 'var',
|
|
12578
12146
|
name: options.name
|
|
12579
12147
|
},
|
|
12580
12148
|
runtime: options.runtime,
|
|
@@ -12657,7 +12225,7 @@ Help:
|
|
|
12657
12225
|
let _options = JSON.stringify(options || {});
|
|
12658
12226
|
return binding_default().transform(source, _options);
|
|
12659
12227
|
}
|
|
12660
|
-
let exports_rspackVersion = "1.7.3-canary-
|
|
12228
|
+
let exports_rspackVersion = "1.7.3-canary-ef467b46-20260115180501", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
|
|
12661
12229
|
getNormalizedRspackOptions: getNormalizedRspackOptions,
|
|
12662
12230
|
applyRspackOptionsDefaults: applyRspackOptionsDefaults,
|
|
12663
12231
|
getNormalizedWebpackOptions: getNormalizedRspackOptions,
|
|
@@ -12700,12 +12268,11 @@ Help:
|
|
|
12700
12268
|
ContainerReferencePlugin: ContainerReferencePlugin,
|
|
12701
12269
|
ModuleFederationPlugin: class {
|
|
12702
12270
|
_options;
|
|
12703
|
-
_treeShakingSharedPlugin;
|
|
12704
12271
|
constructor(_options){
|
|
12705
12272
|
this._options = _options;
|
|
12706
12273
|
}
|
|
12707
12274
|
apply(compiler) {
|
|
12708
|
-
var options
|
|
12275
|
+
var options;
|
|
12709
12276
|
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', {
|
|
12710
12277
|
paths: [
|
|
12711
12278
|
runtimeToolsPath
|
|
@@ -12719,41 +12286,101 @@ Help:
|
|
|
12719
12286
|
bundlerRuntime: bundlerRuntimePath,
|
|
12720
12287
|
runtime: runtimePath
|
|
12721
12288
|
});
|
|
12722
|
-
compiler.options.resolve.alias = {
|
|
12289
|
+
if (compiler.options.resolve.alias = {
|
|
12723
12290
|
'@module-federation/runtime-tools': paths.runtimeTools,
|
|
12724
12291
|
'@module-federation/runtime': paths.runtime,
|
|
12725
12292
|
...compiler.options.resolve.alias
|
|
12726
|
-
},
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
|
|
12736
|
-
|
|
12737
|
-
|
|
12738
|
-
|
|
12739
|
-
|
|
12740
|
-
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
|
|
12744
|
-
|
|
12745
|
-
}
|
|
12746
|
-
}),
|
|
12747
|
-
name: 'ModuleFederationPlugin',
|
|
12748
|
-
stage: 100
|
|
12749
|
-
}, ()=>{
|
|
12750
|
-
runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
|
|
12751
|
-
entryRuntime: getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets || {})
|
|
12752
|
-
}).apply(compiler));
|
|
12753
|
-
}), new webpack.container.ModuleFederationPluginV1({
|
|
12293
|
+
}, new ModuleFederationRuntimePlugin({
|
|
12294
|
+
entryRuntime: function(paths, options, compiler) {
|
|
12295
|
+
let runtimePlugins = options.runtimePlugins ?? [], remoteInfos = getRemoteInfos(options), runtimePluginImports = [], runtimePluginVars = [];
|
|
12296
|
+
for(let i = 0; i < runtimePlugins.length; i++){
|
|
12297
|
+
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;
|
|
12298
|
+
runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
|
|
12299
|
+
let paramsCode = void 0 === pluginParams ? 'undefined' : JSON.stringify(pluginParams);
|
|
12300
|
+
runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
|
|
12301
|
+
}
|
|
12302
|
+
let content = [
|
|
12303
|
+
`import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
|
|
12304
|
+
...runtimePluginImports,
|
|
12305
|
+
`const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(', ')}]`,
|
|
12306
|
+
`const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
|
|
12307
|
+
`const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
|
|
12308
|
+
`const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? 'version-first')}`,
|
|
12309
|
+
compiler.webpack.Template.getFunctionContent(__webpack_require__("./moduleFederationDefaultRuntime.js"))
|
|
12310
|
+
].join(';');
|
|
12311
|
+
return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
|
|
12312
|
+
}(paths, this._options, compiler)
|
|
12313
|
+
}).apply(compiler), new webpack.container.ModuleFederationPluginV1({
|
|
12754
12314
|
...this._options,
|
|
12755
12315
|
enhanced: !0
|
|
12756
|
-
}).apply(compiler), this._options.manifest
|
|
12316
|
+
}).apply(compiler), this._options.manifest) {
|
|
12317
|
+
let manifestOptions = !0 === this._options.manifest ? {} : {
|
|
12318
|
+
...this._options.manifest
|
|
12319
|
+
}, containerName = manifestOptions.name ?? this._options.name, globalName = manifestOptions.globalName ?? function(library) {
|
|
12320
|
+
if (!library) return;
|
|
12321
|
+
let libName = library.name;
|
|
12322
|
+
if (libName) {
|
|
12323
|
+
if ('string' == typeof libName) return libName;
|
|
12324
|
+
if (Array.isArray(libName)) return libName[0];
|
|
12325
|
+
if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
12326
|
+
}
|
|
12327
|
+
}(this._options.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
|
|
12328
|
+
if (cur[1].length > 1) return sum;
|
|
12329
|
+
let { entry, alias, name } = cur[1][0];
|
|
12330
|
+
return entry && name && (sum[alias] = {
|
|
12331
|
+
name,
|
|
12332
|
+
entry
|
|
12333
|
+
}), sum;
|
|
12334
|
+
}, {}), manifestExposes = function(exposes) {
|
|
12335
|
+
if (!exposes) return;
|
|
12336
|
+
let result = parseOptions(exposes, (value)=>({
|
|
12337
|
+
import: Array.isArray(value) ? value : [
|
|
12338
|
+
value
|
|
12339
|
+
],
|
|
12340
|
+
name: void 0
|
|
12341
|
+
}), (value)=>({
|
|
12342
|
+
import: Array.isArray(value.import) ? value.import : [
|
|
12343
|
+
value.import
|
|
12344
|
+
],
|
|
12345
|
+
name: value.name ?? void 0
|
|
12346
|
+
})).map(([exposeKey, info])=>{
|
|
12347
|
+
let exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
|
|
12348
|
+
return {
|
|
12349
|
+
path: exposeKey,
|
|
12350
|
+
name: exposeName
|
|
12351
|
+
};
|
|
12352
|
+
});
|
|
12353
|
+
return result.length > 0 ? result : void 0;
|
|
12354
|
+
}(this._options.exposes);
|
|
12355
|
+
void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes);
|
|
12356
|
+
let manifestShared = function(shared) {
|
|
12357
|
+
if (!shared) return;
|
|
12358
|
+
let result = parseOptions(shared, (item, key)=>{
|
|
12359
|
+
if ('string' != typeof item) throw Error('Unexpected array in shared');
|
|
12360
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
12361
|
+
import: key,
|
|
12362
|
+
requiredVersion: item
|
|
12363
|
+
} : {
|
|
12364
|
+
import: item
|
|
12365
|
+
};
|
|
12366
|
+
}, (item)=>item).map(([key, config])=>{
|
|
12367
|
+
let name = config.shareKey || key, version = 'string' == typeof config.version ? config.version : void 0;
|
|
12368
|
+
return {
|
|
12369
|
+
name,
|
|
12370
|
+
version,
|
|
12371
|
+
requiredVersion: 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0,
|
|
12372
|
+
singleton: config.singleton
|
|
12373
|
+
};
|
|
12374
|
+
});
|
|
12375
|
+
return result.length > 0 ? result : void 0;
|
|
12376
|
+
}(this._options.shared);
|
|
12377
|
+
void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), new ModuleFederationManifestPlugin({
|
|
12378
|
+
...manifestOptions,
|
|
12379
|
+
name: containerName,
|
|
12380
|
+
globalName,
|
|
12381
|
+
remoteAliasMap
|
|
12382
|
+
}).apply(compiler);
|
|
12383
|
+
}
|
|
12757
12384
|
}
|
|
12758
12385
|
},
|
|
12759
12386
|
ModuleFederationPluginV1: class {
|
|
@@ -12790,7 +12417,6 @@ Help:
|
|
|
12790
12417
|
}
|
|
12791
12418
|
}, sharing = {
|
|
12792
12419
|
ProvideSharedPlugin: ProvideSharedPlugin,
|
|
12793
|
-
TreeShakingSharedPlugin: TreeShakingSharedPlugin,
|
|
12794
12420
|
ConsumeSharedPlugin: ConsumeSharedPlugin,
|
|
12795
12421
|
SharePlugin: SharePlugin
|
|
12796
12422
|
}, exports_experiments = {
|
|
@@ -12833,7 +12459,7 @@ Help:
|
|
|
12833
12459
|
return base_create(name, resolve, affectedHooks);
|
|
12834
12460
|
},
|
|
12835
12461
|
VirtualModulesPlugin: VirtualModulesPlugin
|
|
12836
|
-
}, src_fn = Object.assign(
|
|
12462
|
+
}, src_fn = Object.assign(rspack, exports_namespaceObject);
|
|
12837
12463
|
src_fn.rspack = src_fn, src_fn.webpack = src_fn;
|
|
12838
12464
|
let src_rspack_0 = src_fn, src_0 = src_rspack_0;
|
|
12839
12465
|
})(), 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 === [
|