@rspack-canary/core 1.6.5-canary-1b7f543c-20251121112112 → 1.6.5-canary-5c09e49d-20251121173820

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.js CHANGED
@@ -4706,6 +4706,10 @@ Plugins which provide custom chunk loading types must call EnableChunkLoadingPlu
4706
4706
  }
4707
4707
  }(tag);
4708
4708
  if (!tagSrc) return;
4709
+ try {
4710
+ let url = new URL(tagSrc);
4711
+ if (("http:" === url.protocol || "https:" === url.protocol) && (!publicPath || !tagSrc.startsWith(publicPath))) return;
4712
+ } catch (_) {}
4709
4713
  let src = (0, external_node_path_namespaceObject.relative)(publicPath, decodeURIComponent(tagSrc));
4710
4714
  tag.attributes.integrity = this.getIntegrityChecksumForAsset(src) || function(hashFuncNames, source) {
4711
4715
  let { createHash } = __webpack_require__("node:crypto");
@@ -5736,7 +5740,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
5736
5740
  }, applyExperimentsDefaults = (experiments, { development })=>{
5737
5741
  F(experiments, "cache", ()=>development), D(experiments, "futureDefaults", !1), D(experiments, "lazyCompilation", !1), D(experiments, "asyncWebAssembly", experiments.futureDefaults), D(experiments, "css", !!experiments.futureDefaults || void 0), D(experiments, "topLevelAwait", !0), D(experiments, "deferImport", !1), D(experiments, "buildHttp", void 0), experiments.buildHttp && "object" == typeof experiments.buildHttp && D(experiments.buildHttp, "upgrade", !1), D(experiments, "incremental", {}), "object" == typeof experiments.incremental && (D(experiments.incremental, "silent", !0), D(experiments.incremental, "make", !0), D(experiments.incremental, "inferAsyncModules", !0), D(experiments.incremental, "providedExports", !0), D(experiments.incremental, "dependenciesDiagnostics", !0), D(experiments.incremental, "sideEffects", !0), D(experiments.incremental, "buildChunkGraph", !1), D(experiments.incremental, "moduleIds", !0), D(experiments.incremental, "chunkIds", !0), D(experiments.incremental, "modulesHashes", !0), D(experiments.incremental, "modulesCodegen", !0), D(experiments.incremental, "modulesRuntimeRequirements", !0), D(experiments.incremental, "chunksRuntimeRequirements", !0), D(experiments.incremental, "chunksHashes", !0), D(experiments.incremental, "chunksRender", !0), D(experiments.incremental, "emitAssets", !0)), D(experiments, "rspackFuture", {}), D(experiments, "parallelCodeSplitting", !1), D(experiments, "parallelLoader", !1), D(experiments, "useInputFileSystem", !1), D(experiments, "inlineConst", !1), D(experiments, "inlineEnum", !1), D(experiments, "typeReexportsPresence", !1), D(experiments, "lazyBarrel", !0);
5738
5742
  }, applybundlerInfoDefaults = (rspackFuture, library)=>{
5739
- "object" == typeof rspackFuture && (D(rspackFuture, "bundlerInfo", {}), "object" == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, "version", "1.6.5-canary-1b7f543c-20251121112112"), D(rspackFuture.bundlerInfo, "bundler", "rspack"), D(rspackFuture.bundlerInfo, "force", !library)));
5743
+ "object" == typeof rspackFuture && (D(rspackFuture, "bundlerInfo", {}), "object" == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, "version", "1.6.5-canary-5c09e49d-20251121173820"), D(rspackFuture.bundlerInfo, "bundler", "rspack"), D(rspackFuture.bundlerInfo, "force", !library)));
5740
5744
  }, applySnapshotDefaults = (_snapshot, _env)=>{}, applyModuleDefaults = (module1, { cache, asyncWebAssembly, css, targetProperties, mode, uniqueName, usedExports, inlineConst, deferImport })=>{
5741
5745
  if (assertNotNill(module1.parser), assertNotNill(module1.generator), cache ? D(module1, "unsafeCache", /[\\/]node_modules[\\/]/) : D(module1, "unsafeCache", !1), F(module1.parser, "asset", ()=>({})), assertNotNill(module1.parser.asset), F(module1.parser.asset, "dataUrlCondition", ()=>({})), "object" == typeof module1.parser.asset.dataUrlCondition && D(module1.parser.asset.dataUrlCondition, "maxSize", 8096), F(module1.parser, "javascript", ()=>({})), assertNotNill(module1.parser.javascript), ((parserOptions, { usedExports, inlineConst, deferImport })=>{
5742
5746
  D(parserOptions, "dynamicImportMode", "lazy"), D(parserOptions, "dynamicImportPrefetch", !1), D(parserOptions, "dynamicImportPreload", !1), D(parserOptions, "url", !0), D(parserOptions, "exprContextCritical", !0), D(parserOptions, "unknownContextCritical", !0), D(parserOptions, "wrappedContextCritical", !1), D(parserOptions, "wrappedContextRegExp", /.*/), D(parserOptions, "strictExportPresence", !1), D(parserOptions, "requireAsExpression", !0), D(parserOptions, "requireDynamic", !0), D(parserOptions, "requireResolve", !0), D(parserOptions, "commonjs", !0), D(parserOptions, "importDynamic", !0), D(parserOptions, "worker", [
@@ -7386,7 +7390,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
7386
7390
  });
7387
7391
  }
7388
7392
  }
7389
- let CORE_VERSION = "1.6.5-canary-1b7f543c-20251121112112", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
7393
+ let CORE_VERSION = "1.6.5-canary-5c09e49d-20251121173820", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
7390
7394
 
7391
7395
  Help:
7392
7396
  Looks like you are using a custom binding (via environment variable 'RSPACK_BINDING=${process.env.RSPACK_BINDING}').
@@ -8686,7 +8690,7 @@ Help:
8686
8690
  obj.children = this.stats.map((stat, idx)=>{
8687
8691
  let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
8688
8692
  return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
8689
- }), childOptions.version && (obj.rspackVersion = "1.6.5-canary-1b7f543c-20251121112112", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(""));
8693
+ }), childOptions.version && (obj.rspackVersion = "1.6.5-canary-5c09e49d-20251121173820", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(""));
8690
8694
  let mapError = (j, obj)=>({
8691
8695
  ...obj,
8692
8696
  compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
@@ -9585,7 +9589,7 @@ Help:
9585
9589
  object.hash = context.getStatsCompilation(compilation).hash;
9586
9590
  },
9587
9591
  version: (object)=>{
9588
- object.version = "5.75.0", object.rspackVersion = "1.6.5-canary-1b7f543c-20251121112112";
9592
+ object.version = "5.75.0", object.rspackVersion = "1.6.5-canary-5c09e49d-20251121173820";
9589
9593
  },
9590
9594
  env: (object, _compilation, _context, { _env })=>{
9591
9595
  object.env = _env;
@@ -11430,116 +11434,30 @@ Help:
11430
11434
  function isRequiredVersion(str) {
11431
11435
  return VERSION_PATTERN_REGEXP.test(str);
11432
11436
  }
11433
- let encodeName = function(name, prefix = "", withExt = !1) {
11434
- return `${prefix}${name.replace(/@/g, "scope_").replace(/-/g, "_").replace(/\//g, "__").replace(/\./g, "")}${withExt ? ".js" : ""}`;
11435
- }, parseOptions = (options, normalizeSimple, normalizeOptions)=>{
11436
- let items = [];
11437
- var options1 = options, normalizeSimple1 = normalizeSimple, normalizeOptions1 = normalizeOptions, fn = (key, value)=>{
11438
- items.push([
11439
- key,
11440
- value
11441
- ]);
11442
- };
11443
- let object = (obj)=>{
11444
- for (let [key, value] of Object.entries(obj))"string" == typeof value || Array.isArray(value) ? fn(key, normalizeSimple1(value, key)) : fn(key, normalizeOptions1(value, key));
11445
- };
11446
- if (options1) if (Array.isArray(options1)) {
11447
- var items1 = options1;
11448
- for (let item of items1)if ("string" == typeof item) fn(item, normalizeSimple1(item, item));
11449
- else if (item && "object" == typeof item) object(item);
11450
- else throw Error("Unexpected options format");
11451
- } else if ("object" == typeof options1) object(options1);
11452
- else throw Error("Unexpected options format");
11453
- return items;
11454
- }, MANIFEST_FILE_NAME = "mf-manifest.json", STATS_FILE_NAME = "mf-stats.json", JSON_EXT = ".json";
11437
+ let MANIFEST_FILE_NAME = "mf-manifest.json", STATS_FILE_NAME = "mf-stats.json", JSON_EXT = ".json";
11455
11438
  function isPlainObject(value) {
11456
11439
  return !!value && "object" == typeof value && !Array.isArray(value);
11457
11440
  }
11458
- function getFileName(manifestOptions) {
11459
- var name;
11460
- if (!manifestOptions) return {
11461
- statsFileName: STATS_FILE_NAME,
11462
- manifestFileName: MANIFEST_FILE_NAME
11463
- };
11464
- let filePath = "boolean" == typeof manifestOptions ? "" : manifestOptions.filePath || "", fileName = "boolean" == typeof manifestOptions ? "" : manifestOptions.fileName || "", manifestFileName = fileName ? (name = fileName).endsWith(JSON_EXT) ? name : `${name}${JSON_EXT}` : MANIFEST_FILE_NAME, statsFileName = fileName ? manifestFileName.replace(JSON_EXT, `-stats${JSON_EXT}`) : STATS_FILE_NAME;
11465
- return {
11466
- statsFileName: (0, external_node_path_namespaceObject.join)(filePath, statsFileName),
11467
- manifestFileName: (0, external_node_path_namespaceObject.join)(filePath, manifestFileName)
11468
- };
11469
- }
11470
11441
  class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
11471
11442
  name = binding_.BuiltinPluginName.ModuleFederationManifestPlugin;
11472
11443
  opts;
11473
11444
  constructor(opts){
11474
- var mfConfig;
11475
- let manifestOptions, containerName, globalName, remoteAliasMap, manifestExposes, manifestShared;
11476
- super(), this.opts = (manifestOptions = !0 === (mfConfig = opts).manifest ? {} : {
11477
- ...mfConfig.manifest
11478
- }, containerName = mfConfig.name, globalName = function(library) {
11479
- if (!library) return;
11480
- let libName = library.name;
11481
- if (libName) {
11482
- if ("string" == typeof libName) return libName;
11483
- if (Array.isArray(libName)) return libName[0];
11484
- if ("object" == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
11485
- }
11486
- }(mfConfig.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(mfConfig)).reduce((sum, cur)=>{
11487
- if (cur[1].length > 1) return sum;
11488
- let { entry, alias, name } = cur[1][0];
11489
- return entry && name && (sum[alias] = {
11490
- name,
11491
- entry
11492
- }), sum;
11493
- }, {}), manifestExposes = function(exposes) {
11494
- if (!exposes) return;
11495
- let result = parseOptions(exposes, (value)=>({
11496
- import: Array.isArray(value) ? value : [
11497
- value
11498
- ],
11499
- name: void 0
11500
- }), (value)=>({
11501
- import: Array.isArray(value.import) ? value.import : [
11502
- value.import
11503
- ],
11504
- name: value.name ?? void 0
11505
- })).map(([exposeKey, info])=>{
11506
- let exposeName = info.name ?? exposeKey.replace(/^\.\//, "");
11507
- return {
11508
- path: exposeKey,
11509
- name: exposeName
11510
- };
11511
- });
11512
- return result.length > 0 ? result : void 0;
11513
- }(mfConfig.exposes), void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes), manifestShared = function(shared) {
11514
- if (!shared) return;
11515
- let result = parseOptions(shared, (item, key)=>{
11516
- if ("string" != typeof item) throw Error("Unexpected array in shared");
11517
- return item !== key && isRequiredVersion(item) ? {
11518
- import: key,
11519
- requiredVersion: item
11520
- } : {
11521
- import: item
11522
- };
11523
- }, (item)=>item).map(([key, config])=>{
11524
- let name = config.shareKey || key, version = "string" == typeof config.version ? config.version : void 0;
11525
- return {
11526
- name,
11527
- version,
11528
- requiredVersion: "string" == typeof config.requiredVersion ? config.requiredVersion : void 0,
11529
- singleton: config.singleton
11530
- };
11531
- });
11532
- return result.length > 0 ? result : void 0;
11533
- }(mfConfig.shared), void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), {
11534
- ...manifestOptions,
11535
- remoteAliasMap,
11536
- globalName,
11537
- name: containerName
11538
- });
11445
+ super(), this.opts = opts;
11539
11446
  }
11540
11447
  raw(compiler) {
11541
11448
  var isDev;
11542
- let pkg, buildVersion, { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts, { statsFileName, manifestFileName } = getFileName(this.opts), rawOptions = {
11449
+ let pkg, buildVersion, { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts, { statsFileName, manifestFileName } = function(manifestOptions) {
11450
+ var name;
11451
+ if (!manifestOptions) return {
11452
+ statsFileName: STATS_FILE_NAME,
11453
+ manifestFileName: MANIFEST_FILE_NAME
11454
+ };
11455
+ let filePath = "boolean" == typeof manifestOptions ? "" : manifestOptions.filePath || "", fileName = "boolean" == typeof manifestOptions ? "" : manifestOptions.fileName || "", manifestFileName = fileName ? (name = fileName).endsWith(JSON_EXT) ? name : `${name}${JSON_EXT}` : MANIFEST_FILE_NAME, statsFileName = fileName ? manifestFileName.replace(JSON_EXT, `-stats${JSON_EXT}`) : STATS_FILE_NAME;
11456
+ return {
11457
+ statsFileName: (0, external_node_path_namespaceObject.join)(filePath, statsFileName),
11458
+ manifestFileName: (0, external_node_path_namespaceObject.join)(filePath, manifestFileName)
11459
+ };
11460
+ }(this.opts), rawOptions = {
11543
11461
  name: this.opts.name,
11544
11462
  globalName: this.opts.globalName,
11545
11463
  fileName,
@@ -11574,6 +11492,81 @@ Help:
11574
11492
  return createBuiltinPlugin(this.name, rawOptions);
11575
11493
  }
11576
11494
  }
11495
+ let ModuleFederationRuntimePlugin = base_create(binding_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options), parseOptions = (options, normalizeSimple, normalizeOptions)=>{
11496
+ let items = [];
11497
+ var options1 = options, normalizeSimple1 = normalizeSimple, normalizeOptions1 = normalizeOptions, fn = (key, value)=>{
11498
+ items.push([
11499
+ key,
11500
+ value
11501
+ ]);
11502
+ };
11503
+ let object = (obj)=>{
11504
+ for (let [key, value] of Object.entries(obj))"string" == typeof value || Array.isArray(value) ? fn(key, normalizeSimple1(value, key)) : fn(key, normalizeOptions1(value, key));
11505
+ };
11506
+ if (options1) if (Array.isArray(options1)) {
11507
+ var items1 = options1;
11508
+ for (let item of items1)if ("string" == typeof item) fn(item, normalizeSimple1(item, item));
11509
+ else if (item && "object" == typeof item) object(item);
11510
+ else throw Error("Unexpected options format");
11511
+ } else if ("object" == typeof options1) object(options1);
11512
+ else throw Error("Unexpected options format");
11513
+ return items;
11514
+ };
11515
+ function getRemoteInfos(options) {
11516
+ if (!options.remotes) return {};
11517
+ let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
11518
+ external: Array.isArray(item) ? item : [
11519
+ item
11520
+ ],
11521
+ shareScope: options.shareScope || "default"
11522
+ }), (item)=>({
11523
+ external: Array.isArray(item.external) ? item.external : [
11524
+ item.external
11525
+ ],
11526
+ shareScope: item.shareScope || options.shareScope || "default"
11527
+ })), remoteInfos = {};
11528
+ for (let [key, config] of remotes)for (let external of config.external){
11529
+ let [externalType, externalRequest] = function(external) {
11530
+ let result = function(external) {
11531
+ if (/^[a-z0-9-]+ /.test(external)) {
11532
+ let idx = external.indexOf(" ");
11533
+ return [
11534
+ external.slice(0, idx),
11535
+ external.slice(idx + 1)
11536
+ ];
11537
+ }
11538
+ return null;
11539
+ }(external);
11540
+ return null === result ? [
11541
+ remoteType,
11542
+ external
11543
+ ] : result;
11544
+ }(external);
11545
+ if (remoteInfos[key] ??= [], "script" === externalType) {
11546
+ let [url, global] = function(urlAndGlobal) {
11547
+ let index = urlAndGlobal.indexOf("@");
11548
+ return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
11549
+ urlAndGlobal.substring(index + 1),
11550
+ urlAndGlobal.substring(0, index)
11551
+ ];
11552
+ }(externalRequest);
11553
+ remoteInfos[key].push({
11554
+ alias: key,
11555
+ name: global,
11556
+ entry: url,
11557
+ externalType,
11558
+ shareScope: config.shareScope
11559
+ });
11560
+ } else remoteInfos[key].push({
11561
+ alias: key,
11562
+ name: void 0,
11563
+ entry: void 0,
11564
+ externalType,
11565
+ shareScope: config.shareScope
11566
+ });
11567
+ }
11568
+ return remoteInfos;
11569
+ }
11577
11570
  let compilerSet = new WeakSet();
11578
11571
  class ShareRuntimePlugin extends RspackBuiltinPlugin {
11579
11572
  enhanced;
@@ -11586,45 +11579,42 @@ Help:
11586
11579
  if (compiler1 = compiler, !compilerSet.has(compiler1)) return compiler2 = compiler, compilerSet.add(compiler2), createBuiltinPlugin(this.name, this.enhanced);
11587
11580
  }
11588
11581
  }
