@rspack-canary/browser 1.7.1-canary-becc2931-20260103070024 → 1.7.1-canary-cf4486a4-20260104102432

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/index.mjs CHANGED
@@ -58172,7 +58172,7 @@ const applybundlerInfoDefaults = (rspackFuture, library)=>{
58172
58172
  if ('object' == typeof rspackFuture) {
58173
58173
  D(rspackFuture, 'bundlerInfo', {});
58174
58174
  if ('object' == typeof rspackFuture.bundlerInfo) {
58175
- D(rspackFuture.bundlerInfo, 'version', "1.7.1-canary-becc2931-20260103070024");
58175
+ D(rspackFuture.bundlerInfo, 'version', "1.7.1-canary-cf4486a4-20260104102432");
58176
58176
  D(rspackFuture.bundlerInfo, 'bundler', 'rspack');
58177
58177
  D(rspackFuture.bundlerInfo, 'force', !library);
58178
58178
  }
@@ -62365,7 +62365,7 @@ class MultiStats {
62365
62365
  return obj;
62366
62366
  });
62367
62367
  if (childOptions.version) {
62368
- obj.rspackVersion = "1.7.1-canary-becc2931-20260103070024";
62368
+ obj.rspackVersion = "1.7.1-canary-cf4486a4-20260104102432";
62369
62369
  obj.version = "5.75.0";
62370
62370
  }
62371
62371
  if (childOptions.hash) obj.hash = obj.children.map((j)=>j.hash).join('');
@@ -63681,7 +63681,7 @@ const SIMPLE_EXTRACTORS = {
63681
63681
  },
63682
63682
  version: (object)=>{
63683
63683
  object.version = "5.75.0";
63684
- object.rspackVersion = "1.7.1-canary-becc2931-20260103070024";
63684
+ object.rspackVersion = "1.7.1-canary-cf4486a4-20260104102432";
63685
63685
  },
63686
63686
  env: (object, _compilation, _context, { _env })=>{
63687
63687
  object.env = _env;
@@ -66110,10 +66110,266 @@ class NodeTemplatePlugin {
66110
66110
  this._options = _options;
66111
66111
  }
66112
66112
  }
66113
+ const options_process = (options, normalizeSimple, normalizeOptions, fn)=>{
66114
+ const array = (items)=>{
66115
+ for (const item of items)if ('string' == typeof item) fn(item, normalizeSimple(item, item));
66116
+ else if (item && 'object' == typeof item) object(item);
66117
+ else throw new Error('Unexpected options format');
66118
+ };
66119
+ const object = (obj)=>{
66120
+ for (const [key, value] of Object.entries(obj))'string' == typeof value || Array.isArray(value) ? fn(key, normalizeSimple(value, key)) : fn(key, normalizeOptions(value, key));
66121
+ };
66122
+ if (!options) return;
66123
+ if (Array.isArray(options)) array(options);
66124
+ else if ('object' == typeof options) object(options);
66125
+ else throw new Error('Unexpected options format');
66126
+ };
66127
+ const parseOptions = (options, normalizeSimple, normalizeOptions)=>{
66128
+ const items = [];
66129
+ options_process(options, normalizeSimple, normalizeOptions, (key, value)=>{
66130
+ items.push([
66131
+ key,
66132
+ value
66133
+ ]);
66134
+ });
66135
+ return items;
66136
+ };
66137
+ function ShareRuntimePlugin_define_property(obj, key, value) {
66138
+ if (key in obj) Object.defineProperty(obj, key, {
66139
+ value: value,
66140
+ enumerable: true,
66141
+ configurable: true,
66142
+ writable: true
66143
+ });
66144
+ else obj[key] = value;
66145
+ return obj;
66146
+ }
66147
+ const compilerSet = new WeakSet();
66148
+ function isSingleton(compiler) {
66149
+ return compilerSet.has(compiler);
66150
+ }
66151
+ function setSingleton(compiler) {
66152
+ compilerSet.add(compiler);
66153
+ }
66154
+ class ShareRuntimePlugin extends RspackBuiltinPlugin {
66155
+ raw(compiler) {
66156
+ if (isSingleton(compiler)) return;
66157
+ setSingleton(compiler);
66158
+ return createBuiltinPlugin(this.name, this.enhanced);
66159
+ }
66160
+ constructor(enhanced = false){
66161
+ 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;
66162
+ }
66163
+ }
66113
66164
  const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
66114
66165
  function isRequiredVersion(str) {
66115
66166
  return VERSION_PATTERN_REGEXP.test(str);
66116
66167
  }
66168
+ const encodeName = function(name, prefix = '', withExt = false) {
66169
+ const ext = withExt ? '.js' : '';
66170
+ return `${prefix}${name.replace(/@/g, 'scope_').replace(/-/g, '_').replace(/\//g, '__').replace(/\./g, '')}${ext}`;
66171
+ };
66172
+ function ConsumeSharedPlugin_define_property(obj, key, value) {
66173
+ if (key in obj) Object.defineProperty(obj, key, {
66174
+ value: value,
66175
+ enumerable: true,
66176
+ configurable: true,
66177
+ writable: true
66178
+ });
66179
+ else obj[key] = value;
66180
+ return obj;
66181
+ }
66182
+ function normalizeConsumeShareOptions(consumes, shareScope) {
66183
+ return parseOptions(consumes, (item, key)=>{
66184
+ if (Array.isArray(item)) throw new Error('Unexpected array in options');
66185
+ const result = item !== key && isRequiredVersion(item) ? {
66186
+ import: key,
66187
+ shareScope: shareScope || 'default',
66188
+ shareKey: key,
66189
+ requiredVersion: item,
66190
+ strictVersion: true,
66191
+ packageName: void 0,
66192
+ singleton: false,
66193
+ eager: false,
66194
+ treeshakeStrategy: void 0
66195
+ } : {
66196
+ import: key,
66197
+ shareScope: shareScope || 'default',
66198
+ shareKey: key,
66199
+ requiredVersion: void 0,
66200
+ packageName: void 0,
66201
+ strictVersion: false,
66202
+ singleton: false,
66203
+ eager: false,
66204
+ treeshakeStrategy: void 0
66205
+ };
66206
+ return result;
66207
+ }, (item, key)=>({
66208
+ import: false === item.import ? void 0 : item.import || key,
66209
+ shareScope: item.shareScope || shareScope || 'default',
66210
+ shareKey: item.shareKey || key,
66211
+ requiredVersion: item.requiredVersion,
66212
+ strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : false !== item.import && !item.singleton,
66213
+ packageName: item.packageName,
66214
+ singleton: !!item.singleton,
66215
+ eager: !!item.eager,
66216
+ treeshakeStrategy: item.treeshakeStrategy
66217
+ }));
66218
+ }
66219
+ class ConsumeSharedPlugin extends RspackBuiltinPlugin {
66220
+ raw(compiler) {
66221
+ new ShareRuntimePlugin(this._options.enhanced).apply(compiler);
66222
+ const rawOptions = {
66223
+ consumes: this._options.consumes.map(([key, v])=>({
66224
+ key,
66225
+ ...v
66226
+ })),
66227
+ enhanced: this._options.enhanced
66228
+ };
66229
+ return createBuiltinPlugin(this.name, rawOptions);
66230
+ }
66231
+ constructor(options){
66232
+ super(), ConsumeSharedPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ConsumeSharedPlugin), ConsumeSharedPlugin_define_property(this, "_options", void 0);
66233
+ this._options = {
66234
+ consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
66235
+ enhanced: options.enhanced ?? false
66236
+ };
66237
+ }
66238
+ }
66239
+ function ProvideSharedPlugin_define_property(obj, key, value) {
66240
+ if (key in obj) Object.defineProperty(obj, key, {
66241
+ value: value,
66242
+ enumerable: true,
66243
+ configurable: true,
66244
+ writable: true
66245
+ });
66246
+ else obj[key] = value;
66247
+ return obj;
66248
+ }
66249
+ function normalizeProvideShareOptions(options, shareScope, enhanced) {
66250
+ return parseOptions(options, (item)=>{
66251
+ if (Array.isArray(item)) throw new Error('Unexpected array of provides');
66252
+ return {
66253
+ shareKey: item,
66254
+ version: void 0,
66255
+ shareScope: shareScope || 'default',
66256
+ eager: false
66257
+ };
66258
+ }, (item)=>{
66259
+ const raw = {
66260
+ shareKey: item.shareKey,
66261
+ version: item.version,
66262
+ shareScope: item.shareScope || shareScope || 'default',
66263
+ eager: !!item.eager
66264
+ };
66265
+ if (enhanced) {
66266
+ const enhancedItem = item;
66267
+ return {
66268
+ ...raw,
66269
+ singleton: enhancedItem.singleton,
66270
+ requiredVersion: enhancedItem.requiredVersion,
66271
+ strictVersion: enhancedItem.strictVersion,
66272
+ treeshakeStrategy: enhancedItem.treeshakeStrategy
66273
+ };
66274
+ }
66275
+ return raw;
66276
+ });
66277
+ }
66278
+ class ProvideSharedPlugin extends RspackBuiltinPlugin {
66279
+ raw(compiler) {
66280
+ new ShareRuntimePlugin(this._enhanced ?? false).apply(compiler);
66281
+ const rawOptions = this._provides.map(([key, v])=>({
66282
+ key,
66283
+ ...v
66284
+ }));
66285
+ return createBuiltinPlugin(this.name, rawOptions);
66286
+ }
66287
+ constructor(options){
66288
+ 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);
66289
+ this._provides = normalizeProvideShareOptions(options.provides, options.shareScope, options.enhanced);
66290
+ this._enhanced = options.enhanced;
66291
+ }
66292
+ }
66293
+ function SharePlugin_define_property(obj, key, value) {
66294
+ if (key in obj) Object.defineProperty(obj, key, {
66295
+ value: value,
66296
+ enumerable: true,
66297
+ configurable: true,
66298
+ writable: true
66299
+ });
66300
+ else obj[key] = value;
66301
+ return obj;
66302
+ }
66303
+ function normalizeSharedOptions(shared) {
66304
+ return parseOptions(shared, (item, key)=>{
66305
+ if ('string' != typeof item) throw new Error('Unexpected array in shared');
66306
+ const config = item !== key && isRequiredVersion(item) ? {
66307
+ import: key,
66308
+ requiredVersion: item
66309
+ } : {
66310
+ import: item
66311
+ };
66312
+ return config;
66313
+ }, (item)=>item);
66314
+ }
66315
+ function createProvideShareOptions(normalizedSharedOptions) {
66316
+ return normalizedSharedOptions.filter(([, options])=>false !== options.import).map(([key, options])=>({
66317
+ [options.import || key]: {
66318
+ shareKey: options.shareKey || key,
66319
+ shareScope: options.shareScope,
66320
+ version: options.version,
66321
+ eager: options.eager,
66322
+ singleton: options.singleton,
66323
+ requiredVersion: options.requiredVersion,
66324
+ strictVersion: options.strictVersion,
66325
+ treeshakeStrategy: options.treeshake?.strategy
66326
+ }
66327
+ }));
66328
+ }
66329
+ function createConsumeShareOptions(normalizedSharedOptions) {
66330
+ return normalizedSharedOptions.map(([key, options])=>({
66331
+ [key]: {
66332
+ import: options.import,
66333
+ shareKey: options.shareKey || key,
66334
+ shareScope: options.shareScope,
66335
+ requiredVersion: options.requiredVersion,
66336
+ strictVersion: options.strictVersion,
66337
+ singleton: options.singleton,
66338
+ packageName: options.packageName,
66339
+ eager: options.eager,
66340
+ treeshakeStrategy: options.treeshake?.strategy
66341
+ }
66342
+ }));
66343
+ }
66344
+ class SharePlugin {
66345
+ apply(compiler) {
66346
+ new ConsumeSharedPlugin({
66347
+ shareScope: this._shareScope,
66348
+ consumes: this._consumes,
66349
+ enhanced: this._enhanced
66350
+ }).apply(compiler);
66351
+ new ProvideSharedPlugin({
66352
+ shareScope: this._shareScope,
66353
+ provides: this._provides,
66354
+ enhanced: this._enhanced
66355
+ }).apply(compiler);
66356
+ }
66357
+ constructor(options){
66358
+ SharePlugin_define_property(this, "_shareScope", void 0);
66359
+ SharePlugin_define_property(this, "_consumes", void 0);
66360
+ SharePlugin_define_property(this, "_provides", void 0);
66361
+ SharePlugin_define_property(this, "_enhanced", void 0);
66362
+ SharePlugin_define_property(this, "_sharedOptions", void 0);
66363
+ const sharedOptions = normalizeSharedOptions(options.shared);
66364
+ const consumes = createConsumeShareOptions(sharedOptions);
66365
+ const provides = createProvideShareOptions(sharedOptions);
66366
+ this._shareScope = options.shareScope;
66367
+ this._consumes = consumes;
66368
+ this._provides = provides;
66369
+ this._enhanced = options.enhanced ?? false;
66370
+ this._sharedOptions = sharedOptions;
66371
+ }
66372
+ }
66117
66373
  var ModuleFederationManifestPlugin_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
