@rspack-canary/core 1.6.5-canary-a407d226-20251124112255 → 1.6.5-canary-e23badc4-20251124174040

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
@@ -4645,7 +4645,7 @@ Plugins which provide custom chunk loading types must call EnableChunkLoadingPlu
4645
4645
  return createBuiltinPlugin(this.name, rawOptions);
4646
4646
  }
4647
4647
  }
4648
- let SubresourceIntegrityPlugin_PLUGIN_NAME = "SubresourceIntegrityPlugin", NATIVE_HTML_PLUGIN = "HtmlRspackPlugin", NativeSubresourceIntegrityPlugin = base_create(binding_.BuiltinPluginName.SubresourceIntegrityPlugin, function(options) {
4648
+ let SubresourceIntegrityPlugin_PLUGIN_NAME = "SubresourceIntegrityPlugin", NATIVE_HTML_PLUGIN = "HtmlRspackPlugin", HTTP_PROTOCOL_REGEX = /^https?:/, NativeSubresourceIntegrityPlugin = base_create(binding_.BuiltinPluginName.SubresourceIntegrityPlugin, function(options) {
4649
4649
  let htmlPlugin = "Disabled";
4650
4650
  return options.htmlPlugin === NATIVE_HTML_PLUGIN ? htmlPlugin = "Native" : "string" == typeof options.htmlPlugin && (htmlPlugin = "JavaScript"), {
4651
4651
  hashFuncNames: options.hashFuncNames,
@@ -4706,11 +4706,23 @@ Plugins which provide custom chunk loading types must call EnableChunkLoadingPlu
4706
4706
  }
4707
4707
  }(tag);
4708
4708
  if (!tagSrc) return;
4709
+ let isUrlSrc = !1;
4709
4710
  try {
4710
4711
  let url = new URL(tagSrc);
4711
- if (("http:" === url.protocol || "https:" === url.protocol) && (!publicPath || !tagSrc.startsWith(publicPath))) return;
4712
- } catch (_) {}
4713
- let src = (0, external_node_path_namespaceObject.relative)(publicPath, decodeURIComponent(tagSrc));
4712
+ isUrlSrc = "http:" === url.protocol || "https:" === url.protocol;
4713
+ } catch (_) {
4714
+ isUrlSrc = tagSrc.startsWith("//");
4715
+ }
4716
+ let src = "";
4717
+ if (isUrlSrc) {
4718
+ if (!publicPath) return;
4719
+ let protocolRelativePublicPath = publicPath.replace(HTTP_PROTOCOL_REGEX, ""), protocolRelativeTagSrc = tagSrc.replace(HTTP_PROTOCOL_REGEX, "");
4720
+ if (!protocolRelativeTagSrc.startsWith(protocolRelativePublicPath)) return;
4721
+ {
4722
+ let tagSrcWithScheme = `http:${protocolRelativeTagSrc}`, publicPathWithScheme = protocolRelativePublicPath.startsWith("//") ? `http:${protocolRelativePublicPath}` : protocolRelativePublicPath;
4723
+ src = (0, external_node_path_namespaceObject.relative)(publicPathWithScheme, decodeURIComponent(tagSrcWithScheme));
4724
+ }
4725
+ } else src = (0, external_node_path_namespaceObject.relative)(publicPath, decodeURIComponent(tagSrc));
4714
4726
  tag.attributes.integrity = this.getIntegrityChecksumForAsset(src) || function(hashFuncNames, source) {
4715
4727
  let { createHash } = __webpack_require__("node:crypto");
4716
4728
  return hashFuncNames.map((hashFuncName)=>`${hashFuncName}-${createHash(hashFuncName).update("string" == typeof source ? Buffer.from(source, "utf-8") : source).digest("base64")}`).join(" ");
@@ -5740,7 +5752,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
5740
5752
  }, applyExperimentsDefaults = (experiments, { development })=>{
5741
5753
  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);
5742
5754
  }, applybundlerInfoDefaults = (rspackFuture, library)=>{
5743
- "object" == typeof rspackFuture && (D(rspackFuture, "bundlerInfo", {}), "object" == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, "version", "1.6.5-canary-a407d226-20251124112255"), D(rspackFuture.bundlerInfo, "bundler", "rspack"), D(rspackFuture.bundlerInfo, "force", !library)));
5755
+ "object" == typeof rspackFuture && (D(rspackFuture, "bundlerInfo", {}), "object" == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, "version", "1.6.5-canary-e23badc4-20251124174040"), D(rspackFuture.bundlerInfo, "bundler", "rspack"), D(rspackFuture.bundlerInfo, "force", !library)));
5744
5756
  }, applySnapshotDefaults = (_snapshot, _env)=>{}, applyModuleDefaults = (module1, { cache, asyncWebAssembly, css, targetProperties, mode, uniqueName, usedExports, inlineConst, deferImport })=>{
5745
5757
  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 })=>{
5746
5758
  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", [
@@ -7390,7 +7402,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
7390
7402
  });
7391
7403
  }
7392
7404
  }
7393
- let CORE_VERSION = "1.6.5-canary-a407d226-20251124112255", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
7405
+ let CORE_VERSION = "1.6.5-canary-e23badc4-20251124174040", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
7394
7406
 
7395
7407
  Help:
7396
7408
  Looks like you are using a custom binding (via environment variable 'RSPACK_BINDING=${process.env.RSPACK_BINDING}').