11589
- function normalizeConsumeShareOptions(consumes, shareScope) {
11590
- return parseOptions(consumes, (item, key)=>{
11591
- if (Array.isArray(item)) throw Error("Unexpected array in options");
11592
- return item !== key && isRequiredVersion(item) ? {
11593
- import: key,
11594
- shareScope: shareScope || "default",
11595
- shareKey: key,
11596
- requiredVersion: item,
11597
- strictVersion: !0,
11598
- packageName: void 0,
11599
- singleton: !1,
11600
- eager: !1
11601
- } : {
11602
- import: key,
11603
- shareScope: shareScope || "default",
11604
- shareKey: key,
11605
- requiredVersion: void 0,
11606
- packageName: void 0,
11607
- strictVersion: !1,
11608
- singleton: !1,
11609
- eager: !1
11610
- };
11611
- }, (item, key)=>({
11612
- import: !1 === item.import ? void 0 : item.import || key,
11613
- shareScope: item.shareScope || shareScope || "default",
11614
- shareKey: item.shareKey || key,
11615
- requiredVersion: item.requiredVersion,
11616
- strictVersion: "boolean" == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
11617
- packageName: item.packageName,
11618
- singleton: !!item.singleton,
11619
- eager: !!item.eager
11620
- }));
11621
- }
11622
11582
  class ConsumeSharedPlugin extends RspackBuiltinPlugin {
11623
11583
  name = binding_.BuiltinPluginName.ConsumeSharedPlugin;
11624
11584
  _options;
11625
11585
  constructor(options){
11626
11586
  super(), this._options = {
11627
- consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
11587
+ consumes: parseOptions(options.consumes, (item, key)=>{
11588
+ if (Array.isArray(item)) throw Error("Unexpected array in options");
11589
+ return item !== key && isRequiredVersion(item) ? {
11590
+ import: key,
11591
+ shareScope: options.shareScope || "default",
11592
+ shareKey: key,
11593
+ requiredVersion: item,
11594
+ strictVersion: !0,
11595
+ packageName: void 0,
11596
+ singleton: !1,
11597
+ eager: !1
11598
+ } : {
11599
+ import: key,
11600
+ shareScope: options.shareScope || "default",
11601
+ shareKey: key,
11602
+ requiredVersion: void 0,
11603
+ packageName: void 0,
11604
+ strictVersion: !1,
11605
+ singleton: !1,
11606
+ eager: !1
11607
+ };
11608
+ }, (item, key)=>({
11609
+ import: !1 === item.import ? void 0 : item.import || key,
11610
+ shareScope: item.shareScope || options.shareScope || "default",
11611
+ shareKey: item.shareKey || key,
11612
+ requiredVersion: item.requiredVersion,
11613
+ strictVersion: "boolean" == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
11614
+ packageName: item.packageName,
11615
+ singleton: !!item.singleton,
11616
+ eager: !!item.eager
11617
+ })),
11628
11618
  enhanced: options.enhanced ?? !1
11629
11619
  };
11630
11620
  }
@@ -11640,59 +11630,33 @@ Help:
11640
11630
  return createBuiltinPlugin(this.name, rawOptions);
11641
11631
  }