66118
66374
  function ModuleFederationManifestPlugin_define_property(obj, key, value) {
66119
66375
  if (key in obj) Object.defineProperty(obj, key, {
@@ -66152,17 +66408,29 @@ function readPKGJson(root) {
66152
66408
  } catch {}
66153
66409
  return {};
66154
66410
  }
66155
- function getBuildInfo(isDev, root) {
66156
- const rootPath = root || ModuleFederationManifestPlugin_process.cwd();
66411
+ function getBuildInfo(isDev, compiler, mfConfig) {
66412
+ const rootPath = compiler.options.context || ModuleFederationManifestPlugin_process.cwd();
66157
66413
  const pkg = readPKGJson(rootPath);
66158
66414
  const buildVersion = isDev ? LOCAL_BUILD_VERSION : pkg?.version;
66159
- return {
66415
+ const statsBuildInfo = {
66160
66416
  buildVersion: ModuleFederationManifestPlugin_process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
66161
66417
  buildName: ModuleFederationManifestPlugin_process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
66162
66418
  };
66419
+ const normalizedShared = normalizeSharedOptions(mfConfig.shared || {});
66420
+ const enableTreeshake = Object.values(normalizedShared).some((config)=>config[1].treeshake);
66421
+ if (enableTreeshake) {
66422
+ statsBuildInfo.target = Array.isArray(compiler.options.target) ? compiler.options.target : [];
66423
+ statsBuildInfo.plugins = mfConfig.treeshakeSharedPlugins || [];
66424
+ statsBuildInfo.excludePlugins = mfConfig.treeshakeSharedExcludePlugins || [];
66425
+ }
66426
+ return statsBuildInfo;
66163
66427
  }
66164
66428
  function getFileName(manifestOptions) {
66165
66429
  if (!manifestOptions) return {
66430
+ statsFileName: '',
66431
+ manifestFileName: ''
66432
+ };
66433
+ if ('boolean' == typeof manifestOptions) return {
66166
66434
  statsFileName: STATS_FILE_NAME,
66167
66435
  manifestFileName: MANIFEST_FILE_NAME
66168
66436
  };
@@ -66180,13 +66448,95 @@ function getFileName(manifestOptions) {
66180
66448
  manifestFileName: (0, path_browserify.join)(filePath, manifestFileName)
66181
66449
  };
66182
66450
  }
66451
+ function resolveLibraryGlobalName(library) {
66452
+ if (!library) return;
66453
+ const libName = library.name;
66454
+ if (!libName) return;
66455
+ if ('string' == typeof libName) return libName;
66456
+ if (Array.isArray(libName)) return libName[0];
66457
+ if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
66458
+ }
66459
+ function collectManifestExposes(exposes) {
66460
+ if (!exposes) return;
66461
+ const parsed = parseOptions(exposes, (value)=>({
66462
+ import: Array.isArray(value) ? value : [
66463
+ value
66464
+ ],
66465
+ name: void 0
66466
+ }), (value)=>({
66467
+ import: Array.isArray(value.import) ? value.import : [
66468
+ value.import
66469
+ ],
66470
+ name: value.name ?? void 0
66471
+ }));
66472
+ const result = parsed.map(([exposeKey, info])=>{
66473
+ const exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
66474
+ return {
66475
+ path: exposeKey,
66476
+ name: exposeName
66477
+ };
66478
+ });
66479
+ return result.length > 0 ? result : void 0;
66480
+ }
66481
+ function collectManifestShared(shared) {
66482
+ if (!shared) return;
66483
+ const parsed = parseOptions(shared, (item, key)=>{
66484
+ if ('string' != typeof item) throw new Error('Unexpected array in shared');
66485
+ return item !== key && isRequiredVersion(item) ? {
66486
+ import: key,
66487
+ requiredVersion: item
66488
+ } : {
66489
+ import: item
66490
+ };
66491
+ }, (item)=>item);
66492
+ const result = parsed.map(([key, config])=>{
66493
+ const name = config.shareKey || key;
66494
+ const version = 'string' == typeof config.version ? config.version : void 0;
66495
+ const requiredVersion = 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0;
66496
+ return {
66497
+ name,
66498
+ version,
66499
+ requiredVersion,
66500
+ singleton: config.singleton
66501
+ };
66502
+ });
66503
+ return result.length > 0 ? result : void 0;
66504
+ }
66505
+ function normalizeManifestOptions(mfConfig) {
66506
+ const manifestOptions = true === mfConfig.manifest ? {} : {
66507
+ ...mfConfig.manifest
66508
+ };
66509
+ const containerName = mfConfig.name;
66510
+ const globalName = resolveLibraryGlobalName(mfConfig.library) ?? containerName;
66511
+ const remoteAliasMap = Object.entries(getRemoteInfos(mfConfig)).reduce((sum, cur)=>{
66512
+ if (cur[1].length > 1) return sum;
66513
+ const remoteInfo = cur[1][0];
66514
+ const { entry, alias, name } = remoteInfo;
66515
+ if (entry && name) sum[alias] = {
66516
+ name,
66517
+ entry
66518
+ };
66519
+ return sum;
66520
+ }, {});
66521
+ const manifestExposes = collectManifestExposes(mfConfig.exposes);
66522
+ if (void 0 === manifestOptions.exposes && manifestExposes) manifestOptions.exposes = manifestExposes;
66523
+ const manifestShared = collectManifestShared(mfConfig.shared);
66524
+ if (void 0 === manifestOptions.shared && manifestShared) manifestOptions.shared = manifestShared;
66525
+ return {
66526
+ ...manifestOptions,
66527
+ remoteAliasMap,
66528
+ globalName,
66529
+ name: containerName
66530
+ };
66531
+ }
66183
66532
  class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
66184
66533
  raw(compiler) {
66185
- const { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts;
66186
- const { statsFileName, manifestFileName } = getFileName(this.opts);
66534
+ const opts = normalizeManifestOptions(this.rawOpts);
66535
+ const { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = opts;
66536
+ const { statsFileName, manifestFileName } = getFileName(opts);
66187
66537
  const rawOptions = {
66188
- name: this.opts.name,
66189
- globalName: this.opts.globalName,
66538
+ name: opts.name,
66539
+ globalName: opts.globalName,
66190
66540
  fileName,
66191
66541
  filePath,
66192
66542
  manifestFileName,
@@ -66195,40 +66545,494 @@ class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
66195
66545
  remoteAliasMap,
66196
66546
  exposes,
66197
66547
  shared,
66198
- buildInfo: getBuildInfo('development' === compiler.options.mode, compiler.context)
66548
+ buildInfo: getBuildInfo('development' === compiler.options.mode, compiler, this.rawOpts)
66199
66549
  };
66200
66550
  return createBuiltinPlugin(this.name, rawOptions);
66201
66551
  }
66202
- constructor(opts){
66203
- super(), ModuleFederationManifestPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationManifestPlugin), ModuleFederationManifestPlugin_define_property(this, "opts", void 0);
66204
- this.opts = opts;
66552
+ constructor(opts){
66553
+ super(), ModuleFederationManifestPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationManifestPlugin), ModuleFederationManifestPlugin_define_property(this, "rawOpts", void 0);
66554
+ this.rawOpts = opts;
66555
+ }
66556
+ }
66557
+ function CollectSharedEntryPlugin_define_property(obj, key, value) {
66558
+ if (key in obj) Object.defineProperty(obj, key, {
66559
+ value: value,
66560
+ enumerable: true,
66561
+ configurable: true,
66562
+ writable: true
66563
+ });
66564
+ else obj[key] = value;
66565
+ return obj;
66566
+ }
66567
+ const SHARE_ENTRY_ASSET = 'collect-shared-entries.json';
66568
+ class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
66569
+ getData() {
66570
+ return this._collectedEntries;
66571
+ }
66572
+ getFilename() {
66573
+ return SHARE_ENTRY_ASSET;
66574
+ }
66575
+ apply(compiler) {
66576
+ super.apply(compiler);
66577
+ compiler.hooks.thisCompilation.tap('Collect shared entry', (compilation)=>{
66578
+ compilation.hooks.processAssets.tapPromise({
66579
+ name: 'CollectSharedEntry',
66580
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
66581
+ }, async ()=>{
66582
+ compilation.getAssets().forEach((asset)=>{
66583
+ if (asset.name === SHARE_ENTRY_ASSET) this._collectedEntries = JSON.parse(asset.source.source().toString());
66584
+ compilation.deleteAsset(asset.name);
66585
+ });
66586
+ });
66587
+ });
66588
+ }
66589
+ raw() {
66590
+ const consumeShareOptions = createConsumeShareOptions(this.sharedOptions);
66591
+ const normalizedConsumeShareOptions = normalizeConsumeShareOptions(consumeShareOptions);
66592
+ const rawOptions = {
66593
+ consumes: normalizedConsumeShareOptions.map(([key, v])=>({
66594
+ key,
66595
+ ...v
66596
+ })),
66597
+ filename: this.getFilename()
66598
+ };
66599
+ return createBuiltinPlugin(this.name, rawOptions);
66600
+ }
66601
+ constructor(options){
66602
+ 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);
66603
+ const { sharedOptions } = options;
66604
+ this.sharedOptions = sharedOptions;
66605
+ this._collectedEntries = {};
66606
+ }
66607
+ }
66608
+ function SharedContainerPlugin_define_property(obj, key, value) {
66609
+ if (key in obj) Object.defineProperty(obj, key, {
66610
+ value: value,
66611
+ enumerable: true,
66612
+ configurable: true,
66613
+ writable: true
66614
+ });
66615
+ else obj[key] = value;
66616
+ return obj;
66617
+ }
66618
+ function assert(condition, msg) {
66619
+ if (!condition) throw new Error(msg);
66620
+ }
66621
+ const HOT_UPDATE_SUFFIX = '.hot-update';
66622
+ class SharedContainerPlugin extends RspackBuiltinPlugin {
66623
+ getData() {
66624
+ return [
66625
+ this._options.fileName,
66626
+ this._globalName,
66627
+ this._options.version
66628
+ ];
66629
+ }
66630
+ raw(compiler) {
66631
+ const { library } = this._options;
66632
+ if (!compiler.options.output.enabledLibraryTypes.includes(library.type)) compiler.options.output.enabledLibraryTypes.push(library.type);
66633
+ return createBuiltinPlugin(this.name, this._options);
66634
+ }
66635
+ apply(compiler) {
66636
+ super.apply(compiler);
66637
+ const shareName = this._shareName;
66638
+ compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
66639
+ compilation.hooks.processAssets.tapPromise({
66640
+ name: 'getShareContainerFile'
66641
+ }, async ()=>{
66642
+ const remoteEntryPoint = compilation.entrypoints.get(shareName);
66643
+ assert(remoteEntryPoint, `Can not get shared ${shareName} entryPoint!`);
66644
+ const remoteEntryNameChunk = compilation.namedChunks.get(shareName);
66645
+ assert(remoteEntryNameChunk, `Can not get shared ${shareName} chunk!`);
66646
+ const files = Array.from(remoteEntryNameChunk.files).filter((f)=>!f.includes(HOT_UPDATE_SUFFIX) && !f.endsWith('.css'));
66647
+ assert(files.length > 0, `no files found for shared ${shareName} chunk`);
66648
+ assert(1 === files.length, `shared ${shareName} chunk should not have multiple files!, current files: ${files.join(',')}`);
66649
+ this.filename = files[0];
66650
+ });
66651
+ });
66652
+ }
66653
+ constructor(options){
66654
+ 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);
66655
+ const { shareName, library, request, independentShareFileName, mfName } = options;
66656
+ const version = options.version || '0.0.0';
66657
+ this._globalName = encodeName(`${mfName}_${shareName}_${version}`);
66658
+ const fileName = independentShareFileName || `${version}/share-entry.js`;
66659
+ this._shareName = shareName;
66660
+ this._options = {
66661
+ name: shareName,
66662
+ request: request,
66663
+ library: (library ? {
66664
+ ...library,
66665
+ name: this._globalName
66666
+ } : void 0) || {
66667
+ type: 'global',
66668
+ name: this._globalName
66669
+ },
66670
+ version,
66671
+ fileName
66672
+ };
66673
+ }
66674
+ }
66675
+ function SharedUsedExportsOptimizerPlugin_define_property(obj, key, value) {
66676
+ if (key in obj) Object.defineProperty(obj, key, {
66677
+ value: value,
66678
+ enumerable: true,
66679
+ configurable: true,
66680
+ writable: true
66681
+ });
66682
+ else obj[key] = value;
66683
+ return obj;
66684
+ }
66685
+ class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
66686
+ buildOptions() {
66687
+ const shared = this.sharedOptions.map(([shareKey, config])=>({
66688
+ shareKey,
66689
+ treeshake: !!config.treeshake,
66690
+ usedExports: config.treeshake?.usedExports
66691
+ }));
66692
+ const { manifestFileName, statsFileName } = getFileName(this.manifestOptions);
66693
+ return {
66694
+ shared,
66695
+ injectUsedExports: this.injectUsedExports,
66696
+ manifestFileName,
66697
+ statsFileName
66698
+ };
66699
+ }
66700
+ raw() {
66701
+ if (!this.sharedOptions.length) return;
66702
+ return createBuiltinPlugin(this.name, this.buildOptions());
66703
+ }
66704
+ constructor(sharedOptions, injectUsedExports, manifestOptions){
66705
+ super(), SharedUsedExportsOptimizerPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.SharedUsedExportsOptimizerPlugin), SharedUsedExportsOptimizerPlugin_define_property(this, "sharedOptions", void 0), SharedUsedExportsOptimizerPlugin_define_property(this, "injectUsedExports", void 0), SharedUsedExportsOptimizerPlugin_define_property(this, "manifestOptions", void 0);
66706
+ this.sharedOptions = sharedOptions;
66707
+ this.injectUsedExports = injectUsedExports ?? true;
66708
+ this.manifestOptions = manifestOptions ?? {};
66709
+ }
66710
+ }
66711
+ function IndependentSharedPlugin_define_property(obj, key, value) {
66712
+ if (key in obj) Object.defineProperty(obj, key, {
66713
+ value: value,
66714
+ enumerable: true,
66715
+ configurable: true,
66716
+ writable: true
66717
+ });
66718
+ else obj[key] = value;
66719
+ return obj;
66720
+ }
66721
+ const VIRTUAL_ENTRY = './virtual-entry.js';
66722
+ const VIRTUAL_ENTRY_NAME = 'virtual-entry';
66723
+ const filterPlugin = (plugin, excludedPlugins = [])=>{
66724
+ if (!plugin) return true;
66725
+ const pluginName = plugin.name || plugin.constructor?.name;
66726
+ if (!pluginName) return true;
66727
+ return ![
66728
+ 'TreeShakeSharedPlugin',
66729
+ 'IndependentSharedPlugin',
66730
+ 'ModuleFederationPlugin',
66731
+ 'SharedUsedExportsOptimizerPlugin',
66732
+ 'HtmlWebpackPlugin',
66733
+ 'HtmlRspackPlugin',
66734
+ 'RsbuildHtmlPlugin',
66735
+ ...excludedPlugins
66736
+ ].includes(pluginName);
66737
+ };
66738
+ class VirtualEntryPlugin {
66739
+ createEntry() {
66740
+ const { sharedOptions, collectShared } = this;
66741
+ const entryContent = sharedOptions.reduce((acc, cur, index)=>{
66742
+ const importLine = `import shared_${index} from '${cur[0]}';\n`;
66743
+ const logLine = collectShared ? `console.log(shared_${index});\n` : '';
66744
+ return acc + importLine + logLine;
66745
+ }, '');
66746
+ return entryContent;
66747
+ }
66748
+ static entry() {
66749
+ return {
66750
+ [VIRTUAL_ENTRY_NAME]: VIRTUAL_ENTRY
66751
+ };
66752
+ }
66753
+ apply(compiler) {
66754
+ new compiler.rspack.experiments.VirtualModulesPlugin({
66755
+ [VIRTUAL_ENTRY]: this.createEntry()
66756
+ }).apply(compiler);
66757
+ compiler.hooks.thisCompilation.tap('RemoveVirtualEntryAsset', (compilation)=>{
66758
+ compilation.hooks.processAssets.tapPromise({
66759
+ name: 'RemoveVirtualEntryAsset',
66760
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
66761
+ }, async ()=>{
66762
+ try {
66763
+ const chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
66764
+ chunk?.files.forEach((f)=>{
66765
+ compilation.deleteAsset(f);
66766
+ });
66767
+ } catch (_e) {
66768
+ console.error('Failed to remove virtual entry file!');
66769
+ }
66770
+ });
66771
+ });
66772
+ }
66773
+ constructor(sharedOptions, collectShared){
66774
+ IndependentSharedPlugin_define_property(this, "sharedOptions", void 0);
66775
+ IndependentSharedPlugin_define_property(this, "collectShared", false);
66776
+ this.sharedOptions = sharedOptions;
66777
+ this.collectShared = collectShared;
66778
+ }
66779
+ }
66780
+ const resolveOutputDir = (outputDir, shareName)=>shareName ? (0, path_browserify.join)(outputDir, encodeName(shareName)) : outputDir;
66781
+ class IndependentSharedPlugin {
66782
+ apply(compiler) {
66783
+ const { manifest } = this;
66784
+ let runCount = 0;
66785
+ compiler.hooks.beforeRun.tapPromise('IndependentSharedPlugin', async ()=>{
66786
+ if (runCount) return;
66787
+ await this.createIndependentCompilers(compiler);
66788
+ runCount++;
66789
+ });
66790
+ compiler.hooks.watchRun.tapPromise('IndependentSharedPlugin', async ()=>{
66791
+ if (runCount) return;
66792
+ await this.createIndependentCompilers(compiler);
66793
+ runCount++;
66794
+ });
66795
+ compiler.hooks.shutdown.tapAsync('IndependentSharedPlugin', (callback)=>{
66796
+ callback();
66797
+ });
66798
+ if (manifest) compiler.hooks.compilation.tap('IndependentSharedPlugin', (compilation)=>{
66799
+ compilation.hooks.processAssets.tapPromise({
66800
+ name: 'injectBuildAssets',
66801
+ stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
66802
+ }, async ()=>{
66803
+ const { statsFileName, manifestFileName } = getFileName(manifest);
66804
+ const injectBuildAssetsIntoStatsOrManifest = (filename)=>{
66805
+ const stats = compilation.getAsset(filename);
66806
+ if (!stats) return;
66807
+ const statsContent = JSON.parse(stats.source.source().toString());
66808
+ const { shared } = statsContent;
66809
+ Object.entries(this.buildAssets).forEach(([key, item])=>{
66810
+ const targetShared = shared.find((s)=>s.name === key);
66811
+ if (!targetShared) return;
66812
+ item.forEach(([entry, version, globalName])=>{
66813
+ if (version === targetShared.version) {
66814
+ targetShared.fallback = entry;
66815
+ targetShared.fallbackName = globalName;
66816
+ }
66817
+ });
66818
+ });
66819
+ compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
66820
+ };
66821
+ injectBuildAssetsIntoStatsOrManifest(statsFileName);
66822
+ injectBuildAssetsIntoStatsOrManifest(manifestFileName);
66823
+ });
66824
+ });
66825
+ }
66826
+ async createIndependentCompilers(parentCompiler) {
66827
+ const { sharedOptions, buildAssets, outputDir } = this;
66828
+ console.log('🚀 Start creating a standalone compiler...');
66829
+ const shareRequestsMap = await this.createIndependentCompiler(parentCompiler);
66830
+ await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
66831
+ if (!shareConfig.treeshake || false === shareConfig.import) return;
66832
+ const shareRequests = shareRequestsMap[shareName].requests;
66833
+ await Promise.all(shareRequests.map(async ([request, version])=>{
66834
+ const sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1];
66835
+ const [shareFileName, globalName, sharedVersion] = await this.createIndependentCompiler(parentCompiler, {
66836
+ shareRequestsMap,
66837
+ currentShare: {
66838
+ shareName,
66839
+ version,
66840
+ request,
66841
+ independentShareFileName: sharedConfig?.treeshake?.filename
66842
+ }
66843
+ });
66844
+ if ('string' == typeof shareFileName) {
66845
+ buildAssets[shareName] ||= [];
66846
+ buildAssets[shareName].push([
66847
+ (0, path_browserify.join)(resolveOutputDir(outputDir, shareName), shareFileName),
66848
+ sharedVersion,
66849
+ globalName
66850
+ ]);
66851
+ }
66852
+ }));
66853
+ }));
66854
+ console.log('✅ All independent packages have been compiled successfully');
66855
+ }
66856
+ async createIndependentCompiler(parentCompiler, extraOptions) {
66857
+ const { mfName, plugins, outputDir, sharedOptions, treeshake, library, treeshakeSharedExcludePlugins } = this;
66858
+ const outputDirWithShareName = resolveOutputDir(outputDir, extraOptions?.currentShare?.shareName || '');
66859
+ const parentConfig = parentCompiler.options;
66860
+ const finalPlugins = [];
66861
+ const rspack = parentCompiler.rspack;
66862
+ let extraPlugin;
66863
+ extraPlugin = extraOptions ? new SharedContainerPlugin({
66864
+ mfName,
66865
+ library,
66866
+ ...extraOptions.currentShare
66867
+ }) : new CollectSharedEntryPlugin({
66868
+ sharedOptions,
66869
+ shareScope: 'default'
66870
+ });
66871
+ (parentConfig.plugins || []).forEach((plugin)=>{
66872
+ if (void 0 !== plugin && 'string' != typeof plugin && filterPlugin(plugin, treeshakeSharedExcludePlugins)) finalPlugins.push(plugin);
66873
+ });
66874
+ plugins.forEach((plugin)=>{
66875
+ finalPlugins.push(plugin);
66876
+ });
66877
+ finalPlugins.push(extraPlugin);
66878
+ finalPlugins.push(new ConsumeSharedPlugin({
66879
+ consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
66880
+ [key]: {
66881
+ import: extraOptions ? false : options.import,
66882
+ shareKey: options.shareKey || key,
66883
+ shareScope: options.shareScope,
66884
+ requiredVersion: options.requiredVersion,
66885
+ strictVersion: options.strictVersion,
66886
+ singleton: options.singleton,
66887
+ packageName: options.packageName,
66888
+ eager: options.eager
66889
+ }
66890
+ })),
66891
+ enhanced: true
66892
+ }));
66893
+ if (treeshake) finalPlugins.push(new SharedUsedExportsOptimizerPlugin(sharedOptions, this.injectUsedExports));
66894
+ finalPlugins.push(new VirtualEntryPlugin(sharedOptions, !extraOptions));
66895
+ const fullOutputDir = (0, path_browserify.resolve)(parentCompiler.outputPath, outputDirWithShareName);
66896
+ const compilerConfig = {
66897
+ ...parentConfig,
66898
+ module: {
66899
+ ...parentConfig.module,
66900
+ rules: [
66901
+ {
66902
+ test: /virtual-entry\.js$/,
66903
+ type: "javascript/auto",
66904
+ resolve: {
66905
+ fullySpecified: false
66906
+ },
66907
+ use: {
66908
+ loader: 'builtin:swc-loader'
66909
+ }
66910
+ },
66911
+ ...parentConfig.module?.rules || []
66912
+ ]
66913
+ },
66914
+ mode: parentConfig.mode || 'development',
66915
+ entry: VirtualEntryPlugin.entry,
66916
+ output: {
66917
+ path: fullOutputDir,
66918
+ clean: true,
66919
+ publicPath: parentConfig.output?.publicPath || 'auto'
66920
+ },
66921
+ plugins: finalPlugins,
66922
+ optimization: {
66923
+ ...parentConfig.optimization,
66924
+ splitChunks: false
66925
+ }
66926
+ };
66927
+ const compiler = rspack.rspack(compilerConfig);
66928
+ compiler.inputFileSystem = parentCompiler.inputFileSystem;
66929
+ compiler.outputFileSystem = parentCompiler.outputFileSystem;
66930
+ compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
66931
+ const { currentShare } = extraOptions || {};
66932
+ return new Promise((resolve, reject)=>{
66933
+ compiler.run((err, stats)=>{
66934
+ if (err || stats?.hasErrors()) {
66935
+ const target = currentShare ? currentShare.shareName : '收集依赖';
66936
+ console.error(`❌ ${target} 编译失败:`, err || stats.toJson().errors.map((e)=>e.message).join('\n'));
66937
+ reject(err || new Error(`${target} 编译失败`));
66938
+ return;
66939
+ }
66940
+ currentShare && console.log(`✅ 独立包 ${currentShare.shareName} 编译成功`);
66941
+ if (stats) {
66942
+ currentShare && console.log(`📊 ${currentShare.shareName} 编译统计:`);
66943
+ console.log(stats.toString({
66944
+ colors: true,
66945
+ chunks: false,
66946
+ modules: false
66947
+ }));
66948
+ }
66949
+ resolve(extraPlugin.getData());
66950
+ });
66951
+ });
66952
+ }
66953
+ constructor(options){
66954
+ IndependentSharedPlugin_define_property(this, "mfName", void 0);
66955
+ IndependentSharedPlugin_define_property(this, "shared", void 0);
66956
+ IndependentSharedPlugin_define_property(this, "library", void 0);
66957
+ IndependentSharedPlugin_define_property(this, "sharedOptions", void 0);
66958
+ IndependentSharedPlugin_define_property(this, "outputDir", void 0);
66959
+ IndependentSharedPlugin_define_property(this, "plugins", void 0);
66960
+ IndependentSharedPlugin_define_property(this, "treeshake", void 0);
66961
+ IndependentSharedPlugin_define_property(this, "manifest", void 0);
66962
+ IndependentSharedPlugin_define_property(this, "buildAssets", {});
66963
+ IndependentSharedPlugin_define_property(this, "injectUsedExports", void 0);
66964
+ IndependentSharedPlugin_define_property(this, "treeshakeSharedExcludePlugins", void 0);
66965
+ IndependentSharedPlugin_define_property(this, "name", 'IndependentSharedPlugin');
66966
+ const { outputDir, plugins, treeshake, shared, name, manifest, injectUsedExports, library, treeshakeSharedExcludePlugins } = options;
66967
+ this.shared = shared;
66968
+ this.mfName = name;
66969
+ this.outputDir = outputDir || 'independent-packages';
66970
+ this.plugins = plugins || [];
66971
+ this.treeshake = treeshake;
66972
+ this.manifest = manifest;
66973
+ this.injectUsedExports = injectUsedExports ?? true;
66974
+ this.library = library;
66975
+ this.treeshakeSharedExcludePlugins = treeshakeSharedExcludePlugins || [];
66976
+ this.sharedOptions = parseOptions(shared, (item, key)=>{
66977
+ if ('string' != typeof item) throw new Error(`Unexpected array in shared configuration for key "${key}"`);
66978
+ const config = item !== key && isRequiredVersion(item) ? {
66979
+ import: key,
66980
+ requiredVersion: item
66981
+ } : {
66982
+ import: item
66983
+ };
66984
+ return config;
66985
+ }, (item)=>item);
66986
+ }
66987
+ }
66988
+ function TreeShakeSharedPlugin_define_property(obj, key, value) {
66989
+ if (key in obj) Object.defineProperty(obj, key, {
66990
+ value: value,
66991
+ enumerable: true,
66992
+ configurable: true,
66993
+ writable: true
66994
+ });
66995
+ else obj[key] = value;
66996
+ return obj;
66997
+ }
66998
+ class TreeShakeSharedPlugin {
66999
+ apply(compiler) {
67000
+ const { mfConfig, outputDir, reShake } = this;
67001
+ const { name, shared, library, treeshakeSharedPlugins } = mfConfig;
67002
+ if (!shared) return;
67003
+ const sharedOptions = normalizeSharedOptions(shared);
67004
+ if (!sharedOptions.length) return;
67005
+ if (sharedOptions.some(([_, config])=>config.treeshake && false !== config.import)) {
67006
+ if (!reShake) new SharedUsedExportsOptimizerPlugin(sharedOptions, mfConfig.injectUsedExports, mfConfig.manifest).apply(compiler);
67007
+ this._independentSharePlugin = new IndependentSharedPlugin({
67008
+ name: name,
67009
+ shared: shared,
67010
+ outputDir,
67011
+ plugins: treeshakeSharedPlugins?.map((p)=>require(p)) || [],
67012
+ treeshake: reShake,
67013
+ library,
67014
+ manifest: mfConfig.manifest,
67015
+ treeshakeSharedExcludePlugins: mfConfig.treeshakeSharedExcludePlugins
67016
+ });
67017
+ this._independentSharePlugin.apply(compiler);
67018
+ }
67019
+ }
67020
+ get buildAssets() {
67021
+ return this._independentSharePlugin?.buildAssets || {};
67022
+ }
67023
+ constructor(options){
67024
+ TreeShakeSharedPlugin_define_property(this, "mfConfig", void 0);
67025
+ TreeShakeSharedPlugin_define_property(this, "outputDir", void 0);
67026
+ TreeShakeSharedPlugin_define_property(this, "reShake", void 0);
67027
+ TreeShakeSharedPlugin_define_property(this, "_independentSharePlugin", void 0);
67028
+ TreeShakeSharedPlugin_define_property(this, "name", 'TreeShakeSharedPlugin');
67029
+ const { mfConfig, reShake } = options;
67030
+ this.mfConfig = mfConfig;
67031
+ this.outputDir = mfConfig.independentShareDir || 'independent-packages';
67032
+ this.reShake = Boolean(reShake);
66205
67033
  }
66206
67034
  }