@@ -8690,7 +8702,7 @@ Help:
8690
8702
  obj.children = this.stats.map((stat, idx)=>{
8691
8703
  let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
8692
8704
  return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
8693
- }), childOptions.version && (obj.rspackVersion = "1.6.5-canary-a407d226-20251124112255", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(""));
8705
+ }), childOptions.version && (obj.rspackVersion = "1.6.5-canary-e23badc4-20251124174040", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(""));
8694
8706
  let mapError = (j, obj)=>({
8695
8707
  ...obj,
8696
8708
  compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
@@ -9589,7 +9601,7 @@ Help:
9589
9601
  object.hash = context.getStatsCompilation(compilation).hash;
9590
9602
  },
9591
9603
  version: (object)=>{
9592
- object.version = "5.75.0", object.rspackVersion = "1.6.5-canary-a407d226-20251124112255";
9604
+ object.version = "5.75.0", object.rspackVersion = "1.6.5-canary-e23badc4-20251124174040";
9593
9605
  },
9594
9606
  env: (object, _compilation, _context, { _env })=>{
9595
9607
  object.env = _env;
@@ -11434,116 +11446,30 @@ Help:
11434
11446
  function isRequiredVersion(str) {
11435
11447
  return VERSION_PATTERN_REGEXP.test(str);
11436
11448
  }
11437
- let encodeName = function(name, prefix = "", withExt = !1) {
11438
- return `${prefix}${name.replace(/@/g, "scope_").replace(/-/g, "_").replace(/\//g, "__").replace(/\./g, "")}${withExt ? ".js" : ""}`;
11439
- }, parseOptions = (options, normalizeSimple, normalizeOptions)=>{
11440
- let items = [];
11441
- var options1 = options, normalizeSimple1 = normalizeSimple, normalizeOptions1 = normalizeOptions, fn = (key, value)=>{
11442
- items.push([
11443
- key,
11444
- value
11445
- ]);
11446
- };
11447
- let object = (obj)=>{
11448
- for (let [key, value] of Object.entries(obj))"string" == typeof value || Array.isArray(value) ? fn(key, normalizeSimple1(value, key)) : fn(key, normalizeOptions1(value, key));
11449
- };
11450
- if (options1) if (Array.isArray(options1)) {
11451
- var items1 = options1;
11452
- for (let item of items1)if ("string" == typeof item) fn(item, normalizeSimple1(item, item));
11453
- else if (item && "object" == typeof item) object(item);
11454
- else throw Error("Unexpected options format");
11455
- } else if ("object" == typeof options1) object(options1);
11456
- else throw Error("Unexpected options format");
11457
- return items;
11458
- }, MANIFEST_FILE_NAME = "mf-manifest.json", STATS_FILE_NAME = "mf-stats.json", JSON_EXT = ".json";
11449
+ let MANIFEST_FILE_NAME = "mf-manifest.json", STATS_FILE_NAME = "mf-stats.json", JSON_EXT = ".json";
11459
11450
  function isPlainObject(value) {
11460
11451
  return !!value && "object" == typeof value && !Array.isArray(value);
11461
11452
  }
11462
- function getFileName(manifestOptions) {
11463
- var name;
11464
- if (!manifestOptions) return {
11465
- statsFileName: STATS_FILE_NAME,
11466
- manifestFileName: MANIFEST_FILE_NAME
11467
- };
11468
- 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;
11469
- return {
11470
- statsFileName: (0, external_node_path_namespaceObject.join)(filePath, statsFileName),
11471
- manifestFileName: (0, external_node_path_namespaceObject.join)(filePath, manifestFileName)
11472
- };
11473
- }
11474
11453
  class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
11475
11454
  name = binding_.BuiltinPluginName.ModuleFederationManifestPlugin;
11476
11455
  opts;
11477
11456
  constructor(opts){
11478
- var mfConfig;
11479
- let manifestOptions, containerName, globalName, remoteAliasMap, manifestExposes, manifestShared;
11480
- super(), this.opts = (manifestOptions = !0 === (mfConfig = opts).manifest ? {} : {
11481
- ...mfConfig.manifest
11482
- }, containerName = mfConfig.name, globalName = function(library) {
11483
- if (!library) return;
11484
- let libName = library.name;
11485
- if (libName) {
11486
- if ("string" == typeof libName) return libName;
11487
- if (Array.isArray(libName)) return libName[0];
11488
- if ("object" == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
11489
- }
11490
- }(mfConfig.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(mfConfig)).reduce((sum, cur)=>{
11491
- if (cur[1].length > 1) return sum;
11492
- let { entry, alias, name } = cur[1][0];
11493
- return entry && name && (sum[alias] = {
11494
- name,
11495
- entry
11496
- }), sum;
11497
- }, {}), manifestExposes = function(exposes) {
11498
- if (!exposes) return;
11499
- let result = parseOptions(exposes, (value)=>({
11500
- import: Array.isArray(value) ? value : [
11501
- value
11502
- ],
11503
- name: void 0
11504
- }), (value)=>({
11505
- import: Array.isArray(value.import) ? value.import : [
11506
- value.import
11507
- ],
11508
- name: value.name ?? void 0
11509
- })).map(([exposeKey, info])=>{
11510
- let exposeName = info.name ?? exposeKey.replace(/^\.\//, "");
11511
- return {
11512
- path: exposeKey,
11513
- name: exposeName
11514
- };
11515
- });
11516
- return result.length > 0 ? result : void 0;
11517
- }(mfConfig.exposes), void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes), manifestShared = function(shared) {
11518
- if (!shared) return;
11519
- let result = parseOptions(shared, (item, key)=>{
11520
- if ("string" != typeof item) throw Error("Unexpected array in shared");
11521
- return item !== key && isRequiredVersion(item) ? {
11522
- import: key,
11523
- requiredVersion: item
11524
- } : {
11525
- import: item
11526
- };
11527
- }, (item)=>item).map(([key, config])=>{
11528
- let name = config.shareKey || key, version = "string" == typeof config.version ? config.version : void 0;
11529
- return {
11530
- name,
11531
- version,
11532
- requiredVersion: "string" == typeof config.requiredVersion ? config.requiredVersion : void 0,
11533
- singleton: config.singleton
11534
- };
11535
- });
11536
- return result.length > 0 ? result : void 0;
11537
- }(mfConfig.shared), void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), {
11538
- ...manifestOptions,
11539
- remoteAliasMap,
11540
- globalName,
11541
- name: containerName
11542
- });
11457
+ super(), this.opts = opts;
11543
11458
  }
11544
11459
  raw(compiler) {
11545
11460
  var isDev;
11546
- let pkg, buildVersion, { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts, { statsFileName, manifestFileName } = getFileName(this.opts), rawOptions = {
11461
+ let pkg, buildVersion, { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts, { statsFileName, manifestFileName } = function(manifestOptions) {
11462
+ var name;
11463
+ if (!manifestOptions) return {
11464
+ statsFileName: STATS_FILE_NAME,
11465
+ manifestFileName: MANIFEST_FILE_NAME
11466
+ };
11467
+ 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;
11468
+ return {
11469
+ statsFileName: (0, external_node_path_namespaceObject.join)(filePath, statsFileName),
11470
+ manifestFileName: (0, external_node_path_namespaceObject.join)(filePath, manifestFileName)
11471
+ };
11472
+ }(this.opts), rawOptions = {
11547
11473
  name: this.opts.name,
11548
11474
  globalName: this.opts.globalName,
11549
11475
  fileName,
@@ -11578,6 +11504,81 @@ Help:
11578
11504
  return createBuiltinPlugin(this.name, rawOptions);
11579
11505
  }
11580
11506
  }
11507
+ let ModuleFederationRuntimePlugin = base_create(binding_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options), parseOptions = (options, normalizeSimple, normalizeOptions)=>{
11508
+ let items = [];
11509
+ var options1 = options, normalizeSimple1 = normalizeSimple, normalizeOptions1 = normalizeOptions, fn = (key, value)=>{
11510
+ items.push([
11511
+ key,
11512
+ value
11513
+ ]);
11514
+ };
11515
+ let object = (obj)=>{
11516
+ for (let [key, value] of Object.entries(obj))"string" == typeof value || Array.isArray(value) ? fn(key, normalizeSimple1(value, key)) : fn(key, normalizeOptions1(value, key));
11517
+ };
11518
+ if (options1) if (Array.isArray(options1)) {
11519
+ var items1 = options1;
11520
+ for (let item of items1)if ("string" == typeof item) fn(item, normalizeSimple1(item, item));
11521
+ else if (item && "object" == typeof item) object(item);
11522
+ else throw Error("Unexpected options format");
11523
+ } else if ("object" == typeof options1) object(options1);
11524
+ else throw Error("Unexpected options format");
11525
+ return items;
11526
+ };
11527
+ function getRemoteInfos(options) {
11528
+ if (!options.remotes) return {};
11529
+ let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
11530
+ external: Array.isArray(item) ? item : [
11531
+ item
11532
+ ],
11533
+ shareScope: options.shareScope || "default"
11534
+ }), (item)=>({
11535
+ external: Array.isArray(item.external) ? item.external : [
11536
+ item.external
11537
+ ],
11538
+ shareScope: item.shareScope || options.shareScope || "default"
11539
+ })), remoteInfos = {};
11540
+ for (let [key, config] of remotes)for (let external of config.external){
11541
+ let [externalType, externalRequest] = function(external) {
11542
+ let result = function(external) {
11543
+ if (/^[a-z0-9-]+ /.test(external)) {
11544
+ let idx = external.indexOf(" ");
11545
+ return [
11546
+ external.slice(0, idx),
11547
+ external.slice(idx + 1)
11548
+ ];
11549
+ }
11550
+ return null;
11551
+ }(external);
11552
+ return null === result ? [
11553
+ remoteType,
11554
+ external
11555
+ ] : result;
11556
+ }(external);
11557
+ if (remoteInfos[key] ??= [], "script" === externalType) {
11558
+ let [url, global] = function(urlAndGlobal) {
11559
+ let index = urlAndGlobal.indexOf("@");
11560
+ return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
11561
+ urlAndGlobal.substring(index + 1),
11562
+ urlAndGlobal.substring(0, index)
11563
+ ];
11564
+ }(externalRequest);
11565
+ remoteInfos[key].push({
11566
+ alias: key,
11567
+ name: global,
11568
+ entry: url,
11569
+ externalType,
11570
+ shareScope: config.shareScope
11571
+ });
11572
+ } else remoteInfos[key].push({
11573
+ alias: key,
11574
+ name: void 0,
11575
+ entry: void 0,
11576
+ externalType,
11577
+ shareScope: config.shareScope
11578
+ });
11579
+ }
11580
+ return remoteInfos;
11581
+ }
11581
11582
  let compilerSet = new WeakSet();
11582
11583
  class ShareRuntimePlugin extends RspackBuiltinPlugin {
11583
11584
  enhanced;
@@ -11590,45 +11591,42 @@ Help:
11590
11591
  if (compiler1 = compiler, !compilerSet.has(compiler1)) return compiler2 = compiler, compilerSet.add(compiler2), createBuiltinPlugin(this.name, this.enhanced);
11591
11592
  }
11592
11593
  }