11642
11632
  }
11643
- class OptimizeDependencyReferencedExportsPlugin extends RspackBuiltinPlugin {
11644
- name = binding_.BuiltinPluginName.OptimizeDependencyReferencedExportsPlugin;
11645
- sharedOptions;
11646
- injectUsedExports;
11647
- manifestOptions;
11648
- constructor(sharedOptions, injectUsedExports, manifestOptions){
11649
- super(), this.sharedOptions = sharedOptions, this.injectUsedExports = injectUsedExports ?? !0, this.manifestOptions = manifestOptions ?? {};
11650
- }
11651
- buildOptions() {
11652
- let shared = this.sharedOptions.map(([shareKey, config])=>({
11653
- shareKey,
11654
- treeshake: !!config.treeshake,
11655
- usedExports: config.usedExports
11656
- })), { manifestFileName, statsFileName } = getFileName(this.manifestOptions);
11657
- return {
11658
- shared,
11659
- injectUsedExports: this.injectUsedExports,
11660
- manifestFileName,
11661
- statsFileName
11662
- };
11663
- }
11664
- raw() {
11665
- if (this.sharedOptions.length) return createBuiltinPlugin(this.name, this.buildOptions());
11666
- }
11667
- }
11668
11633
  class ProvideSharedPlugin extends RspackBuiltinPlugin {
11669
11634
  name = binding_.BuiltinPluginName.ProvideSharedPlugin;
11670
11635
  _provides;
11671
11636
  _enhanced;
11672
11637
  constructor(options){
11673
- var options1, shareScope, enhanced;
11674
- super(), this._provides = (options1 = options.provides, shareScope = options.shareScope, enhanced = options.enhanced, parseOptions(options1, (item)=>{
11638
+ super(), this._provides = parseOptions(options.provides, (item)=>{
11675
11639
  if (Array.isArray(item)) throw Error("Unexpected array of provides");
11676
11640
  return {
11677
11641
  shareKey: item,
11678
11642
  version: void 0,
11679
- shareScope: shareScope || "default",
11643
+ shareScope: options.shareScope || "default",
11680
11644
  eager: !1
11681
11645
  };
11682
11646
  }, (item)=>{
11683
11647
  let raw = {
11684
11648
  shareKey: item.shareKey,
11685
11649
  version: item.version,
11686
- shareScope: item.shareScope || shareScope || "default",
11650
+ shareScope: item.shareScope || options.shareScope || "default",
11687
11651
  eager: !!item.eager
11688
11652
  };
11689
- return enhanced ? {
11653
+ return options.enhanced ? {
11690
11654
  ...raw,
11691
11655
  singleton: item.singleton,
11692
11656
  requiredVersion: item.requiredVersion,
11693
11657
  strictVersion: item.strictVersion
11694
11658
  } : raw;
11695
- })), this._enhanced = options.enhanced;
11659
+ }), this._enhanced = options.enhanced;
11696
11660
  }
11697
11661
  raw(compiler) {
11698
11662
  new ShareRuntimePlugin(this._enhanced ?? !1).apply(compiler);
@@ -11703,39 +11667,32 @@ Help:
11703
11667
  return createBuiltinPlugin(this.name, rawOptions);
11704
11668
  }
11705
11669
  }
11706
- function normalizeSharedOptions(shared) {
11707
- return parseOptions(shared, (item, key)=>{
11708
- if ("string" != typeof item) throw Error("Unexpected array in shared");
11709
- return item !== key && isRequiredVersion(item) ? {
11710
- import: key,
11711
- requiredVersion: item
11712
- } : {
11713
- import: item
11714
- };
11715
- }, (item)=>item);
11716
- }
11717
- function createConsumeShareOptions(normalizedSharedOptions) {
11718
- return normalizedSharedOptions.map(([key, options])=>({
11719
- [key]: {
11720
- import: options.import,
11721
- shareKey: options.shareKey || key,
11722
- shareScope: options.shareScope,
11723
- requiredVersion: options.requiredVersion,
11724
- strictVersion: options.strictVersion,
11725
- singleton: options.singleton,
11726
- packageName: options.packageName,
11727
- eager: options.eager
11728
- }
11729
- }));
11730
- }
11731
11670
  class SharePlugin {
11732
11671
  _shareScope;
11733
11672
  _consumes;
11734
11673
  _provides;
11735
11674
  _enhanced;
11736
- _sharedOptions;
11737
11675
  constructor(options){
11738
- const sharedOptions = normalizeSharedOptions(options.shared), consumes = createConsumeShareOptions(sharedOptions), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
11676
+ const sharedOptions = parseOptions(options.shared, (item, key)=>{
11677
+ if ("string" != typeof item) throw Error("Unexpected array in shared");
11678
+ return item !== key && isRequiredVersion(item) ? {
11679
+ import: key,
11680
+ requiredVersion: item
11681
+ } : {
11682
+ import: item
11683
+ };
11684
+ }, (item)=>item), consumes = sharedOptions.map(([key, options])=>({
11685
+ [key]: {
11686
+ import: options.import,
11687
+ shareKey: options.shareKey || key,
11688
+ shareScope: options.shareScope,
11689
+ requiredVersion: options.requiredVersion,
11690
+ strictVersion: options.strictVersion,
11691
+ singleton: options.singleton,
11692
+ packageName: options.packageName,
11693
+ eager: options.eager
11694
+ }
11695
+ })), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
11739
11696
  [options.import || key]: {
11740
11697
  shareKey: options.shareKey || key,
11741
11698
  shareScope: options.shareScope,
@@ -11746,7 +11703,7 @@ Help:
11746
11703
  strictVersion: options.strictVersion
11747
11704
  }
11748
11705
  }));