66207
67035
  const ModuleFederationRuntimePlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
66208
- const options_process = (options, normalizeSimple, normalizeOptions, fn)=>{
66209
- const array = (items)=>{
66210
- for (const item of items)if ('string' == typeof item) fn(item, normalizeSimple(item, item));
66211
- else if (item && 'object' == typeof item) object(item);
66212
- else throw new Error('Unexpected options format');
66213
- };
66214
- const object = (obj)=>{
66215
- for (const [key, value] of Object.entries(obj))'string' == typeof value || Array.isArray(value) ? fn(key, normalizeSimple(value, key)) : fn(key, normalizeOptions(value, key));
66216
- };
66217
- if (!options) return;
66218
- if (Array.isArray(options)) array(options);
66219
- else if ('object' == typeof options) object(options);
66220
- else throw new Error('Unexpected options format');
66221
- };
66222
- const parseOptions = (options, normalizeSimple, normalizeOptions)=>{
66223
- const items = [];
66224
- options_process(options, normalizeSimple, normalizeOptions, (key, value)=>{
66225
- items.push([
66226
- key,
66227
- value
66228
- ]);
66229
- });
66230
- return items;
66231
- };
66232
67036
  function ModuleFederationPlugin_define_property(obj, key, value) {
66233
67037
  if (key in obj) Object.defineProperty(obj, key, {
66234
67038
  value: value,
@@ -66248,116 +67052,50 @@ class ModuleFederationPlugin {
66248
67052
  '@module-federation/runtime': paths.runtime,
66249
67053
  ...compiler.options.resolve.alias
66250
67054
  };
66251
- const entryRuntime = getDefaultEntryRuntime(paths, this._options, compiler);
66252
- const asyncStartup = this._options.experiments?.asyncStartup ?? false;
66253
- const runtimeExperiments = {
66254
- asyncStartup
66255
- };
66256
- new ModuleFederationRuntimePlugin({
66257
- entryRuntime,
66258
- experiments: runtimeExperiments,
66259
- asyncStartup
66260
- }).apply(compiler);
66261
- const v1Options = {
66262
- name: this._options.name,
66263
- exposes: this._options.exposes,
66264
- filename: this._options.filename,
66265
- library: this._options.library,
66266
- remoteType: this._options.remoteType,
66267
- remotes: this._options.remotes,
66268
- runtime: this._options.runtime,
66269
- shareScope: this._options.shareScope,
66270
- shared: this._options.shared,
66271
- enhanced: true
66272
- };
66273
- new webpack.container.ModuleFederationPluginV1(v1Options).apply(compiler);
66274
- if (this._options.manifest) {
66275
- const manifestOptions = true === this._options.manifest ? {} : {
66276
- ...this._options.manifest
66277
- };
66278
- const containerName = manifestOptions.name ?? this._options.name;
66279
- const globalName = manifestOptions.globalName ?? resolveLibraryGlobalName(this._options.library) ?? containerName;
66280
- const remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
66281
- if (cur[1].length > 1) return sum;
66282
- const remoteInfo = cur[1][0];
66283
- const { entry, alias, name } = remoteInfo;
66284
- if (entry && name) sum[alias] = {
66285
- name,
66286
- entry
66287
- };
66288
- return sum;
66289
- }, {});
66290
- const manifestExposes = collectManifestExposes(this._options.exposes);
66291
- if (void 0 === manifestOptions.exposes && manifestExposes) manifestOptions.exposes = manifestExposes;
66292
- const manifestShared = collectManifestShared(this._options.shared);
66293
- if (void 0 === manifestOptions.shared && manifestShared) manifestOptions.shared = manifestShared;
66294
- new ModuleFederationManifestPlugin({
66295
- ...manifestOptions,
66296
- name: containerName,
66297
- globalName,
66298
- remoteAliasMap
67055
+ const sharedOptions = getSharedOptions(this._options);
67056
+ const treeshakeEntries = sharedOptions.filter(([, config])=>config.treeshake);
67057
+ if (treeshakeEntries.length > 0) {
67058
+ this._treeShakeSharedPlugin = new TreeShakeSharedPlugin({
67059
+ mfConfig: this._options,
67060
+ reShake: false
67061
+ });
67062
+ this._treeShakeSharedPlugin.apply(compiler);
67063
+ }
67064
+ let runtimePluginApplied = false;
67065
+ compiler.hooks.beforeRun.tapPromise({
67066
+ name: 'ModuleFederationPlugin',
67067
+ stage: 100
67068
+ }, async ()=>{
67069
+ if (runtimePluginApplied) return;
67070
+ runtimePluginApplied = true;
67071
+ const entryRuntime = getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakeSharedPlugin?.buildAssets || {});
67072
+ new ModuleFederationRuntimePlugin({
67073
+ entryRuntime
66299
67074
  }).apply(compiler);
66300
- }
67075
+ });
67076
+ compiler.hooks.watchRun.tapPromise({
67077
+ name: 'ModuleFederationPlugin',
67078
+ stage: 100
67079
+ }, async ()=>{
67080
+ if (runtimePluginApplied) return;
67081
+ runtimePluginApplied = true;
67082
+ const entryRuntime = getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakeSharedPlugin?.buildAssets || {});
67083
+ new ModuleFederationRuntimePlugin({
67084
+ entryRuntime
67085
+ }).apply(compiler);
67086
+ });
67087
+ new webpack.container.ModuleFederationPluginV1({
67088
+ ...this._options,
67089
+ enhanced: true
67090
+ }).apply(compiler);
67091
+ if (this._options.manifest) new ModuleFederationManifestPlugin(this._options).apply(compiler);
66301
67092
  }