11593
- function normalizeConsumeShareOptions(consumes, shareScope) {
11594
- return parseOptions(consumes, (item, key)=>{
11595
- if (Array.isArray(item)) throw Error("Unexpected array in options");
11596
- return item !== key && isRequiredVersion(item) ? {
11597
- import: key,
11598
- shareScope: shareScope || "default",
11599
- shareKey: key,
11600
- requiredVersion: item,
11601
- strictVersion: !0,
11602
- packageName: void 0,
11603
- singleton: !1,
11604
- eager: !1
11605
- } : {
11606
- import: key,
11607
- shareScope: shareScope || "default",
11608
- shareKey: key,
11609
- requiredVersion: void 0,
11610
- packageName: void 0,
11611
- strictVersion: !1,
11612
- singleton: !1,
11613
- eager: !1
11614
- };
11615
- }, (item, key)=>({
11616
- import: !1 === item.import ? void 0 : item.import || key,
11617
- shareScope: item.shareScope || shareScope || "default",
11618
- shareKey: item.shareKey || key,
11619
- requiredVersion: item.requiredVersion,
11620
- strictVersion: "boolean" == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
11621
- packageName: item.packageName,
11622
- singleton: !!item.singleton,
11623
- eager: !!item.eager
11624
- }));
11625
- }
11626
11594
  class ConsumeSharedPlugin extends RspackBuiltinPlugin {
11627
11595
  name = binding_.BuiltinPluginName.ConsumeSharedPlugin;
11628
11596
  _options;
11629
11597
  constructor(options){
11630
11598
  super(), this._options = {
11631
- consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
11599
+ consumes: parseOptions(options.consumes, (item, key)=>{
11600
+ if (Array.isArray(item)) throw Error("Unexpected array in options");
11601
+ return item !== key && isRequiredVersion(item) ? {
11602
+ import: key,
11603
+ shareScope: options.shareScope || "default",
11604
+ shareKey: key,
11605
+ requiredVersion: item,
11606
+ strictVersion: !0,
11607
+ packageName: void 0,
11608
+ singleton: !1,
11609
+ eager: !1
11610
+ } : {
11611
+ import: key,
11612
+ shareScope: options.shareScope || "default",
11613
+ shareKey: key,
11614
+ requiredVersion: void 0,
11615
+ packageName: void 0,
11616
+ strictVersion: !1,
11617
+ singleton: !1,
11618
+ eager: !1
11619
+ };
11620
+ }, (item, key)=>({
11621
+ import: !1 === item.import ? void 0 : item.import || key,
11622
+ shareScope: item.shareScope || options.shareScope || "default",
11623
+ shareKey: item.shareKey || key,
11624
+ requiredVersion: item.requiredVersion,
11625
+ strictVersion: "boolean" == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
11626
+ packageName: item.packageName,
11627
+ singleton: !!item.singleton,
11628
+ eager: !!item.eager
11629
+ })),
11632
11630
  enhanced: options.enhanced ?? !1
11633
11631
  };
11634
11632
  }
@@ -11649,29 +11647,28 @@ Help:
11649
11647
  _provides;
11650
11648
  _enhanced;
11651
11649
  constructor(options){
11652
- var options1, shareScope, enhanced;
11653
- super(), this._provides = (options1 = options.provides, shareScope = options.shareScope, enhanced = options.enhanced, parseOptions(options1, (item)=>{
11650
+ super(), this._provides = parseOptions(options.provides, (item)=>{
11654
11651
  if (Array.isArray(item)) throw Error("Unexpected array of provides");
11655
11652
  return {
11656
11653
  shareKey: item,
11657
11654
  version: void 0,
11658
- shareScope: shareScope || "default",
11655
+ shareScope: options.shareScope || "default",
11659
11656
  eager: !1
11660
11657
  };
11661
11658
  }, (item)=>{
11662
11659
  let raw = {
11663
11660
  shareKey: item.shareKey,
11664
11661
  version: item.version,
11665
- shareScope: item.shareScope || shareScope || "default",
11662
+ shareScope: item.shareScope || options.shareScope || "default",
11666
11663
  eager: !!item.eager
11667
11664
  };
11668
- return enhanced ? {
11665
+ return options.enhanced ? {
11669
11666
  ...raw,
11670
11667
  singleton: item.singleton,
11671
11668
  requiredVersion: item.requiredVersion,
11672
11669
  strictVersion: item.strictVersion
11673
11670
  } : raw;
11674
- })), this._enhanced = options.enhanced;
11671
+ }), this._enhanced = options.enhanced;
11675
11672
  }
11676
11673
  raw(compiler) {
11677
11674
  new ShareRuntimePlugin(this._enhanced ?? !1).apply(compiler);
@@ -11682,39 +11679,32 @@ Help:
11682
11679
  return createBuiltinPlugin(this.name, rawOptions);
11683
11680
  }
11684
11681
  }
11685
- function normalizeSharedOptions(shared) {
11686
- return parseOptions(shared, (item, key)=>{
11687
- if ("string" != typeof item) throw Error("Unexpected array in shared");
11688
- return item !== key && isRequiredVersion(item) ? {
11689
- import: key,
11690
- requiredVersion: item
11691
- } : {
11692
- import: item
11693
- };
11694
- }, (item)=>item);
11695
- }
11696
- function createConsumeShareOptions(normalizedSharedOptions) {
11697
- return normalizedSharedOptions.map(([key, options])=>({
11698
- [key]: {
11699
- import: options.import,
11700
- shareKey: options.shareKey || key,
11701
- shareScope: options.shareScope,
11702
- requiredVersion: options.requiredVersion,
11703
- strictVersion: options.strictVersion,
11704
- singleton: options.singleton,
11705
- packageName: options.packageName,
11706
- eager: options.eager
11707
- }
11708
- }));
11709
- }
11710
11682
  class SharePlugin {
11711
11683
  _shareScope;
11712
11684
  _consumes;
11713
11685
  _provides;
11714
11686
  _enhanced;
11715
- _sharedOptions;
11716
11687
  constructor(options){
11717
- const sharedOptions = normalizeSharedOptions(options.shared), consumes = createConsumeShareOptions(sharedOptions), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
11688
+ const sharedOptions = parseOptions(options.shared, (item, key)=>{
11689
+ if ("string" != typeof item) throw Error("Unexpected array in shared");
11690
+ return item !== key && isRequiredVersion(item) ? {
11691
+ import: key,
11692
+ requiredVersion: item
11693
+ } : {
11694
+ import: item
11695
+ };
11696
+ }, (item)=>item), consumes = sharedOptions.map(([key, options])=>({
11697
+ [key]: {
11698
+ import: options.import,
11699
+ shareKey: options.shareKey || key,
11700
+ shareScope: options.shareScope,
11701
+ requiredVersion: options.requiredVersion,
11702
+ strictVersion: options.strictVersion,
11703
+ singleton: options.singleton,
11704
+ packageName: options.packageName,
11705
+ eager: options.eager
11706
+ }
11707
+ })), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
11718
11708
  [options.import || key]: {
11719
11709
  shareKey: options.shareKey || key,
11720
11710
  shareScope: options.shareScope,
@@ -11725,7 +11715,7 @@ Help:
11725
11715
  strictVersion: options.strictVersion
11726
11716
  }
11727
11717
  }));