11749
- this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1, this._sharedOptions = sharedOptions;
11706
+ this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1;
11750
11707
  }
11751
11708
  apply(compiler) {
11752
11709
  new ConsumeSharedPlugin({
@@ -11758,345 +11715,8 @@ Help:
11758
11715
  provides: this._provides,
11759
11716
  enhanced: this._enhanced
11760
11717
  }).apply(compiler);
11761
- let treeshakeOptions = this._sharedOptions.filter(([, config])=>config.treeshake);
11762
- treeshakeOptions.length > 0 && new OptimizeDependencyReferencedExportsPlugin(treeshakeOptions).apply(compiler);
11763
11718
  }
11764
11719
  }
11765
- class CollectShareEntryPlugin extends RspackBuiltinPlugin {
11766
- name = binding_.BuiltinPluginName.CollectShareEntryPlugin;
11767
- sharedOptions;
11768
- _collectedEntries;
11769
- constructor(options){
11770
- super();
11771
- const { sharedOptions } = options;
11772
- this.sharedOptions = sharedOptions, this._collectedEntries = {};
11773
- }
11774
- getData() {
11775
- return this._collectedEntries;
11776
- }
11777
- getFilename() {
11778
- return "collect-share-entries.json";
11779
- }
11780
- apply(compiler) {
11781
- super.apply(compiler), compiler.hooks.thisCompilation.tap("Collect share entry", (compilation)=>{
11782
- compilation.hooks.processAssets.tapPromise({
11783
- name: "CollectShareEntry",
11784
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
11785
- }, async ()=>{
11786
- let filename = this.getFilename(), asset = compilation.getAsset(filename);
11787
- if (!asset) throw Error(`Can not get ${filename}`);
11788
- this._collectedEntries = JSON.parse(asset.source.source().toString()), compilation.deleteAsset(filename);
11789
- });
11790
- });
11791
- }
11792
- raw() {
11793
- let rawOptions = {
11794
- consumes: normalizeConsumeShareOptions(createConsumeShareOptions(this.sharedOptions)).map(([key, v])=>({
11795
- key,
11796
- ...v
11797
- })),
11798
- filename: this.getFilename()
11799
- };
11800
- return createBuiltinPlugin(this.name, rawOptions);
11801
- }
11802
- }
11803
- function assert(condition, msg) {
11804
- if (!condition) throw Error(msg);
11805
- }
11806
- class ShareContainerPlugin extends RspackBuiltinPlugin {
11807
- name = binding_.BuiltinPluginName.ShareContainerPlugin;
11808
- filename = "";
11809
- _options;
11810
- _shareName;
11811
- _globalName;
11812
- constructor(options){
11813
- super();
11814
- const { shareName, library, request, independentShareFileName } = options, version = options.version || "0.0.0";
11815
- this._globalName = encodeName(`${options.mfName}_${shareName}_${version}`);
11816
- const fileName = independentShareFileName || `${version}/share-entry.js`;
11817
- this._shareName = shareName, this._options = {
11818
- name: shareName,
11819
- request: request,
11820
- library: (library ? {
11821
- ...library,
11822
- name: this._globalName
11823
- } : void 0) || {
11824
- type: "var",
11825
- name: this._globalName
11826
- },
11827
- version,
11828
- fileName
11829
- };
11830
- }
11831
- getData() {
11832
- return [
11833
- this.name,
11834
- this._globalName
11835
- ];
11836
- }
11837
- raw(compiler) {
11838
- let { library } = this._options;
11839
- return compiler.options.output.enabledLibraryTypes.includes(library.type) || compiler.options.output.enabledLibraryTypes.push(library.type), createBuiltinPlugin(this.name, this._options);
11840
- }
11841
- apply(compiler) {
11842
- super.apply(compiler);
11843
- let shareName = this._shareName;
11844
- compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
11845
- compilation.hooks.processAssets.tapPromise({
11846
- name: "getShareContainerFile"
11847
- }, async ()=>{
11848
- assert(compilation.entrypoints.get(shareName), `Can not get shared ${shareName} entryPoint!`);
11849
- let remoteEntryNameChunk = compilation.namedChunks.get(shareName);
11850
- assert(remoteEntryNameChunk, `Can not get shared ${shareName} chunk!`);
11851
- let files = Array.from(remoteEntryNameChunk.files).filter((f)=>!f.includes(".hot-update") && !f.endsWith(".css"));
11852
- assert(files.length > 0, `no files found for shared ${shareName} chunk`), assert(1 === files.length, `shared ${shareName} chunk should not have multiple files!, current files: ${files.join(",")}`), this.filename = files[0];
11853
- });
11854
- });
11855
- }
11856
- }
11857
- let VIRTUAL_ENTRY = "./virtual-entry.js", VIRTUAL_ENTRY_NAME = "virtual-entry";
11858
- class VirtualEntryPlugin {
11859
- sharedOptions;
11860
- constructor(sharedOptions){
11861
- this.sharedOptions = sharedOptions;
11862
- }
11863
- createEntry() {
11864
- let { sharedOptions } = this;
11865
- return sharedOptions.reduce((acc, cur, index)=>`${acc}import shared_${index} from '${cur[0]}';\n`, "");
11866
- }
11867
- static entry() {
11868
- return {
11869
- [VIRTUAL_ENTRY_NAME]: VIRTUAL_ENTRY
11870
- };
11871
- }
11872
- apply(compiler) {
11873
- new compiler.rspack.experiments.VirtualModulesPlugin({
11874
- [VIRTUAL_ENTRY]: this.createEntry()
11875
- }).apply(compiler), compiler.hooks.thisCompilation.tap("RemoveVirtualEntryAsset", (compilation)=>{
11876
- compilation.hooks.processAssets.tapPromise({
11877
- name: "RemoveVirtualEntryAsset",
11878
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
11879
- }, async ()=>{
11880
- try {
11881
- let chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
11882
- chunk?.files.forEach((f)=>{
11883
- compilation.deleteAsset(f);
11884
- });
11885
- } catch (_e) {
11886
- console.error("Failed to remove virtual entry file!");
11887
- }
11888
- });
11889
- });
11890
- }
11891
- }
11892
- class IndependentSharePlugin {
11893
- mfName;
11894
- shared;
11895
- library;
11896
- sharedOptions;
11897
- outputDir;
11898
- outputFilePath;
11899
- plugins;
11900
- compilers = new Map();
11901
- treeshake;
11902
- manifest;
11903
- buildAssets = {};
11904
- injectUsedExports;
11905
- name = "IndependentSharePlugin";
11906
- constructor(options){
11907
- const { outputDir, outputFilePath, plugins, treeshake, shared, name, manifest, injectUsedExports, library } = options;
11908
- this.shared = shared, this.mfName = name, this.outputDir = outputFilePath ? "" : outputDir || "independent-packages", this.outputFilePath = outputFilePath, this.plugins = plugins || [], this.treeshake = treeshake, this.manifest = manifest, this.injectUsedExports = injectUsedExports ?? !0, this.library = library, this.sharedOptions = parseOptions(shared, (item, key)=>{
11909
- if ("string" != typeof item) throw Error(`Unexpected array in shared configuration for key "${key}"`);
11910
- return item !== key && isRequiredVersion(item) ? {
11911
- import: key,
11912
- requiredVersion: item
11913
- } : {
11914
- import: item
11915
- };
11916
- }, (item)=>item);
11917
- }
11918
- apply(compiler) {
11919
- compiler.hooks.beforeRun.tapAsync("IndependentSharePlugin", async (compiler, callback)=>{
11920
- await this.createIndependentCompilers(compiler), callback();
11921
- }), compiler.hooks.shutdown.tapAsync("IndependentSharePlugin", (callback)=>{
11922
- this.cleanup(), console.log("cleanup"), callback();
11923
- }), compiler.hooks.compilation.tap("IndependentSharePlugin", (compilation)=>{
11924
- compilation.hooks.processAssets.tapPromise({
11925
- name: "injectBuildAssets",
11926
- stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
11927
- }, async ()=>{
11928
- if (!this.manifest) return;
11929
- let { statsFileName } = getFileName(this.manifest), stats = compilation.getAsset(statsFileName);
11930
- if (!stats) return;
11931
- let statsContent = JSON.parse(stats.source.source().toString()), { shared } = statsContent;
11932
- Object.entries(this.buildAssets).forEach(([key, item])=>{
11933
- let targetShared = shared.find((s)=>s.name === key);
11934
- targetShared && item.forEach(([entry, version, globalName])=>{
11935
- version === targetShared.version && (targetShared.fallback = entry, targetShared.fallbackName = globalName);
11936
- });
11937
- }), compilation.updateAsset(statsFileName, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
11938
- });
11939
- });
11940
- }
11941
- async createIndependentCompilers(parentCompiler) {
11942
- let { sharedOptions, buildAssets } = this;
11943
- console.log("🚀 Start creating a standalone compiler...");
11944
- let parentOutputDir = parentCompiler.options.output.path ? (0, external_node_path_namespaceObject.basename)(parentCompiler.options.output.path) : "", shareRequestsMap = await this.createIndependentCompiler(parentCompiler, parentOutputDir);
11945
- await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
11946
- if (!shareConfig.treeshake || !1 === shareConfig.import) return;
11947
- let shareRequests = shareRequestsMap[shareName].requests;
11948
- await Promise.all(shareRequests.map(async ([request, version])=>{
11949
- let sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1], [shareFileName, globalName] = await this.createIndependentCompiler(parentCompiler, parentOutputDir, {
11950
- shareRequestsMap,
11951
- currentShare: {
11952
- shareName,
11953
- version,
11954
- request,
11955
- independentShareFileName: sharedConfig?.independentShareFileName
11956
- }
11957
- });
11958
- "string" == typeof shareFileName && (buildAssets[shareName] ||= [], buildAssets[shareName].push([
11959
- shareFileName,
11960
- version,
11961
- globalName
11962
- ]));
11963
- }));
11964
- })), console.log("✅ All independent packages have been compiled successfully");
11965
- }
11966
- async createIndependentCompiler(parentCompiler, parentOutputDir, extraOptions) {
11967
- let extraPlugin, { mfName, plugins, outputDir, outputFilePath, sharedOptions, treeshake, library } = this, outputDirWithShareName = outputFilePath || (0, external_node_path_namespaceObject.join)(outputDir, encodeName(extraOptions?.currentShare?.shareName || "")), parentConfig = parentCompiler.options, finalPlugins = [], rspack = parentCompiler.rspack;
11968
- extraPlugin = extraOptions ? new ShareContainerPlugin({
11969
- mfName,
11970
- library,
11971
- ...extraOptions.currentShare
11972
- }) : new CollectShareEntryPlugin({
11973
- sharedOptions,
11974
- shareScope: "default"
11975
- }), (parentConfig.plugins || []).forEach((plugin)=>{
11976
- void 0 !== plugin && "string" != typeof plugin && ((plugin)=>{
11977
- if (!plugin) return !0;
11978
- let pluginName = plugin.name || plugin.constructor?.name;
11979
- return !pluginName || ![
11980
- "TreeshakeSharePlugin",
11981
- "IndependentSharePlugin",
11982
- "ModuleFederationPlugin",
11983
- "OptimizeDependencyReferencedExportsPlugin",
11984
- "HtmlWebpackPlugin"
11985
- ].includes(pluginName);
11986
- })(plugin) && finalPlugins.push(plugin);
11987
- }), plugins.forEach((plugin)=>{
11988
- finalPlugins.push(plugin);
11989
- }), finalPlugins.push(extraPlugin), finalPlugins.push(new ConsumeSharedPlugin({
11990
- consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
11991
- [key]: {
11992
- import: !!extraOptions && options.import,
11993
- shareKey: options.shareKey || key,
11994
- shareScope: options.shareScope,
11995
- requiredVersion: options.requiredVersion,
11996
- strictVersion: options.strictVersion,
11997
- singleton: options.singleton,
11998
- packageName: options.packageName,
11999
- eager: options.eager
12000
- }
12001
- })),
12002
- enhanced: !0
12003
- })), treeshake && finalPlugins.push(new OptimizeDependencyReferencedExportsPlugin(sharedOptions, this.injectUsedExports)), finalPlugins.push(new VirtualEntryPlugin(sharedOptions));
12004
- let fullOutputDir = (0, external_node_path_namespaceObject.resolve)(parentCompiler.outputPath, outputDirWithShareName), compilerConfig = {
12005
- ...parentConfig,
12006
- mode: parentConfig.mode || "development",
12007
- entry: VirtualEntryPlugin.entry,
12008
- output: {
12009
- path: fullOutputDir,
12010
- clean: !0,
12011
- publicPath: parentConfig.output?.publicPath || "auto"
12012
- },
12013
- plugins: finalPlugins,
12014
- optimization: {
12015
- ...parentConfig.optimization,
12016
- splitChunks: !1
12017
- }
12018
- }, compiler = rspack.rspack(compilerConfig);
12019
- compiler.inputFileSystem = parentCompiler.inputFileSystem, compiler.outputFileSystem = parentCompiler.outputFileSystem, compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
12020
- let { currentShare } = extraOptions || {};
12021
- return currentShare && this.compilers.set(`${currentShare.shareName}@${currentShare.version}`, compiler), new Promise((resolve, reject)=>{
12022
- compiler.run((err, stats)=>{
12023
- if (err || stats?.hasErrors()) {
12024
- let target = currentShare ? currentShare.shareName : "收集依赖";
12025
- console.error(`❌ ${target} 编译失败:`, err || stats.toJson().errors.map((e)=>e.message).join("\n")), reject(err || Error(`${target} 编译失败`));
12026
- return;
12027
- }
12028
- currentShare && console.log(`✅ 独立包 ${currentShare.shareName} 编译成功`), stats && (currentShare && console.log(`📊 ${currentShare.shareName} 编译统计:`), console.log(stats.toString({
12029
- colors: !0,
12030
- chunks: !1,
12031
- modules: !1
12032
- }))), resolve(extraPlugin.getData());
12033
- });
12034
- });
12035
- }
12036
- cleanup() {
12037
- this.compilers.forEach((compiler)=>{
12038
- compiler.watching && compiler.watching.close(()=>{
12039
- console.log("👋 编译器已关闭");
12040
- });
12041
- }), this.compilers.clear();
12042
- }
12043
- }
12044
- let ModuleFederationRuntimePlugin = base_create(binding_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
12045
- function getRemoteInfos(options) {
12046
- if (!options.remotes) return {};
12047
- let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
12048
- external: Array.isArray(item) ? item : [
12049
- item
12050
- ],
12051
- shareScope: options.shareScope || "default"
12052
- }), (item)=>({
12053
- external: Array.isArray(item.external) ? item.external : [
12054
- item.external
12055
- ],
12056
- shareScope: item.shareScope || options.shareScope || "default"
12057
- })), remoteInfos = {};
12058
- for (let [key, config] of remotes)for (let external of config.external){
12059
- let [externalType, externalRequest] = function(external) {
12060
- let result = function(external) {
12061
- if (/^[a-z0-9-]+ /.test(external)) {
12062
- let idx = external.indexOf(" ");
12063
- return [
12064
- external.slice(0, idx),
12065
- external.slice(idx + 1)
12066
- ];
12067
- }
12068
- return null;
12069
- }(external);
12070
- return null === result ? [
12071
- remoteType,
12072
- external
12073
- ] : result;
12074
- }(external);
12075
- if (remoteInfos[key] ??= [], "script" === externalType) {
12076
- let [url, global] = function(urlAndGlobal) {
12077
- let index = urlAndGlobal.indexOf("@");
12078
- return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
12079
- urlAndGlobal.substring(index + 1),
12080
- urlAndGlobal.substring(0, index)
12081
- ];
12082
- }(externalRequest);
12083
- remoteInfos[key].push({
12084
- alias: key,
12085
- name: global,
12086
- entry: url,
12087
- externalType,
12088
- shareScope: config.shareScope
12089
- });
12090
- } else remoteInfos[key].push({
12091
- alias: key,
12092
- name: void 0,
12093
- entry: void 0,
12094
- externalType,
12095
- shareScope: config.shareScope
12096
- });
12097
- }
12098
- return remoteInfos;
12099
- }
12100
11720
  class ContainerPlugin extends RspackBuiltinPlugin {
12101
11721
  name = binding_.BuiltinPluginName.ContainerPlugin;
12102
11722
  _options;
@@ -12188,7 +11808,7 @@ Help:
12188
11808
  let _options = JSON.stringify(options || {});
12189
11809
  return binding_default().transform(source, _options);
12190
11810
  }
