@rspack-canary/browser 1.7.3-canary-785c0f6f-20260114175124 → 1.7.3-canary-58d41d16-20260115035302
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.mjs +894 -335
- package/dist/napi-binding.d.ts +33 -0
- package/dist/rspack.wasm32-wasi.wasm +0 -0
- 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/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -58216,7 +58216,7 @@ const applybundlerInfoDefaults = (rspackFuture, library)=>{
|
|
|
58216
58216
|
if ('object' == typeof rspackFuture) {
|
|
58217
58217
|
D(rspackFuture, 'bundlerInfo', {});
|
|
58218
58218
|
if ('object' == typeof rspackFuture.bundlerInfo) {
|
|
58219
|
-
D(rspackFuture.bundlerInfo, 'version', "1.7.3-canary-
|
|
58219
|
+
D(rspackFuture.bundlerInfo, 'version', "1.7.3-canary-58d41d16-20260115035302");
|
|
58220
58220
|
D(rspackFuture.bundlerInfo, 'bundler', 'rspack');
|
|
58221
58221
|
D(rspackFuture.bundlerInfo, 'force', !library);
|
|
58222
58222
|
}
|
|
@@ -60486,7 +60486,7 @@ class MultiStats {
|
|
|
60486
60486
|
return obj;
|
|
60487
60487
|
});
|
|
60488
60488
|
if (childOptions.version) {
|
|
60489
|
-
obj.rspackVersion = "1.7.3-canary-
|
|
60489
|
+
obj.rspackVersion = "1.7.3-canary-58d41d16-20260115035302";
|
|
60490
60490
|
obj.version = "5.75.0";
|
|
60491
60491
|
}
|
|
60492
60492
|
if (childOptions.hash) obj.hash = obj.children.map((j)=>j.hash).join('');
|
|
@@ -62318,7 +62318,7 @@ const SIMPLE_EXTRACTORS = {
|
|
|
62318
62318
|
},
|
|
62319
62319
|
version: (object)=>{
|
|
62320
62320
|
object.version = "5.75.0";
|
|
62321
|
-
object.rspackVersion = "1.7.3-canary-
|
|
62321
|
+
object.rspackVersion = "1.7.3-canary-58d41d16-20260115035302";
|
|
62322
62322
|
},
|
|
62323
62323
|
env: (object, _compilation, _context, { _env })=>{
|
|
62324
62324
|
object.env = _env;
|
|
@@ -64113,7 +64113,7 @@ function createCompiler(userOptions) {
|
|
|
64113
64113
|
function isMultiRspackOptions(o) {
|
|
64114
64114
|
return Array.isArray(o);
|
|
64115
64115
|
}
|
|
64116
|
-
function
|
|
64116
|
+
function rspack_rspack(options, callback) {
|
|
64117
64117
|
try {
|
|
64118
64118
|
if (isMultiRspackOptions(options)) for (const option of options)validateRspackConfig(option);
|
|
64119
64119
|
else validateRspackConfig(options);
|
|
@@ -65778,7 +65778,7 @@ class Compiler {
|
|
|
65778
65778
|
};
|
|
65779
65779
|
const compilerRuntimeGlobals = createCompilerRuntimeGlobals(options);
|
|
65780
65780
|
const compilerFn = function(...params) {
|
|
65781
|
-
return
|
|
65781
|
+
return rspack_rspack(...params);
|
|
65782
65782
|
};
|
|
65783
65783
|
const compilerRspack = Object.assign(compilerFn, exports_namespaceObject, {
|
|
65784
65784
|
RuntimeGlobals: compilerRuntimeGlobals
|
|
@@ -66280,10 +66280,266 @@ class NodeTemplatePlugin {
|
|
|
66280
66280
|
this._options = _options;
|
|
66281
66281
|
}
|
|
66282
66282
|
}
|
|
66283
|
+
const options_process = (options, normalizeSimple, normalizeOptions, fn)=>{
|
|
66284
|
+
const array = (items)=>{
|
|
66285
|
+
for (const item of items)if ('string' == typeof item) fn(item, normalizeSimple(item, item));
|
|
66286
|
+
else if (item && 'object' == typeof item) object(item);
|
|
66287
|
+
else throw new Error('Unexpected options format');
|
|
66288
|
+
};
|
|
66289
|
+
const object = (obj)=>{
|
|
66290
|
+
for (const [key, value] of Object.entries(obj))'string' == typeof value || Array.isArray(value) ? fn(key, normalizeSimple(value, key)) : fn(key, normalizeOptions(value, key));
|
|
66291
|
+
};
|
|
66292
|
+
if (!options) return;
|
|
66293
|
+
if (Array.isArray(options)) array(options);
|
|
66294
|
+
else if ('object' == typeof options) object(options);
|
|
66295
|
+
else throw new Error('Unexpected options format');
|
|
66296
|
+
};
|
|
66297
|
+
const parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
66298
|
+
const items = [];
|
|
66299
|
+
options_process(options, normalizeSimple, normalizeOptions, (key, value)=>{
|
|
66300
|
+
items.push([
|
|
66301
|
+
key,
|
|
66302
|
+
value
|
|
66303
|
+
]);
|
|
66304
|
+
});
|
|
66305
|
+
return items;
|
|
66306
|
+
};
|
|
66307
|
+
function ShareRuntimePlugin_define_property(obj, key, value) {
|
|
66308
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
66309
|
+
value: value,
|
|
66310
|
+
enumerable: true,
|
|
66311
|
+
configurable: true,
|
|
66312
|
+
writable: true
|
|
66313
|
+
});
|
|
66314
|
+
else obj[key] = value;
|
|
66315
|
+
return obj;
|
|
66316
|
+
}
|
|
66317
|
+
const compilerSet = new WeakSet();
|
|
66318
|
+
function isSingleton(compiler) {
|
|
66319
|
+
return compilerSet.has(compiler);
|
|
66320
|
+
}
|
|
66321
|
+
function setSingleton(compiler) {
|
|
66322
|
+
compilerSet.add(compiler);
|
|
66323
|
+
}
|
|
66324
|
+
class ShareRuntimePlugin extends RspackBuiltinPlugin {
|
|
66325
|
+
raw(compiler) {
|
|
66326
|
+
if (isSingleton(compiler)) return;
|
|
66327
|
+
setSingleton(compiler);
|
|
66328
|
+
return createBuiltinPlugin(this.name, this.enhanced);
|
|
66329
|
+
}
|
|
66330
|
+
constructor(enhanced = false){
|
|
66331
|
+
super(), ShareRuntimePlugin_define_property(this, "enhanced", void 0), ShareRuntimePlugin_define_property(this, "name", void 0), this.enhanced = enhanced, this.name = external_rspack_wasi_browser_js_.BuiltinPluginName.ShareRuntimePlugin;
|
|
66332
|
+
}
|
|
66333
|
+
}
|
|
66283
66334
|
const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
|
|
66284
66335
|
function isRequiredVersion(str) {
|
|
66285
66336
|
return VERSION_PATTERN_REGEXP.test(str);
|
|
66286
66337
|
}
|
|
66338
|
+
const encodeName = function(name, prefix = '', withExt = false) {
|
|
66339
|
+
const ext = withExt ? '.js' : '';
|
|
66340
|
+
return `${prefix}${name.replace(/@/g, 'scope_').replace(/-/g, '_').replace(/\//g, '__').replace(/\./g, '')}${ext}`;
|
|
66341
|
+
};
|
|
66342
|
+
function ConsumeSharedPlugin_define_property(obj, key, value) {
|
|
66343
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
66344
|
+
value: value,
|
|
66345
|
+
enumerable: true,
|
|
66346
|
+
configurable: true,
|
|
66347
|
+
writable: true
|
|
66348
|
+
});
|
|
66349
|
+
else obj[key] = value;
|
|
66350
|
+
return obj;
|
|
66351
|
+
}
|
|
66352
|
+
function normalizeConsumeShareOptions(consumes, shareScope) {
|
|
66353
|
+
return parseOptions(consumes, (item, key)=>{
|
|
66354
|
+
if (Array.isArray(item)) throw new Error('Unexpected array in options');
|
|
66355
|
+
const result = item !== key && isRequiredVersion(item) ? {
|
|
66356
|
+
import: key,
|
|
66357
|
+
shareScope: shareScope || 'default',
|
|
66358
|
+
shareKey: key,
|
|
66359
|
+
requiredVersion: item,
|
|
66360
|
+
strictVersion: true,
|
|
66361
|
+
packageName: void 0,
|
|
66362
|
+
singleton: false,
|
|
66363
|
+
eager: false,
|
|
66364
|
+
treeShakingMode: void 0
|
|
66365
|
+
} : {
|
|
66366
|
+
import: key,
|
|
66367
|
+
shareScope: shareScope || 'default',
|
|
66368
|
+
shareKey: key,
|
|
66369
|
+
requiredVersion: void 0,
|
|
66370
|
+
packageName: void 0,
|
|
66371
|
+
strictVersion: false,
|
|
66372
|
+
singleton: false,
|
|
66373
|
+
eager: false,
|
|
66374
|
+
treeShakingMode: void 0
|
|
66375
|
+
};
|
|
66376
|
+
return result;
|
|
66377
|
+
}, (item, key)=>({
|
|
66378
|
+
import: false === item.import ? void 0 : item.import || key,
|
|
66379
|
+
shareScope: item.shareScope || shareScope || 'default',
|
|
66380
|
+
shareKey: item.shareKey || key,
|
|
66381
|
+
requiredVersion: item.requiredVersion,
|
|
66382
|
+
strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : false !== item.import && !item.singleton,
|
|
66383
|
+
packageName: item.packageName,
|
|
66384
|
+
singleton: !!item.singleton,
|
|
66385
|
+
eager: !!item.eager,
|
|
66386
|
+
treeShakingMode: item.treeShakingMode
|
|
66387
|
+
}));
|
|
66388
|
+
}
|
|
66389
|
+
class ConsumeSharedPlugin extends RspackBuiltinPlugin {
|
|
66390
|
+
raw(compiler) {
|
|
66391
|
+
new ShareRuntimePlugin(this._options.enhanced).apply(compiler);
|
|
66392
|
+
const rawOptions = {
|
|
66393
|
+
consumes: this._options.consumes.map(([key, v])=>({
|
|
66394
|
+
key,
|
|
66395
|
+
...v
|
|
66396
|
+
})),
|
|
66397
|
+
enhanced: this._options.enhanced
|
|
66398
|
+
};
|
|
66399
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
66400
|
+
}
|
|
66401
|
+
constructor(options){
|
|
66402
|
+
super(), ConsumeSharedPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ConsumeSharedPlugin), ConsumeSharedPlugin_define_property(this, "_options", void 0);
|
|
66403
|
+
this._options = {
|
|
66404
|
+
consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
|
|
66405
|
+
enhanced: options.enhanced ?? false
|
|
66406
|
+
};
|
|
66407
|
+
}
|
|
66408
|
+
}
|
|
66409
|
+
function ProvideSharedPlugin_define_property(obj, key, value) {
|
|
66410
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
66411
|
+
value: value,
|
|
66412
|
+
enumerable: true,
|
|
66413
|
+
configurable: true,
|
|
66414
|
+
writable: true
|
|
66415
|
+
});
|
|
66416
|
+
else obj[key] = value;
|
|
66417
|
+
return obj;
|
|
66418
|
+
}
|
|
66419
|
+
function normalizeProvideShareOptions(options, shareScope, enhanced) {
|
|
66420
|
+
return parseOptions(options, (item)=>{
|
|
66421
|
+
if (Array.isArray(item)) throw new Error('Unexpected array of provides');
|
|
66422
|
+
return {
|
|
66423
|
+
shareKey: item,
|
|
66424
|
+
version: void 0,
|
|
66425
|
+
shareScope: shareScope || 'default',
|
|
66426
|
+
eager: false
|
|
66427
|
+
};
|
|
66428
|
+
}, (item)=>{
|
|
66429
|
+
const raw = {
|
|
66430
|
+
shareKey: item.shareKey,
|
|
66431
|
+
version: item.version,
|
|
66432
|
+
shareScope: item.shareScope || shareScope || 'default',
|
|
66433
|
+
eager: !!item.eager
|
|
66434
|
+
};
|
|
66435
|
+
if (enhanced) {
|
|
66436
|
+
const enhancedItem = item;
|
|
66437
|
+
return {
|
|
66438
|
+
...raw,
|
|
66439
|
+
singleton: enhancedItem.singleton,
|
|
66440
|
+
requiredVersion: enhancedItem.requiredVersion,
|
|
66441
|
+
strictVersion: enhancedItem.strictVersion,
|
|
66442
|
+
treeShakingMode: enhancedItem.treeShakingMode
|
|
66443
|
+
};
|
|
66444
|
+
}
|
|
66445
|
+
return raw;
|
|
66446
|
+
});
|
|
66447
|
+
}
|
|
66448
|
+
class ProvideSharedPlugin extends RspackBuiltinPlugin {
|
|
66449
|
+
raw(compiler) {
|
|
66450
|
+
new ShareRuntimePlugin(this._enhanced ?? false).apply(compiler);
|
|
66451
|
+
const rawOptions = this._provides.map(([key, v])=>({
|
|
66452
|
+
key,
|
|
66453
|
+
...v
|
|
66454
|
+
}));
|
|
66455
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
66456
|
+
}
|
|
66457
|
+
constructor(options){
|
|
66458
|
+
super(), ProvideSharedPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ProvideSharedPlugin), ProvideSharedPlugin_define_property(this, "_provides", void 0), ProvideSharedPlugin_define_property(this, "_enhanced", void 0);
|
|
66459
|
+
this._provides = normalizeProvideShareOptions(options.provides, options.shareScope, options.enhanced);
|
|
66460
|
+
this._enhanced = options.enhanced;
|
|
66461
|
+
}
|
|
66462
|
+
}
|
|
66463
|
+
function SharePlugin_define_property(obj, key, value) {
|
|
66464
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
66465
|
+
value: value,
|
|
66466
|
+
enumerable: true,
|
|
66467
|
+
configurable: true,
|
|
66468
|
+
writable: true
|
|
66469
|
+
});
|
|
66470
|
+
else obj[key] = value;
|
|
66471
|
+
return obj;
|
|
66472
|
+
}
|
|
66473
|
+
function normalizeSharedOptions(shared) {
|
|
66474
|
+
return parseOptions(shared, (item, key)=>{
|
|
66475
|
+
if ('string' != typeof item) throw new Error('Unexpected array in shared');
|
|
66476
|
+
const config = item !== key && isRequiredVersion(item) ? {
|
|
66477
|
+
import: key,
|
|
66478
|
+
requiredVersion: item
|
|
66479
|
+
} : {
|
|
66480
|
+
import: item
|
|
66481
|
+
};
|
|
66482
|
+
return config;
|
|
66483
|
+
}, (item)=>item);
|
|
66484
|
+
}
|
|
66485
|
+
function createProvideShareOptions(normalizedSharedOptions) {
|
|
66486
|
+
return normalizedSharedOptions.filter(([, options])=>false !== options.import).map(([key, options])=>({
|
|
66487
|
+
[options.import || key]: {
|
|
66488
|
+
shareKey: options.shareKey || key,
|
|
66489
|
+
shareScope: options.shareScope,
|
|
66490
|
+
version: options.version,
|
|
66491
|
+
eager: options.eager,
|
|
66492
|
+
singleton: options.singleton,
|
|
66493
|
+
requiredVersion: options.requiredVersion,
|
|
66494
|
+
strictVersion: options.strictVersion,
|
|
66495
|
+
treeShakingMode: options.treeShaking?.mode
|
|
66496
|
+
}
|
|
66497
|
+
}));
|
|
66498
|
+
}
|
|
66499
|
+
function createConsumeShareOptions(normalizedSharedOptions) {
|
|
66500
|
+
return normalizedSharedOptions.map(([key, options])=>({
|
|
66501
|
+
[key]: {
|
|
66502
|
+
import: options.import,
|
|
66503
|
+
shareKey: options.shareKey || key,
|
|
66504
|
+
shareScope: options.shareScope,
|
|
66505
|
+
requiredVersion: options.requiredVersion,
|
|
66506
|
+
strictVersion: options.strictVersion,
|
|
66507
|
+
singleton: options.singleton,
|
|
66508
|
+
packageName: options.packageName,
|
|
66509
|
+
eager: options.eager,
|
|
66510
|
+
treeShakingMode: options.treeShaking?.mode
|
|
66511
|
+
}
|
|
66512
|
+
}));
|
|
66513
|
+
}
|
|
66514
|
+
class SharePlugin {
|
|
66515
|
+
apply(compiler) {
|
|
66516
|
+
new ConsumeSharedPlugin({
|
|
66517
|
+
shareScope: this._shareScope,
|
|
66518
|
+
consumes: this._consumes,
|
|
66519
|
+
enhanced: this._enhanced
|
|
66520
|
+
}).apply(compiler);
|
|
66521
|
+
new ProvideSharedPlugin({
|
|
66522
|
+
shareScope: this._shareScope,
|
|
66523
|
+
provides: this._provides,
|
|
66524
|
+
enhanced: this._enhanced
|
|
66525
|
+
}).apply(compiler);
|
|
66526
|
+
}
|
|
66527
|
+
constructor(options){
|
|
66528
|
+
SharePlugin_define_property(this, "_shareScope", void 0);
|
|
66529
|
+
SharePlugin_define_property(this, "_consumes", void 0);
|
|
66530
|
+
SharePlugin_define_property(this, "_provides", void 0);
|
|
66531
|
+
SharePlugin_define_property(this, "_enhanced", void 0);
|
|
66532
|
+
SharePlugin_define_property(this, "_sharedOptions", void 0);
|
|
66533
|
+
const sharedOptions = normalizeSharedOptions(options.shared);
|
|
66534
|
+
const consumes = createConsumeShareOptions(sharedOptions);
|
|
66535
|
+
const provides = createProvideShareOptions(sharedOptions);
|
|
66536
|
+
this._shareScope = options.shareScope;
|
|
66537
|
+
this._consumes = consumes;
|
|
66538
|
+
this._provides = provides;
|
|
66539
|
+
this._enhanced = options.enhanced ?? false;
|
|
66540
|
+
this._sharedOptions = sharedOptions;
|
|
66541
|
+
}
|
|
66542
|
+
}
|
|
66287
66543
|
var ModuleFederationManifestPlugin_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
|
|
66288
66544
|
function ModuleFederationManifestPlugin_define_property(obj, key, value) {
|
|
66289
66545
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
@@ -66322,17 +66578,29 @@ function readPKGJson(root) {
|
|
|
66322
66578
|
} catch {}
|
|
66323
66579
|
return {};
|
|
66324
66580
|
}
|
|
66325
|
-
function getBuildInfo(isDev,
|
|
66326
|
-
const rootPath =
|
|
66581
|
+
function getBuildInfo(isDev, compiler, mfConfig) {
|
|
66582
|
+
const rootPath = compiler.options.context || ModuleFederationManifestPlugin_process.cwd();
|
|
66327
66583
|
const pkg = readPKGJson(rootPath);
|
|
66328
66584
|
const buildVersion = isDev ? LOCAL_BUILD_VERSION : pkg?.version;
|
|
66329
|
-
|
|
66585
|
+
const statsBuildInfo = {
|
|
66330
66586
|
buildVersion: ModuleFederationManifestPlugin_process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
|
|
66331
66587
|
buildName: ModuleFederationManifestPlugin_process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
|
|
66332
66588
|
};
|
|
66589
|
+
const normalizedShared = normalizeSharedOptions(mfConfig.shared || {});
|
|
66590
|
+
const enableTreeShaking = Object.values(normalizedShared).some((config)=>config[1].treeShaking);
|
|
66591
|
+
if (enableTreeShaking) {
|
|
66592
|
+
statsBuildInfo.target = Array.isArray(compiler.options.target) ? compiler.options.target : [];
|
|
66593
|
+
statsBuildInfo.plugins = mfConfig.treeShakingSharedPlugins || [];
|
|
66594
|
+
statsBuildInfo.excludePlugins = mfConfig.treeShakingSharedExcludePlugins || [];
|
|
66595
|
+
}
|
|
66596
|
+
return statsBuildInfo;
|
|
66333
66597
|
}
|
|
66334
66598
|
function getFileName(manifestOptions) {
|
|
66335
66599
|
if (!manifestOptions) return {
|
|
66600
|
+
statsFileName: '',
|
|
66601
|
+
manifestFileName: ''
|
|
66602
|
+
};
|
|
66603
|
+
if ('boolean' == typeof manifestOptions) return {
|
|
66336
66604
|
statsFileName: STATS_FILE_NAME,
|
|
66337
66605
|
manifestFileName: MANIFEST_FILE_NAME
|
|
66338
66606
|
};
|
|
@@ -66350,13 +66618,95 @@ function getFileName(manifestOptions) {
|
|
|
66350
66618
|
manifestFileName: (0, path_browserify.join)(filePath, manifestFileName)
|
|
66351
66619
|
};
|
|
66352
66620
|
}
|
|
66621
|
+
function resolveLibraryGlobalName(library) {
|
|
66622
|
+
if (!library) return;
|
|
66623
|
+
const libName = library.name;
|
|
66624
|
+
if (!libName) return;
|
|
66625
|
+
if ('string' == typeof libName) return libName;
|
|
66626
|
+
if (Array.isArray(libName)) return libName[0];
|
|
66627
|
+
if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
66628
|
+
}
|
|
66629
|
+
function collectManifestExposes(exposes) {
|
|
66630
|
+
if (!exposes) return;
|
|
66631
|
+
const parsed = parseOptions(exposes, (value)=>({
|
|
66632
|
+
import: Array.isArray(value) ? value : [
|
|
66633
|
+
value
|
|
66634
|
+
],
|
|
66635
|
+
name: void 0
|
|
66636
|
+
}), (value)=>({
|
|
66637
|
+
import: Array.isArray(value.import) ? value.import : [
|
|
66638
|
+
value.import
|
|
66639
|
+
],
|
|
66640
|
+
name: value.name ?? void 0
|
|
66641
|
+
}));
|
|
66642
|
+
const result = parsed.map(([exposeKey, info])=>{
|
|
66643
|
+
const exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
|
|
66644
|
+
return {
|
|
66645
|
+
path: exposeKey,
|
|
66646
|
+
name: exposeName
|
|
66647
|
+
};
|
|
66648
|
+
});
|
|
66649
|
+
return result.length > 0 ? result : void 0;
|
|
66650
|
+
}
|
|
66651
|
+
function collectManifestShared(shared) {
|
|
66652
|
+
if (!shared) return;
|
|
66653
|
+
const parsed = parseOptions(shared, (item, key)=>{
|
|
66654
|
+
if ('string' != typeof item) throw new Error('Unexpected array in shared');
|
|
66655
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
66656
|
+
import: key,
|
|
66657
|
+
requiredVersion: item
|
|
66658
|
+
} : {
|
|
66659
|
+
import: item
|
|
66660
|
+
};
|
|
66661
|
+
}, (item)=>item);
|
|
66662
|
+
const result = parsed.map(([key, config])=>{
|
|
66663
|
+
const name = config.shareKey || key;
|
|
66664
|
+
const version = 'string' == typeof config.version ? config.version : void 0;
|
|
66665
|
+
const requiredVersion = 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0;
|
|
66666
|
+
return {
|
|
66667
|
+
name,
|
|
66668
|
+
version,
|
|
66669
|
+
requiredVersion,
|
|
66670
|
+
singleton: config.singleton
|
|
66671
|
+
};
|
|
66672
|
+
});
|
|
66673
|
+
return result.length > 0 ? result : void 0;
|
|
66674
|
+
}
|
|
66675
|
+
function normalizeManifestOptions(mfConfig) {
|
|
66676
|
+
const manifestOptions = true === mfConfig.manifest ? {} : {
|
|
66677
|
+
...mfConfig.manifest
|
|
66678
|
+
};
|
|
66679
|
+
const containerName = mfConfig.name;
|
|
66680
|
+
const globalName = resolveLibraryGlobalName(mfConfig.library) ?? containerName;
|
|
66681
|
+
const remoteAliasMap = Object.entries(getRemoteInfos(mfConfig)).reduce((sum, cur)=>{
|
|
66682
|
+
if (cur[1].length > 1) return sum;
|
|
66683
|
+
const remoteInfo = cur[1][0];
|
|
66684
|
+
const { entry, alias, name } = remoteInfo;
|
|
66685
|
+
if (entry && name) sum[alias] = {
|
|
66686
|
+
name,
|
|
66687
|
+
entry
|
|
66688
|
+
};
|
|
66689
|
+
return sum;
|
|
66690
|
+
}, {});
|
|
66691
|
+
const manifestExposes = collectManifestExposes(mfConfig.exposes);
|
|
66692
|
+
if (void 0 === manifestOptions.exposes && manifestExposes) manifestOptions.exposes = manifestExposes;
|
|
66693
|
+
const manifestShared = collectManifestShared(mfConfig.shared);
|
|
66694
|
+
if (void 0 === manifestOptions.shared && manifestShared) manifestOptions.shared = manifestShared;
|
|
66695
|
+
return {
|
|
66696
|
+
...manifestOptions,
|
|
66697
|
+
remoteAliasMap,
|
|
66698
|
+
globalName,
|
|
66699
|
+
name: containerName
|
|
66700
|
+
};
|
|
66701
|
+
}
|
|
66353
66702
|
class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
66354
66703
|
raw(compiler) {
|
|
66355
|
-
const
|
|
66356
|
-
const {
|
|
66704
|
+
const opts = normalizeManifestOptions(this.rawOpts);
|
|
66705
|
+
const { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = opts;
|
|
66706
|
+
const { statsFileName, manifestFileName } = getFileName(opts);
|
|
66357
66707
|
const rawOptions = {
|
|
66358
|
-
name:
|
|
66359
|
-
globalName:
|
|
66708
|
+
name: opts.name,
|
|
66709
|
+
globalName: opts.globalName,
|
|
66360
66710
|
fileName,
|
|
66361
66711
|
filePath,
|
|
66362
66712
|
manifestFileName,
|
|
@@ -66365,40 +66715,489 @@ class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
|
66365
66715
|
remoteAliasMap,
|
|
66366
66716
|
exposes,
|
|
66367
66717
|
shared,
|
|
66368
|
-
buildInfo: getBuildInfo('development' === compiler.options.mode, compiler.
|
|
66718
|
+
buildInfo: getBuildInfo('development' === compiler.options.mode, compiler, this.rawOpts)
|
|
66369
66719
|
};
|
|
66370
66720
|
return createBuiltinPlugin(this.name, rawOptions);
|
|
66371
66721
|
}
|
|
66372
|
-
constructor(opts){
|
|
66373
|
-
super(), ModuleFederationManifestPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationManifestPlugin), ModuleFederationManifestPlugin_define_property(this, "
|
|
66374
|
-
this.
|
|
66722
|
+
constructor(opts){
|
|
66723
|
+
super(), ModuleFederationManifestPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationManifestPlugin), ModuleFederationManifestPlugin_define_property(this, "rawOpts", void 0);
|
|
66724
|
+
this.rawOpts = opts;
|
|
66725
|
+
}
|
|
66726
|
+
}
|
|
66727
|
+
function CollectSharedEntryPlugin_define_property(obj, key, value) {
|
|
66728
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
66729
|
+
value: value,
|
|
66730
|
+
enumerable: true,
|
|
66731
|
+
configurable: true,
|
|
66732
|
+
writable: true
|
|
66733
|
+
});
|
|
66734
|
+
else obj[key] = value;
|
|
66735
|
+
return obj;
|
|
66736
|
+
}
|
|
66737
|
+
const SHARE_ENTRY_ASSET = 'collect-shared-entries.json';
|
|
66738
|
+
class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
|
|
66739
|
+
getData() {
|
|
66740
|
+
return this._collectedEntries;
|
|
66741
|
+
}
|
|
66742
|
+
getFilename() {
|
|
66743
|
+
return SHARE_ENTRY_ASSET;
|
|
66744
|
+
}
|
|
66745
|
+
apply(compiler) {
|
|
66746
|
+
super.apply(compiler);
|
|
66747
|
+
compiler.hooks.thisCompilation.tap('Collect shared entry', (compilation)=>{
|
|
66748
|
+
compilation.hooks.processAssets.tap({
|
|
66749
|
+
name: 'CollectSharedEntry',
|
|
66750
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
|
|
66751
|
+
}, ()=>{
|
|
66752
|
+
compilation.getAssets().forEach((asset)=>{
|
|
66753
|
+
if (asset.name === SHARE_ENTRY_ASSET) this._collectedEntries = JSON.parse(asset.source.source().toString());
|
|
66754
|
+
compilation.deleteAsset(asset.name);
|
|
66755
|
+
});
|
|
66756
|
+
});
|
|
66757
|
+
});
|
|
66758
|
+
}
|
|
66759
|
+
raw() {
|
|
66760
|
+
const consumeShareOptions = createConsumeShareOptions(this.sharedOptions);
|
|
66761
|
+
const normalizedConsumeShareOptions = normalizeConsumeShareOptions(consumeShareOptions);
|
|
66762
|
+
const rawOptions = {
|
|
66763
|
+
consumes: normalizedConsumeShareOptions.map(([key, v])=>({
|
|
66764
|
+
key,
|
|
66765
|
+
...v
|
|
66766
|
+
})),
|
|
66767
|
+
filename: this.getFilename()
|
|
66768
|
+
};
|
|
66769
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
66770
|
+
}
|
|
66771
|
+
constructor(options){
|
|
66772
|
+
super(), CollectSharedEntryPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.CollectSharedEntryPlugin), CollectSharedEntryPlugin_define_property(this, "sharedOptions", void 0), CollectSharedEntryPlugin_define_property(this, "_collectedEntries", void 0);
|
|
66773
|
+
const { sharedOptions } = options;
|
|
66774
|
+
this.sharedOptions = sharedOptions;
|
|
66775
|
+
this._collectedEntries = {};
|
|
66776
|
+
}
|
|
66777
|
+
}
|
|
66778
|
+
function SharedContainerPlugin_define_property(obj, key, value) {
|
|
66779
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
66780
|
+
value: value,
|
|
66781
|
+
enumerable: true,
|
|
66782
|
+
configurable: true,
|
|
66783
|
+
writable: true
|
|
66784
|
+
});
|
|
66785
|
+
else obj[key] = value;
|
|
66786
|
+
return obj;
|
|
66787
|
+
}
|
|
66788
|
+
function assert(condition, msg) {
|
|
66789
|
+
if (!condition) throw new Error(msg);
|
|
66790
|
+
}
|
|
66791
|
+
const HOT_UPDATE_SUFFIX = '.hot-update';
|
|
66792
|
+
class SharedContainerPlugin extends RspackBuiltinPlugin {
|
|
66793
|
+
getData() {
|
|
66794
|
+
return [
|
|
66795
|
+
this._options.fileName,
|
|
66796
|
+
this._globalName,
|
|
66797
|
+
this._options.version
|
|
66798
|
+
];
|
|
66799
|
+
}
|
|
66800
|
+
raw(compiler) {
|
|
66801
|
+
const { library } = this._options;
|
|
66802
|
+
if (!compiler.options.output.enabledLibraryTypes.includes(library.type)) compiler.options.output.enabledLibraryTypes.push(library.type);
|
|
66803
|
+
return createBuiltinPlugin(this.name, this._options);
|
|
66804
|
+
}
|
|
66805
|
+
apply(compiler) {
|
|
66806
|
+
super.apply(compiler);
|
|
66807
|
+
const shareName = this._shareName;
|
|
66808
|
+
compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
|
|
66809
|
+
compilation.hooks.processAssets.tap({
|
|
66810
|
+
name: 'getShareContainerFile'
|
|
66811
|
+
}, ()=>{
|
|
66812
|
+
const remoteEntryPoint = compilation.entrypoints.get(shareName);
|
|
66813
|
+
assert(remoteEntryPoint, `Can not get shared ${shareName} entryPoint!`);
|
|
66814
|
+
const remoteEntryNameChunk = compilation.namedChunks.get(shareName);
|
|
66815
|
+
assert(remoteEntryNameChunk, `Can not get shared ${shareName} chunk!`);
|
|
66816
|
+
const files = Array.from(remoteEntryNameChunk.files).filter((f)=>!f.includes(HOT_UPDATE_SUFFIX) && !f.endsWith('.css'));
|
|
66817
|
+
assert(files.length > 0, `no files found for shared ${shareName} chunk`);
|
|
66818
|
+
assert(1 === files.length, `shared ${shareName} chunk should not have multiple files!, current files: ${files.join(',')}`);
|
|
66819
|
+
this.filename = files[0];
|
|
66820
|
+
});
|
|
66821
|
+
});
|
|
66822
|
+
}
|
|
66823
|
+
constructor(options){
|
|
66824
|
+
super(), SharedContainerPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.SharedContainerPlugin), SharedContainerPlugin_define_property(this, "filename", ''), SharedContainerPlugin_define_property(this, "_options", void 0), SharedContainerPlugin_define_property(this, "_shareName", void 0), SharedContainerPlugin_define_property(this, "_globalName", void 0);
|
|
66825
|
+
const { shareName, library, request, independentShareFileName, mfName } = options;
|
|
66826
|
+
const version = options.version || '0.0.0';
|
|
66827
|
+
this._globalName = encodeName(`${mfName}_${shareName}_${version}`);
|
|
66828
|
+
const fileName = independentShareFileName || `${version}/share-entry.js`;
|
|
66829
|
+
this._shareName = shareName;
|
|
66830
|
+
this._options = {
|
|
66831
|
+
name: shareName,
|
|
66832
|
+
request: request,
|
|
66833
|
+
library: (library ? {
|
|
66834
|
+
...library,
|
|
66835
|
+
name: this._globalName
|
|
66836
|
+
} : void 0) || {
|
|
66837
|
+
type: 'global',
|
|
66838
|
+
name: this._globalName
|
|
66839
|
+
},
|
|
66840
|
+
version,
|
|
66841
|
+
fileName
|
|
66842
|
+
};
|
|
66843
|
+
}
|
|
66844
|
+
}
|
|
66845
|
+
function SharedUsedExportsOptimizerPlugin_define_property(obj, key, value) {
|
|
66846
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
66847
|
+
value: value,
|
|
66848
|
+
enumerable: true,
|
|
66849
|
+
configurable: true,
|
|
66850
|
+
writable: true
|
|
66851
|
+
});
|
|
66852
|
+
else obj[key] = value;
|
|
66853
|
+
return obj;
|
|
66854
|
+
}
|
|
66855
|
+
class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
|
|
66856
|
+
buildOptions() {
|
|
66857
|
+
const shared = this.sharedOptions.map(([shareKey, config])=>({
|
|
66858
|
+
shareKey,
|
|
66859
|
+
treeShaking: !!config.treeShaking,
|
|
66860
|
+
usedExports: config.treeShaking?.usedExports
|
|
66861
|
+
}));
|
|
66862
|
+
const { manifestFileName, statsFileName } = getFileName(this.manifestOptions);
|
|
66863
|
+
return {
|
|
66864
|
+
shared,
|
|
66865
|
+
injectTreeShakingUsedExports: this.injectTreeShakingUsedExports,
|
|
66866
|
+
manifestFileName,
|
|
66867
|
+
statsFileName
|
|
66868
|
+
};
|
|
66869
|
+
}
|
|
66870
|
+
raw() {
|
|
66871
|
+
if (!this.sharedOptions.length) return;
|
|
66872
|
+
return createBuiltinPlugin(this.name, this.buildOptions());
|
|
66873
|
+
}
|
|
66874
|
+
constructor(sharedOptions, injectTreeShakingUsedExports, manifestOptions){
|
|
66875
|
+
super(), SharedUsedExportsOptimizerPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.SharedUsedExportsOptimizerPlugin), SharedUsedExportsOptimizerPlugin_define_property(this, "sharedOptions", void 0), SharedUsedExportsOptimizerPlugin_define_property(this, "injectTreeShakingUsedExports", void 0), SharedUsedExportsOptimizerPlugin_define_property(this, "manifestOptions", void 0);
|
|
66876
|
+
this.sharedOptions = sharedOptions;
|
|
66877
|
+
this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? true;
|
|
66878
|
+
this.manifestOptions = manifestOptions ?? {};
|
|
66879
|
+
}
|
|
66880
|
+
}
|
|
66881
|
+
function IndependentSharedPlugin_define_property(obj, key, value) {
|
|
66882
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
66883
|
+
value: value,
|
|
66884
|
+
enumerable: true,
|
|
66885
|
+
configurable: true,
|
|
66886
|
+
writable: true
|
|
66887
|
+
});
|
|
66888
|
+
else obj[key] = value;
|
|
66889
|
+
return obj;
|
|
66890
|
+
}
|
|
66891
|
+
const VIRTUAL_ENTRY = './virtual-entry.js';
|
|
66892
|
+
const VIRTUAL_ENTRY_NAME = 'virtual-entry';
|
|
66893
|
+
const filterPlugin = (plugin, excludedPlugins = [])=>{
|
|
66894
|
+
if (!plugin) return true;
|
|
66895
|
+
const pluginName = plugin.name || plugin.constructor?.name;
|
|
66896
|
+
if (!pluginName) return true;
|
|
66897
|
+
return ![
|
|
66898
|
+
'TreeShakingSharedPlugin',
|
|
66899
|
+
'IndependentSharedPlugin',
|
|
66900
|
+
'ModuleFederationPlugin',
|
|
66901
|
+
'SharedUsedExportsOptimizerPlugin',
|
|
66902
|
+
'HtmlWebpackPlugin',
|
|
66903
|
+
'HtmlRspackPlugin',
|
|
66904
|
+
'RsbuildHtmlPlugin',
|
|
66905
|
+
...excludedPlugins
|
|
66906
|
+
].includes(pluginName);
|
|
66907
|
+
};
|
|
66908
|
+
class VirtualEntryPlugin {
|
|
66909
|
+
createEntry() {
|
|
66910
|
+
const { sharedOptions, collectShared } = this;
|
|
66911
|
+
const entryContent = sharedOptions.reduce((acc, cur, index)=>{
|
|
66912
|
+
const importLine = `import shared_${index} from '${cur[0]}';\n`;
|
|
66913
|
+
const logLine = collectShared ? `console.log(shared_${index});\n` : '';
|
|
66914
|
+
return acc + importLine + logLine;
|
|
66915
|
+
}, '');
|
|
66916
|
+
return entryContent;
|
|
66917
|
+
}
|
|
66918
|
+
static entry() {
|
|
66919
|
+
return {
|
|
66920
|
+
[VIRTUAL_ENTRY_NAME]: VIRTUAL_ENTRY
|
|
66921
|
+
};
|
|
66922
|
+
}
|
|
66923
|
+
apply(compiler) {
|
|
66924
|
+
new compiler.rspack.experiments.VirtualModulesPlugin({
|
|
66925
|
+
[VIRTUAL_ENTRY]: this.createEntry()
|
|
66926
|
+
}).apply(compiler);
|
|
66927
|
+
compiler.hooks.thisCompilation.tap('RemoveVirtualEntryAsset', (compilation)=>{
|
|
66928
|
+
compilation.hooks.processAssets.tap({
|
|
66929
|
+
name: 'RemoveVirtualEntryAsset',
|
|
66930
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
|
|
66931
|
+
}, ()=>{
|
|
66932
|
+
try {
|
|
66933
|
+
const chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
|
|
66934
|
+
chunk?.files.forEach((f)=>{
|
|
66935
|
+
compilation.deleteAsset(f);
|
|
66936
|
+
});
|
|
66937
|
+
} catch (_e) {
|
|
66938
|
+
console.error('Failed to remove virtual entry file!');
|
|
66939
|
+
}
|
|
66940
|
+
});
|
|
66941
|
+
});
|
|
66942
|
+
}
|
|
66943
|
+
constructor(sharedOptions, collectShared){
|
|
66944
|
+
IndependentSharedPlugin_define_property(this, "sharedOptions", void 0);
|
|
66945
|
+
IndependentSharedPlugin_define_property(this, "collectShared", false);
|
|
66946
|
+
this.sharedOptions = sharedOptions;
|
|
66947
|
+
this.collectShared = collectShared;
|
|
66948
|
+
}
|
|
66949
|
+
}
|
|
66950
|
+
const resolveOutputDir = (outputDir, shareName)=>shareName ? (0, path_browserify.join)(outputDir, encodeName(shareName)) : outputDir;
|
|
66951
|
+
class IndependentSharedPlugin {
|
|
66952
|
+
apply(compiler) {
|
|
66953
|
+
const { manifest } = this;
|
|
66954
|
+
let runCount = 0;
|
|
66955
|
+
compiler.hooks.beforeRun.tapPromise('IndependentSharedPlugin', async ()=>{
|
|
66956
|
+
if (runCount) return;
|
|
66957
|
+
await this.createIndependentCompilers(compiler);
|
|
66958
|
+
runCount++;
|
|
66959
|
+
});
|
|
66960
|
+
compiler.hooks.watchRun.tapPromise('IndependentSharedPlugin', async ()=>{
|
|
66961
|
+
if (runCount) return;
|
|
66962
|
+
await this.createIndependentCompilers(compiler);
|
|
66963
|
+
runCount++;
|
|
66964
|
+
});
|
|
66965
|
+
compiler.hooks.shutdown.tapAsync('IndependentSharedPlugin', (callback)=>{
|
|
66966
|
+
callback();
|
|
66967
|
+
});
|
|
66968
|
+
if (manifest) compiler.hooks.compilation.tap('IndependentSharedPlugin', (compilation)=>{
|
|
66969
|
+
compilation.hooks.processAssets.tap({
|
|
66970
|
+
name: 'injectBuildAssets',
|
|
66971
|
+
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
66972
|
+
}, ()=>{
|
|
66973
|
+
const { statsFileName, manifestFileName } = getFileName(manifest);
|
|
66974
|
+
const injectBuildAssetsIntoStatsOrManifest = (filename)=>{
|
|
66975
|
+
const stats = compilation.getAsset(filename);
|
|
66976
|
+
if (!stats) return;
|
|
66977
|
+
const statsContent = JSON.parse(stats.source.source().toString());
|
|
66978
|
+
const { shared } = statsContent;
|
|
66979
|
+
Object.entries(this.buildAssets).forEach(([key, item])=>{
|
|
66980
|
+
const targetShared = shared.find((s)=>s.name === key);
|
|
66981
|
+
if (!targetShared) return;
|
|
66982
|
+
item.forEach(([entry, version, globalName])=>{
|
|
66983
|
+
if (version === targetShared.version) {
|
|
66984
|
+
targetShared.fallback = entry;
|
|
66985
|
+
targetShared.fallbackName = globalName;
|
|
66986
|
+
}
|
|
66987
|
+
});
|
|
66988
|
+
});
|
|
66989
|
+
compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
|
|
66990
|
+
};
|
|
66991
|
+
injectBuildAssetsIntoStatsOrManifest(statsFileName);
|
|
66992
|
+
injectBuildAssetsIntoStatsOrManifest(manifestFileName);
|
|
66993
|
+
});
|
|
66994
|
+
});
|
|
66995
|
+
}
|
|
66996
|
+
async createIndependentCompilers(parentCompiler) {
|
|
66997
|
+
const { sharedOptions, buildAssets, outputDir } = this;
|
|
66998
|
+
console.log('Start building shared fallback resources ...');
|
|
66999
|
+
const shareRequestsMap = await this.createIndependentCompiler(parentCompiler);
|
|
67000
|
+
await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
|
|
67001
|
+
if (!shareConfig.treeShaking || false === shareConfig.import) return;
|
|
67002
|
+
const shareRequests = shareRequestsMap[shareName].requests;
|
|
67003
|
+
await Promise.all(shareRequests.map(async ([request, version])=>{
|
|
67004
|
+
const sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1];
|
|
67005
|
+
const [shareFileName, globalName, sharedVersion] = await this.createIndependentCompiler(parentCompiler, {
|
|
67006
|
+
shareRequestsMap,
|
|
67007
|
+
currentShare: {
|
|
67008
|
+
shareName,
|
|
67009
|
+
version,
|
|
67010
|
+
request,
|
|
67011
|
+
independentShareFileName: sharedConfig?.treeShaking?.filename
|
|
67012
|
+
}
|
|
67013
|
+
});
|
|
67014
|
+
if ('string' == typeof shareFileName) {
|
|
67015
|
+
buildAssets[shareName] ||= [];
|
|
67016
|
+
buildAssets[shareName].push([
|
|
67017
|
+
(0, path_browserify.join)(resolveOutputDir(outputDir, shareName), shareFileName),
|
|
67018
|
+
sharedVersion,
|
|
67019
|
+
globalName
|
|
67020
|
+
]);
|
|
67021
|
+
}
|
|
67022
|
+
}));
|
|
67023
|
+
}));
|
|
67024
|
+
console.log('All shared fallback have been compiled successfully!');
|
|
67025
|
+
}
|
|
67026
|
+
async createIndependentCompiler(parentCompiler, extraOptions) {
|
|
67027
|
+
const { mfName, plugins, outputDir, sharedOptions, treeShaking, library, treeShakingSharedExcludePlugins } = this;
|
|
67028
|
+
const outputDirWithShareName = resolveOutputDir(outputDir, extraOptions?.currentShare?.shareName || '');
|
|
67029
|
+
const parentConfig = parentCompiler.options;
|
|
67030
|
+
const finalPlugins = [];
|
|
67031
|
+
const rspack = parentCompiler.rspack;
|
|
67032
|
+
let extraPlugin;
|
|
67033
|
+
extraPlugin = extraOptions ? new SharedContainerPlugin({
|
|
67034
|
+
mfName,
|
|
67035
|
+
library,
|
|
67036
|
+
...extraOptions.currentShare
|
|
67037
|
+
}) : new CollectSharedEntryPlugin({
|
|
67038
|
+
sharedOptions,
|
|
67039
|
+
shareScope: 'default'
|
|
67040
|
+
});
|
|
67041
|
+
(parentConfig.plugins || []).forEach((plugin)=>{
|
|
67042
|
+
if (void 0 !== plugin && 'string' != typeof plugin && filterPlugin(plugin, treeShakingSharedExcludePlugins)) finalPlugins.push(plugin);
|
|
67043
|
+
});
|
|
67044
|
+
plugins.forEach((plugin)=>{
|
|
67045
|
+
finalPlugins.push(plugin);
|
|
67046
|
+
});
|
|
67047
|
+
finalPlugins.push(extraPlugin);
|
|
67048
|
+
finalPlugins.push(new ConsumeSharedPlugin({
|
|
67049
|
+
consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
|
|
67050
|
+
[key]: {
|
|
67051
|
+
import: extraOptions ? false : options.import,
|
|
67052
|
+
shareKey: options.shareKey || key,
|
|
67053
|
+
shareScope: options.shareScope,
|
|
67054
|
+
requiredVersion: options.requiredVersion,
|
|
67055
|
+
strictVersion: options.strictVersion,
|
|
67056
|
+
singleton: options.singleton,
|
|
67057
|
+
packageName: options.packageName,
|
|
67058
|
+
eager: options.eager
|
|
67059
|
+
}
|
|
67060
|
+
})),
|
|
67061
|
+
enhanced: true
|
|
67062
|
+
}));
|
|
67063
|
+
if (treeShaking) finalPlugins.push(new SharedUsedExportsOptimizerPlugin(sharedOptions, this.injectTreeShakingUsedExports));
|
|
67064
|
+
finalPlugins.push(new VirtualEntryPlugin(sharedOptions, !extraOptions));
|
|
67065
|
+
const fullOutputDir = (0, path_browserify.resolve)(parentCompiler.outputPath, outputDirWithShareName);
|
|
67066
|
+
const compilerConfig = {
|
|
67067
|
+
...parentConfig,
|
|
67068
|
+
module: {
|
|
67069
|
+
...parentConfig.module,
|
|
67070
|
+
rules: [
|
|
67071
|
+
{
|
|
67072
|
+
test: /virtual-entry\.js$/,
|
|
67073
|
+
type: "javascript/auto",
|
|
67074
|
+
resolve: {
|
|
67075
|
+
fullySpecified: false
|
|
67076
|
+
},
|
|
67077
|
+
use: {
|
|
67078
|
+
loader: 'builtin:swc-loader'
|
|
67079
|
+
}
|
|
67080
|
+
},
|
|
67081
|
+
...parentConfig.module?.rules || []
|
|
67082
|
+
]
|
|
67083
|
+
},
|
|
67084
|
+
mode: parentConfig.mode || 'development',
|
|
67085
|
+
entry: VirtualEntryPlugin.entry,
|
|
67086
|
+
output: {
|
|
67087
|
+
path: fullOutputDir,
|
|
67088
|
+
clean: true,
|
|
67089
|
+
publicPath: parentConfig.output?.publicPath || 'auto'
|
|
67090
|
+
},
|
|
67091
|
+
plugins: finalPlugins,
|
|
67092
|
+
optimization: {
|
|
67093
|
+
...parentConfig.optimization,
|
|
67094
|
+
splitChunks: false
|
|
67095
|
+
}
|
|
67096
|
+
};
|
|
67097
|
+
const compiler = rspack.rspack(compilerConfig);
|
|
67098
|
+
compiler.inputFileSystem = parentCompiler.inputFileSystem;
|
|
67099
|
+
compiler.outputFileSystem = parentCompiler.outputFileSystem;
|
|
67100
|
+
compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
|
|
67101
|
+
const { currentShare } = extraOptions || {};
|
|
67102
|
+
return new Promise((resolve, reject)=>{
|
|
67103
|
+
compiler.run((err, stats)=>{
|
|
67104
|
+
if (err || stats?.hasErrors()) {
|
|
67105
|
+
const target = currentShare ? currentShare.shareName : 'Collect deps';
|
|
67106
|
+
console.error(`${target} Compile failed:`, err || stats.toJson().errors.map((e)=>e.message).join('\n'));
|
|
67107
|
+
reject(err || new Error(`${target} Compile failed`));
|
|
67108
|
+
return;
|
|
67109
|
+
}
|
|
67110
|
+
currentShare && console.log(`${currentShare.shareName} Compile success`);
|
|
67111
|
+
resolve(extraPlugin.getData());
|
|
67112
|
+
});
|
|
67113
|
+
});
|
|
67114
|
+
}
|
|
67115
|
+
constructor(options){
|
|
67116
|
+
IndependentSharedPlugin_define_property(this, "mfName", void 0);
|
|
67117
|
+
IndependentSharedPlugin_define_property(this, "shared", void 0);
|
|
67118
|
+
IndependentSharedPlugin_define_property(this, "library", void 0);
|
|
67119
|
+
IndependentSharedPlugin_define_property(this, "sharedOptions", void 0);
|
|
67120
|
+
IndependentSharedPlugin_define_property(this, "outputDir", void 0);
|
|
67121
|
+
IndependentSharedPlugin_define_property(this, "plugins", void 0);
|
|
67122
|
+
IndependentSharedPlugin_define_property(this, "treeShaking", void 0);
|
|
67123
|
+
IndependentSharedPlugin_define_property(this, "manifest", void 0);
|
|
67124
|
+
IndependentSharedPlugin_define_property(this, "buildAssets", {});
|
|
67125
|
+
IndependentSharedPlugin_define_property(this, "injectTreeShakingUsedExports", void 0);
|
|
67126
|
+
IndependentSharedPlugin_define_property(this, "treeShakingSharedExcludePlugins", void 0);
|
|
67127
|
+
IndependentSharedPlugin_define_property(this, "name", 'IndependentSharedPlugin');
|
|
67128
|
+
const { outputDir, plugins, treeShaking, shared, name, manifest, injectTreeShakingUsedExports, library, treeShakingSharedExcludePlugins } = options;
|
|
67129
|
+
this.shared = shared;
|
|
67130
|
+
this.mfName = name;
|
|
67131
|
+
this.outputDir = outputDir || 'independent-packages';
|
|
67132
|
+
this.plugins = plugins || [];
|
|
67133
|
+
this.treeShaking = treeShaking;
|
|
67134
|
+
this.manifest = manifest;
|
|
67135
|
+
this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? true;
|
|
67136
|
+
this.library = library;
|
|
67137
|
+
this.treeShakingSharedExcludePlugins = treeShakingSharedExcludePlugins || [];
|
|
67138
|
+
this.sharedOptions = parseOptions(shared, (item, key)=>{
|
|
67139
|
+
if ('string' != typeof item) throw new Error(`Unexpected array in shared configuration for key "${key}"`);
|
|
67140
|
+
const config = item !== key && isRequiredVersion(item) ? {
|
|
67141
|
+
import: key,
|
|
67142
|
+
requiredVersion: item
|
|
67143
|
+
} : {
|
|
67144
|
+
import: item
|
|
67145
|
+
};
|
|
67146
|
+
return config;
|
|
67147
|
+
}, (item)=>item);
|
|
67148
|
+
}
|
|
67149
|
+
}
|
|
67150
|
+
function TreeShakingSharedPlugin_define_property(obj, key, value) {
|
|
67151
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
67152
|
+
value: value,
|
|
67153
|
+
enumerable: true,
|
|
67154
|
+
configurable: true,
|
|
67155
|
+
writable: true
|
|
67156
|
+
});
|
|
67157
|
+
else obj[key] = value;
|
|
67158
|
+
return obj;
|
|
67159
|
+
}
|
|
67160
|
+
class TreeShakingSharedPlugin {
|
|
67161
|
+
apply(compiler) {
|
|
67162
|
+
const { mfConfig, outputDir, secondary } = this;
|
|
67163
|
+
const { name, shared, library, treeShakingSharedPlugins } = mfConfig;
|
|
67164
|
+
if (!shared) return;
|
|
67165
|
+
const sharedOptions = normalizeSharedOptions(shared);
|
|
67166
|
+
if (!sharedOptions.length) return;
|
|
67167
|
+
if (sharedOptions.some(([_, config])=>config.treeShaking && false !== config.import)) {
|
|
67168
|
+
if (!secondary) new SharedUsedExportsOptimizerPlugin(sharedOptions, mfConfig.injectTreeShakingUsedExports, mfConfig.manifest).apply(compiler);
|
|
67169
|
+
this._independentSharePlugin = new IndependentSharedPlugin({
|
|
67170
|
+
name: name,
|
|
67171
|
+
shared: shared,
|
|
67172
|
+
outputDir,
|
|
67173
|
+
plugins: treeShakingSharedPlugins?.map((p)=>{
|
|
67174
|
+
const _constructor = require(p);
|
|
67175
|
+
return new _constructor();
|
|
67176
|
+
}) || [],
|
|
67177
|
+
treeShaking: secondary,
|
|
67178
|
+
library,
|
|
67179
|
+
manifest: mfConfig.manifest,
|
|
67180
|
+
treeShakingSharedExcludePlugins: mfConfig.treeShakingSharedExcludePlugins
|
|
67181
|
+
});
|
|
67182
|
+
this._independentSharePlugin.apply(compiler);
|
|
67183
|
+
}
|
|
67184
|
+
}
|
|
67185
|
+
get buildAssets() {
|
|
67186
|
+
return this._independentSharePlugin?.buildAssets || {};
|
|
67187
|
+
}
|
|
67188
|
+
constructor(options){
|
|
67189
|
+
TreeShakingSharedPlugin_define_property(this, "mfConfig", void 0);
|
|
67190
|
+
TreeShakingSharedPlugin_define_property(this, "outputDir", void 0);
|
|
67191
|
+
TreeShakingSharedPlugin_define_property(this, "secondary", void 0);
|
|
67192
|
+
TreeShakingSharedPlugin_define_property(this, "_independentSharePlugin", void 0);
|
|
67193
|
+
TreeShakingSharedPlugin_define_property(this, "name", 'TreeShakingSharedPlugin');
|
|
67194
|
+
const { mfConfig, secondary } = options;
|
|
67195
|
+
this.mfConfig = mfConfig;
|
|
67196
|
+
this.outputDir = mfConfig.treeShakingSharedDir || 'independent-packages';
|
|
67197
|
+
this.secondary = Boolean(secondary);
|
|
66375
67198
|
}
|
|
66376
67199
|
}
|
|
66377
67200
|
const ModuleFederationRuntimePlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
|
|
66378
|
-
const options_process = (options, normalizeSimple, normalizeOptions, fn)=>{
|
|
66379
|
-
const array = (items)=>{
|
|
66380
|
-
for (const item of items)if ('string' == typeof item) fn(item, normalizeSimple(item, item));
|
|
66381
|
-
else if (item && 'object' == typeof item) object(item);
|
|
66382
|
-
else throw new Error('Unexpected options format');
|
|
66383
|
-
};
|
|
66384
|
-
const object = (obj)=>{
|
|
66385
|
-
for (const [key, value] of Object.entries(obj))'string' == typeof value || Array.isArray(value) ? fn(key, normalizeSimple(value, key)) : fn(key, normalizeOptions(value, key));
|
|
66386
|
-
};
|
|
66387
|
-
if (!options) return;
|
|
66388
|
-
if (Array.isArray(options)) array(options);
|
|
66389
|
-
else if ('object' == typeof options) object(options);
|
|
66390
|
-
else throw new Error('Unexpected options format');
|
|
66391
|
-
};
|
|
66392
|
-
const parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
66393
|
-
const items = [];
|
|
66394
|
-
options_process(options, normalizeSimple, normalizeOptions, (key, value)=>{
|
|
66395
|
-
items.push([
|
|
66396
|
-
key,
|
|
66397
|
-
value
|
|
66398
|
-
]);
|
|
66399
|
-
});
|
|
66400
|
-
return items;
|
|
66401
|
-
};
|
|
66402
67201
|
function ModuleFederationPlugin_define_property(obj, key, value) {
|
|
66403
67202
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
66404
67203
|
value: value,
|
|
@@ -66418,101 +67217,50 @@ class ModuleFederationPlugin {
|
|
|
66418
67217
|
'@module-federation/runtime': paths.runtime,
|
|
66419
67218
|
...compiler.options.resolve.alias
|
|
66420
67219
|
};
|
|
66421
|
-
const
|
|
66422
|
-
|
|
66423
|
-
|
|
66424
|
-
|
|
67220
|
+
const sharedOptions = getSharedOptions(this._options);
|
|
67221
|
+
const treeShakingEntries = sharedOptions.filter(([, config])=>config.treeShaking);
|
|
67222
|
+
if (treeShakingEntries.length > 0) {
|
|
67223
|
+
this._treeShakingSharedPlugin = new TreeShakingSharedPlugin({
|
|
67224
|
+
mfConfig: this._options,
|
|
67225
|
+
secondary: false
|
|
67226
|
+
});
|
|
67227
|
+
this._treeShakingSharedPlugin.apply(compiler);
|
|
67228
|
+
}
|
|
67229
|
+
let runtimePluginApplied = false;
|
|
67230
|
+
compiler.hooks.beforeRun.tap({
|
|
67231
|
+
name: 'ModuleFederationPlugin',
|
|
67232
|
+
stage: 100
|
|
67233
|
+
}, ()=>{
|
|
67234
|
+
if (runtimePluginApplied) return;
|
|
67235
|
+
runtimePluginApplied = true;
|
|
67236
|
+
const entryRuntime = getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets);
|
|
67237
|
+
new ModuleFederationRuntimePlugin({
|
|
67238
|
+
entryRuntime
|
|
67239
|
+
}).apply(compiler);
|
|
67240
|
+
});
|
|
67241
|
+
compiler.hooks.watchRun.tap({
|
|
67242
|
+
name: 'ModuleFederationPlugin',
|
|
67243
|
+
stage: 100
|
|
67244
|
+
}, ()=>{
|
|
67245
|
+
if (runtimePluginApplied) return;
|
|
67246
|
+
runtimePluginApplied = true;
|
|
67247
|
+
const entryRuntime = getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets || {});
|
|
67248
|
+
new ModuleFederationRuntimePlugin({
|
|
67249
|
+
entryRuntime
|
|
67250
|
+
}).apply(compiler);
|
|
67251
|
+
});
|
|
66425
67252
|
new webpack.container.ModuleFederationPluginV1({
|
|
66426
67253
|
...this._options,
|
|
66427
67254
|
enhanced: true
|
|
66428
67255
|
}).apply(compiler);
|
|
66429
|
-
if (this._options.manifest)
|
|
66430
|
-
const manifestOptions = true === this._options.manifest ? {} : {
|
|
66431
|
-
...this._options.manifest
|
|
66432
|
-
};
|
|
66433
|
-
const containerName = manifestOptions.name ?? this._options.name;
|
|
66434
|
-
const globalName = manifestOptions.globalName ?? resolveLibraryGlobalName(this._options.library) ?? containerName;
|
|
66435
|
-
const remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
|
|
66436
|
-
if (cur[1].length > 1) return sum;
|
|
66437
|
-
const remoteInfo = cur[1][0];
|
|
66438
|
-
const { entry, alias, name } = remoteInfo;
|
|
66439
|
-
if (entry && name) sum[alias] = {
|
|
66440
|
-
name,
|
|
66441
|
-
entry
|
|
66442
|
-
};
|
|
66443
|
-
return sum;
|
|
66444
|
-
}, {});
|
|
66445
|
-
const manifestExposes = collectManifestExposes(this._options.exposes);
|
|
66446
|
-
if (void 0 === manifestOptions.exposes && manifestExposes) manifestOptions.exposes = manifestExposes;
|
|
66447
|
-
const manifestShared = collectManifestShared(this._options.shared);
|
|
66448
|
-
if (void 0 === manifestOptions.shared && manifestShared) manifestOptions.shared = manifestShared;
|
|
66449
|
-
new ModuleFederationManifestPlugin({
|
|
66450
|
-
...manifestOptions,
|
|
66451
|
-
name: containerName,
|
|
66452
|
-
globalName,
|
|
66453
|
-
remoteAliasMap
|
|
66454
|
-
}).apply(compiler);
|
|
66455
|
-
}
|
|
67256
|
+
if (this._options.manifest) new ModuleFederationManifestPlugin(this._options).apply(compiler);
|
|
66456
67257
|
}
|
|
66457
67258
|
constructor(_options){
|
|
66458
67259
|
ModuleFederationPlugin_define_property(this, "_options", void 0);
|
|
67260
|
+
ModuleFederationPlugin_define_property(this, "_treeShakingSharedPlugin", void 0);
|
|
66459
67261
|
this._options = _options;
|
|
66460
67262
|
}
|
|
66461
67263
|
}
|
|
66462
|
-
function collectManifestExposes(exposes) {
|
|
66463
|
-
if (!exposes) return;
|
|
66464
|
-
const parsed = parseOptions(exposes, (value)=>({
|
|
66465
|
-
import: Array.isArray(value) ? value : [
|
|
66466
|
-
value
|
|
66467
|
-
],
|
|
66468
|
-
name: void 0
|
|
66469
|
-
}), (value)=>({
|
|
66470
|
-
import: Array.isArray(value.import) ? value.import : [
|
|
66471
|
-
value.import
|
|
66472
|
-
],
|
|
66473
|
-
name: value.name ?? void 0
|
|
66474
|
-
}));
|
|
66475
|
-
const result = parsed.map(([exposeKey, info])=>{
|
|
66476
|
-
const exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
|
|
66477
|
-
return {
|
|
66478
|
-
path: exposeKey,
|
|
66479
|
-
name: exposeName
|
|
66480
|
-
};
|
|
66481
|
-
});
|
|
66482
|
-
return result.length > 0 ? result : void 0;
|
|
66483
|
-
}
|
|
66484
|
-
function collectManifestShared(shared) {
|
|
66485
|
-
if (!shared) return;
|
|
66486
|
-
const parsed = parseOptions(shared, (item, key)=>{
|
|
66487
|
-
if ('string' != typeof item) throw new Error('Unexpected array in shared');
|
|
66488
|
-
return item !== key && isRequiredVersion(item) ? {
|
|
66489
|
-
import: key,
|
|
66490
|
-
requiredVersion: item
|
|
66491
|
-
} : {
|
|
66492
|
-
import: item
|
|
66493
|
-
};
|
|
66494
|
-
}, (item)=>item);
|
|
66495
|
-
const result = parsed.map(([key, config])=>{
|
|
66496
|
-
const name = config.shareKey || key;
|
|
66497
|
-
const version = 'string' == typeof config.version ? config.version : void 0;
|
|
66498
|
-
const requiredVersion = 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0;
|
|
66499
|
-
return {
|
|
66500
|
-
name,
|
|
66501
|
-
version,
|
|
66502
|
-
requiredVersion,
|
|
66503
|
-
singleton: config.singleton
|
|
66504
|
-
};
|
|
66505
|
-
});
|
|
66506
|
-
return result.length > 0 ? result : void 0;
|
|
66507
|
-
}
|
|
66508
|
-
function resolveLibraryGlobalName(library) {
|
|
66509
|
-
if (!library) return;
|
|
66510
|
-
const libName = library.name;
|
|
66511
|
-
if (!libName) return;
|
|
66512
|
-
if ('string' == typeof libName) return libName;
|
|
66513
|
-
if (Array.isArray(libName)) return libName[0];
|
|
66514
|
-
if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
66515
|
-
}
|
|
66516
67264
|
function getRemoteInfos(options) {
|
|
66517
67265
|
if (!options.remotes) return {};
|
|
66518
67266
|
function extractUrlAndGlobal(urlAndGlobal) {
|
|
@@ -66579,6 +67327,18 @@ function getRemoteInfos(options) {
|
|
|
66579
67327
|
function getRuntimePlugins(options) {
|
|
66580
67328
|
return options.runtimePlugins ?? [];
|
|
66581
67329
|
}
|
|
67330
|
+
function getSharedOptions(options) {
|
|
67331
|
+
if (!options.shared) return [];
|
|
67332
|
+
return parseOptions(options.shared, (item, key)=>{
|
|
67333
|
+
if ('string' != typeof item) throw new Error('Unexpected array in shared');
|
|
67334
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
67335
|
+
import: key,
|
|
67336
|
+
requiredVersion: item
|
|
67337
|
+
} : {
|
|
67338
|
+
import: item
|
|
67339
|
+
};
|
|
67340
|
+
}, (item)=>item);
|
|
67341
|
+
}
|
|
66582
67342
|
function getPaths(options) {
|
|
66583
67343
|
return {
|
|
66584
67344
|
runtimeTools: '@module-federation/runtime-tools',
|
|
@@ -66586,11 +67346,12 @@ function getPaths(options) {
|
|
|
66586
67346
|
runtime: '@module-federation/runtime'
|
|
66587
67347
|
};
|
|
66588
67348
|
}
|
|
66589
|
-
function getDefaultEntryRuntime(paths, options, compiler) {
|
|
67349
|
+
function getDefaultEntryRuntime(paths, options, compiler, treeShakingShareFallbacks) {
|
|
66590
67350
|
const runtimePlugins = getRuntimePlugins(options);
|
|
66591
67351
|
const remoteInfos = getRemoteInfos(options);
|
|
66592
67352
|
const runtimePluginImports = [];
|
|
66593
67353
|
const runtimePluginVars = [];
|
|
67354
|
+
const libraryType = options.library?.type || 'var';
|
|
66594
67355
|
for(let i = 0; i < runtimePlugins.length; i++){
|
|
66595
67356
|
const runtimePluginVar = `__module_federation_runtime_plugin_${i}__`;
|
|
66596
67357
|
const pluginSpec = runtimePlugins[i];
|
|
@@ -66607,215 +67368,12 @@ function getDefaultEntryRuntime(paths, options, compiler) {
|
|
|
66607
67368
|
`const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
|
|
66608
67369
|
`const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
|
|
66609
67370
|
`const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? 'version-first')}`,
|
|
66610
|
-
|
|
67371
|
+
`const __module_federation_share_fallbacks__ = ${JSON.stringify(treeShakingShareFallbacks)}`,
|
|
67372
|
+
`const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
|
|
67373
|
+
'if((__webpack_require__.initializeSharingData||__webpack_require__.initializeExposesData)&&__webpack_require__.federation){var _ref,_ref1,_ref2,_ref3,_ref4;var __webpack_require___remotesLoadingData,__webpack_require___remotesLoadingData1,__webpack_require___initializeSharingData,__webpack_require___consumesLoadingData,__webpack_require___consumesLoadingData1,__webpack_require___initializeExposesData,__webpack_require___consumesLoadingData2;const override=(obj,key,value)=>{if(!obj)return;if(obj[key])obj[key]=value};const merge=(obj,key,fn)=>{const value=fn();if(Array.isArray(value)){var _obj,_key,_;(_=(_obj=obj)[_key=key])!==null&&_!==void 0?_:_obj[_key]=[];obj[key].push(...value)}else if(typeof value==="object"&&value!==null){var _obj1,_key1,_1;(_1=(_obj1=obj)[_key1=key])!==null&&_1!==void 0?_1:_obj1[_key1]={};Object.assign(obj[key],value)}};const early=(obj,key,initial)=>{var _obj,_key,_;(_=(_obj=obj)[_key=key])!==null&&_!==void 0?_:_obj[_key]=initial()};const remotesLoadingChunkMapping=(_ref=(__webpack_require___remotesLoadingData=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData===void 0?void 0:__webpack_require___remotesLoadingData.chunkMapping)!==null&&_ref!==void 0?_ref:{};const remotesLoadingModuleIdToRemoteDataMapping=(_ref1=(__webpack_require___remotesLoadingData1=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData1===void 0?void 0:__webpack_require___remotesLoadingData1.moduleIdToRemoteDataMapping)!==null&&_ref1!==void 0?_ref1:{};const initializeSharingScopeToInitDataMapping=(_ref2=(__webpack_require___initializeSharingData=__webpack_require__.initializeSharingData)===null||__webpack_require___initializeSharingData===void 0?void 0:__webpack_require___initializeSharingData.scopeToSharingDataMapping)!==null&&_ref2!==void 0?_ref2:{};const consumesLoadingChunkMapping=(_ref3=(__webpack_require___consumesLoadingData=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData===void 0?void 0:__webpack_require___consumesLoadingData.chunkMapping)!==null&&_ref3!==void 0?_ref3:{};const consumesLoadingModuleToConsumeDataMapping=(_ref4=(__webpack_require___consumesLoadingData1=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData1===void 0?void 0:__webpack_require___consumesLoadingData1.moduleIdToConsumeDataMapping)!==null&&_ref4!==void 0?_ref4:{};const consumesLoadinginstalledModules={};const initializeSharingInitPromises=[];const initializeSharingInitTokens={};const containerShareScope=(__webpack_require___initializeExposesData=__webpack_require__.initializeExposesData)===null||__webpack_require___initializeExposesData===void 0?void 0:__webpack_require___initializeExposesData.shareScope;for(const key in __module_federation_bundler_runtime__){__webpack_require__.federation[key]=__module_federation_bundler_runtime__[key]}early(__webpack_require__.federation,"libraryType",()=>__module_federation_library_type__);early(__webpack_require__.federation,"sharedFallback",()=>__module_federation_share_fallbacks__);const sharedFallback=__webpack_require__.federation.sharedFallback;early(__webpack_require__.federation,"consumesLoadingModuleToHandlerMapping",()=>{const consumesLoadingModuleToHandlerMapping={};for(let[moduleId,data]of Object.entries(consumesLoadingModuleToConsumeDataMapping)){var __webpack_require___federation_bundlerRuntime;consumesLoadingModuleToHandlerMapping[moduleId]={getter:sharedFallback?(__webpack_require___federation_bundlerRuntime=__webpack_require__.federation.bundlerRuntime)===null||__webpack_require___federation_bundlerRuntime===void 0?void 0:__webpack_require___federation_bundlerRuntime.getSharedFallbackGetter({shareKey:data.shareKey,factory:data.fallback,webpackRequire:__webpack_require__,libraryType:__webpack_require__.federation.libraryType}):data.fallback,treeShakingGetter:sharedFallback?data.fallback:undefined,shareInfo:{shareConfig:{fixedDependencies:false,requiredVersion:data.requiredVersion,strictVersion:data.strictVersion,singleton:data.singleton,eager:data.eager},scope:[data.shareScope]},shareKey:data.shareKey,treeShaking:__webpack_require__.federation.sharedFallback?{get:data.fallback,mode:data.treeShakingMode}:undefined}}return consumesLoadingModuleToHandlerMapping});early(__webpack_require__.federation,"initOptions",()=>({}));early(__webpack_require__.federation.initOptions,"name",()=>__module_federation_container_name__);early(__webpack_require__.federation.initOptions,"shareStrategy",()=>__module_federation_share_strategy__);early(__webpack_require__.federation.initOptions,"shared",()=>{const shared={};for(let[scope,stages]of Object.entries(initializeSharingScopeToInitDataMapping)){for(let stage of stages){if(typeof stage==="object"&&stage!==null){const{name,version,factory,eager,singleton,requiredVersion,strictVersion,treeShakingMode}=stage;const shareConfig={};const isValidValue=function(val){return typeof val!=="undefined"};if(isValidValue(singleton)){shareConfig.singleton=singleton}if(isValidValue(requiredVersion)){shareConfig.requiredVersion=requiredVersion}if(isValidValue(eager)){shareConfig.eager=eager}if(isValidValue(strictVersion)){shareConfig.strictVersion=strictVersion}const options={version,scope:[scope],shareConfig,get:factory,treeShaking:treeShakingMode?{mode:treeShakingMode}:undefined};if(shared[name]){shared[name].push(options)}else{shared[name]=[options]}}}}return shared});merge(__webpack_require__.federation.initOptions,"remotes",()=>Object.values(__module_federation_remote_infos__).flat().filter(remote=>remote.externalType==="script"));merge(__webpack_require__.federation.initOptions,"plugins",()=>__module_federation_runtime_plugins__);early(__webpack_require__.federation,"bundlerRuntimeOptions",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions,"remotes",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"chunkMapping",()=>remotesLoadingChunkMapping);early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"remoteInfos",()=>__module_federation_remote_infos__);early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToExternalAndNameMapping",()=>{const remotesLoadingIdToExternalAndNameMappingMapping={};for(let[moduleId,data]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){remotesLoadingIdToExternalAndNameMappingMapping[moduleId]=[data.shareScope,data.name,data.externalModuleId,data.remoteName]}return remotesLoadingIdToExternalAndNameMappingMapping});early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"webpackRequire",()=>__webpack_require__);merge(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToRemoteMap",()=>{const idToRemoteMap={};for(let[id,remoteData]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){const info=__module_federation_remote_infos__[remoteData.remoteName];if(info)idToRemoteMap[id]=info}return idToRemoteMap});override(__webpack_require__,"S",__webpack_require__.federation.bundlerRuntime.S);if(__webpack_require__.federation.attachShareScopeMap){__webpack_require__.federation.attachShareScopeMap(__webpack_require__)}override(__webpack_require__.f,"remotes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.remotes({chunkId,promises,chunkMapping:remotesLoadingChunkMapping,idToExternalAndNameMapping:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToExternalAndNameMapping,idToRemoteMap:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToRemoteMap,webpackRequire:__webpack_require__}));override(__webpack_require__.f,"consumes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.consumes({chunkId,promises,chunkMapping:consumesLoadingChunkMapping,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping,installedModules:consumesLoadinginstalledModules,webpackRequire:__webpack_require__}));override(__webpack_require__,"I",(name,initScope)=>__webpack_require__.federation.bundlerRuntime.I({shareScopeName:name,initScope,initPromises:initializeSharingInitPromises,initTokens:initializeSharingInitTokens,webpackRequire:__webpack_require__}));override(__webpack_require__,"initContainer",(shareScope,initScope,remoteEntryInitOptions)=>__webpack_require__.federation.bundlerRuntime.initContainerEntry({shareScope,initScope,remoteEntryInitOptions,shareScopeKey:containerShareScope,webpackRequire:__webpack_require__}));override(__webpack_require__,"getContainer",(module1,getScope)=>{var moduleMap=__webpack_require__.initializeExposesData.moduleMap;__webpack_require__.R=getScope;getScope=Object.prototype.hasOwnProperty.call(moduleMap,module1)?moduleMap[module1]():Promise.resolve().then(()=>{throw new Error(\'Module "\'+module1+\'" does not exist in container.\')});__webpack_require__.R=undefined;return getScope});__webpack_require__.federation.instance=__webpack_require__.federation.bundlerRuntime.init({webpackRequire:__webpack_require__});if((__webpack_require___consumesLoadingData2=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData2===void 0?void 0:__webpack_require___consumesLoadingData2.initialConsumes){__webpack_require__.federation.bundlerRuntime.installInitialConsumes({webpackRequire:__webpack_require__,installedModules:consumesLoadinginstalledModules,initialConsumes:__webpack_require__.consumesLoadingData.initialConsumes,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping})}}'
|
|
66611
67374
|
].join(';');
|
|
66612
67375
|
return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
|
|
66613
67376
|
}
|
|
66614
|
-
function ShareRuntimePlugin_define_property(obj, key, value) {
|
|
66615
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
66616
|
-
value: value,
|
|
66617
|
-
enumerable: true,
|
|
66618
|
-
configurable: true,
|
|
66619
|
-
writable: true
|
|
66620
|
-
});
|
|
66621
|
-
else obj[key] = value;
|
|
66622
|
-
return obj;
|
|
66623
|
-
}
|
|
66624
|
-
const compilerSet = new WeakSet();
|
|
66625
|
-
function isSingleton(compiler) {
|
|
66626
|
-
return compilerSet.has(compiler);
|
|
66627
|
-
}
|
|
66628
|
-
function setSingleton(compiler) {
|
|
66629
|
-
compilerSet.add(compiler);
|
|
66630
|
-
}
|
|
66631
|
-
class ShareRuntimePlugin extends RspackBuiltinPlugin {
|
|
66632
|
-
raw(compiler) {
|
|
66633
|
-
if (isSingleton(compiler)) return;
|
|
66634
|
-
setSingleton(compiler);
|
|
66635
|
-
return createBuiltinPlugin(this.name, this.enhanced);
|
|
66636
|
-
}
|
|
66637
|
-
constructor(enhanced = false){
|
|
66638
|
-
super(), ShareRuntimePlugin_define_property(this, "enhanced", void 0), ShareRuntimePlugin_define_property(this, "name", void 0), this.enhanced = enhanced, this.name = external_rspack_wasi_browser_js_.BuiltinPluginName.ShareRuntimePlugin;
|
|
66639
|
-
}
|
|
66640
|
-
}
|
|
66641
|
-
function ConsumeSharedPlugin_define_property(obj, key, value) {
|
|
66642
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
66643
|
-
value: value,
|
|
66644
|
-
enumerable: true,
|
|
66645
|
-
configurable: true,
|
|
66646
|
-
writable: true
|
|
66647
|
-
});
|
|
66648
|
-
else obj[key] = value;
|
|
66649
|
-
return obj;
|
|
66650
|
-
}
|
|
66651
|
-
class ConsumeSharedPlugin extends RspackBuiltinPlugin {
|
|
66652
|
-
raw(compiler) {
|
|
66653
|
-
new ShareRuntimePlugin(this._options.enhanced).apply(compiler);
|
|
66654
|
-
const rawOptions = {
|
|
66655
|
-
consumes: this._options.consumes.map(([key, v])=>({
|
|
66656
|
-
key,
|
|
66657
|
-
...v
|
|
66658
|
-
})),
|
|
66659
|
-
enhanced: this._options.enhanced
|
|
66660
|
-
};
|
|
66661
|
-
return createBuiltinPlugin(this.name, rawOptions);
|
|
66662
|
-
}
|
|
66663
|
-
constructor(options){
|
|
66664
|
-
super(), ConsumeSharedPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ConsumeSharedPlugin), ConsumeSharedPlugin_define_property(this, "_options", void 0);
|
|
66665
|
-
this._options = {
|
|
66666
|
-
consumes: parseOptions(options.consumes, (item, key)=>{
|
|
66667
|
-
if (Array.isArray(item)) throw new Error('Unexpected array in options');
|
|
66668
|
-
const result = item !== key && isRequiredVersion(item) ? {
|
|
66669
|
-
import: key,
|
|
66670
|
-
shareScope: options.shareScope || 'default',
|
|
66671
|
-
shareKey: key,
|
|
66672
|
-
requiredVersion: item,
|
|
66673
|
-
strictVersion: true,
|
|
66674
|
-
packageName: void 0,
|
|
66675
|
-
singleton: false,
|
|
66676
|
-
eager: false
|
|
66677
|
-
} : {
|
|
66678
|
-
import: key,
|
|
66679
|
-
shareScope: options.shareScope || 'default',
|
|
66680
|
-
shareKey: key,
|
|
66681
|
-
requiredVersion: void 0,
|
|
66682
|
-
packageName: void 0,
|
|
66683
|
-
strictVersion: false,
|
|
66684
|
-
singleton: false,
|
|
66685
|
-
eager: false
|
|
66686
|
-
};
|
|
66687
|
-
return result;
|
|
66688
|
-
}, (item, key)=>({
|
|
66689
|
-
import: false === item.import ? void 0 : item.import || key,
|
|
66690
|
-
shareScope: item.shareScope || options.shareScope || 'default',
|
|
66691
|
-
shareKey: item.shareKey || key,
|
|
66692
|
-
requiredVersion: item.requiredVersion,
|
|
66693
|
-
strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : false !== item.import && !item.singleton,
|
|
66694
|
-
packageName: item.packageName,
|
|
66695
|
-
singleton: !!item.singleton,
|
|
66696
|
-
eager: !!item.eager
|
|
66697
|
-
})),
|
|
66698
|
-
enhanced: options.enhanced ?? false
|
|
66699
|
-
};
|
|
66700
|
-
}
|
|
66701
|
-
}
|
|
66702
|
-
function ProvideSharedPlugin_define_property(obj, key, value) {
|
|
66703
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
66704
|
-
value: value,
|
|
66705
|
-
enumerable: true,
|
|
66706
|
-
configurable: true,
|
|
66707
|
-
writable: true
|
|
66708
|
-
});
|
|
66709
|
-
else obj[key] = value;
|
|
66710
|
-
return obj;
|
|
66711
|
-
}
|
|
66712
|
-
class ProvideSharedPlugin extends RspackBuiltinPlugin {
|
|
66713
|
-
raw(compiler) {
|
|
66714
|
-
new ShareRuntimePlugin(this._enhanced ?? false).apply(compiler);
|
|
66715
|
-
const rawOptions = this._provides.map(([key, v])=>({
|
|
66716
|
-
key,
|
|
66717
|
-
...v
|
|
66718
|
-
}));
|
|
66719
|
-
return createBuiltinPlugin(this.name, rawOptions);
|
|
66720
|
-
}
|
|
66721
|
-
constructor(options){
|
|
66722
|
-
super(), ProvideSharedPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ProvideSharedPlugin), ProvideSharedPlugin_define_property(this, "_provides", void 0), ProvideSharedPlugin_define_property(this, "_enhanced", void 0);
|
|
66723
|
-
this._provides = parseOptions(options.provides, (item)=>{
|
|
66724
|
-
if (Array.isArray(item)) throw new Error('Unexpected array of provides');
|
|
66725
|
-
return {
|
|
66726
|
-
shareKey: item,
|
|
66727
|
-
version: void 0,
|
|
66728
|
-
shareScope: options.shareScope || 'default',
|
|
66729
|
-
eager: false
|
|
66730
|
-
};
|
|
66731
|
-
}, (item)=>{
|
|
66732
|
-
const raw = {
|
|
66733
|
-
shareKey: item.shareKey,
|
|
66734
|
-
version: item.version,
|
|
66735
|
-
shareScope: item.shareScope || options.shareScope || 'default',
|
|
66736
|
-
eager: !!item.eager
|
|
66737
|
-
};
|
|
66738
|
-
if (options.enhanced) {
|
|
66739
|
-
const enhancedItem = item;
|
|
66740
|
-
return {
|
|
66741
|
-
...raw,
|
|
66742
|
-
singleton: enhancedItem.singleton,
|
|
66743
|
-
requiredVersion: enhancedItem.requiredVersion,
|
|
66744
|
-
strictVersion: enhancedItem.strictVersion
|
|
66745
|
-
};
|
|
66746
|
-
}
|
|
66747
|
-
return raw;
|
|
66748
|
-
});
|
|
66749
|
-
this._enhanced = options.enhanced;
|
|
66750
|
-
}
|
|
66751
|
-
}
|
|
66752
|
-
function SharePlugin_define_property(obj, key, value) {
|
|
66753
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
66754
|
-
value: value,
|
|
66755
|
-
enumerable: true,
|
|
66756
|
-
configurable: true,
|
|
66757
|
-
writable: true
|
|
66758
|
-
});
|
|
66759
|
-
else obj[key] = value;
|
|
66760
|
-
return obj;
|
|
66761
|
-
}
|
|
66762
|
-
class SharePlugin {
|
|
66763
|
-
apply(compiler) {
|
|
66764
|
-
new ConsumeSharedPlugin({
|
|
66765
|
-
shareScope: this._shareScope,
|
|
66766
|
-
consumes: this._consumes,
|
|
66767
|
-
enhanced: this._enhanced
|
|
66768
|
-
}).apply(compiler);
|
|
66769
|
-
new ProvideSharedPlugin({
|
|
66770
|
-
shareScope: this._shareScope,
|
|
66771
|
-
provides: this._provides,
|
|
66772
|
-
enhanced: this._enhanced
|
|
66773
|
-
}).apply(compiler);
|
|
66774
|
-
}
|
|
66775
|
-
constructor(options){
|
|
66776
|
-
SharePlugin_define_property(this, "_shareScope", void 0);
|
|
66777
|
-
SharePlugin_define_property(this, "_consumes", void 0);
|
|
66778
|
-
SharePlugin_define_property(this, "_provides", void 0);
|
|
66779
|
-
SharePlugin_define_property(this, "_enhanced", void 0);
|
|
66780
|
-
const sharedOptions = parseOptions(options.shared, (item, key)=>{
|
|
66781
|
-
if ('string' != typeof item) throw new Error('Unexpected array in shared');
|
|
66782
|
-
const config = item !== key && isRequiredVersion(item) ? {
|
|
66783
|
-
import: key,
|
|
66784
|
-
requiredVersion: item
|
|
66785
|
-
} : {
|
|
66786
|
-
import: item
|
|
66787
|
-
};
|
|
66788
|
-
return config;
|
|
66789
|
-
}, (item)=>item);
|
|
66790
|
-
const consumes = sharedOptions.map(([key, options])=>({
|
|
66791
|
-
[key]: {
|
|
66792
|
-
import: options.import,
|
|
66793
|
-
shareKey: options.shareKey || key,
|
|
66794
|
-
shareScope: options.shareScope,
|
|
66795
|
-
requiredVersion: options.requiredVersion,
|
|
66796
|
-
strictVersion: options.strictVersion,
|
|
66797
|
-
singleton: options.singleton,
|
|
66798
|
-
packageName: options.packageName,
|
|
66799
|
-
eager: options.eager
|
|
66800
|
-
}
|
|
66801
|
-
}));
|
|
66802
|
-
const provides = sharedOptions.filter(([, options])=>false !== options.import).map(([key, options])=>({
|
|
66803
|
-
[options.import || key]: {
|
|
66804
|
-
shareKey: options.shareKey || key,
|
|
66805
|
-
shareScope: options.shareScope,
|
|
66806
|
-
version: options.version,
|
|
66807
|
-
eager: options.eager,
|
|
66808
|
-
singleton: options.singleton,
|
|
66809
|
-
requiredVersion: options.requiredVersion,
|
|
66810
|
-
strictVersion: options.strictVersion
|
|
66811
|
-
}
|
|
66812
|
-
}));
|
|
66813
|
-
this._shareScope = options.shareScope;
|
|
66814
|
-
this._consumes = consumes;
|
|
66815
|
-
this._provides = provides;
|
|
66816
|
-
this._enhanced = options.enhanced ?? false;
|
|
66817
|
-
}
|
|
66818
|
-
}
|
|
66819
67377
|
function ContainerPlugin_define_property(obj, key, value) {
|
|
66820
67378
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
66821
67379
|
value: value,
|
|
@@ -66851,7 +67409,7 @@ class ContainerPlugin extends RspackBuiltinPlugin {
|
|
|
66851
67409
|
name: options.name,
|
|
66852
67410
|
shareScope: options.shareScope || 'default',
|
|
66853
67411
|
library: options.library || {
|
|
66854
|
-
type: '
|
|
67412
|
+
type: 'global',
|
|
66855
67413
|
name: options.name
|
|
66856
67414
|
},
|
|
66857
67415
|
runtime: options.runtime,
|
|
@@ -66988,7 +67546,7 @@ function transformSync(source, options) {
|
|
|
66988
67546
|
const _options = JSON.stringify(options || {});
|
|
66989
67547
|
return external_rspack_wasi_browser_js_["default"].transformSync(source, _options);
|
|
66990
67548
|
}
|
|
66991
|
-
const exports_rspackVersion = "1.7.3-canary-
|
|
67549
|
+
const exports_rspackVersion = "1.7.3-canary-58d41d16-20260115035302";
|
|
66992
67550
|
const exports_version = "5.75.0";
|
|
66993
67551
|
const exports_WebpackError = Error;
|
|
66994
67552
|
const sources = __webpack_require__("../../node_modules/.pnpm/webpack-sources@3.3.3_patch_hash=b2a26650f08a2359d0a3cd81fa6fa272aa7441a28dd7e601792da5ed5d2b4aee/node_modules/webpack-sources/lib/index.js");
|
|
@@ -67039,6 +67597,7 @@ const container = {
|
|
|
67039
67597
|
};
|
|
67040
67598
|
const sharing = {
|
|
67041
67599
|
ProvideSharedPlugin: ProvideSharedPlugin,
|
|
67600
|
+
TreeShakingSharedPlugin: TreeShakingSharedPlugin,
|
|
67042
67601
|
ConsumeSharedPlugin: ConsumeSharedPlugin,
|
|
67043
67602
|
SharePlugin: SharePlugin
|
|
67044
67603
|
};
|
|
@@ -67078,7 +67637,7 @@ const exports_experiments = {
|
|
|
67078
67637
|
createNativePlugin: createNativePlugin,
|
|
67079
67638
|
VirtualModulesPlugin: VirtualModulesPlugin
|
|
67080
67639
|
};
|
|
67081
|
-
const src_fn = Object.assign(
|
|
67640
|
+
const src_fn = Object.assign(rspack_rspack, exports_namespaceObject);
|
|
67082
67641
|
src_fn.rspack = src_fn;
|
|
67083
67642
|
src_fn.webpack = src_fn;
|
|
67084
67643
|
const src_rspack_0 = src_fn;
|