11728
- this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1, this._sharedOptions = sharedOptions;
11718
+ this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1;
11729
11719
  }
11730
11720
  apply(compiler) {
11731
11721
  new ConsumeSharedPlugin({
@@ -11739,398 +11729,6 @@ Help:
11739
11729
  }).apply(compiler);
11740
11730
  }
11741
11731
  }
11742
- class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
11743
- name = binding_.BuiltinPluginName.CollectSharedEntryPlugin;
11744
- sharedOptions;
11745
- _collectedEntries;
11746
- constructor(options){
11747
- super();
11748
- const { sharedOptions } = options;
11749
- this.sharedOptions = sharedOptions, this._collectedEntries = {};
11750
- }
11751
- getData() {
11752
- return this._collectedEntries;
11753
- }
11754
- getFilename() {
11755
- return "collect-shared-entries.json";
11756
- }
11757
- apply(compiler) {
11758
- super.apply(compiler), compiler.hooks.thisCompilation.tap("Collect shared entry", (compilation)=>{
11759
- compilation.hooks.processAssets.tapPromise({
11760
- name: "CollectSharedEntry",
11761
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
11762
- }, async ()=>{
11763
- let filename = this.getFilename(), asset = compilation.getAsset(filename);
11764
- if (!asset) throw Error(`Can not get ${filename}`);
11765
- this._collectedEntries = JSON.parse(asset.source.source().toString()), compilation.deleteAsset(filename);
11766
- });
11767
- });
11768
- }
11769
- raw() {
11770
- let rawOptions = {
11771
- consumes: normalizeConsumeShareOptions(createConsumeShareOptions(this.sharedOptions)).map(([key, v])=>({
11772
- key,
11773
- ...v
11774
- })),
11775
- filename: this.getFilename()
11776
- };
11777
- return createBuiltinPlugin(this.name, rawOptions);
11778
- }
11779
- }
11780
- function assert(condition, msg) {
11781
- if (!condition) throw Error(msg);
11782
- }
11783
- class ShareContainerPlugin extends RspackBuiltinPlugin {
11784
- name = binding_.BuiltinPluginName.ShareContainerPlugin;
11785
- filename = "";
11786
- _options;
11787
- _shareName;
11788
- _globalName;
11789
- constructor(options){
11790
- super();
11791
- const { shareName, library, request, independentShareFileName } = options, version = options.version || "0.0.0";
11792
- this._globalName = encodeName(`${options.mfName}_${shareName}_${version}`);
11793
- const fileName = independentShareFileName || `${version}/share-entry.js`;
11794
- this._shareName = shareName, this._options = {
11795
- name: shareName,
11796
- request: request,
11797
- library: (library ? {
11798
- ...library,
11799
- name: this._globalName
11800
- } : void 0) || {
11801
- type: "var",
11802
- name: this._globalName
11803
- },
11804
- version,
11805
- fileName
11806
- };
11807
- }
11808
- getData() {
11809
- return [
11810
- this.name,
11811
- this._globalName
11812
- ];
11813
- }
11814
- raw(compiler) {
11815
- let { library } = this._options;
11816
- return compiler.options.output.enabledLibraryTypes.includes(library.type) || compiler.options.output.enabledLibraryTypes.push(library.type), createBuiltinPlugin(this.name, this._options);
11817
- }
11818
- apply(compiler) {
11819
- super.apply(compiler);
11820
- let shareName = this._shareName;
11821
- compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
11822
- compilation.hooks.processAssets.tapPromise({
11823
- name: "getShareContainerFile"
11824
- }, async ()=>{
11825
- assert(compilation.entrypoints.get(shareName), `Can not get shared ${shareName} entryPoint!`);
11826
- let remoteEntryNameChunk = compilation.namedChunks.get(shareName);
11827
- assert(remoteEntryNameChunk, `Can not get shared ${shareName} chunk!`);
11828
- let files = Array.from(remoteEntryNameChunk.files).filter((f)=>!f.includes(".hot-update") && !f.endsWith(".css"));
11829
- 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];
11830
- });
11831
- });
11832
- }
11833
- }
11834
- class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
11835
- name = binding_.BuiltinPluginName.SharedUsedExportsOptimizerPlugin;
11836
- sharedOptions;
11837
- injectUsedExports;
11838
- manifestOptions;
11839
- constructor(sharedOptions, injectUsedExports, manifestOptions){
11840
- super(), this.sharedOptions = sharedOptions, this.injectUsedExports = injectUsedExports ?? !0, this.manifestOptions = manifestOptions ?? {};
11841
- }
11842
- buildOptions() {
11843
- let shared = this.sharedOptions.map(([shareKey, config])=>({
11844
- shareKey,
11845
- treeshake: !!config.treeshake,
11846
- usedExports: config.usedExports
11847
- })), { manifestFileName, statsFileName } = getFileName(this.manifestOptions);
11848
- return {
11849
- shared,
11850
- injectUsedExports: this.injectUsedExports,
11851
- manifestFileName,
11852
- statsFileName
11853
- };
11854
- }
11855
- raw() {
11856
- if (this.sharedOptions.length) return createBuiltinPlugin(this.name, this.buildOptions());
11857
- }
11858
- }
11859
- let VIRTUAL_ENTRY = "./virtual-entry.js", VIRTUAL_ENTRY_NAME = "virtual-entry";
11860
- class VirtualEntryPlugin {
11861
- sharedOptions;
11862
- constructor(sharedOptions){
11863
- this.sharedOptions = sharedOptions;
11864
- }
11865
- createEntry() {
11866
- let { sharedOptions } = this;
11867
- return sharedOptions.reduce((acc, cur, index)=>`${acc}import shared_${index} from '${cur[0]}';\n`, "");
11868
- }
11869
- static entry() {
11870
- return {
11871
- [VIRTUAL_ENTRY_NAME]: VIRTUAL_ENTRY
11872
- };
11873
- }
11874
- apply(compiler) {
11875
- new compiler.rspack.experiments.VirtualModulesPlugin({
11876
- [VIRTUAL_ENTRY]: this.createEntry()
11877
- }).apply(compiler), compiler.hooks.thisCompilation.tap("RemoveVirtualEntryAsset", (compilation)=>{
11878
- compilation.hooks.processAssets.tapPromise({
11879
- name: "RemoveVirtualEntryAsset",
11880
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
11881
- }, async ()=>{
11882
- try {
11883
- let chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
11884
- chunk?.files.forEach((f)=>{
11885
- compilation.deleteAsset(f);
11886
- });
11887
- } catch (_e) {
11888
- console.error("Failed to remove virtual entry file!");
11889
- }
11890
- });
11891
- });
11892
- }
11893
- }
11894
- class IndependentSharedPlugin {
11895
- mfName;
11896
- shared;
11897
- library;
11898
- sharedOptions;
11899
- outputDir;
11900
- outputFilePath;
11901
- plugins;
11902
- compilers = new Map();
11903
- treeshake;
11904
- manifest;
11905
- buildAssets = {};
11906
- injectUsedExports;
11907
- name = "IndependentSharedPlugin";
11908
- constructor(options){
11909
- const { outputDir, outputFilePath, plugins, treeshake, shared, name, manifest, injectUsedExports, library } = options;
11910
- 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)=>{
11911
- if ("string" != typeof item) throw Error(`Unexpected array in shared configuration for key "${key}"`);
11912
- return item !== key && isRequiredVersion(item) ? {
11913
- import: key,
11914
- requiredVersion: item
11915
- } : {
11916
- import: item
11917
- };
11918
- }, (item)=>item);
11919
- }
11920
- apply(compiler) {
11921
- compiler.hooks.beforeRun.tapPromise("IndependentSharedPlugin", async (compiler)=>{
11922
- await this.createIndependentCompilers(compiler);
11923
- }), compiler.hooks.shutdown.tapAsync("IndependentSharedPlugin", (callback)=>{
11924
- this.cleanup(), callback();
11925
- }), compiler.hooks.compilation.tap("IndependentSharedPlugin", (compilation)=>{
11926
- compilation.hooks.processAssets.tapPromise({
11927
- name: "injectBuildAssets",
11928
- stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
11929
- }, async ()=>{
11930
- if (!this.manifest) return;
11931
- let { statsFileName, manifestFileName } = getFileName(this.manifest), injectBuildAssetsIntoStatsOrManifest = (filename)=>{
11932
- let stats = compilation.getAsset(filename);
11933
- if (!stats) return;
11934
- let statsContent = JSON.parse(stats.source.source().toString()), { shared } = statsContent;
11935
- Object.entries(this.buildAssets).forEach(([key, item])=>{
11936
- let targetShared = shared.find((s)=>s.name === key);
11937
- targetShared && item.forEach(([entry, version, globalName])=>{
11938
- version === targetShared.version && (targetShared.fallback = entry, targetShared.fallbackName = globalName);
11939
- });
11940
- }), compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
11941
- };
11942
- injectBuildAssetsIntoStatsOrManifest(statsFileName), injectBuildAssetsIntoStatsOrManifest(manifestFileName);
11943
- });
11944
- });
11945
- }
11946
- async createIndependentCompilers(parentCompiler) {
11947
- let { sharedOptions, buildAssets } = this;
11948
- console.log("🚀 Start creating a standalone compiler...");
11949
- let parentOutputDir = parentCompiler.options.output.path ? (0, external_node_path_namespaceObject.basename)(parentCompiler.options.output.path) : "", shareRequestsMap = await this.createIndependentCompiler(parentCompiler, parentOutputDir);
11950
- await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
11951
- if (!shareConfig.treeshake || !1 === shareConfig.import) return;
11952
- let shareRequests = shareRequestsMap[shareName].requests;
11953
- await Promise.all(shareRequests.map(async ([request, version])=>{
11954
- let sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1], [shareFileName, globalName] = await this.createIndependentCompiler(parentCompiler, parentOutputDir, {
11955
- shareRequestsMap,
11956
- currentShare: {
11957
- shareName,
11958
- version,
11959
- request,
11960
- independentShareFileName: sharedConfig?.independentShareFileName
11961
- }
11962
- });
11963
- "string" == typeof shareFileName && (buildAssets[shareName] ||= [], buildAssets[shareName].push([
11964
- shareFileName,
11965
- version,
11966
- globalName
11967
- ]));
11968
- }));
11969
- })), console.log("✅ All independent packages have been compiled successfully");
11970
- }
11971
- async createIndependentCompiler(parentCompiler, parentOutputDir, extraOptions) {
11972
- 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;
11973
- extraPlugin = extraOptions ? new ShareContainerPlugin({
11974
- mfName,
11975
- library,
11976
- ...extraOptions.currentShare
11977
- }) : new CollectSharedEntryPlugin({
11978
- sharedOptions,
11979
- shareScope: "default"
11980
- }), (parentConfig.plugins || []).forEach((plugin)=>{
11981
- void 0 !== plugin && "string" != typeof plugin && ((plugin)=>{
11982
- if (!plugin) return !0;
11983
- let pluginName = plugin.name || plugin.constructor?.name;
11984
- return !pluginName || ![
11985
- "TreeShakeSharedPlugin",
11986
- "IndependentSharedPlugin",
11987
- "ModuleFederationPlugin",
11988
- "SharedUsedExportsOptimizerPlugin",
11989
- "HtmlWebpackPlugin"
11990
- ].includes(pluginName);
11991
- })(plugin) && finalPlugins.push(plugin);
11992
- }), plugins.forEach((plugin)=>{
11993
- finalPlugins.push(plugin);
11994
- }), finalPlugins.push(extraPlugin), finalPlugins.push(new ConsumeSharedPlugin({
11995
- consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
11996
- [key]: {
11997
- import: !extraOptions && options.import,
11998
- shareKey: options.shareKey || key,
11999
- shareScope: options.shareScope,
12000
- requiredVersion: options.requiredVersion,
12001
- strictVersion: options.strictVersion,
12002
- singleton: options.singleton,
12003
- packageName: options.packageName,
12004
- eager: options.eager
12005
- }
12006
- })),
12007
- enhanced: !0
12008
- })), treeshake && finalPlugins.push(new SharedUsedExportsOptimizerPlugin(sharedOptions, this.injectUsedExports)), finalPlugins.push(new VirtualEntryPlugin(sharedOptions));
12009
- let fullOutputDir = (0, external_node_path_namespaceObject.resolve)(parentCompiler.outputPath, outputDirWithShareName), compilerConfig = {
12010
- ...parentConfig,
12011
- mode: parentConfig.mode || "development",
12012
- entry: VirtualEntryPlugin.entry,
12013
- output: {
12014
- path: fullOutputDir,
12015
- clean: !0,
12016
- publicPath: parentConfig.output?.publicPath || "auto"
12017
- },
12018
- plugins: finalPlugins,
12019
- optimization: {
12020
- ...parentConfig.optimization,
12021
- splitChunks: !1
12022
- }
12023
- }, compiler = rspack.rspack(compilerConfig);
12024
- compiler.inputFileSystem = parentCompiler.inputFileSystem, compiler.outputFileSystem = parentCompiler.outputFileSystem, compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
12025
- let { currentShare } = extraOptions || {};
12026
- return currentShare && this.compilers.set(`${currentShare.shareName}@${currentShare.version}`, compiler), new Promise((resolve, reject)=>{
12027
- compiler.run((err, stats)=>{
12028
- if (err || stats?.hasErrors()) {
12029
- let target = currentShare ? currentShare.shareName : "收集依赖";
12030
- console.error(`❌ ${target} 编译失败:`, err || stats.toJson().errors.map((e)=>e.message).join("\n")), reject(err || Error(`${target} 编译失败`));
12031
- return;
12032
- }
12033
- currentShare && console.log(`✅ 独立包 ${currentShare.shareName} 编译成功`), stats && (currentShare && console.log(`📊 ${currentShare.shareName} 编译统计:`), console.log(stats.toString({
12034
- colors: !0,
12035
- chunks: !1,
12036
- modules: !1
12037
- }))), resolve(extraPlugin.getData());
12038
- });
12039
- });
12040
- }
12041
- cleanup() {
12042
- this.compilers.forEach((compiler)=>{
12043
- compiler.watching && compiler.watching.close(()=>{
12044
- console.log("👋 编译器已关闭");
12045
- });
12046
- }), this.compilers.clear();
12047
- }
12048
- }
12049
- class TreeShakeSharedPlugin {
12050
- mfConfig;
12051
- outputDir;
12052
- plugins;
12053
- reshake;
12054
- _independentSharePlugin;
12055
- name = "TreeShakeSharedPlugin";
12056
- constructor(options){
12057
- const { mfConfig, plugins, reshake } = options;
12058
- this.mfConfig = mfConfig, this.outputDir = mfConfig.independentShareDir || "independent-packages", this.plugins = plugins, this.reshake = !!reshake;
12059
- }
12060
- apply(compiler) {
12061
- let { mfConfig, outputDir, plugins, reshake } = this, { name, shared, library } = mfConfig;
12062
- if (!shared) return;
12063
- let sharedOptions = normalizeSharedOptions(shared);
12064
- sharedOptions.length && (reshake || new SharedUsedExportsOptimizerPlugin(sharedOptions, mfConfig.injectUsedExports, mfConfig.manifest).apply(compiler), sharedOptions.some(([_, config])=>config.treeshake && !1 !== config.import) && (this._independentSharePlugin = new IndependentSharedPlugin({
12065
- name: name,
12066
- shared: shared,
12067
- outputDir,
12068
- plugins,
12069
- treeshake: reshake,
12070
- library,
12071
- manifest: mfConfig.manifest
12072
- }), this._independentSharePlugin.apply(compiler)));
12073
- }
12074
- get buildAssets() {
12075
- return this._independentSharePlugin?.buildAssets || {};
12076
- }
12077
- }
12078
- let ModuleFederationRuntimePlugin = base_create(binding_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
12079
- function getRemoteInfos(options) {
12080
- if (!options.remotes) return {};
12081
- let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
12082
- external: Array.isArray(item) ? item : [
12083
- item
12084
- ],
12085
- shareScope: options.shareScope || "default"
12086
- }), (item)=>({
12087
- external: Array.isArray(item.external) ? item.external : [
12088
- item.external
12089
- ],
12090
- shareScope: item.shareScope || options.shareScope || "default"
12091
- })), remoteInfos = {};
12092
- for (let [key, config] of remotes)for (let external of config.external){
12093
- let [externalType, externalRequest] = function(external) {
12094
- let result = function(external) {
12095
- if (/^[a-z0-9-]+ /.test(external)) {
12096
- let idx = external.indexOf(" ");
12097
- return [
12098
- external.slice(0, idx),
12099
- external.slice(idx + 1)
12100
- ];
12101
- }
12102
- return null;
12103
- }(external);
12104
- return null === result ? [
12105
- remoteType,
12106
- external
12107
- ] : result;
12108
- }(external);
12109
- if (remoteInfos[key] ??= [], "script" === externalType) {
12110
- let [url, global] = function(urlAndGlobal) {
12111
- let index = urlAndGlobal.indexOf("@");
12112
- return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
12113
- urlAndGlobal.substring(index + 1),
12114
- urlAndGlobal.substring(0, index)
12115
- ];
12116
- }(externalRequest);
12117
- remoteInfos[key].push({
12118
- alias: key,
12119
- name: global,
12120
- entry: url,
12121
- externalType,
12122
- shareScope: config.shareScope
12123
- });
12124
- } else remoteInfos[key].push({
12125
- alias: key,
12126
- name: void 0,
12127
- entry: void 0,
12128
- externalType,
12129
- shareScope: config.shareScope
12130
- });
12131
- }
12132
- return remoteInfos;
12133
- }
12134
11732
  class ContainerPlugin extends RspackBuiltinPlugin {
12135
11733
  name = binding_.BuiltinPluginName.ContainerPlugin;
12136
11734
  _options;
@@ -12222,7 +11820,7 @@ Help:
12222
11820
  let _options = JSON.stringify(options || {});
12223
11821
  return binding_default().transform(source, _options);
12224
11822
  }