12191
- let exports_rspackVersion = "1.6.5-canary-1b7f543c-20251121112112", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
11811
+ let exports_rspackVersion = "1.6.5-canary-5c09e49d-20251121173820", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
12192
11812
  getNormalizedRspackOptions: getNormalizedRspackOptions,
12193
11813
  applyRspackOptionsDefaults: applyRspackOptionsDefaults,
12194
11814
  getNormalizedWebpackOptions: getNormalizedRspackOptions,
@@ -12231,13 +11851,12 @@ Help:
12231
11851
  ContainerReferencePlugin: ContainerReferencePlugin,
12232
11852
  ModuleFederationPlugin: class {
12233
11853
  _options;
12234
- _independentSharePlugin;
12235
11854
  constructor(_options){
12236
11855
  this._options = _options;
12237
11856
  }
12238
11857
  apply(compiler) {
12239
- var options, options1;
12240
- let runtimeToolsPath, bundlerRuntimePath, runtimePath, { name, shared } = this._options, { webpack } = compiler, paths = (runtimeToolsPath = (options = this._options).implementation ?? require.resolve("@module-federation/runtime-tools"), bundlerRuntimePath = require.resolve("@module-federation/webpack-bundler-runtime", {
11858
+ var options;
11859
+ let runtimeToolsPath, bundlerRuntimePath, runtimePath, { webpack } = compiler, paths = (runtimeToolsPath = (options = this._options).implementation ?? require.resolve("@module-federation/runtime-tools"), bundlerRuntimePath = require.resolve("@module-federation/webpack-bundler-runtime", {
12241
11860
  paths: [
12242
11861
  runtimeToolsPath
12243
11862
  ]
@@ -12250,54 +11869,101 @@ Help:
12250
11869
  bundlerRuntime: bundlerRuntimePath,
12251
11870
  runtime: runtimePath
12252
11871
  });
12253
- compiler.options.resolve.alias = {
11872
+ if (compiler.options.resolve.alias = {
12254
11873
  "@module-federation/runtime-tools": paths.runtimeTools,
12255
11874
  "@module-federation/runtime": paths.runtime,
12256
11875
  ...compiler.options.resolve.alias
12257
- }, ((options1 = this._options).shared ? parseOptions(options1.shared, (item, key)=>{
12258
- if ("string" != typeof item) throw Error("Unexpected array in shared");
12259
- return item !== key && isRequiredVersion(item) ? {
12260
- import: key,
12261
- requiredVersion: item
12262
- } : {
12263
- import: item
12264
- };
12265
- }, (item)=>item) : []).filter(([, config])=>config.treeshake).length > 0 && (this._independentSharePlugin = new IndependentSharePlugin({
12266
- name,
12267
- shared: shared || {},
12268
- outputFilePath: this._options.independentShareFilePath
12269
- }), this._independentSharePlugin.apply(compiler));
12270
- let runtimePluginApplied = !1;
12271
- compiler.hooks.beforeRun.tapPromise({
12272
- name: "ModuleFederationPlugin",
12273
- stage: 100
12274
- }, async ()=>{
12275
- runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
12276
- entryRuntime: function(paths, options, compiler, treeshakeShareFallbacks) {
12277
- let runtimePlugins = options.runtimePlugins ?? [], remoteInfos = getRemoteInfos(options), runtimePluginImports = [], runtimePluginVars = [];
12278
- for(let i = 0; i < runtimePlugins.length; i++){
12279
- let runtimePluginVar = `__module_federation_runtime_plugin_${i}__`, pluginSpec = runtimePlugins[i], pluginPath = Array.isArray(pluginSpec) ? pluginSpec[0] : pluginSpec, pluginParams = Array.isArray(pluginSpec) ? pluginSpec[1] : void 0;
12280
- runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
12281
- let paramsCode = void 0 === pluginParams ? "undefined" : JSON.stringify(pluginParams);
12282
- runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
12283
- }
12284
- let content = [
12285
- `import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
12286
- ...runtimePluginImports,
12287
- `const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(", ")}]`,
12288
- `const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
12289
- `const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
12290
- `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? "version-first")}`,
12291
- `const __module_federation_share_fallbacks__ = ${JSON.stringify(treeshakeShareFallbacks)}`,
12292
- compiler.webpack.Template.getFunctionContent(__webpack_require__("./moduleFederationDefaultRuntime.js"))
12293
- ].join(";");
12294
- return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
12295
- }(paths, this._options, compiler, this._independentSharePlugin?.buildAssets || {})
12296
- }).apply(compiler));
12297
- }), new webpack.container.ModuleFederationPluginV1({
11876
+ }, new ModuleFederationRuntimePlugin({
11877
+ entryRuntime: function(paths, options, compiler) {
11878
+ let runtimePlugins = options.runtimePlugins ?? [], remoteInfos = getRemoteInfos(options), runtimePluginImports = [], runtimePluginVars = [];
11879
+ for(let i = 0; i < runtimePlugins.length; i++){
11880
+ let runtimePluginVar = `__module_federation_runtime_plugin_${i}__`, pluginSpec = runtimePlugins[i], pluginPath = Array.isArray(pluginSpec) ? pluginSpec[0] : pluginSpec, pluginParams = Array.isArray(pluginSpec) ? pluginSpec[1] : void 0;
11881
+ runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
11882
+ let paramsCode = void 0 === pluginParams ? "undefined" : JSON.stringify(pluginParams);
11883
+ runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
11884
+ }
11885
+ let content = [
11886
+ `import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
11887
+ ...runtimePluginImports,
11888
+ `const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(", ")}]`,
11889
+ `const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
11890
+ `const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
11891
+ `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? "version-first")}`,
11892
+ compiler.webpack.Template.getFunctionContent(__webpack_require__("./moduleFederationDefaultRuntime.js"))
11893
+ ].join(";");
11894
+ return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
11895
+ }(paths, this._options, compiler)
11896
+ }).apply(compiler), new webpack.container.ModuleFederationPluginV1({
12298
11897
  ...this._options,
12299
11898
  enhanced: !0
12300
- }).apply(compiler), this._options.manifest && new ModuleFederationManifestPlugin(this._options).apply(compiler);
11899
+ }).apply(compiler), this._options.manifest) {
11900
+ let manifestOptions = !0 === this._options.manifest ? {} : {
11901
+ ...this._options.manifest
11902
+ }, containerName = manifestOptions.name ?? this._options.name, globalName = manifestOptions.globalName ?? function(library) {
11903
+ if (!library) return;
11904
+ let libName = library.name;
11905
+ if (libName) {
11906
+ if ("string" == typeof libName) return libName;
11907
+ if (Array.isArray(libName)) return libName[0];
11908
+ if ("object" == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
11909
+ }
11910
+ }(this._options.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
11911
+ if (cur[1].length > 1) return sum;
11912
+ let { entry, alias, name } = cur[1][0];
11913
+ return entry && name && (sum[alias] = {
11914
+ name,
11915
+ entry
11916
+ }), sum;
11917
+ }, {}), manifestExposes = function(exposes) {
11918
+ if (!exposes) return;
11919
+ let result = parseOptions(exposes, (value, key)=>({
11920
+ import: Array.isArray(value) ? value : [
11921
+ value
11922
+ ],
11923
+ name: void 0
11924
+ }), (value)=>({
11925
+ import: Array.isArray(value.import) ? value.import : [
11926
+ value.import
11927
+ ],
11928
+ name: value.name ?? void 0
11929
+ })).map(([exposeKey, info])=>{
11930
+ let exposeName = info.name ?? exposeKey.replace(/^\.\//, "");
11931
+ return {
11932
+ path: exposeKey,
11933
+ name: exposeName
11934
+ };
11935
+ });
11936
+ return result.length > 0 ? result : void 0;
11937
+ }(this._options.exposes);
11938
+ void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes);
11939
+ let manifestShared = function(shared) {
11940
+ if (!shared) return;
11941
+ let result = parseOptions(shared, (item, key)=>{
11942
+ if ("string" != typeof item) throw Error("Unexpected array in shared");
11943
+ return item !== key && isRequiredVersion(item) ? {
11944
+ import: key,
11945
+ requiredVersion: item
11946
+ } : {
11947
+ import: item
11948
+ };
11949
+ }, (item)=>item).map(([key, config])=>{
11950
+ let name = config.shareKey || key, version = "string" == typeof config.version ? config.version : void 0;
11951
+ return {
11952
+ name,
11953
+ version,
11954
+ requiredVersion: "string" == typeof config.requiredVersion ? config.requiredVersion : void 0,
11955
+ singleton: config.singleton
11956
+ };
11957
+ });
11958
+ return result.length > 0 ? result : void 0;
11959
+ }(this._options.shared);
11960
+ void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), new ModuleFederationManifestPlugin({
11961
+ ...manifestOptions,
11962
+ name: containerName,
11963
+ globalName,
11964
+ remoteAliasMap
11965
+ }).apply(compiler);
11966
+ }
12301
11967
  }