66302
67093
  constructor(_options){
66303
67094
  ModuleFederationPlugin_define_property(this, "_options", void 0);
67095
+ ModuleFederationPlugin_define_property(this, "_treeShakeSharedPlugin", void 0);
66304
67096
  this._options = _options;
66305
67097
  }
66306
67098
  }
66307
- function collectManifestExposes(exposes) {
66308
- if (!exposes) return;
66309
- const parsed = parseOptions(exposes, (value)=>({
66310
- import: Array.isArray(value) ? value : [
66311
- value
66312
- ],
66313
- name: void 0
66314
- }), (value)=>({
66315
- import: Array.isArray(value.import) ? value.import : [
66316
- value.import
66317
- ],
66318
- name: value.name ?? void 0
66319
- }));
66320
- const result = parsed.map(([exposeKey, info])=>{
66321
- const exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
66322
- return {
66323
- path: exposeKey,
66324
- name: exposeName
66325
- };
66326
- });
66327
- return result.length > 0 ? result : void 0;
66328
- }
66329
- function collectManifestShared(shared) {
66330
- if (!shared) return;
66331
- const parsed = parseOptions(shared, (item, key)=>{
66332
- if ('string' != typeof item) throw new Error('Unexpected array in shared');
66333
- return item !== key && isRequiredVersion(item) ? {
66334
- import: key,
66335
- requiredVersion: item
66336
- } : {
66337
- import: item
66338
- };
66339
- }, (item)=>item);
66340
- const result = parsed.map(([key, config])=>{
66341
- const name = config.shareKey || key;
66342
- const version = 'string' == typeof config.version ? config.version : void 0;
66343
- const requiredVersion = 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0;
66344
- return {
66345
- name,
66346
- version,
66347
- requiredVersion,
66348
- singleton: config.singleton
66349
- };
66350
- });
66351
- return result.length > 0 ? result : void 0;
66352
- }
66353
- function resolveLibraryGlobalName(library) {
66354
- if (!library) return;
66355
- const libName = library.name;
66356
- if (!libName) return;
66357
- if ('string' == typeof libName) return libName;
66358
- if (Array.isArray(libName)) return libName[0];
66359
- if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
66360
- }
66361
67099
  function getRemoteInfos(options) {
66362
67100
  if (!options.remotes) return {};
66363
67101
  function extractUrlAndGlobal(urlAndGlobal) {
@@ -66424,6 +67162,18 @@ function getRemoteInfos(options) {
66424
67162
  function getRuntimePlugins(options) {
66425
67163
  return options.runtimePlugins ?? [];
66426
67164
  }
67165
+ function getSharedOptions(options) {
67166
+ if (!options.shared) return [];
67167
+ return parseOptions(options.shared, (item, key)=>{
67168
+ if ('string' != typeof item) throw new Error('Unexpected array in shared');
67169
+ return item !== key && isRequiredVersion(item) ? {
67170
+ import: key,
67171
+ requiredVersion: item
67172
+ } : {
67173
+ import: item
67174
+ };
67175
+ }, (item)=>item);
67176
+ }
66427
67177
  function getPaths(options) {
66428
67178
  return {
66429
67179
  runtimeTools: '@module-federation/runtime-tools',
@@ -66431,11 +67181,12 @@ function getPaths(options) {
66431
67181
  runtime: '@module-federation/runtime'
66432
67182
  };
66433
67183
  }
66434
- function getDefaultEntryRuntime(paths, options, compiler) {
67184
+ function getDefaultEntryRuntime(paths, options, compiler, treeshakeShareFallbacks) {
66435
67185
  const runtimePlugins = getRuntimePlugins(options);
66436
67186
  const remoteInfos = getRemoteInfos(options);
66437
67187
  const runtimePluginImports = [];
66438
67188
  const runtimePluginVars = [];
67189
+ const libraryType = options.library?.type || 'var';
66439
67190
  for(let i = 0; i < runtimePlugins.length; i++){
66440
67191
  const runtimePluginVar = `__module_federation_runtime_plugin_${i}__`;
66441
67192
  const pluginSpec = runtimePlugins[i];
@@ -66452,215 +67203,12 @@ function getDefaultEntryRuntime(paths, options, compiler) {
66452
67203
  `const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
66453
67204
  `const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
66454
67205
  `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? 'version-first')}`,
66455
- '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,"consumesLoadingModuleToHandlerMapping",()=>{const consumesLoadingModuleToHandlerMapping={};for(let[moduleId,data]of Object.entries(consumesLoadingModuleToConsumeDataMapping)){consumesLoadingModuleToHandlerMapping[moduleId]={getter:data.fallback,shareInfo:{shareConfig:{fixedDependencies:false,requiredVersion:data.requiredVersion,strictVersion:data.strictVersion,singleton:data.singleton,eager:data.eager},scope:[data.shareScope]},shareKey:data.shareKey}}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}=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};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.runtime.init(__webpack_require__.federation.initOptions);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})}}'
67206
+ `const __module_federation_share_fallbacks__ = ${JSON.stringify(treeshakeShareFallbacks)}`,
67207
+ `const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
67208
+ '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,treeshakeGetter: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,treeshake:__webpack_require__.federation.sharedFallback?{get:data.fallback,strategy:data.treeshakeStrategy}: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,treeshakeStrategy}=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,treeshake:treeshakeStrategy?{strategy:treeshakeStrategy}: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})}}'
66456
67209
  ].join(';');
66457
67210
  return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
66458
67211
  }
66459
- function ShareRuntimePlugin_define_property(obj, key, value) {
66460
- if (key in obj) Object.defineProperty(obj, key, {
66461
- value: value,
66462
- enumerable: true,
66463
- configurable: true,
66464
- writable: true
66465
- });
66466
- else obj[key] = value;
66467
- return obj;
66468
- }
66469
- const compilerSet = new WeakSet();
66470
- function isSingleton(compiler) {
66471
- return compilerSet.has(compiler);
66472
- }
66473
- function setSingleton(compiler) {
66474
- compilerSet.add(compiler);
66475
- }
66476
- class ShareRuntimePlugin extends RspackBuiltinPlugin {
66477
- raw(compiler) {
66478
- if (isSingleton(compiler)) return;
66479
- setSingleton(compiler);
66480
- return createBuiltinPlugin(this.name, this.enhanced);
66481
- }
66482
- constructor(enhanced = false){
66483
- 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;
66484
- }
66485
- }
66486
- function ConsumeSharedPlugin_define_property(obj, key, value) {
66487
- if (key in obj) Object.defineProperty(obj, key, {
66488
- value: value,
66489
- enumerable: true,
66490
- configurable: true,
66491
- writable: true
66492
- });
66493
- else obj[key] = value;
66494
- return obj;
66495
- }
66496
- class ConsumeSharedPlugin extends RspackBuiltinPlugin {
66497
- raw(compiler) {
66498
- new ShareRuntimePlugin(this._options.enhanced).apply(compiler);
66499
- const rawOptions = {
66500
- consumes: this._options.consumes.map(([key, v])=>({
66501
- key,
66502
- ...v
66503
- })),
66504
- enhanced: this._options.enhanced
66505
- };
66506
- return createBuiltinPlugin(this.name, rawOptions);
66507
- }
66508
- constructor(options){
66509
- super(), ConsumeSharedPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ConsumeSharedPlugin), ConsumeSharedPlugin_define_property(this, "_options", void 0);
66510
- this._options = {
66511
- consumes: parseOptions(options.consumes, (item, key)=>{
66512
- if (Array.isArray(item)) throw new Error('Unexpected array in options');
66513
- const result = item !== key && isRequiredVersion(item) ? {
66514
- import: key,
66515
- shareScope: options.shareScope || 'default',
66516
- shareKey: key,
66517
- requiredVersion: item,
66518
- strictVersion: true,
66519
- packageName: void 0,
66520
- singleton: false,
66521
- eager: false
66522
- } : {
66523
- import: key,
66524
- shareScope: options.shareScope || 'default',
66525
- shareKey: key,
66526
- requiredVersion: void 0,
66527
- packageName: void 0,
66528
- strictVersion: false,
66529
- singleton: false,
66530
- eager: false
66531
- };
66532
- return result;
66533
- }, (item, key)=>({
66534
- import: false === item.import ? void 0 : item.import || key,
66535
- shareScope: item.shareScope || options.shareScope || 'default',
66536
- shareKey: item.shareKey || key,
66537
- requiredVersion: item.requiredVersion,
66538
- strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : false !== item.import && !item.singleton,
66539
- packageName: item.packageName,
66540
- singleton: !!item.singleton,
66541
- eager: !!item.eager
66542
- })),
66543
- enhanced: options.enhanced ?? false
66544
- };
66545
- }
66546
- }
66547
- function ProvideSharedPlugin_define_property(obj, key, value) {
66548
- if (key in obj) Object.defineProperty(obj, key, {
66549
- value: value,
66550
- enumerable: true,
66551
- configurable: true,
66552
- writable: true
66553
- });
66554
- else obj[key] = value;
66555
- return obj;
66556
- }
66557
- class ProvideSharedPlugin extends RspackBuiltinPlugin {
66558
- raw(compiler) {
66559
- new ShareRuntimePlugin(this._enhanced ?? false).apply(compiler);
66560
- const rawOptions = this._provides.map(([key, v])=>({
66561
- key,
66562
- ...v
66563
- }));
66564
- return createBuiltinPlugin(this.name, rawOptions);
66565
- }
66566
- constructor(options){
66567
- 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);
66568
- this._provides = parseOptions(options.provides, (item)=>{
66569
- if (Array.isArray(item)) throw new Error('Unexpected array of provides');
66570
- return {
66571
- shareKey: item,
66572
- version: void 0,
66573
- shareScope: options.shareScope || 'default',
66574
- eager: false
66575
- };
66576
- }, (item)=>{
66577
- const raw = {
66578
- shareKey: item.shareKey,
66579
- version: item.version,
66580
- shareScope: item.shareScope || options.shareScope || 'default',
66581
- eager: !!item.eager
66582
- };
66583
- if (options.enhanced) {
66584
- const enhancedItem = item;
66585
- return {
66586
- ...raw,
66587
- singleton: enhancedItem.singleton,
66588
- requiredVersion: enhancedItem.requiredVersion,
66589
- strictVersion: enhancedItem.strictVersion
66590
- };
66591
- }
66592
- return raw;
66593
- });
66594
- this._enhanced = options.enhanced;
66595
- }
66596
- }
66597
- function SharePlugin_define_property(obj, key, value) {
66598
- if (key in obj) Object.defineProperty(obj, key, {
66599
- value: value,
66600
- enumerable: true,
66601
- configurable: true,
66602
- writable: true
66603
- });
66604
- else obj[key] = value;
66605
- return obj;
66606
- }
66607
- class SharePlugin {
66608
- apply(compiler) {
66609
- new ConsumeSharedPlugin({
66610
- shareScope: this._shareScope,
66611
- consumes: this._consumes,
66612
- enhanced: this._enhanced
66613
- }).apply(compiler);
66614
- new ProvideSharedPlugin({
66615
- shareScope: this._shareScope,
66616
- provides: this._provides,
66617
- enhanced: this._enhanced
66618
- }).apply(compiler);
66619
- }
66620
- constructor(options){
66621
- SharePlugin_define_property(this, "_shareScope", void 0);
66622
- SharePlugin_define_property(this, "_consumes", void 0);
66623
- SharePlugin_define_property(this, "_provides", void 0);
66624
- SharePlugin_define_property(this, "_enhanced", void 0);
66625
- const sharedOptions = parseOptions(options.shared, (item, key)=>{
66626
- if ('string' != typeof item) throw new Error('Unexpected array in shared');
66627
- const config = item !== key && isRequiredVersion(item) ? {
66628
- import: key,
66629
- requiredVersion: item
66630
- } : {
66631
- import: item
66632
- };
66633
- return config;
66634
- }, (item)=>item);
66635
- const consumes = sharedOptions.map(([key, options])=>({
66636
- [key]: {
66637
- import: options.import,
66638
- shareKey: options.shareKey || key,
66639
- shareScope: options.shareScope,
66640
- requiredVersion: options.requiredVersion,
66641
- strictVersion: options.strictVersion,
66642
- singleton: options.singleton,
66643
- packageName: options.packageName,
66644
- eager: options.eager
66645
- }
66646
- }));
66647
- const provides = sharedOptions.filter(([, options])=>false !== options.import).map(([key, options])=>({
66648
- [options.import || key]: {
66649
- shareKey: options.shareKey || key,
66650
- shareScope: options.shareScope,
66651
- version: options.version,
66652
- eager: options.eager,
66653
- singleton: options.singleton,
66654
- requiredVersion: options.requiredVersion,
66655
- strictVersion: options.strictVersion
66656
- }
66657
- }));
66658
- this._shareScope = options.shareScope;
66659
- this._consumes = consumes;
66660
- this._provides = provides;
66661
- this._enhanced = options.enhanced ?? false;
66662
- }
66663
- }
66664
67212
  function ContainerPlugin_define_property(obj, key, value) {
66665
67213
  if (key in obj) Object.defineProperty(obj, key, {
66666
67214
  value: value,
@@ -66696,7 +67244,7 @@ class ContainerPlugin extends RspackBuiltinPlugin {
66696
67244
  name: options.name,
66697
67245
  shareScope: options.shareScope || 'default',
66698
67246
  library: options.library || {
66699
- type: 'var',
67247
+ type: 'global',
66700
67248
  name: options.name
66701
67249
  },
66702
67250
  runtime: options.runtime,
@@ -66730,19 +67278,14 @@ class ContainerReferencePlugin extends RspackBuiltinPlugin {
66730
67278
  raw(compiler) {
66731
67279
  const { remoteType, remotes } = this._options;
66732
67280
  const remoteExternals = {};
66733
- const importExternals = {};
66734
67281
  for (const [key, config] of remotes){
66735
67282
  let i = 0;
66736
- for (const external of config.external){
66737
- if (external.startsWith('internal ')) continue;
66738
- const request = `webpack/container/reference/${key}${i ? `/fallback-${i}` : ''}`;
66739
- if (('module' === remoteType || 'module-import' === remoteType) && external.startsWith('.')) importExternals[request] = external;
66740
- else remoteExternals[request] = external;
67283
+ for (const external of config.external)if (!external.startsWith('internal ')) {
67284
+ remoteExternals[`webpack/container/reference/${key}${i ? `/fallback-${i}` : ''}`] = external;
66741
67285
  i++;
66742
67286
  }
66743
67287
  }
66744
67288
  new ExternalsPlugin(remoteType, remoteExternals, true).apply(compiler);
66745
- if (Object.keys(importExternals).length > 0) new ExternalsPlugin('import', importExternals, true).apply(compiler);
66746
67289
  new ShareRuntimePlugin(this._options.enhanced).apply(compiler);
66747
67290
  const rawOptions = {
66748
67291
  remoteType: this._options.remoteType,
@@ -66838,7 +67381,7 @@ function transformSync(source, options) {
66838
67381
  const _options = JSON.stringify(options || {});
66839
67382
  return external_rspack_wasi_browser_js_["default"].transformSync(source, _options);
66840
67383
  }
66841
- const exports_rspackVersion = "1.7.1-canary-becc2931-20260103070024";
67384
+ const exports_rspackVersion = "1.7.1-canary-cf4486a4-20260104102432";
66842
67385
  const exports_version = "5.75.0";
66843
67386
  const exports_WebpackError = Error;
66844
67387
  const sources = __webpack_require__("../../node_modules/.pnpm/webpack-sources@3.3.3_patch_hash=b2a26650f08a2359d0a3cd81fa6fa272aa7441a28dd7e601792da5ed5d2b4aee/node_modules/webpack-sources/lib/index.js");
@@ -66889,6 +67432,7 @@ const container = {
66889
67432
  };
66890
67433
  const sharing = {
66891
67434
  ProvideSharedPlugin: ProvideSharedPlugin,
67435
+ TreeShakeSharedPlugin: TreeShakeSharedPlugin,
66892
67436
  ConsumeSharedPlugin: ConsumeSharedPlugin,
66893
67437
  SharePlugin: SharePlugin
66894
67438
  };
@@ -66998,7 +67542,7 @@ function createCompiler(userOptions) {
66998
67542
  function isMultiRspackOptions(o) {
66999
67543
  return Array.isArray(o);
67000
67544
  }
67001
- function rspack(options, callback) {
67545
+ function rspack_rspack(options, callback) {
67002
67546
  try {
67003
67547
  if (isMultiRspackOptions(options)) for (const option of options)validateRspackConfig(option);
67004
67548
  else validateRspackConfig(options);
@@ -67048,7 +67592,7 @@ function rspack(options, callback) {
67048
67592
  return compiler;
67049
67593
  }
67050
67594
  }
67051
- const src_fn = Object.assign(rspack, exports_namespaceObject);
67595
+ const src_fn = Object.assign(rspack_rspack, exports_namespaceObject);
67052
67596
  src_fn.rspack = src_fn;
67053
67597
  src_fn.webpack = src_fn;
67054
67598
  const src_rspack_0 = src_fn;