@rspack-canary/browser 1.7.2-canary-6ee0d4b1-20260111191401 → 1.7.2-canary-cad7e7a3-20260113065652

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