@rspack-canary/browser 1.7.3-canary-785c0f6f-20260114175124 → 1.7.3-canary-1138ed18-20260115124957
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/container/ModuleFederationManifestPlugin.d.ts +10 -3
- package/dist/container/ModuleFederationPlugin.d.ts +17 -1
- package/dist/exports.d.ts +3 -0
- package/dist/index.mjs +952 -342
- 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
|
@@ -56337,6 +56337,7 @@ const BuiltinLazyCompilationPlugin = base_create(external_rspack_wasi_browser_js
|
|
|
56337
56337
|
client,
|
|
56338
56338
|
currentActiveModules
|
|
56339
56339
|
}), 'thisCompilation');
|
|
56340
|
+
var middleware_Buffer = __webpack_require__("./src/browser/buffer.ts")["Buffer"];
|
|
56340
56341
|
const LAZY_COMPILATION_PREFIX = '/lazy-compilation-using-';
|
|
56341
56342
|
const getDefaultClient = (compiler)=>require.resolve(`../hot/lazy-compilation-${compiler.options.externalsPresets.node ? 'node' : 'web'}.js`);
|
|
56342
56343
|
const noop = (_req, _res, next)=>{
|
|
@@ -56399,15 +56400,62 @@ function applyPlugin(compiler, options, activeModules) {
|
|
|
56399
56400
|
}, options.entries ?? true, options.imports ?? true, `${options.client || getDefaultClient(compiler)}?${encodeURIComponent(getFullServerUrl(options))}`, options.test);
|
|
56400
56401
|
plugin.apply(compiler);
|
|
56401
56402
|
}
|
|
56403
|
+
function readModuleIdsFromBody(req) {
|
|
56404
|
+
if (void 0 !== req.body) {
|
|
56405
|
+
if (Array.isArray(req.body)) return Promise.resolve(req.body);
|
|
56406
|
+
if ('string' == typeof req.body) return Promise.resolve(req.body.split('\n').filter(Boolean));
|
|
56407
|
+
throw new Error('Invalid body type');
|
|
56408
|
+
}
|
|
56409
|
+
return new Promise((resolve, reject)=>{
|
|
56410
|
+
if (req.aborted || req.destroyed) return void reject(new Error('Request was aborted before body could be read'));
|
|
56411
|
+
const cleanup = ()=>{
|
|
56412
|
+
req.removeListener('data', onData);
|
|
56413
|
+
req.removeListener('end', onEnd);
|
|
56414
|
+
req.removeListener('error', onError);
|
|
56415
|
+
req.removeListener('close', onClose);
|
|
56416
|
+
req.removeListener('aborted', onAborted);
|
|
56417
|
+
};
|
|
56418
|
+
const chunks = [];
|
|
56419
|
+
const onData = (chunk)=>{
|
|
56420
|
+
chunks.push(chunk);
|
|
56421
|
+
};
|
|
56422
|
+
const onEnd = ()=>{
|
|
56423
|
+
cleanup();
|
|
56424
|
+
const body = middleware_Buffer.concat(chunks).toString('utf8');
|
|
56425
|
+
resolve(body.split('\n').filter(Boolean));
|
|
56426
|
+
};
|
|
56427
|
+
const onError = (err)=>{
|
|
56428
|
+
cleanup();
|
|
56429
|
+
reject(err);
|
|
56430
|
+
};
|
|
56431
|
+
const onClose = ()=>{
|
|
56432
|
+
cleanup();
|
|
56433
|
+
reject(new Error('Request was closed before body could be read'));
|
|
56434
|
+
};
|
|
56435
|
+
const onAborted = ()=>{
|
|
56436
|
+
cleanup();
|
|
56437
|
+
reject(new Error('Request was aborted before body could be read'));
|
|
56438
|
+
};
|
|
56439
|
+
req.on('data', onData);
|
|
56440
|
+
req.on('end', onEnd);
|
|
56441
|
+
req.on('error', onError);
|
|
56442
|
+
req.on('close', onClose);
|
|
56443
|
+
req.on('aborted', onAborted);
|
|
56444
|
+
});
|
|
56445
|
+
}
|
|
56402
56446
|
const lazyCompilationMiddlewareInternal = (compiler, activeModules, lazyCompilationPrefix)=>{
|
|
56403
56447
|
const logger = compiler.getInfrastructureLogger('LazyCompilation');
|
|
56404
|
-
return (req, res, next)=>{
|
|
56405
|
-
if (!req.url?.startsWith(lazyCompilationPrefix)) return next?.();
|
|
56406
|
-
|
|
56407
|
-
|
|
56408
|
-
|
|
56409
|
-
|
|
56410
|
-
|
|
56448
|
+
return async (req, res, next)=>{
|
|
56449
|
+
if (!req.url?.startsWith(lazyCompilationPrefix) || 'POST' !== req.method) return next?.();
|
|
56450
|
+
let modules = [];
|
|
56451
|
+
try {
|
|
56452
|
+
modules = await readModuleIdsFromBody(req);
|
|
56453
|
+
} catch (err) {
|
|
56454
|
+
logger.error('Failed to parse request body: ' + err);
|
|
56455
|
+
res.writeHead(400);
|
|
56456
|
+
res.end('Bad Request');
|
|
56457
|
+
return;
|
|
56458
|
+
}
|
|
56411
56459
|
const moduleActivated = [];
|
|
56412
56460
|
for (const key of modules){
|
|
56413
56461
|
const activated = activeModules.has(key);
|
|
@@ -56418,6 +56466,9 @@ const lazyCompilationMiddlewareInternal = (compiler, activeModules, lazyCompilat
|
|
|
56418
56466
|
}
|
|
56419
56467
|
}
|
|
56420
56468
|
if (moduleActivated.length && compiler.watching) compiler.watching.invalidate();
|
|
56469
|
+
res.writeHead(200);
|
|
56470
|
+
res.write('\n');
|
|
56471
|
+
res.end();
|
|
56421
56472
|
};
|
|
56422
56473
|
};
|
|
56423
56474
|
function MangleExportsPlugin_define_property(obj, key, value) {
|
|
@@ -58216,7 +58267,7 @@ const applybundlerInfoDefaults = (rspackFuture, library)=>{
|
|
|
58216
58267
|
if ('object' == typeof rspackFuture) {
|
|
58217
58268
|
D(rspackFuture, 'bundlerInfo', {});
|
|
58218
58269
|
if ('object' == typeof rspackFuture.bundlerInfo) {
|
|
58219
|
-
D(rspackFuture.bundlerInfo, 'version', "1.7.3-canary-
|
|
58270
|
+
D(rspackFuture.bundlerInfo, 'version', "1.7.3-canary-1138ed18-20260115124957");
|
|
58220
58271
|
D(rspackFuture.bundlerInfo, 'bundler', 'rspack');
|
|
58221
58272
|
D(rspackFuture.bundlerInfo, 'force', !library);
|
|
58222
58273
|
}
|
|
@@ -60486,7 +60537,7 @@ class MultiStats {
|
|
|
60486
60537
|
return obj;
|
|
60487
60538
|
});
|
|
60488
60539
|
if (childOptions.version) {
|
|
60489
|
-
obj.rspackVersion = "1.7.3-canary-
|
|
60540
|
+
obj.rspackVersion = "1.7.3-canary-1138ed18-20260115124957";
|
|
60490
60541
|
obj.version = "5.75.0";
|
|
60491
60542
|
}
|
|
60492
60543
|
if (childOptions.hash) obj.hash = obj.children.map((j)=>j.hash).join('');
|
|
@@ -60531,10 +60582,10 @@ class MultiStats {
|
|
|
60531
60582
|
this.stats = stats;
|
|
60532
60583
|
}
|
|
60533
60584
|
}
|
|
60534
|
-
function createChildOptions(options
|
|
60585
|
+
function createChildOptions(options, context) {
|
|
60535
60586
|
const { children: childrenOptions, ...baseOptions } = 'string' == typeof options || 'boolean' == typeof options ? {
|
|
60536
60587
|
preset: options
|
|
60537
|
-
} : options;
|
|
60588
|
+
} : options ?? {};
|
|
60538
60589
|
const children = this.stats.map((stat, idx)=>{
|
|
60539
60590
|
const childOptions = Array.isArray(childrenOptions) ? childrenOptions[idx] : childrenOptions;
|
|
60540
60591
|
return stat.compilation.createStatsOptions({
|
|
@@ -62318,7 +62369,7 @@ const SIMPLE_EXTRACTORS = {
|
|
|
62318
62369
|
},
|
|
62319
62370
|
version: (object)=>{
|
|
62320
62371
|
object.version = "5.75.0";
|
|
62321
|
-
object.rspackVersion = "1.7.3-canary-
|
|
62372
|
+
object.rspackVersion = "1.7.3-canary-1138ed18-20260115124957";
|
|
62322
62373
|
},
|
|
62323
62374
|
env: (object, _compilation, _context, { _env })=>{
|
|
62324
62375
|
object.env = _env;
|
|
@@ -64113,7 +64164,7 @@ function createCompiler(userOptions) {
|
|
|
64113
64164
|
function isMultiRspackOptions(o) {
|
|
64114
64165
|
return Array.isArray(o);
|
|
64115
64166
|
}
|
|
64116
|
-
function
|
|
64167
|
+
function rspack_rspack(options, callback) {
|
|
64117
64168
|
try {
|
|
64118
64169
|
if (isMultiRspackOptions(options)) for (const option of options)validateRspackConfig(option);
|
|
64119
64170
|
else validateRspackConfig(options);
|
|
@@ -65778,7 +65829,7 @@ class Compiler {
|
|
|
65778
65829
|
};
|
|
65779
65830
|
const compilerRuntimeGlobals = createCompilerRuntimeGlobals(options);
|
|
65780
65831
|
const compilerFn = function(...params) {
|
|
65781
|
-
return
|
|
65832
|
+
return rspack_rspack(...params);
|
|
65782
65833
|
};
|
|
65783
65834
|
const compilerRspack = Object.assign(compilerFn, exports_namespaceObject, {
|
|
65784
65835
|
RuntimeGlobals: compilerRuntimeGlobals
|
|
@@ -66280,10 +66331,266 @@ class NodeTemplatePlugin {
|
|
|
66280
66331
|
this._options = _options;
|
|
66281
66332
|
}
|
|
66282
66333
|
}
|
|
66334
|
+
const options_process = (options, normalizeSimple, normalizeOptions, fn)=>{
|
|
66335
|
+
const array = (items)=>{
|
|
66336
|
+
for (const item of items)if ('string' == typeof item) fn(item, normalizeSimple(item, item));
|
|
66337
|
+
else if (item && 'object' == typeof item) object(item);
|
|
66338
|
+
else throw new Error('Unexpected options format');
|
|
66339
|
+
};
|
|
66340
|
+
const object = (obj)=>{
|
|
66341
|
+
for (const [key, value] of Object.entries(obj))'string' == typeof value || Array.isArray(value) ? fn(key, normalizeSimple(value, key)) : fn(key, normalizeOptions(value, key));
|
|
66342
|
+
};
|
|
66343
|
+
if (!options) return;
|
|
66344
|
+
if (Array.isArray(options)) array(options);
|
|
66345
|
+
else if ('object' == typeof options) object(options);
|
|
66346
|
+
else throw new Error('Unexpected options format');
|
|
66347
|
+
};
|
|
66348
|
+
const parseOptions = (options, normalizeSimple, normalizeOptions)=>{
|
|
66349
|
+
const items = [];
|
|
66350
|
+
options_process(options, normalizeSimple, normalizeOptions, (key, value)=>{
|
|
66351
|
+
items.push([
|
|
66352
|
+
key,
|
|
66353
|
+
value
|
|
66354
|
+
]);
|
|
66355
|
+
});
|
|
66356
|
+
return items;
|
|
66357
|
+
};
|
|
66358
|
+
function ShareRuntimePlugin_define_property(obj, key, value) {
|
|
66359
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
66360
|
+
value: value,
|
|
66361
|
+
enumerable: true,
|
|
66362
|
+
configurable: true,
|
|
66363
|
+
writable: true
|
|
66364
|
+
});
|
|
66365
|
+
else obj[key] = value;
|
|
66366
|
+
return obj;
|
|
66367
|
+
}
|
|
66368
|
+
const compilerSet = new WeakSet();
|
|
66369
|
+
function isSingleton(compiler) {
|
|
66370
|
+
return compilerSet.has(compiler);
|
|
66371
|
+
}
|
|
66372
|
+
function setSingleton(compiler) {
|
|
66373
|
+
compilerSet.add(compiler);
|
|
66374
|
+
}
|
|
66375
|
+
class ShareRuntimePlugin extends RspackBuiltinPlugin {
|
|
66376
|
+
raw(compiler) {
|
|
66377
|
+
if (isSingleton(compiler)) return;
|
|
66378
|
+
setSingleton(compiler);
|
|
66379
|
+
return createBuiltinPlugin(this.name, this.enhanced);
|
|
66380
|
+
}
|
|
66381
|
+
constructor(enhanced = false){
|
|
66382
|
+
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;
|
|
66383
|
+
}
|
|
66384
|
+
}
|
|
66283
66385
|
const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
|
|
66284
66386
|
function isRequiredVersion(str) {
|
|
66285
66387
|
return VERSION_PATTERN_REGEXP.test(str);
|
|
66286
66388
|
}
|
|
66389
|
+
const encodeName = function(name, prefix = '', withExt = false) {
|
|
66390
|
+
const ext = withExt ? '.js' : '';
|
|
66391
|
+
return `${prefix}${name.replace(/@/g, 'scope_').replace(/-/g, '_').replace(/\//g, '__').replace(/\./g, '')}${ext}`;
|
|
66392
|
+
};
|
|
66393
|
+
function ConsumeSharedPlugin_define_property(obj, key, value) {
|
|
66394
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
66395
|
+
value: value,
|
|
66396
|
+
enumerable: true,
|
|
66397
|
+
configurable: true,
|
|
66398
|
+
writable: true
|
|
66399
|
+
});
|
|
66400
|
+
else obj[key] = value;
|
|
66401
|
+
return obj;
|
|
66402
|
+
}
|
|
66403
|
+
function normalizeConsumeShareOptions(consumes, shareScope) {
|
|
66404
|
+
return parseOptions(consumes, (item, key)=>{
|
|
66405
|
+
if (Array.isArray(item)) throw new Error('Unexpected array in options');
|
|
66406
|
+
const result = item !== key && isRequiredVersion(item) ? {
|
|
66407
|
+
import: key,
|
|
66408
|
+
shareScope: shareScope || 'default',
|
|
66409
|
+
shareKey: key,
|
|
66410
|
+
requiredVersion: item,
|
|
66411
|
+
strictVersion: true,
|
|
66412
|
+
packageName: void 0,
|
|
66413
|
+
singleton: false,
|
|
66414
|
+
eager: false,
|
|
66415
|
+
treeShakingMode: void 0
|
|
66416
|
+
} : {
|
|
66417
|
+
import: key,
|
|
66418
|
+
shareScope: shareScope || 'default',
|
|
66419
|
+
shareKey: key,
|
|
66420
|
+
requiredVersion: void 0,
|
|
66421
|
+
packageName: void 0,
|
|
66422
|
+
strictVersion: false,
|
|
66423
|
+
singleton: false,
|
|
66424
|
+
eager: false,
|
|
66425
|
+
treeShakingMode: void 0
|
|
66426
|
+
};
|
|
66427
|
+
return result;
|
|
66428
|
+
}, (item, key)=>({
|
|
66429
|
+
import: false === item.import ? void 0 : item.import || key,
|
|
66430
|
+
shareScope: item.shareScope || shareScope || 'default',
|
|
66431
|
+
shareKey: item.shareKey || key,
|
|
66432
|
+
requiredVersion: item.requiredVersion,
|
|
66433
|
+
strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : false !== item.import && !item.singleton,
|
|
66434
|
+
packageName: item.packageName,
|
|
66435
|
+
singleton: !!item.singleton,
|
|
66436
|
+
eager: !!item.eager,
|
|
66437
|
+
treeShakingMode: item.treeShakingMode
|
|
66438
|
+
}));
|
|
66439
|
+
}
|
|
66440
|
+
class ConsumeSharedPlugin extends RspackBuiltinPlugin {
|
|
66441
|
+
raw(compiler) {
|
|
66442
|
+
new ShareRuntimePlugin(this._options.enhanced).apply(compiler);
|
|
66443
|
+
const rawOptions = {
|
|
66444
|
+
consumes: this._options.consumes.map(([key, v])=>({
|
|
66445
|
+
key,
|
|
66446
|
+
...v
|
|
66447
|
+
})),
|
|
66448
|
+
enhanced: this._options.enhanced
|
|
66449
|
+
};
|
|
66450
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
66451
|
+
}
|
|
66452
|
+
constructor(options){
|
|
66453
|
+
super(), ConsumeSharedPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ConsumeSharedPlugin), ConsumeSharedPlugin_define_property(this, "_options", void 0);
|
|
66454
|
+
this._options = {
|
|
66455
|
+
consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
|
|
66456
|
+
enhanced: options.enhanced ?? false
|
|
66457
|
+
};
|
|
66458
|
+
}
|
|
66459
|
+
}
|
|
66460
|
+
function ProvideSharedPlugin_define_property(obj, key, value) {
|
|
66461
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
66462
|
+
value: value,
|
|
66463
|
+
enumerable: true,
|
|
66464
|
+
configurable: true,
|
|
66465
|
+
writable: true
|
|
66466
|
+
});
|
|
66467
|
+
else obj[key] = value;
|
|
66468
|
+
return obj;
|
|
66469
|
+
}
|
|
66470
|
+
function normalizeProvideShareOptions(options, shareScope, enhanced) {
|
|
66471
|
+
return parseOptions(options, (item)=>{
|
|
66472
|
+
if (Array.isArray(item)) throw new Error('Unexpected array of provides');
|
|
66473
|
+
return {
|
|
66474
|
+
shareKey: item,
|
|
66475
|
+
version: void 0,
|
|
66476
|
+
shareScope: shareScope || 'default',
|
|
66477
|
+
eager: false
|
|
66478
|
+
};
|
|
66479
|
+
}, (item)=>{
|
|
66480
|
+
const raw = {
|
|
66481
|
+
shareKey: item.shareKey,
|
|
66482
|
+
version: item.version,
|
|
66483
|
+
shareScope: item.shareScope || shareScope || 'default',
|
|
66484
|
+
eager: !!item.eager
|
|
66485
|
+
};
|
|
66486
|
+
if (enhanced) {
|
|
66487
|
+
const enhancedItem = item;
|
|
66488
|
+
return {
|
|
66489
|
+
...raw,
|
|
66490
|
+
singleton: enhancedItem.singleton,
|
|
66491
|
+
requiredVersion: enhancedItem.requiredVersion,
|
|
66492
|
+
strictVersion: enhancedItem.strictVersion,
|
|
66493
|
+
treeShakingMode: enhancedItem.treeShakingMode
|
|
66494
|
+
};
|
|
66495
|
+
}
|
|
66496
|
+
return raw;
|
|
66497
|
+
});
|
|
66498
|
+
}
|
|
66499
|
+
class ProvideSharedPlugin extends RspackBuiltinPlugin {
|
|
66500
|
+
raw(compiler) {
|
|
66501
|
+
new ShareRuntimePlugin(this._enhanced ?? false).apply(compiler);
|
|
66502
|
+
const rawOptions = this._provides.map(([key, v])=>({
|
|
66503
|
+
key,
|
|
66504
|
+
...v
|
|
66505
|
+
}));
|
|
66506
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
66507
|
+
}
|
|
66508
|
+
constructor(options){
|
|
66509
|
+
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);
|
|
66510
|
+
this._provides = normalizeProvideShareOptions(options.provides, options.shareScope, options.enhanced);
|
|
66511
|
+
this._enhanced = options.enhanced;
|
|
66512
|
+
}
|
|
66513
|
+
}
|
|
66514
|
+
function SharePlugin_define_property(obj, key, value) {
|
|
66515
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
66516
|
+
value: value,
|
|
66517
|
+
enumerable: true,
|
|
66518
|
+
configurable: true,
|
|
66519
|
+
writable: true
|
|
66520
|
+
});
|
|
66521
|
+
else obj[key] = value;
|
|
66522
|
+
return obj;
|
|
66523
|
+
}
|
|
66524
|
+
function normalizeSharedOptions(shared) {
|
|
66525
|
+
return parseOptions(shared, (item, key)=>{
|
|
66526
|
+
if ('string' != typeof item) throw new Error('Unexpected array in shared');
|
|
66527
|
+
const config = item !== key && isRequiredVersion(item) ? {
|
|
66528
|
+
import: key,
|
|
66529
|
+
requiredVersion: item
|
|
66530
|
+
} : {
|
|
66531
|
+
import: item
|
|
66532
|
+
};
|
|
66533
|
+
return config;
|
|
66534
|
+
}, (item)=>item);
|
|
66535
|
+
}
|
|
66536
|
+
function createProvideShareOptions(normalizedSharedOptions) {
|
|
66537
|
+
return normalizedSharedOptions.filter(([, options])=>false !== options.import).map(([key, options])=>({
|
|
66538
|
+
[options.import || key]: {
|
|
66539
|
+
shareKey: options.shareKey || key,
|
|
66540
|
+
shareScope: options.shareScope,
|
|
66541
|
+
version: options.version,
|
|
66542
|
+
eager: options.eager,
|
|
66543
|
+
singleton: options.singleton,
|
|
66544
|
+
requiredVersion: options.requiredVersion,
|
|
66545
|
+
strictVersion: options.strictVersion,
|
|
66546
|
+
treeShakingMode: options.treeShaking?.mode
|
|
66547
|
+
}
|
|
66548
|
+
}));
|
|
66549
|
+
}
|
|
66550
|
+
function createConsumeShareOptions(normalizedSharedOptions) {
|
|
66551
|
+
return normalizedSharedOptions.map(([key, options])=>({
|
|
66552
|
+
[key]: {
|
|
66553
|
+
import: options.import,
|
|
66554
|
+
shareKey: options.shareKey || key,
|
|
66555
|
+
shareScope: options.shareScope,
|
|
66556
|
+
requiredVersion: options.requiredVersion,
|
|
66557
|
+
strictVersion: options.strictVersion,
|
|
66558
|
+
singleton: options.singleton,
|
|
66559
|
+
packageName: options.packageName,
|
|
66560
|
+
eager: options.eager,
|
|
66561
|
+
treeShakingMode: options.treeShaking?.mode
|
|
66562
|
+
}
|
|
66563
|
+
}));
|
|
66564
|
+
}
|
|
66565
|
+
class SharePlugin {
|
|
66566
|
+
apply(compiler) {
|
|
66567
|
+
new ConsumeSharedPlugin({
|
|
66568
|
+
shareScope: this._shareScope,
|
|
66569
|
+
consumes: this._consumes,
|
|
66570
|
+
enhanced: this._enhanced
|
|
66571
|
+
}).apply(compiler);
|
|
66572
|
+
new ProvideSharedPlugin({
|
|
66573
|
+
shareScope: this._shareScope,
|
|
66574
|
+
provides: this._provides,
|
|
66575
|
+
enhanced: this._enhanced
|
|
66576
|
+
}).apply(compiler);
|
|
66577
|
+
}
|
|
66578
|
+
constructor(options){
|
|
66579
|
+
SharePlugin_define_property(this, "_shareScope", void 0);
|
|
66580
|
+
SharePlugin_define_property(this, "_consumes", void 0);
|
|
66581
|
+
SharePlugin_define_property(this, "_provides", void 0);
|
|
66582
|
+
SharePlugin_define_property(this, "_enhanced", void 0);
|
|
66583
|
+
SharePlugin_define_property(this, "_sharedOptions", void 0);
|
|
66584
|
+
const sharedOptions = normalizeSharedOptions(options.shared);
|
|
66585
|
+
const consumes = createConsumeShareOptions(sharedOptions);
|
|
66586
|
+
const provides = createProvideShareOptions(sharedOptions);
|
|
66587
|
+
this._shareScope = options.shareScope;
|
|
66588
|
+
this._consumes = consumes;
|
|
66589
|
+
this._provides = provides;
|
|
66590
|
+
this._enhanced = options.enhanced ?? false;
|
|
66591
|
+
this._sharedOptions = sharedOptions;
|
|
66592
|
+
}
|
|
66593
|
+
}
|
|
66287
66594
|
var ModuleFederationManifestPlugin_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
|
|
66288
66595
|
function ModuleFederationManifestPlugin_define_property(obj, key, value) {
|
|
66289
66596
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
@@ -66322,17 +66629,29 @@ function readPKGJson(root) {
|
|
|
66322
66629
|
} catch {}
|
|
66323
66630
|
return {};
|
|
66324
66631
|
}
|
|
66325
|
-
function getBuildInfo(isDev,
|
|
66326
|
-
const rootPath =
|
|
66632
|
+
function getBuildInfo(isDev, compiler, mfConfig) {
|
|
66633
|
+
const rootPath = compiler.options.context || ModuleFederationManifestPlugin_process.cwd();
|
|
66327
66634
|
const pkg = readPKGJson(rootPath);
|
|
66328
66635
|
const buildVersion = isDev ? LOCAL_BUILD_VERSION : pkg?.version;
|
|
66329
|
-
|
|
66636
|
+
const statsBuildInfo = {
|
|
66330
66637
|
buildVersion: ModuleFederationManifestPlugin_process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
|
|
66331
66638
|
buildName: ModuleFederationManifestPlugin_process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
|
|
66332
66639
|
};
|
|
66640
|
+
const normalizedShared = normalizeSharedOptions(mfConfig.shared || {});
|
|
66641
|
+
const enableTreeShaking = Object.values(normalizedShared).some((config)=>config[1].treeShaking);
|
|
66642
|
+
if (enableTreeShaking) {
|
|
66643
|
+
statsBuildInfo.target = Array.isArray(compiler.options.target) ? compiler.options.target : [];
|
|
66644
|
+
statsBuildInfo.plugins = mfConfig.treeShakingSharedPlugins || [];
|
|
66645
|
+
statsBuildInfo.excludePlugins = mfConfig.treeShakingSharedExcludePlugins || [];
|
|
66646
|
+
}
|
|
66647
|
+
return statsBuildInfo;
|
|
66333
66648
|
}
|
|
66334
66649
|
function getFileName(manifestOptions) {
|
|
66335
66650
|
if (!manifestOptions) return {
|
|
66651
|
+
statsFileName: '',
|
|
66652
|
+
manifestFileName: ''
|
|
66653
|
+
};
|
|
66654
|
+
if ('boolean' == typeof manifestOptions) return {
|
|
66336
66655
|
statsFileName: STATS_FILE_NAME,
|
|
66337
66656
|
manifestFileName: MANIFEST_FILE_NAME
|
|
66338
66657
|
};
|
|
@@ -66350,13 +66669,95 @@ function getFileName(manifestOptions) {
|
|
|
66350
66669
|
manifestFileName: (0, path_browserify.join)(filePath, manifestFileName)
|
|
66351
66670
|
};
|
|
66352
66671
|
}
|
|
66672
|
+
function resolveLibraryGlobalName(library) {
|
|
66673
|
+
if (!library) return;
|
|
66674
|
+
const libName = library.name;
|
|
66675
|
+
if (!libName) return;
|
|
66676
|
+
if ('string' == typeof libName) return libName;
|
|
66677
|
+
if (Array.isArray(libName)) return libName[0];
|
|
66678
|
+
if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
|
|
66679
|
+
}
|
|
66680
|
+
function collectManifestExposes(exposes) {
|
|
66681
|
+
if (!exposes) return;
|
|
66682
|
+
const parsed = parseOptions(exposes, (value)=>({
|
|
66683
|
+
import: Array.isArray(value) ? value : [
|
|
66684
|
+
value
|
|
66685
|
+
],
|
|
66686
|
+
name: void 0
|
|
66687
|
+
}), (value)=>({
|
|
66688
|
+
import: Array.isArray(value.import) ? value.import : [
|
|
66689
|
+
value.import
|
|
66690
|
+
],
|
|
66691
|
+
name: value.name ?? void 0
|
|
66692
|
+
}));
|
|
66693
|
+
const result = parsed.map(([exposeKey, info])=>{
|
|
66694
|
+
const exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
|
|
66695
|
+
return {
|
|
66696
|
+
path: exposeKey,
|
|
66697
|
+
name: exposeName
|
|
66698
|
+
};
|
|
66699
|
+
});
|
|
66700
|
+
return result.length > 0 ? result : void 0;
|
|
66701
|
+
}
|
|
66702
|
+
function collectManifestShared(shared) {
|
|
66703
|
+
if (!shared) return;
|
|
66704
|
+
const parsed = parseOptions(shared, (item, key)=>{
|
|
66705
|
+
if ('string' != typeof item) throw new Error('Unexpected array in shared');
|
|
66706
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
66707
|
+
import: key,
|
|
66708
|
+
requiredVersion: item
|
|
66709
|
+
} : {
|
|
66710
|
+
import: item
|
|
66711
|
+
};
|
|
66712
|
+
}, (item)=>item);
|
|
66713
|
+
const result = parsed.map(([key, config])=>{
|
|
66714
|
+
const name = config.shareKey || key;
|
|
66715
|
+
const version = 'string' == typeof config.version ? config.version : void 0;
|
|
66716
|
+
const requiredVersion = 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0;
|
|
66717
|
+
return {
|
|
66718
|
+
name,
|
|
66719
|
+
version,
|
|
66720
|
+
requiredVersion,
|
|
66721
|
+
singleton: config.singleton
|
|
66722
|
+
};
|
|
66723
|
+
});
|
|
66724
|
+
return result.length > 0 ? result : void 0;
|
|
66725
|
+
}
|
|
66726
|
+
function normalizeManifestOptions(mfConfig) {
|
|
66727
|
+
const manifestOptions = true === mfConfig.manifest ? {} : {
|
|
66728
|
+
...mfConfig.manifest
|
|
66729
|
+
};
|
|
66730
|
+
const containerName = mfConfig.name;
|
|
66731
|
+
const globalName = resolveLibraryGlobalName(mfConfig.library) ?? containerName;
|
|
66732
|
+
const remoteAliasMap = Object.entries(getRemoteInfos(mfConfig)).reduce((sum, cur)=>{
|
|
66733
|
+
if (cur[1].length > 1) return sum;
|
|
66734
|
+
const remoteInfo = cur[1][0];
|
|
66735
|
+
const { entry, alias, name } = remoteInfo;
|
|
66736
|
+
if (entry && name) sum[alias] = {
|
|
66737
|
+
name,
|
|
66738
|
+
entry
|
|
66739
|
+
};
|
|
66740
|
+
return sum;
|
|
66741
|
+
}, {});
|
|
66742
|
+
const manifestExposes = collectManifestExposes(mfConfig.exposes);
|
|
66743
|
+
if (void 0 === manifestOptions.exposes && manifestExposes) manifestOptions.exposes = manifestExposes;
|
|
66744
|
+
const manifestShared = collectManifestShared(mfConfig.shared);
|
|
66745
|
+
if (void 0 === manifestOptions.shared && manifestShared) manifestOptions.shared = manifestShared;
|
|
66746
|
+
return {
|
|
66747
|
+
...manifestOptions,
|
|
66748
|
+
remoteAliasMap,
|
|
66749
|
+
globalName,
|
|
66750
|
+
name: containerName
|
|
66751
|
+
};
|
|
66752
|
+
}
|
|
66353
66753
|
class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
66354
66754
|
raw(compiler) {
|
|
66355
|
-
const
|
|
66356
|
-
const {
|
|
66755
|
+
const opts = normalizeManifestOptions(this.rawOpts);
|
|
66756
|
+
const { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = opts;
|
|
66757
|
+
const { statsFileName, manifestFileName } = getFileName(opts);
|
|
66357
66758
|
const rawOptions = {
|
|
66358
|
-
name:
|
|
66359
|
-
globalName:
|
|
66759
|
+
name: opts.name,
|
|
66760
|
+
globalName: opts.globalName,
|
|
66360
66761
|
fileName,
|
|
66361
66762
|
filePath,
|
|
66362
66763
|
manifestFileName,
|
|
@@ -66365,40 +66766,489 @@ class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
|
|
|
66365
66766
|
remoteAliasMap,
|
|
66366
66767
|
exposes,
|
|
66367
66768
|
shared,
|
|
66368
|
-
buildInfo: getBuildInfo('development' === compiler.options.mode, compiler.
|
|
66769
|
+
buildInfo: getBuildInfo('development' === compiler.options.mode, compiler, this.rawOpts)
|
|
66369
66770
|
};
|
|
66370
66771
|
return createBuiltinPlugin(this.name, rawOptions);
|
|
66371
66772
|
}
|
|
66372
66773
|
constructor(opts){
|
|
66373
|
-
super(), ModuleFederationManifestPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationManifestPlugin), ModuleFederationManifestPlugin_define_property(this, "
|
|
66374
|
-
this.
|
|
66774
|
+
super(), ModuleFederationManifestPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationManifestPlugin), ModuleFederationManifestPlugin_define_property(this, "rawOpts", void 0);
|
|
66775
|
+
this.rawOpts = opts;
|
|
66375
66776
|
}
|
|
66376
66777
|
}
|
|
66377
|
-
|
|
66378
|
-
|
|
66379
|
-
|
|
66380
|
-
|
|
66381
|
-
|
|
66382
|
-
|
|
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
|
-
]);
|
|
66778
|
+
function CollectSharedEntryPlugin_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
|
|
66399
66784
|
});
|
|
66400
|
-
|
|
66785
|
+
else obj[key] = value;
|
|
66786
|
+
return obj;
|
|
66787
|
+
}
|
|
66788
|
+
const SHARE_ENTRY_ASSET = 'collect-shared-entries.json';
|
|
66789
|
+
class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
|
|
66790
|
+
getData() {
|
|
66791
|
+
return this._collectedEntries;
|
|
66792
|
+
}
|
|
66793
|
+
getFilename() {
|
|
66794
|
+
return SHARE_ENTRY_ASSET;
|
|
66795
|
+
}
|
|
66796
|
+
apply(compiler) {
|
|
66797
|
+
super.apply(compiler);
|
|
66798
|
+
compiler.hooks.thisCompilation.tap('Collect shared entry', (compilation)=>{
|
|
66799
|
+
compilation.hooks.processAssets.tap({
|
|
66800
|
+
name: 'CollectSharedEntry',
|
|
66801
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
|
|
66802
|
+
}, ()=>{
|
|
66803
|
+
compilation.getAssets().forEach((asset)=>{
|
|
66804
|
+
if (asset.name === SHARE_ENTRY_ASSET) this._collectedEntries = JSON.parse(asset.source.source().toString());
|
|
66805
|
+
compilation.deleteAsset(asset.name);
|
|
66806
|
+
});
|
|
66807
|
+
});
|
|
66808
|
+
});
|
|
66809
|
+
}
|
|
66810
|
+
raw() {
|
|
66811
|
+
const consumeShareOptions = createConsumeShareOptions(this.sharedOptions);
|
|
66812
|
+
const normalizedConsumeShareOptions = normalizeConsumeShareOptions(consumeShareOptions);
|
|
66813
|
+
const rawOptions = {
|
|
66814
|
+
consumes: normalizedConsumeShareOptions.map(([key, v])=>({
|
|
66815
|
+
key,
|
|
66816
|
+
...v
|
|
66817
|
+
})),
|
|
66818
|
+
filename: this.getFilename()
|
|
66819
|
+
};
|
|
66820
|
+
return createBuiltinPlugin(this.name, rawOptions);
|
|
66821
|
+
}
|
|
66822
|
+
constructor(options){
|
|
66823
|
+
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);
|
|
66824
|
+
const { sharedOptions } = options;
|
|
66825
|
+
this.sharedOptions = sharedOptions;
|
|
66826
|
+
this._collectedEntries = {};
|
|
66827
|
+
}
|
|
66828
|
+
}
|
|
66829
|
+
function SharedContainerPlugin_define_property(obj, key, value) {
|
|
66830
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
66831
|
+
value: value,
|
|
66832
|
+
enumerable: true,
|
|
66833
|
+
configurable: true,
|
|
66834
|
+
writable: true
|
|
66835
|
+
});
|
|
66836
|
+
else obj[key] = value;
|
|
66837
|
+
return obj;
|
|
66838
|
+
}
|
|
66839
|
+
function assert(condition, msg) {
|
|
66840
|
+
if (!condition) throw new Error(msg);
|
|
66841
|
+
}
|
|
66842
|
+
const HOT_UPDATE_SUFFIX = '.hot-update';
|
|
66843
|
+
class SharedContainerPlugin extends RspackBuiltinPlugin {
|
|
66844
|
+
getData() {
|
|
66845
|
+
return [
|
|
66846
|
+
this._options.fileName,
|
|
66847
|
+
this._globalName,
|
|
66848
|
+
this._options.version
|
|
66849
|
+
];
|
|
66850
|
+
}
|
|
66851
|
+
raw(compiler) {
|
|
66852
|
+
const { library } = this._options;
|
|
66853
|
+
if (!compiler.options.output.enabledLibraryTypes.includes(library.type)) compiler.options.output.enabledLibraryTypes.push(library.type);
|
|
66854
|
+
return createBuiltinPlugin(this.name, this._options);
|
|
66855
|
+
}
|
|
66856
|
+
apply(compiler) {
|
|
66857
|
+
super.apply(compiler);
|
|
66858
|
+
const shareName = this._shareName;
|
|
66859
|
+
compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
|
|
66860
|
+
compilation.hooks.processAssets.tap({
|
|
66861
|
+
name: 'getShareContainerFile'
|
|
66862
|
+
}, ()=>{
|
|
66863
|
+
const remoteEntryPoint = compilation.entrypoints.get(shareName);
|
|
66864
|
+
assert(remoteEntryPoint, `Can not get shared ${shareName} entryPoint!`);
|
|
66865
|
+
const remoteEntryNameChunk = compilation.namedChunks.get(shareName);
|
|
66866
|
+
assert(remoteEntryNameChunk, `Can not get shared ${shareName} chunk!`);
|
|
66867
|
+
const files = Array.from(remoteEntryNameChunk.files).filter((f)=>!f.includes(HOT_UPDATE_SUFFIX) && !f.endsWith('.css'));
|
|
66868
|
+
assert(files.length > 0, `no files found for shared ${shareName} chunk`);
|
|
66869
|
+
assert(1 === files.length, `shared ${shareName} chunk should not have multiple files!, current files: ${files.join(',')}`);
|
|
66870
|
+
this.filename = files[0];
|
|
66871
|
+
});
|
|
66872
|
+
});
|
|
66873
|
+
}
|
|
66874
|
+
constructor(options){
|
|
66875
|
+
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);
|
|
66876
|
+
const { shareName, library, request, independentShareFileName, mfName } = options;
|
|
66877
|
+
const version = options.version || '0.0.0';
|
|
66878
|
+
this._globalName = encodeName(`${mfName}_${shareName}_${version}`);
|
|
66879
|
+
const fileName = independentShareFileName || `${version}/share-entry.js`;
|
|
66880
|
+
this._shareName = shareName;
|
|
66881
|
+
this._options = {
|
|
66882
|
+
name: shareName,
|
|
66883
|
+
request: request,
|
|
66884
|
+
library: (library ? {
|
|
66885
|
+
...library,
|
|
66886
|
+
name: this._globalName
|
|
66887
|
+
} : void 0) || {
|
|
66888
|
+
type: 'global',
|
|
66889
|
+
name: this._globalName
|
|
66890
|
+
},
|
|
66891
|
+
version,
|
|
66892
|
+
fileName
|
|
66893
|
+
};
|
|
66894
|
+
}
|
|
66895
|
+
}
|
|
66896
|
+
function SharedUsedExportsOptimizerPlugin_define_property(obj, key, value) {
|
|
66897
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
66898
|
+
value: value,
|
|
66899
|
+
enumerable: true,
|
|
66900
|
+
configurable: true,
|
|
66901
|
+
writable: true
|
|
66902
|
+
});
|
|
66903
|
+
else obj[key] = value;
|
|
66904
|
+
return obj;
|
|
66905
|
+
}
|
|
66906
|
+
class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
|
|
66907
|
+
buildOptions() {
|
|
66908
|
+
const shared = this.sharedOptions.map(([shareKey, config])=>({
|
|
66909
|
+
shareKey,
|
|
66910
|
+
treeShaking: !!config.treeShaking,
|
|
66911
|
+
usedExports: config.treeShaking?.usedExports
|
|
66912
|
+
}));
|
|
66913
|
+
const { manifestFileName, statsFileName } = getFileName(this.manifestOptions);
|
|
66914
|
+
return {
|
|
66915
|
+
shared,
|
|
66916
|
+
injectTreeShakingUsedExports: this.injectTreeShakingUsedExports,
|
|
66917
|
+
manifestFileName,
|
|
66918
|
+
statsFileName
|
|
66919
|
+
};
|
|
66920
|
+
}
|
|
66921
|
+
raw() {
|
|
66922
|
+
if (!this.sharedOptions.length) return;
|
|
66923
|
+
return createBuiltinPlugin(this.name, this.buildOptions());
|
|
66924
|
+
}
|
|
66925
|
+
constructor(sharedOptions, injectTreeShakingUsedExports, manifestOptions){
|
|
66926
|
+
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);
|
|
66927
|
+
this.sharedOptions = sharedOptions;
|
|
66928
|
+
this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? true;
|
|
66929
|
+
this.manifestOptions = manifestOptions ?? {};
|
|
66930
|
+
}
|
|
66931
|
+
}
|
|
66932
|
+
function IndependentSharedPlugin_define_property(obj, key, value) {
|
|
66933
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
66934
|
+
value: value,
|
|
66935
|
+
enumerable: true,
|
|
66936
|
+
configurable: true,
|
|
66937
|
+
writable: true
|
|
66938
|
+
});
|
|
66939
|
+
else obj[key] = value;
|
|
66940
|
+
return obj;
|
|
66941
|
+
}
|
|
66942
|
+
const VIRTUAL_ENTRY = './virtual-entry.js';
|
|
66943
|
+
const VIRTUAL_ENTRY_NAME = 'virtual-entry';
|
|
66944
|
+
const filterPlugin = (plugin, excludedPlugins = [])=>{
|
|
66945
|
+
if (!plugin) return true;
|
|
66946
|
+
const pluginName = plugin.name || plugin.constructor?.name;
|
|
66947
|
+
if (!pluginName) return true;
|
|
66948
|
+
return ![
|
|
66949
|
+
'TreeShakingSharedPlugin',
|
|
66950
|
+
'IndependentSharedPlugin',
|
|
66951
|
+
'ModuleFederationPlugin',
|
|
66952
|
+
'SharedUsedExportsOptimizerPlugin',
|
|
66953
|
+
'HtmlWebpackPlugin',
|
|
66954
|
+
'HtmlRspackPlugin',
|
|
66955
|
+
'RsbuildHtmlPlugin',
|
|
66956
|
+
...excludedPlugins
|
|
66957
|
+
].includes(pluginName);
|
|
66401
66958
|
};
|
|
66959
|
+
class VirtualEntryPlugin {
|
|
66960
|
+
createEntry() {
|
|
66961
|
+
const { sharedOptions, collectShared } = this;
|
|
66962
|
+
const entryContent = sharedOptions.reduce((acc, cur, index)=>{
|
|
66963
|
+
const importLine = `import shared_${index} from '${cur[0]}';\n`;
|
|
66964
|
+
const logLine = collectShared ? `console.log(shared_${index});\n` : '';
|
|
66965
|
+
return acc + importLine + logLine;
|
|
66966
|
+
}, '');
|
|
66967
|
+
return entryContent;
|
|
66968
|
+
}
|
|
66969
|
+
static entry() {
|
|
66970
|
+
return {
|
|
66971
|
+
[VIRTUAL_ENTRY_NAME]: VIRTUAL_ENTRY
|
|
66972
|
+
};
|
|
66973
|
+
}
|
|
66974
|
+
apply(compiler) {
|
|
66975
|
+
new compiler.rspack.experiments.VirtualModulesPlugin({
|
|
66976
|
+
[VIRTUAL_ENTRY]: this.createEntry()
|
|
66977
|
+
}).apply(compiler);
|
|
66978
|
+
compiler.hooks.thisCompilation.tap('RemoveVirtualEntryAsset', (compilation)=>{
|
|
66979
|
+
compilation.hooks.processAssets.tap({
|
|
66980
|
+
name: 'RemoveVirtualEntryAsset',
|
|
66981
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
|
|
66982
|
+
}, ()=>{
|
|
66983
|
+
try {
|
|
66984
|
+
const chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
|
|
66985
|
+
chunk?.files.forEach((f)=>{
|
|
66986
|
+
compilation.deleteAsset(f);
|
|
66987
|
+
});
|
|
66988
|
+
} catch (_e) {
|
|
66989
|
+
console.error('Failed to remove virtual entry file!');
|
|
66990
|
+
}
|
|
66991
|
+
});
|
|
66992
|
+
});
|
|
66993
|
+
}
|
|
66994
|
+
constructor(sharedOptions, collectShared){
|
|
66995
|
+
IndependentSharedPlugin_define_property(this, "sharedOptions", void 0);
|
|
66996
|
+
IndependentSharedPlugin_define_property(this, "collectShared", false);
|
|
66997
|
+
this.sharedOptions = sharedOptions;
|
|
66998
|
+
this.collectShared = collectShared;
|
|
66999
|
+
}
|
|
67000
|
+
}
|
|
67001
|
+
const resolveOutputDir = (outputDir, shareName)=>shareName ? (0, path_browserify.join)(outputDir, encodeName(shareName)) : outputDir;
|
|
67002
|
+
class IndependentSharedPlugin {
|
|
67003
|
+
apply(compiler) {
|
|
67004
|
+
const { manifest } = this;
|
|
67005
|
+
let runCount = 0;
|
|
67006
|
+
compiler.hooks.beforeRun.tapPromise('IndependentSharedPlugin', async ()=>{
|
|
67007
|
+
if (runCount) return;
|
|
67008
|
+
await this.createIndependentCompilers(compiler);
|
|
67009
|
+
runCount++;
|
|
67010
|
+
});
|
|
67011
|
+
compiler.hooks.watchRun.tapPromise('IndependentSharedPlugin', async ()=>{
|
|
67012
|
+
if (runCount) return;
|
|
67013
|
+
await this.createIndependentCompilers(compiler);
|
|
67014
|
+
runCount++;
|
|
67015
|
+
});
|
|
67016
|
+
compiler.hooks.shutdown.tapAsync('IndependentSharedPlugin', (callback)=>{
|
|
67017
|
+
callback();
|
|
67018
|
+
});
|
|
67019
|
+
if (manifest) compiler.hooks.compilation.tap('IndependentSharedPlugin', (compilation)=>{
|
|
67020
|
+
compilation.hooks.processAssets.tap({
|
|
67021
|
+
name: 'injectBuildAssets',
|
|
67022
|
+
stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
|
|
67023
|
+
}, ()=>{
|
|
67024
|
+
const { statsFileName, manifestFileName } = getFileName(manifest);
|
|
67025
|
+
const injectBuildAssetsIntoStatsOrManifest = (filename)=>{
|
|
67026
|
+
const stats = compilation.getAsset(filename);
|
|
67027
|
+
if (!stats) return;
|
|
67028
|
+
const statsContent = JSON.parse(stats.source.source().toString());
|
|
67029
|
+
const { shared } = statsContent;
|
|
67030
|
+
Object.entries(this.buildAssets).forEach(([key, item])=>{
|
|
67031
|
+
const targetShared = shared.find((s)=>s.name === key);
|
|
67032
|
+
if (!targetShared) return;
|
|
67033
|
+
item.forEach(([entry, version, globalName])=>{
|
|
67034
|
+
if (version === targetShared.version) {
|
|
67035
|
+
targetShared.fallback = entry;
|
|
67036
|
+
targetShared.fallbackName = globalName;
|
|
67037
|
+
}
|
|
67038
|
+
});
|
|
67039
|
+
});
|
|
67040
|
+
compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
|
|
67041
|
+
};
|
|
67042
|
+
injectBuildAssetsIntoStatsOrManifest(statsFileName);
|
|
67043
|
+
injectBuildAssetsIntoStatsOrManifest(manifestFileName);
|
|
67044
|
+
});
|
|
67045
|
+
});
|
|
67046
|
+
}
|
|
67047
|
+
async createIndependentCompilers(parentCompiler) {
|
|
67048
|
+
const { sharedOptions, buildAssets, outputDir } = this;
|
|
67049
|
+
console.log('Start building shared fallback resources ...');
|
|
67050
|
+
const shareRequestsMap = await this.createIndependentCompiler(parentCompiler);
|
|
67051
|
+
await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
|
|
67052
|
+
if (!shareConfig.treeShaking || false === shareConfig.import) return;
|
|
67053
|
+
const shareRequests = shareRequestsMap[shareName].requests;
|
|
67054
|
+
await Promise.all(shareRequests.map(async ([request, version])=>{
|
|
67055
|
+
const sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1];
|
|
67056
|
+
const [shareFileName, globalName, sharedVersion] = await this.createIndependentCompiler(parentCompiler, {
|
|
67057
|
+
shareRequestsMap,
|
|
67058
|
+
currentShare: {
|
|
67059
|
+
shareName,
|
|
67060
|
+
version,
|
|
67061
|
+
request,
|
|
67062
|
+
independentShareFileName: sharedConfig?.treeShaking?.filename
|
|
67063
|
+
}
|
|
67064
|
+
});
|
|
67065
|
+
if ('string' == typeof shareFileName) {
|
|
67066
|
+
buildAssets[shareName] ||= [];
|
|
67067
|
+
buildAssets[shareName].push([
|
|
67068
|
+
(0, path_browserify.join)(resolveOutputDir(outputDir, shareName), shareFileName),
|
|
67069
|
+
sharedVersion,
|
|
67070
|
+
globalName
|
|
67071
|
+
]);
|
|
67072
|
+
}
|
|
67073
|
+
}));
|
|
67074
|
+
}));
|
|
67075
|
+
console.log('All shared fallback have been compiled successfully!');
|
|
67076
|
+
}
|
|
67077
|
+
async createIndependentCompiler(parentCompiler, extraOptions) {
|
|
67078
|
+
const { mfName, plugins, outputDir, sharedOptions, treeShaking, library, treeShakingSharedExcludePlugins } = this;
|
|
67079
|
+
const outputDirWithShareName = resolveOutputDir(outputDir, extraOptions?.currentShare?.shareName || '');
|
|
67080
|
+
const parentConfig = parentCompiler.options;
|
|
67081
|
+
const finalPlugins = [];
|
|
67082
|
+
const rspack = parentCompiler.rspack;
|
|
67083
|
+
let extraPlugin;
|
|
67084
|
+
extraPlugin = extraOptions ? new SharedContainerPlugin({
|
|
67085
|
+
mfName,
|
|
67086
|
+
library,
|
|
67087
|
+
...extraOptions.currentShare
|
|
67088
|
+
}) : new CollectSharedEntryPlugin({
|
|
67089
|
+
sharedOptions,
|
|
67090
|
+
shareScope: 'default'
|
|
67091
|
+
});
|
|
67092
|
+
(parentConfig.plugins || []).forEach((plugin)=>{
|
|
67093
|
+
if (void 0 !== plugin && 'string' != typeof plugin && filterPlugin(plugin, treeShakingSharedExcludePlugins)) finalPlugins.push(plugin);
|
|
67094
|
+
});
|
|
67095
|
+
plugins.forEach((plugin)=>{
|
|
67096
|
+
finalPlugins.push(plugin);
|
|
67097
|
+
});
|
|
67098
|
+
finalPlugins.push(extraPlugin);
|
|
67099
|
+
finalPlugins.push(new ConsumeSharedPlugin({
|
|
67100
|
+
consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
|
|
67101
|
+
[key]: {
|
|
67102
|
+
import: extraOptions ? false : options.import,
|
|
67103
|
+
shareKey: options.shareKey || key,
|
|
67104
|
+
shareScope: options.shareScope,
|
|
67105
|
+
requiredVersion: options.requiredVersion,
|
|
67106
|
+
strictVersion: options.strictVersion,
|
|
67107
|
+
singleton: options.singleton,
|
|
67108
|
+
packageName: options.packageName,
|
|
67109
|
+
eager: options.eager
|
|
67110
|
+
}
|
|
67111
|
+
})),
|
|
67112
|
+
enhanced: true
|
|
67113
|
+
}));
|
|
67114
|
+
if (treeShaking) finalPlugins.push(new SharedUsedExportsOptimizerPlugin(sharedOptions, this.injectTreeShakingUsedExports));
|
|
67115
|
+
finalPlugins.push(new VirtualEntryPlugin(sharedOptions, !extraOptions));
|
|
67116
|
+
const fullOutputDir = (0, path_browserify.resolve)(parentCompiler.outputPath, outputDirWithShareName);
|
|
67117
|
+
const compilerConfig = {
|
|
67118
|
+
...parentConfig,
|
|
67119
|
+
module: {
|
|
67120
|
+
...parentConfig.module,
|
|
67121
|
+
rules: [
|
|
67122
|
+
{
|
|
67123
|
+
test: /virtual-entry\.js$/,
|
|
67124
|
+
type: "javascript/auto",
|
|
67125
|
+
resolve: {
|
|
67126
|
+
fullySpecified: false
|
|
67127
|
+
},
|
|
67128
|
+
use: {
|
|
67129
|
+
loader: 'builtin:swc-loader'
|
|
67130
|
+
}
|
|
67131
|
+
},
|
|
67132
|
+
...parentConfig.module?.rules || []
|
|
67133
|
+
]
|
|
67134
|
+
},
|
|
67135
|
+
mode: parentConfig.mode || 'development',
|
|
67136
|
+
entry: VirtualEntryPlugin.entry,
|
|
67137
|
+
output: {
|
|
67138
|
+
path: fullOutputDir,
|
|
67139
|
+
clean: true,
|
|
67140
|
+
publicPath: parentConfig.output?.publicPath || 'auto'
|
|
67141
|
+
},
|
|
67142
|
+
plugins: finalPlugins,
|
|
67143
|
+
optimization: {
|
|
67144
|
+
...parentConfig.optimization,
|
|
67145
|
+
splitChunks: false
|
|
67146
|
+
}
|
|
67147
|
+
};
|
|
67148
|
+
const compiler = rspack.rspack(compilerConfig);
|
|
67149
|
+
compiler.inputFileSystem = parentCompiler.inputFileSystem;
|
|
67150
|
+
compiler.outputFileSystem = parentCompiler.outputFileSystem;
|
|
67151
|
+
compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
|
|
67152
|
+
const { currentShare } = extraOptions || {};
|
|
67153
|
+
return new Promise((resolve, reject)=>{
|
|
67154
|
+
compiler.run((err, stats)=>{
|
|
67155
|
+
if (err || stats?.hasErrors()) {
|
|
67156
|
+
const target = currentShare ? currentShare.shareName : 'Collect deps';
|
|
67157
|
+
console.error(`${target} Compile failed:`, err || stats.toJson().errors.map((e)=>e.message).join('\n'));
|
|
67158
|
+
reject(err || new Error(`${target} Compile failed`));
|
|
67159
|
+
return;
|
|
67160
|
+
}
|
|
67161
|
+
currentShare && console.log(`${currentShare.shareName} Compile success`);
|
|
67162
|
+
resolve(extraPlugin.getData());
|
|
67163
|
+
});
|
|
67164
|
+
});
|
|
67165
|
+
}
|
|
67166
|
+
constructor(options){
|
|
67167
|
+
IndependentSharedPlugin_define_property(this, "mfName", void 0);
|
|
67168
|
+
IndependentSharedPlugin_define_property(this, "shared", void 0);
|
|
67169
|
+
IndependentSharedPlugin_define_property(this, "library", void 0);
|
|
67170
|
+
IndependentSharedPlugin_define_property(this, "sharedOptions", void 0);
|
|
67171
|
+
IndependentSharedPlugin_define_property(this, "outputDir", void 0);
|
|
67172
|
+
IndependentSharedPlugin_define_property(this, "plugins", void 0);
|
|
67173
|
+
IndependentSharedPlugin_define_property(this, "treeShaking", void 0);
|
|
67174
|
+
IndependentSharedPlugin_define_property(this, "manifest", void 0);
|
|
67175
|
+
IndependentSharedPlugin_define_property(this, "buildAssets", {});
|
|
67176
|
+
IndependentSharedPlugin_define_property(this, "injectTreeShakingUsedExports", void 0);
|
|
67177
|
+
IndependentSharedPlugin_define_property(this, "treeShakingSharedExcludePlugins", void 0);
|
|
67178
|
+
IndependentSharedPlugin_define_property(this, "name", 'IndependentSharedPlugin');
|
|
67179
|
+
const { outputDir, plugins, treeShaking, shared, name, manifest, injectTreeShakingUsedExports, library, treeShakingSharedExcludePlugins } = options;
|
|
67180
|
+
this.shared = shared;
|
|
67181
|
+
this.mfName = name;
|
|
67182
|
+
this.outputDir = outputDir || 'independent-packages';
|
|
67183
|
+
this.plugins = plugins || [];
|
|
67184
|
+
this.treeShaking = treeShaking;
|
|
67185
|
+
this.manifest = manifest;
|
|
67186
|
+
this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? true;
|
|
67187
|
+
this.library = library;
|
|
67188
|
+
this.treeShakingSharedExcludePlugins = treeShakingSharedExcludePlugins || [];
|
|
67189
|
+
this.sharedOptions = parseOptions(shared, (item, key)=>{
|
|
67190
|
+
if ('string' != typeof item) throw new Error(`Unexpected array in shared configuration for key "${key}"`);
|
|
67191
|
+
const config = item !== key && isRequiredVersion(item) ? {
|
|
67192
|
+
import: key,
|
|
67193
|
+
requiredVersion: item
|
|
67194
|
+
} : {
|
|
67195
|
+
import: item
|
|
67196
|
+
};
|
|
67197
|
+
return config;
|
|
67198
|
+
}, (item)=>item);
|
|
67199
|
+
}
|
|
67200
|
+
}
|
|
67201
|
+
function TreeShakingSharedPlugin_define_property(obj, key, value) {
|
|
67202
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
67203
|
+
value: value,
|
|
67204
|
+
enumerable: true,
|
|
67205
|
+
configurable: true,
|
|
67206
|
+
writable: true
|
|
67207
|
+
});
|
|
67208
|
+
else obj[key] = value;
|
|
67209
|
+
return obj;
|
|
67210
|
+
}
|
|
67211
|
+
class TreeShakingSharedPlugin {
|
|
67212
|
+
apply(compiler) {
|
|
67213
|
+
const { mfConfig, outputDir, secondary } = this;
|
|
67214
|
+
const { name, shared, library, treeShakingSharedPlugins } = mfConfig;
|
|
67215
|
+
if (!shared) return;
|
|
67216
|
+
const sharedOptions = normalizeSharedOptions(shared);
|
|
67217
|
+
if (!sharedOptions.length) return;
|
|
67218
|
+
if (sharedOptions.some(([_, config])=>config.treeShaking && false !== config.import)) {
|
|
67219
|
+
if (!secondary) new SharedUsedExportsOptimizerPlugin(sharedOptions, mfConfig.injectTreeShakingUsedExports, mfConfig.manifest).apply(compiler);
|
|
67220
|
+
this._independentSharePlugin = new IndependentSharedPlugin({
|
|
67221
|
+
name: name,
|
|
67222
|
+
shared: shared,
|
|
67223
|
+
outputDir,
|
|
67224
|
+
plugins: treeShakingSharedPlugins?.map((p)=>{
|
|
67225
|
+
const _constructor = require(p);
|
|
67226
|
+
return new _constructor();
|
|
67227
|
+
}) || [],
|
|
67228
|
+
treeShaking: secondary,
|
|
67229
|
+
library,
|
|
67230
|
+
manifest: mfConfig.manifest,
|
|
67231
|
+
treeShakingSharedExcludePlugins: mfConfig.treeShakingSharedExcludePlugins
|
|
67232
|
+
});
|
|
67233
|
+
this._independentSharePlugin.apply(compiler);
|
|
67234
|
+
}
|
|
67235
|
+
}
|
|
67236
|
+
get buildAssets() {
|
|
67237
|
+
return this._independentSharePlugin?.buildAssets || {};
|
|
67238
|
+
}
|
|
67239
|
+
constructor(options){
|
|
67240
|
+
TreeShakingSharedPlugin_define_property(this, "mfConfig", void 0);
|
|
67241
|
+
TreeShakingSharedPlugin_define_property(this, "outputDir", void 0);
|
|
67242
|
+
TreeShakingSharedPlugin_define_property(this, "secondary", void 0);
|
|
67243
|
+
TreeShakingSharedPlugin_define_property(this, "_independentSharePlugin", void 0);
|
|
67244
|
+
TreeShakingSharedPlugin_define_property(this, "name", 'TreeShakingSharedPlugin');
|
|
67245
|
+
const { mfConfig, secondary } = options;
|
|
67246
|
+
this.mfConfig = mfConfig;
|
|
67247
|
+
this.outputDir = mfConfig.treeShakingSharedDir || 'independent-packages';
|
|
67248
|
+
this.secondary = Boolean(secondary);
|
|
67249
|
+
}
|
|
67250
|
+
}
|
|
67251
|
+
const ModuleFederationRuntimePlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
|
|
66402
67252
|
function ModuleFederationPlugin_define_property(obj, key, value) {
|
|
66403
67253
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
66404
67254
|
value: value,
|
|
@@ -66418,101 +67268,50 @@ class ModuleFederationPlugin {
|
|
|
66418
67268
|
'@module-federation/runtime': paths.runtime,
|
|
66419
67269
|
...compiler.options.resolve.alias
|
|
66420
67270
|
};
|
|
66421
|
-
const
|
|
66422
|
-
|
|
66423
|
-
|
|
66424
|
-
|
|
67271
|
+
const sharedOptions = getSharedOptions(this._options);
|
|
67272
|
+
const treeShakingEntries = sharedOptions.filter(([, config])=>config.treeShaking);
|
|
67273
|
+
if (treeShakingEntries.length > 0) {
|
|
67274
|
+
this._treeShakingSharedPlugin = new TreeShakingSharedPlugin({
|
|
67275
|
+
mfConfig: this._options,
|
|
67276
|
+
secondary: false
|
|
67277
|
+
});
|
|
67278
|
+
this._treeShakingSharedPlugin.apply(compiler);
|
|
67279
|
+
}
|
|
67280
|
+
let runtimePluginApplied = false;
|
|
67281
|
+
compiler.hooks.beforeRun.tap({
|
|
67282
|
+
name: 'ModuleFederationPlugin',
|
|
67283
|
+
stage: 100
|
|
67284
|
+
}, ()=>{
|
|
67285
|
+
if (runtimePluginApplied) return;
|
|
67286
|
+
runtimePluginApplied = true;
|
|
67287
|
+
const entryRuntime = getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets);
|
|
67288
|
+
new ModuleFederationRuntimePlugin({
|
|
67289
|
+
entryRuntime
|
|
67290
|
+
}).apply(compiler);
|
|
67291
|
+
});
|
|
67292
|
+
compiler.hooks.watchRun.tap({
|
|
67293
|
+
name: 'ModuleFederationPlugin',
|
|
67294
|
+
stage: 100
|
|
67295
|
+
}, ()=>{
|
|
67296
|
+
if (runtimePluginApplied) return;
|
|
67297
|
+
runtimePluginApplied = true;
|
|
67298
|
+
const entryRuntime = getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets || {});
|
|
67299
|
+
new ModuleFederationRuntimePlugin({
|
|
67300
|
+
entryRuntime
|
|
67301
|
+
}).apply(compiler);
|
|
67302
|
+
});
|
|
66425
67303
|
new webpack.container.ModuleFederationPluginV1({
|
|
66426
67304
|
...this._options,
|
|
66427
67305
|
enhanced: true
|
|
66428
67306
|
}).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
|
-
}
|
|
67307
|
+
if (this._options.manifest) new ModuleFederationManifestPlugin(this._options).apply(compiler);
|
|
66456
67308
|
}
|
|
66457
67309
|
constructor(_options){
|
|
66458
67310
|
ModuleFederationPlugin_define_property(this, "_options", void 0);
|
|
67311
|
+
ModuleFederationPlugin_define_property(this, "_treeShakingSharedPlugin", void 0);
|
|
66459
67312
|
this._options = _options;
|
|
66460
67313
|
}
|
|
66461
67314
|
}
|
|
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
67315
|
function getRemoteInfos(options) {
|
|
66517
67316
|
if (!options.remotes) return {};
|
|
66518
67317
|
function extractUrlAndGlobal(urlAndGlobal) {
|
|
@@ -66579,6 +67378,18 @@ function getRemoteInfos(options) {
|
|
|
66579
67378
|
function getRuntimePlugins(options) {
|
|
66580
67379
|
return options.runtimePlugins ?? [];
|
|
66581
67380
|
}
|
|
67381
|
+
function getSharedOptions(options) {
|
|
67382
|
+
if (!options.shared) return [];
|
|
67383
|
+
return parseOptions(options.shared, (item, key)=>{
|
|
67384
|
+
if ('string' != typeof item) throw new Error('Unexpected array in shared');
|
|
67385
|
+
return item !== key && isRequiredVersion(item) ? {
|
|
67386
|
+
import: key,
|
|
67387
|
+
requiredVersion: item
|
|
67388
|
+
} : {
|
|
67389
|
+
import: item
|
|
67390
|
+
};
|
|
67391
|
+
}, (item)=>item);
|
|
67392
|
+
}
|
|
66582
67393
|
function getPaths(options) {
|
|
66583
67394
|
return {
|
|
66584
67395
|
runtimeTools: '@module-federation/runtime-tools',
|
|
@@ -66586,11 +67397,12 @@ function getPaths(options) {
|
|
|
66586
67397
|
runtime: '@module-federation/runtime'
|
|
66587
67398
|
};
|
|
66588
67399
|
}
|
|
66589
|
-
function getDefaultEntryRuntime(paths, options, compiler) {
|
|
67400
|
+
function getDefaultEntryRuntime(paths, options, compiler, treeShakingShareFallbacks) {
|
|
66590
67401
|
const runtimePlugins = getRuntimePlugins(options);
|
|
66591
67402
|
const remoteInfos = getRemoteInfos(options);
|
|
66592
67403
|
const runtimePluginImports = [];
|
|
66593
67404
|
const runtimePluginVars = [];
|
|
67405
|
+
const libraryType = options.library?.type || 'var';
|
|
66594
67406
|
for(let i = 0; i < runtimePlugins.length; i++){
|
|
66595
67407
|
const runtimePluginVar = `__module_federation_runtime_plugin_${i}__`;
|
|
66596
67408
|
const pluginSpec = runtimePlugins[i];
|
|
@@ -66607,215 +67419,12 @@ function getDefaultEntryRuntime(paths, options, compiler) {
|
|
|
66607
67419
|
`const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
|
|
66608
67420
|
`const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
|
|
66609
67421
|
`const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? 'version-first')}`,
|
|
66610
|
-
|
|
67422
|
+
`const __module_federation_share_fallbacks__ = ${JSON.stringify(treeShakingShareFallbacks)}`,
|
|
67423
|
+
`const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
|
|
67424
|
+
'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
67425
|
].join(';');
|
|
66612
67426
|
return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
|
|
66613
67427
|
}
|
|
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
67428
|
function ContainerPlugin_define_property(obj, key, value) {
|
|
66820
67429
|
if (key in obj) Object.defineProperty(obj, key, {
|
|
66821
67430
|
value: value,
|
|
@@ -66851,7 +67460,7 @@ class ContainerPlugin extends RspackBuiltinPlugin {
|
|
|
66851
67460
|
name: options.name,
|
|
66852
67461
|
shareScope: options.shareScope || 'default',
|
|
66853
67462
|
library: options.library || {
|
|
66854
|
-
type: '
|
|
67463
|
+
type: 'global',
|
|
66855
67464
|
name: options.name
|
|
66856
67465
|
},
|
|
66857
67466
|
runtime: options.runtime,
|
|
@@ -66988,7 +67597,7 @@ function transformSync(source, options) {
|
|
|
66988
67597
|
const _options = JSON.stringify(options || {});
|
|
66989
67598
|
return external_rspack_wasi_browser_js_["default"].transformSync(source, _options);
|
|
66990
67599
|
}
|
|
66991
|
-
const exports_rspackVersion = "1.7.3-canary-
|
|
67600
|
+
const exports_rspackVersion = "1.7.3-canary-1138ed18-20260115124957";
|
|
66992
67601
|
const exports_version = "5.75.0";
|
|
66993
67602
|
const exports_WebpackError = Error;
|
|
66994
67603
|
const sources = __webpack_require__("../../node_modules/.pnpm/webpack-sources@3.3.3_patch_hash=b2a26650f08a2359d0a3cd81fa6fa272aa7441a28dd7e601792da5ed5d2b4aee/node_modules/webpack-sources/lib/index.js");
|
|
@@ -67039,6 +67648,7 @@ const container = {
|
|
|
67039
67648
|
};
|
|
67040
67649
|
const sharing = {
|
|
67041
67650
|
ProvideSharedPlugin: ProvideSharedPlugin,
|
|
67651
|
+
TreeShakingSharedPlugin: TreeShakingSharedPlugin,
|
|
67042
67652
|
ConsumeSharedPlugin: ConsumeSharedPlugin,
|
|
67043
67653
|
SharePlugin: SharePlugin
|
|
67044
67654
|
};
|
|
@@ -67078,7 +67688,7 @@ const exports_experiments = {
|
|
|
67078
67688
|
createNativePlugin: createNativePlugin,
|
|
67079
67689
|
VirtualModulesPlugin: VirtualModulesPlugin
|
|
67080
67690
|
};
|
|
67081
|
-
const src_fn = Object.assign(
|
|
67691
|
+
const src_fn = Object.assign(rspack_rspack, exports_namespaceObject);
|
|
67082
67692
|
src_fn.rspack = src_fn;
|
|
67083
67693
|
src_fn.webpack = src_fn;
|
|
67084
67694
|
const src_rspack_0 = src_fn;
|