12302
11968
  },
12303
11969
  ModuleFederationPluginV1: class {
@@ -12334,33 +12000,6 @@ Help:
12334
12000
  }
12335
12001
  }, sharing = {
12336
12002
  ProvideSharedPlugin: ProvideSharedPlugin,
12337
- CollectShareEntryPlugin: CollectShareEntryPlugin,
12338
- TreeshakeSharePlugin: class {
12339
- mfConfig;
12340
- outputDir;
12341
- plugins;
12342
- reshake;
12343
- name = "TreeshakeSharePlugin";
12344
- constructor(options){
12345
- const { mfConfig, plugins, reshake } = options;
12346
- this.mfConfig = mfConfig, this.outputDir = mfConfig.independentShareDir || "independent-packages", this.plugins = plugins, this.reshake = !!reshake;
12347
- }
12348
- apply(compiler) {
12349
- let { mfConfig, outputDir, plugins, reshake } = this, { name, shared, library } = mfConfig;
12350
- if (!shared) return;
12351
- let sharedOptions = normalizeSharedOptions(shared);
12352
- sharedOptions.length && (reshake || new OptimizeDependencyReferencedExportsPlugin(sharedOptions, mfConfig.injectUsedExports, mfConfig.manifest).apply(compiler), sharedOptions.some(([_, config])=>config.treeshake && !1 !== config.import) && new IndependentSharePlugin({
12353
- name: name,
12354
- shared: shared,
12355
- outputDir,
12356
- plugins,
12357
- treeshake: reshake,
12358
- library
12359
- }).apply(compiler));
12360
- }
12361
- },
12362
- ShareContainerPlugin: ShareContainerPlugin,
12363
- OptimizeDependencyReferencedExportsPlugin: OptimizeDependencyReferencedExportsPlugin,
12364
12003
  ConsumeSharedPlugin: ConsumeSharedPlugin,
12365
12004
  SharePlugin: SharePlugin
12366
12005
  }, exports_experiments = {