12225
- let exports_rspackVersion = "1.6.5-canary-a407d226-20251124112255", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
11823
+ let exports_rspackVersion = "1.6.5-canary-e23badc4-20251124174040", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
12226
11824
  getNormalizedRspackOptions: getNormalizedRspackOptions,
12227
11825
  applyRspackOptionsDefaults: applyRspackOptionsDefaults,
12228
11826
  getNormalizedWebpackOptions: getNormalizedRspackOptions,
@@ -12265,12 +11863,11 @@ Help:
12265
11863
  ContainerReferencePlugin: ContainerReferencePlugin,
12266
11864
  ModuleFederationPlugin: class {
12267
11865
  _options;
12268
- _treeShakeSharedPlugin;
12269
11866
  constructor(_options){
12270
11867
  this._options = _options;
12271
11868
  }
12272
11869
  apply(compiler) {
12273
- var options, options1;
11870
+ var options;
12274
11871
  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", {
12275
11872
  paths: [
12276
11873
  runtimeToolsPath
@@ -12284,53 +11881,101 @@ Help:
12284
11881
  bundlerRuntime: bundlerRuntimePath,
12285
11882
  runtime: runtimePath
12286
11883
  });
12287
- compiler.options.resolve.alias = {
11884
+ if (compiler.options.resolve.alias = {
12288
11885
  "@module-federation/runtime-tools": paths.runtimeTools,
12289
11886
  "@module-federation/runtime": paths.runtime,
12290
11887
  ...compiler.options.resolve.alias
12291
- }, ((options1 = this._options).shared ? parseOptions(options1.shared, (item, key)=>{
12292
- if ("string" != typeof item) throw Error("Unexpected array in shared");
12293
- return item !== key && isRequiredVersion(item) ? {
12294
- import: key,
12295
- requiredVersion: item
12296
- } : {
12297
- import: item
12298
- };
12299
- }, (item)=>item) : []).filter(([, config])=>config.treeshake).length > 0 && (this._treeShakeSharedPlugin = new TreeShakeSharedPlugin({
12300
- mfConfig: this._options,
12301
- reshake: !1
12302
- }), this._treeShakeSharedPlugin.apply(compiler));
12303
- let runtimePluginApplied = !1;
12304
- compiler.hooks.beforeRun.tapPromise({
12305
- name: "ModuleFederationPlugin",
12306
- stage: 100
12307
- }, async ()=>{
12308
- runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
12309
- entryRuntime: function(paths, options, compiler, treeshakeShareFallbacks) {
12310
- let runtimePlugins = options.runtimePlugins ?? [], remoteInfos = getRemoteInfos(options), runtimePluginImports = [], runtimePluginVars = [];
12311
- for(let i = 0; i < runtimePlugins.length; i++){
12312
- 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;
12313
- runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
12314
- let paramsCode = void 0 === pluginParams ? "undefined" : JSON.stringify(pluginParams);
12315
- runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
12316
- }
12317
- let content = [
12318
- `import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
12319
- ...runtimePluginImports,
12320
- `const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(", ")}]`,
12321
- `const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
12322
- `const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
12323
- `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? "version-first")}`,
12324
- `const __module_federation_share_fallbacks__ = ${JSON.stringify(treeshakeShareFallbacks)}`,
12325
- compiler.webpack.Template.getFunctionContent(__webpack_require__("./moduleFederationDefaultRuntime.js"))
12326
- ].join(";");
12327
- return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
12328
- }(paths, this._options, compiler, this._treeShakeSharedPlugin?.buildAssets || {})
12329
- }).apply(compiler));
12330
- }), new webpack.container.ModuleFederationPluginV1({
11888
+ }, new ModuleFederationRuntimePlugin({
11889
+ entryRuntime: function(paths, options, compiler) {
11890
+ let runtimePlugins = options.runtimePlugins ?? [], remoteInfos = getRemoteInfos(options), runtimePluginImports = [], runtimePluginVars = [];
11891
+ for(let i = 0; i < runtimePlugins.length; i++){
11892
+ 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;
11893
+ runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
11894
+ let paramsCode = void 0 === pluginParams ? "undefined" : JSON.stringify(pluginParams);
11895
+ runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
11896
+ }
11897
+ let content = [
11898
+ `import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
11899
+ ...runtimePluginImports,
11900
+ `const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(", ")}]`,
11901
+ `const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
11902
+ `const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
11903
+ `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? "version-first")}`,
11904
+ compiler.webpack.Template.getFunctionContent(__webpack_require__("./moduleFederationDefaultRuntime.js"))
11905
+ ].join(";");
11906
+ return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
11907
+ }(paths, this._options, compiler)
11908
+ }).apply(compiler), new webpack.container.ModuleFederationPluginV1({
12331
11909
  ...this._options,
12332
11910
  enhanced: !0
12333
- }).apply(compiler), this._options.manifest && new ModuleFederationManifestPlugin(this._options).apply(compiler);
11911
+ }).apply(compiler), this._options.manifest) {
11912
+ let manifestOptions = !0 === this._options.manifest ? {} : {
11913
+ ...this._options.manifest
11914
+ }, containerName = manifestOptions.name ?? this._options.name, globalName = manifestOptions.globalName ?? function(library) {
11915
+ if (!library) return;
11916
+ let libName = library.name;
11917
+ if (libName) {
11918
+ if ("string" == typeof libName) return libName;
11919
+ if (Array.isArray(libName)) return libName[0];
11920
+ if ("object" == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
11921
+ }
11922
+ }(this._options.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
11923
+ if (cur[1].length > 1) return sum;
11924
+ let { entry, alias, name } = cur[1][0];
11925
+ return entry && name && (sum[alias] = {
11926
+ name,
11927
+ entry
11928
+ }), sum;
11929
+ }, {}), manifestExposes = function(exposes) {
11930
+ if (!exposes) return;
11931
+ let result = parseOptions(exposes, (value, key)=>({
11932
+ import: Array.isArray(value) ? value : [
11933
+ value
11934
+ ],
11935
+ name: void 0
11936
+ }), (value)=>({
11937
+ import: Array.isArray(value.import) ? value.import : [
11938
+ value.import
11939
+ ],
11940
+ name: value.name ?? void 0
11941
+ })).map(([exposeKey, info])=>{
11942
+ let exposeName = info.name ?? exposeKey.replace(/^\.\//, "");
11943
+ return {
11944
+ path: exposeKey,
11945
+ name: exposeName
11946
+ };
11947
+ });
11948
+ return result.length > 0 ? result : void 0;
11949
+ }(this._options.exposes);
11950
+ void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes);
11951
+ let manifestShared = function(shared) {
11952
+ if (!shared) return;
11953
+ let result = parseOptions(shared, (item, key)=>{
11954
+ if ("string" != typeof item) throw Error("Unexpected array in shared");
11955
+ return item !== key && isRequiredVersion(item) ? {
11956
+ import: key,
11957
+ requiredVersion: item
11958
+ } : {
11959
+ import: item
11960
+ };
11961
+ }, (item)=>item).map(([key, config])=>{
11962
+ let name = config.shareKey || key, version = "string" == typeof config.version ? config.version : void 0;
11963
+ return {
11964
+ name,
11965
+ version,
11966
+ requiredVersion: "string" == typeof config.requiredVersion ? config.requiredVersion : void 0,
11967
+ singleton: config.singleton
11968
+ };
11969
+ });
11970
+ return result.length > 0 ? result : void 0;
11971
+ }(this._options.shared);
11972
+ void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), new ModuleFederationManifestPlugin({
11973
+ ...manifestOptions,
11974
+ name: containerName,
11975
+ globalName,
11976
+ remoteAliasMap
11977
+ }).apply(compiler);
11978
+ }
12334
11979
  }
12335
11980
  },
12336
11981
  ModuleFederationPluginV1: class {
@@ -12367,7 +12012,6 @@ Help:
12367
12012
  }
12368
12013
  }, sharing = {
12369
12014
  ProvideSharedPlugin: ProvideSharedPlugin,
12370
- TreeShakeSharedPlugin: TreeShakeSharedPlugin,
12371
12015
  ConsumeSharedPlugin: ConsumeSharedPlugin,
12372
12016
  SharePlugin: SharePlugin
12373
12017
  }, exports_experiments = {