@rspack-canary/browser 1.6.5-canary-e23badc4-20251124174040 → 1.6.5-canary-a27f526c-20251125032833

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2738,7 +2738,7 @@ var __webpack_modules__ = {
2738
2738
  BN.wordSize = 26;
2739
2739
  var Buffer;
2740
2740
  try {
2741
- Buffer = 'undefined' != typeof window && void 0 !== window.Buffer ? window.Buffer : __webpack_require__("?4fc0").Buffer;
2741
+ Buffer = 'undefined' != typeof window && void 0 !== window.Buffer ? window.Buffer : __webpack_require__("?82da").Buffer;
2742
2742
  } catch (e) {}
2743
2743
  BN.isBN = function(num) {
2744
2744
  if (num instanceof BN) return true;
@@ -5228,7 +5228,7 @@ var __webpack_modules__ = {
5228
5228
  BN.wordSize = 26;
5229
5229
  var Buffer;
5230
5230
  try {
5231
- Buffer = 'undefined' != typeof window && void 0 !== window.Buffer ? window.Buffer : __webpack_require__("?dcfb").Buffer;
5231
+ Buffer = 'undefined' != typeof window && void 0 !== window.Buffer ? window.Buffer : __webpack_require__("?6bd9").Buffer;
5232
5232
  } catch (e) {}
5233
5233
  BN.isBN = function(num) {
5234
5234
  if (num instanceof BN) return true;
@@ -7776,7 +7776,7 @@ var __webpack_modules__ = {
7776
7776
  throw new Error('Not implemented yet');
7777
7777
  };
7778
7778
  } else try {
7779
- var crypto = __webpack_require__("?69f8");
7779
+ var crypto = __webpack_require__("?8a00");
7780
7780
  if ('function' != typeof crypto.randomBytes) throw new Error('Not supported');
7781
7781
  Rand.prototype._rand = function(n) {
7782
7782
  return crypto.randomBytes(n);
@@ -18975,7 +18975,7 @@ var __webpack_modules__ = {
18975
18975
  }
18976
18976
  return $replace.call(str, sepRegex, '$&_');
18977
18977
  }
18978
- var utilInspect = __webpack_require__("?f42a");
18978
+ var utilInspect = __webpack_require__("?75b9");
18979
18979
  var inspectCustom = utilInspect.custom;
18980
18980
  var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null;
18981
18981
  var quotes = {
@@ -24912,7 +24912,7 @@ var __webpack_modules__ = {
24912
24912
  }
24913
24913
  var util = Object.create(__webpack_require__("../../node_modules/.pnpm/core-util-is@1.0.3/node_modules/core-util-is/lib/util.js"));
24914
24914
  util.inherits = __webpack_require__("../../node_modules/.pnpm/inherits@2.0.4/node_modules/inherits/inherits_browser.js");
24915
- var debugUtil = __webpack_require__("?b05f");
24915
+ var debugUtil = __webpack_require__("?48e1");
24916
24916
  var debug = void 0;
24917
24917
  debug = debugUtil && debugUtil.debuglog ? debugUtil.debuglog('stream') : function() {};
24918
24918
  var BufferList = __webpack_require__("../../node_modules/.pnpm/readable-stream@2.3.8/node_modules/readable-stream/lib/internal/streams/BufferList.js");
@@ -26032,7 +26032,7 @@ var __webpack_modules__ = {
26032
26032
  if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
26033
26033
  }
26034
26034
  var Buffer = __webpack_require__("../../node_modules/.pnpm/safe-buffer@5.1.2/node_modules/safe-buffer/index.js").Buffer;
26035
- var util = __webpack_require__("?5f4e");
26035
+ var util = __webpack_require__("?bc12");
26036
26036
  function copyBuffer(src, target, offset) {
26037
26037
  src.copy(target, offset);
26038
26038
  }
@@ -26348,7 +26348,7 @@ var __webpack_modules__ = {
26348
26348
  function _isUint8Array(obj) {
26349
26349
  return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
26350
26350
  }
26351
- var debugUtil = __webpack_require__("?8beb");
26351
+ var debugUtil = __webpack_require__("?14dd");
26352
26352
  var debug;
26353
26353
  debug = debugUtil && debugUtil.debuglog ? debugUtil.debuglog('stream') : function() {};
26354
26354
  var BufferList = __webpack_require__("../../node_modules/.pnpm/readable-stream@3.6.2/node_modules/readable-stream/lib/internal/streams/buffer_list.js");
@@ -27725,7 +27725,7 @@ var __webpack_modules__ = {
27725
27725
  return ("string" === hint ? String : Number)(input);
27726
27726
  }
27727
27727
  var _require = __webpack_require__("./src/browser/buffer.ts"), Buffer = _require.Buffer;
27728
- var _require2 = __webpack_require__("?c028"), inspect = _require2.inspect;
27728
+ var _require2 = __webpack_require__("?fe28"), inspect = _require2.inspect;
27729
27729
  var custom = inspect && inspect.custom || 'inspect';
27730
27730
  function copyBuffer(src, target, offset) {
27731
27731
  Buffer.prototype.copy.call(src, target, offset);
@@ -35341,14 +35341,14 @@ var __webpack_modules__ = {
35341
35341
  "@rspack/binding": function(module1) {
35342
35342
  module1.exports = __WEBPACK_EXTERNAL_MODULE__rspack_wasi_browser_js_bd433424__;
35343
35343
  },
35344
- "?4fc0": function() {},
35345
- "?dcfb": function() {},
35346
- "?69f8": function() {},
35347
- "?f42a": function() {},
35348
- "?5f4e": function() {},
35349
- "?b05f": function() {},
35350
- "?c028": function() {},
35351
- "?8beb": function() {},
35344
+ "?82da": function() {},
35345
+ "?6bd9": function() {},
35346
+ "?8a00": function() {},
35347
+ "?75b9": function() {},
35348
+ "?bc12": function() {},
35349
+ "?48e1": function() {},
35350
+ "?fe28": function() {},
35351
+ "?14dd": function() {},
35352
35352
  "../../node_modules/.pnpm/available-typed-arrays@1.0.7/node_modules/available-typed-arrays/index.js": function(module1, __unused_webpack_exports, __webpack_require__) {
35353
35353
  var possibleNames = __webpack_require__("../../node_modules/.pnpm/possible-typed-array-names@1.1.0/node_modules/possible-typed-array-names/index.js");
35354
35354
  var g = 'undefined' == typeof globalThis ? __webpack_require__.g : globalThis;
@@ -56766,7 +56766,6 @@ function SubresourceIntegrityPlugin_define_property(obj, key, value) {
56766
56766
  }
56767
56767
  const SubresourceIntegrityPlugin_PLUGIN_NAME = "SubresourceIntegrityPlugin";
56768
56768
  const NATIVE_HTML_PLUGIN = "HtmlRspackPlugin";
56769
- const HTTP_PROTOCOL_REGEX = /^https?:/;
56770
56769
  const NativeSubresourceIntegrityPlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.SubresourceIntegrityPlugin, function(options) {
56771
56770
  let htmlPlugin = "Disabled";
56772
56771
  if (options.htmlPlugin === NATIVE_HTML_PLUGIN) htmlPlugin = "Native";
@@ -56804,25 +56803,11 @@ class SubresourceIntegrityPlugin extends NativeSubresourceIntegrityPlugin {
56804
56803
  if (tag.attributes && "integrity" in tag.attributes) return;
56805
56804
  const tagSrc = getTagSrc(tag);
56806
56805
  if (!tagSrc) return;
56807
- let isUrlSrc = false;
56808
56806
  try {
56809
56807
  const url = new URL(tagSrc);
56810
- isUrlSrc = "http:" === url.protocol || "https:" === url.protocol;
56811
- } catch (_) {
56812
- isUrlSrc = tagSrc.startsWith("//");
56813
- }
56814
- let src = "";
56815
- if (isUrlSrc) {
56816
- if (!publicPath) return;
56817
- const protocolRelativePublicPath = publicPath.replace(HTTP_PROTOCOL_REGEX, "");
56818
- const protocolRelativeTagSrc = tagSrc.replace(HTTP_PROTOCOL_REGEX, "");
56819
- if (!protocolRelativeTagSrc.startsWith(protocolRelativePublicPath)) return;
56820
- {
56821
- const tagSrcWithScheme = `http:${protocolRelativeTagSrc}`;
56822
- const publicPathWithScheme = protocolRelativePublicPath.startsWith("//") ? `http:${protocolRelativePublicPath}` : protocolRelativePublicPath;
56823
- src = (0, path_browserify.relative)(publicPathWithScheme, decodeURIComponent(tagSrcWithScheme));
56824
- }
56825
- } else src = (0, path_browserify.relative)(publicPath, decodeURIComponent(tagSrc));
56808
+ if (("http:" === url.protocol || "https:" === url.protocol) && (!publicPath || !tagSrc.startsWith(publicPath))) return;
56809
+ } catch (_) {}
56810
+ const src = (0, path_browserify.relative)(publicPath, decodeURIComponent(tagSrc));
56826
56811
  tag.attributes.integrity = this.getIntegrityChecksumForAsset(src) || computeIntegrity(this.options.hashFuncNames, (0, browser_fs.readFileSync)((0, path_browserify.join)(outputPath, src)));
56827
56812
  tag.attributes.crossorigin = crossOriginLoading || "anonymous";
56828
56813
  }
@@ -58156,7 +58141,7 @@ const applybundlerInfoDefaults = (rspackFuture, library)=>{
58156
58141
  if ("object" == typeof rspackFuture) {
58157
58142
  D(rspackFuture, "bundlerInfo", {});
58158
58143
  if ("object" == typeof rspackFuture.bundlerInfo) {
58159
- D(rspackFuture.bundlerInfo, "version", "1.6.5-canary-e23badc4-20251124174040");
58144
+ D(rspackFuture.bundlerInfo, "version", "1.6.5-canary-a27f526c-20251125032833");
58160
58145
  D(rspackFuture.bundlerInfo, "bundler", "rspack");
58161
58146
  D(rspackFuture.bundlerInfo, "force", !library);
58162
58147
  }
@@ -62105,7 +62090,7 @@ class MultiStats {
62105
62090
  return obj;
62106
62091
  });
62107
62092
  if (childOptions.version) {
62108
- obj.rspackVersion = "1.6.5-canary-e23badc4-20251124174040";
62093
+ obj.rspackVersion = "1.6.5-canary-a27f526c-20251125032833";
62109
62094
  obj.version = "5.75.0";
62110
62095
  }
62111
62096
  if (childOptions.hash) obj.hash = obj.children.map((j)=>j.hash).join("");
@@ -63410,7 +63395,7 @@ const SIMPLE_EXTRACTORS = {
63410
63395
  },
63411
63396
  version: (object)=>{
63412
63397
  object.version = "5.75.0";
63413
- object.rspackVersion = "1.6.5-canary-e23badc4-20251124174040";
63398
+ object.rspackVersion = "1.6.5-canary-a27f526c-20251125032833";
63414
63399
  },
63415
63400
  env: (object, _compilation, _context, { _env })=>{
63416
63401
  object.env = _env;
@@ -65843,6 +65828,34 @@ const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
65843
65828
  function isRequiredVersion(str) {
65844
65829
  return VERSION_PATTERN_REGEXP.test(str);
65845
65830
  }
65831
+ const encodeName = function(name, prefix = "", withExt = false) {
65832
+ const ext = withExt ? ".js" : "";
65833
+ return `${prefix}${name.replace(/@/g, "scope_").replace(/-/g, "_").replace(/\//g, "__").replace(/\./g, "")}${ext}`;
65834
+ };
65835
+ const options_process = (options, normalizeSimple, normalizeOptions, fn)=>{
65836
+ const array = (items)=>{
65837
+ for (const item of items)if ("string" == typeof item) fn(item, normalizeSimple(item, item));
65838
+ else if (item && "object" == typeof item) object(item);
65839
+ else throw new Error("Unexpected options format");
65840
+ };
65841
+ const object = (obj)=>{
65842
+ for (const [key, value] of Object.entries(obj))"string" == typeof value || Array.isArray(value) ? fn(key, normalizeSimple(value, key)) : fn(key, normalizeOptions(value, key));
65843
+ };
65844
+ if (!options) return;
65845
+ if (Array.isArray(options)) array(options);
65846
+ else if ("object" == typeof options) object(options);
65847
+ else throw new Error("Unexpected options format");
65848
+ };
65849
+ const parseOptions = (options, normalizeSimple, normalizeOptions)=>{
65850
+ const items = [];
65851
+ options_process(options, normalizeSimple, normalizeOptions, (key, value)=>{
65852
+ items.push([
65853
+ key,
65854
+ value
65855
+ ]);
65856
+ });
65857
+ return items;
65858
+ };
65846
65859
  var ModuleFederationManifestPlugin_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
65847
65860
  function ModuleFederationManifestPlugin_define_property(obj, key, value) {
65848
65861
  if (key in obj) Object.defineProperty(obj, key, {
@@ -65909,118 +65922,17 @@ function getFileName(manifestOptions) {
65909
65922
  manifestFileName: (0, path_browserify.join)(filePath, manifestFileName)
65910
65923
  };
65911
65924
  }
65912
- class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
65913
- raw(compiler) {
65914
- const { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts;
65915
- const { statsFileName, manifestFileName } = getFileName(this.opts);
65916
- const rawOptions = {
65917
- name: this.opts.name,
65918
- globalName: this.opts.globalName,
65919
- fileName,
65920
- filePath,
65921
- manifestFileName,
65922
- statsFileName,
65923
- disableAssetsAnalyze,
65924
- remoteAliasMap,
65925
- exposes,
65926
- shared,
65927
- buildInfo: getBuildInfo("development" === compiler.options.mode, compiler.context)
65928
- };
65929
- return createBuiltinPlugin(this.name, rawOptions);
65930
- }
65931
- constructor(opts){
65932
- super(), ModuleFederationManifestPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationManifestPlugin), ModuleFederationManifestPlugin_define_property(this, "opts", void 0);
65933
- this.opts = opts;
65934
- }
65935
- }
65936
- const ModuleFederationRuntimePlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
65937
- const options_process = (options, normalizeSimple, normalizeOptions, fn)=>{
65938
- const array = (items)=>{
65939
- for (const item of items)if ("string" == typeof item) fn(item, normalizeSimple(item, item));
65940
- else if (item && "object" == typeof item) object(item);
65941
- else throw new Error("Unexpected options format");
65942
- };
65943
- const object = (obj)=>{
65944
- for (const [key, value] of Object.entries(obj))"string" == typeof value || Array.isArray(value) ? fn(key, normalizeSimple(value, key)) : fn(key, normalizeOptions(value, key));
65945
- };
65946
- if (!options) return;
65947
- if (Array.isArray(options)) array(options);
65948
- else if ("object" == typeof options) object(options);
65949
- else throw new Error("Unexpected options format");
65950
- };
65951
- const parseOptions = (options, normalizeSimple, normalizeOptions)=>{
65952
- const items = [];
65953
- options_process(options, normalizeSimple, normalizeOptions, (key, value)=>{
65954
- items.push([
65955
- key,
65956
- value
65957
- ]);
65958
- });
65959
- return items;
65960
- };
65961
- function ModuleFederationPlugin_define_property(obj, key, value) {
65962
- if (key in obj) Object.defineProperty(obj, key, {
65963
- value: value,
65964
- enumerable: true,
65965
- configurable: true,
65966
- writable: true
65967
- });
65968
- else obj[key] = value;
65969
- return obj;
65970
- }
65971
- class ModuleFederationPlugin {
65972
- apply(compiler) {
65973
- const { webpack } = compiler;
65974
- const paths = getPaths(this._options);
65975
- compiler.options.resolve.alias = {
65976
- "@module-federation/runtime-tools": paths.runtimeTools,
65977
- "@module-federation/runtime": paths.runtime,
65978
- ...compiler.options.resolve.alias
65979
- };
65980
- const entryRuntime = getDefaultEntryRuntime(paths, this._options, compiler);
65981
- new ModuleFederationRuntimePlugin({
65982
- entryRuntime
65983
- }).apply(compiler);
65984
- new webpack.container.ModuleFederationPluginV1({
65985
- ...this._options,
65986
- enhanced: true
65987
- }).apply(compiler);
65988
- if (this._options.manifest) {
65989
- const manifestOptions = true === this._options.manifest ? {} : {
65990
- ...this._options.manifest
65991
- };
65992
- const containerName = manifestOptions.name ?? this._options.name;
65993
- const globalName = manifestOptions.globalName ?? resolveLibraryGlobalName(this._options.library) ?? containerName;
65994
- const remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
65995
- if (cur[1].length > 1) return sum;
65996
- const remoteInfo = cur[1][0];
65997
- const { entry, alias, name } = remoteInfo;
65998
- if (entry && name) sum[alias] = {
65999
- name,
66000
- entry
66001
- };
66002
- return sum;
66003
- }, {});
66004
- const manifestExposes = collectManifestExposes(this._options.exposes);
66005
- if (void 0 === manifestOptions.exposes && manifestExposes) manifestOptions.exposes = manifestExposes;
66006
- const manifestShared = collectManifestShared(this._options.shared);
66007
- if (void 0 === manifestOptions.shared && manifestShared) manifestOptions.shared = manifestShared;
66008
- new ModuleFederationManifestPlugin({
66009
- ...manifestOptions,
66010
- name: containerName,
66011
- globalName,
66012
- remoteAliasMap
66013
- }).apply(compiler);
66014
- }
66015
- }
66016
- constructor(_options){
66017
- ModuleFederationPlugin_define_property(this, "_options", void 0);
66018
- this._options = _options;
66019
- }
65925
+ function resolveLibraryGlobalName(library) {
65926
+ if (!library) return;
65927
+ const libName = library.name;
65928
+ if (!libName) return;
65929
+ if ("string" == typeof libName) return libName;
65930
+ if (Array.isArray(libName)) return libName[0];
65931
+ if ("object" == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
66020
65932
  }
66021
65933
  function collectManifestExposes(exposes) {
66022
65934
  if (!exposes) return;
66023
- const parsed = parseOptions(exposes, (value, key)=>({
65935
+ const parsed = parseOptions(exposes, (value)=>({
66024
65936
  import: Array.isArray(value) ? value : [
66025
65937
  value
66026
65938
  ],
@@ -66064,111 +65976,56 @@ function collectManifestShared(shared) {
66064
65976
  });
66065
65977
  return result.length > 0 ? result : void 0;
66066
65978
  }
66067
- function resolveLibraryGlobalName(library) {
66068
- if (!library) return;
66069
- const libName = library.name;
66070
- if (!libName) return;
66071
- if ("string" == typeof libName) return libName;
66072
- if (Array.isArray(libName)) return libName[0];
66073
- if ("object" == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
66074
- }
66075
- function getRemoteInfos(options) {
66076
- if (!options.remotes) return {};
66077
- function extractUrlAndGlobal(urlAndGlobal) {
66078
- const index = urlAndGlobal.indexOf("@");
66079
- if (index <= 0 || index === urlAndGlobal.length - 1) return null;
66080
- return [
66081
- urlAndGlobal.substring(index + 1),
66082
- urlAndGlobal.substring(0, index)
66083
- ];
66084
- }
66085
- function getExternalTypeFromExternal(external) {
66086
- if (/^[a-z0-9-]+ /.test(external)) {
66087
- const idx = external.indexOf(" ");
66088
- return [
66089
- external.slice(0, idx),
66090
- external.slice(idx + 1)
66091
- ];
66092
- }
66093
- return null;
66094
- }
66095
- function getExternal(external) {
66096
- const result = getExternalTypeFromExternal(external);
66097
- if (null === result) return [
66098
- remoteType,
66099
- external
66100
- ];
66101
- return result;
66102
- }
66103
- const remoteType = options.remoteType || (options.library ? options.library.type : "script");
66104
- const remotes = parseOptions(options.remotes, (item)=>({
66105
- external: Array.isArray(item) ? item : [
66106
- item
66107
- ],
66108
- shareScope: options.shareScope || "default"
66109
- }), (item)=>({
66110
- external: Array.isArray(item.external) ? item.external : [
66111
- item.external
66112
- ],
66113
- shareScope: item.shareScope || options.shareScope || "default"
66114
- }));
66115
- const remoteInfos = {};
66116
- for (const [key, config] of remotes)for (const external of config.external){
66117
- const [externalType, externalRequest] = getExternal(external);
66118
- remoteInfos[key] ??= [];
66119
- if ("script" === externalType) {
66120
- const [url, global] = extractUrlAndGlobal(externalRequest);
66121
- remoteInfos[key].push({
66122
- alias: key,
66123
- name: global,
66124
- entry: url,
66125
- externalType,
66126
- shareScope: config.shareScope
66127
- });
66128
- } else remoteInfos[key].push({
66129
- alias: key,
66130
- name: void 0,
66131
- entry: void 0,
66132
- externalType,
66133
- shareScope: config.shareScope
66134
- });
66135
- }
66136
- return remoteInfos;
66137
- }
66138
- function getRuntimePlugins(options) {
66139
- return options.runtimePlugins ?? [];
66140
- }
66141
- function getPaths(options) {
65979
+ function normalizeManifestOptions(mfConfig) {
65980
+ const manifestOptions = true === mfConfig.manifest ? {} : {
65981
+ ...mfConfig.manifest
65982
+ };
65983
+ const containerName = mfConfig.name;
65984
+ const globalName = resolveLibraryGlobalName(mfConfig.library) ?? containerName;
65985
+ const remoteAliasMap = Object.entries(getRemoteInfos(mfConfig)).reduce((sum, cur)=>{
65986
+ if (cur[1].length > 1) return sum;
65987
+ const remoteInfo = cur[1][0];
65988
+ const { entry, alias, name } = remoteInfo;
65989
+ if (entry && name) sum[alias] = {
65990
+ name,
65991
+ entry
65992
+ };
65993
+ return sum;
65994
+ }, {});
65995
+ const manifestExposes = collectManifestExposes(mfConfig.exposes);
65996
+ if (void 0 === manifestOptions.exposes && manifestExposes) manifestOptions.exposes = manifestExposes;
65997
+ const manifestShared = collectManifestShared(mfConfig.shared);
65998
+ if (void 0 === manifestOptions.shared && manifestShared) manifestOptions.shared = manifestShared;
66142
65999
  return {
66143
- runtimeTools: "@module-federation/runtime-tools",
66144
- bundlerRuntime: "@module-federation/webpack-bundler-runtime",
66145
- runtime: "@module-federation/runtime"
66000
+ ...manifestOptions,
66001
+ remoteAliasMap,
66002
+ globalName,
66003
+ name: containerName
66146
66004
  };
66147
66005
  }
66148
- function getDefaultEntryRuntime(paths, options, compiler) {
66149
- const runtimePlugins = getRuntimePlugins(options);
66150
- const remoteInfos = getRemoteInfos(options);
66151
- const runtimePluginImports = [];
66152
- const runtimePluginVars = [];
66153
- for(let i = 0; i < runtimePlugins.length; i++){
66154
- const runtimePluginVar = `__module_federation_runtime_plugin_${i}__`;
66155
- const pluginSpec = runtimePlugins[i];
66156
- const pluginPath = Array.isArray(pluginSpec) ? pluginSpec[0] : pluginSpec;
66157
- const pluginParams = Array.isArray(pluginSpec) ? pluginSpec[1] : void 0;
66158
- runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
66159
- const paramsCode = void 0 === pluginParams ? "undefined" : JSON.stringify(pluginParams);
66160
- runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
66006
+ class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
66007
+ raw(compiler) {
66008
+ const { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts;
66009
+ const { statsFileName, manifestFileName } = getFileName(this.opts);
66010
+ const rawOptions = {
66011
+ name: this.opts.name,
66012
+ globalName: this.opts.globalName,
66013
+ fileName,
66014
+ filePath,
66015
+ manifestFileName,
66016
+ statsFileName,
66017
+ disableAssetsAnalyze,
66018
+ remoteAliasMap,
66019
+ exposes,
66020
+ shared,
66021
+ buildInfo: getBuildInfo("development" === compiler.options.mode, compiler.context)
66022
+ };
66023
+ return createBuiltinPlugin(this.name, rawOptions);
66024
+ }
66025
+ constructor(opts){
66026
+ super(), ModuleFederationManifestPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationManifestPlugin), ModuleFederationManifestPlugin_define_property(this, "opts", void 0);
66027
+ this.opts = normalizeManifestOptions(opts);
66161
66028
  }
66162
- const content = [
66163
- `import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
66164
- ...runtimePluginImports,
66165
- `const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(", ")}]`,
66166
- `const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
66167
- `const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
66168
- `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? "version-first")}`,
66169
- 'if((__webpack_require__.initializeSharingData||__webpack_require__.initializeExposesData)&&__webpack_require__.federation){var __webpack_require___remotesLoadingData,__webpack_require___remotesLoadingData1,__webpack_require___initializeSharingData,__webpack_require___consumesLoadingData,__webpack_require___consumesLoadingData1,__webpack_require___initializeExposesData,__webpack_require___consumesLoadingData2;const override=(obj,key,value)=>{if(!obj)return;if(obj[key])obj[key]=value};const merge=(obj,key,fn)=>{const value=fn();if(Array.isArray(value)){var _obj,_key;var _;(_=(_obj=obj)[_key=key])!==null&&_!==void 0?_:_obj[_key]=[];obj[key].push(...value)}else if(typeof value==="object"&&value!==null){var _obj1,_key1;var _1;(_1=(_obj1=obj)[_key1=key])!==null&&_1!==void 0?_1:_obj1[_key1]={};Object.assign(obj[key],value)}};const early=(obj,key,initial)=>{var _obj,_key;var _;(_=(_obj=obj)[_key=key])!==null&&_!==void 0?_:_obj[_key]=initial()};var __webpack_require___remotesLoadingData_chunkMapping;const remotesLoadingChunkMapping=(__webpack_require___remotesLoadingData_chunkMapping=(__webpack_require___remotesLoadingData=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData===void 0?void 0:__webpack_require___remotesLoadingData.chunkMapping)!==null&&__webpack_require___remotesLoadingData_chunkMapping!==void 0?__webpack_require___remotesLoadingData_chunkMapping:{};var __webpack_require___remotesLoadingData_moduleIdToRemoteDataMapping;const remotesLoadingModuleIdToRemoteDataMapping=(__webpack_require___remotesLoadingData_moduleIdToRemoteDataMapping=(__webpack_require___remotesLoadingData1=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData1===void 0?void 0:__webpack_require___remotesLoadingData1.moduleIdToRemoteDataMapping)!==null&&__webpack_require___remotesLoadingData_moduleIdToRemoteDataMapping!==void 0?__webpack_require___remotesLoadingData_moduleIdToRemoteDataMapping:{};var __webpack_require___initializeSharingData_scopeToSharingDataMapping;const initializeSharingScopeToInitDataMapping=(__webpack_require___initializeSharingData_scopeToSharingDataMapping=(__webpack_require___initializeSharingData=__webpack_require__.initializeSharingData)===null||__webpack_require___initializeSharingData===void 0?void 0:__webpack_require___initializeSharingData.scopeToSharingDataMapping)!==null&&__webpack_require___initializeSharingData_scopeToSharingDataMapping!==void 0?__webpack_require___initializeSharingData_scopeToSharingDataMapping:{};var __webpack_require___consumesLoadingData_chunkMapping;const consumesLoadingChunkMapping=(__webpack_require___consumesLoadingData_chunkMapping=(__webpack_require___consumesLoadingData=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData===void 0?void 0:__webpack_require___consumesLoadingData.chunkMapping)!==null&&__webpack_require___consumesLoadingData_chunkMapping!==void 0?__webpack_require___consumesLoadingData_chunkMapping:{};var __webpack_require___consumesLoadingData_moduleIdToConsumeDataMapping;const consumesLoadingModuleToConsumeDataMapping=(__webpack_require___consumesLoadingData_moduleIdToConsumeDataMapping=(__webpack_require___consumesLoadingData1=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData1===void 0?void 0:__webpack_require___consumesLoadingData1.moduleIdToConsumeDataMapping)!==null&&__webpack_require___consumesLoadingData_moduleIdToConsumeDataMapping!==void 0?__webpack_require___consumesLoadingData_moduleIdToConsumeDataMapping:{};const consumesLoadinginstalledModules={};const initializeSharingInitPromises=[];const initializeSharingInitTokens={};const containerShareScope=(__webpack_require___initializeExposesData=__webpack_require__.initializeExposesData)===null||__webpack_require___initializeExposesData===void 0?void 0:__webpack_require___initializeExposesData.shareScope;for(const key in __module_federation_bundler_runtime__){__webpack_require__.federation[key]=__module_federation_bundler_runtime__[key]}early(__webpack_require__.federation,"consumesLoadingModuleToHandlerMapping",()=>{const consumesLoadingModuleToHandlerMapping={};for(let[moduleId,data]of Object.entries(consumesLoadingModuleToConsumeDataMapping)){consumesLoadingModuleToHandlerMapping[moduleId]={getter:data.fallback,shareInfo:{shareConfig:{fixedDependencies:false,requiredVersion:data.requiredVersion,strictVersion:data.strictVersion,singleton:data.singleton,eager:data.eager},scope:[data.shareScope]},shareKey:data.shareKey}}return consumesLoadingModuleToHandlerMapping});early(__webpack_require__.federation,"initOptions",()=>({}));early(__webpack_require__.federation.initOptions,"name",()=>__module_federation_container_name__);early(__webpack_require__.federation.initOptions,"shareStrategy",()=>__module_federation_share_strategy__);early(__webpack_require__.federation.initOptions,"shared",()=>{const shared={};for(let[scope,stages]of Object.entries(initializeSharingScopeToInitDataMapping)){for(let stage of stages){if(typeof stage==="object"&&stage!==null){const{name,version,factory,eager,singleton,requiredVersion,strictVersion}=stage;const shareConfig={};const isValidValue=function(val){return typeof val!=="undefined"};if(isValidValue(singleton)){shareConfig.singleton=singleton}if(isValidValue(requiredVersion)){shareConfig.requiredVersion=requiredVersion}if(isValidValue(eager)){shareConfig.eager=eager}if(isValidValue(strictVersion)){shareConfig.strictVersion=strictVersion}const options={version,scope:[scope],shareConfig,get:factory};if(shared[name]){shared[name].push(options)}else{shared[name]=[options]}}}}return shared});merge(__webpack_require__.federation.initOptions,"remotes",()=>Object.values(__module_federation_remote_infos__).flat().filter(remote=>remote.externalType==="script"));merge(__webpack_require__.federation.initOptions,"plugins",()=>__module_federation_runtime_plugins__);early(__webpack_require__.federation,"bundlerRuntimeOptions",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions,"remotes",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"chunkMapping",()=>remotesLoadingChunkMapping);early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"remoteInfos",()=>__module_federation_remote_infos__);early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToExternalAndNameMapping",()=>{const remotesLoadingIdToExternalAndNameMappingMapping={};for(let[moduleId,data]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){remotesLoadingIdToExternalAndNameMappingMapping[moduleId]=[data.shareScope,data.name,data.externalModuleId,data.remoteName]}return remotesLoadingIdToExternalAndNameMappingMapping});early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"webpackRequire",()=>__webpack_require__);merge(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToRemoteMap",()=>{const idToRemoteMap={};for(let[id,remoteData]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){const info=__module_federation_remote_infos__[remoteData.remoteName];if(info)idToRemoteMap[id]=info}return idToRemoteMap});override(__webpack_require__,"S",__webpack_require__.federation.bundlerRuntime.S);if(__webpack_require__.federation.attachShareScopeMap){__webpack_require__.federation.attachShareScopeMap(__webpack_require__)}override(__webpack_require__.f,"remotes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.remotes({chunkId,promises,chunkMapping:remotesLoadingChunkMapping,idToExternalAndNameMapping:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToExternalAndNameMapping,idToRemoteMap:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToRemoteMap,webpackRequire:__webpack_require__}));override(__webpack_require__.f,"consumes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.consumes({chunkId,promises,chunkMapping:consumesLoadingChunkMapping,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping,installedModules:consumesLoadinginstalledModules,webpackRequire:__webpack_require__}));override(__webpack_require__,"I",(name,initScope)=>__webpack_require__.federation.bundlerRuntime.I({shareScopeName:name,initScope,initPromises:initializeSharingInitPromises,initTokens:initializeSharingInitTokens,webpackRequire:__webpack_require__}));override(__webpack_require__,"initContainer",(shareScope,initScope,remoteEntryInitOptions)=>__webpack_require__.federation.bundlerRuntime.initContainerEntry({shareScope,initScope,remoteEntryInitOptions,shareScopeKey:containerShareScope,webpackRequire:__webpack_require__}));override(__webpack_require__,"getContainer",(module1,getScope)=>{var moduleMap=__webpack_require__.initializeExposesData.moduleMap;__webpack_require__.R=getScope;getScope=Object.prototype.hasOwnProperty.call(moduleMap,module1)?moduleMap[module1]():Promise.resolve().then(()=>{throw new Error(\'Module "\'+module1+\'" does not exist in container.\')});__webpack_require__.R=undefined;return getScope});__webpack_require__.federation.instance=__webpack_require__.federation.runtime.init(__webpack_require__.federation.initOptions);if((__webpack_require___consumesLoadingData2=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData2===void 0?void 0:__webpack_require___consumesLoadingData2.initialConsumes){__webpack_require__.federation.bundlerRuntime.installInitialConsumes({webpackRequire:__webpack_require__,installedModules:consumesLoadinginstalledModules,initialConsumes:__webpack_require__.consumesLoadingData.initialConsumes,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping})}}'
66170
- ].join(";");
66171
- return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
66172
66029
  }
66173
66030
  function ShareRuntimePlugin_define_property(obj, key, value) {
66174
66031
  if (key in obj) Object.defineProperty(obj, key, {
@@ -66207,6 +66064,40 @@ function ConsumeSharedPlugin_define_property(obj, key, value) {
66207
66064
  else obj[key] = value;
66208
66065
  return obj;
66209
66066
  }
66067
+ function normalizeConsumeShareOptions(consumes, shareScope) {
66068
+ return parseOptions(consumes, (item, key)=>{
66069
+ if (Array.isArray(item)) throw new Error("Unexpected array in options");
66070
+ const result = item !== key && isRequiredVersion(item) ? {
66071
+ import: key,
66072
+ shareScope: shareScope || "default",
66073
+ shareKey: key,
66074
+ requiredVersion: item,
66075
+ strictVersion: true,
66076
+ packageName: void 0,
66077
+ singleton: false,
66078
+ eager: false
66079
+ } : {
66080
+ import: key,
66081
+ shareScope: shareScope || "default",
66082
+ shareKey: key,
66083
+ requiredVersion: void 0,
66084
+ packageName: void 0,
66085
+ strictVersion: false,
66086
+ singleton: false,
66087
+ eager: false
66088
+ };
66089
+ return result;
66090
+ }, (item, key)=>({
66091
+ import: false === item.import ? void 0 : item.import || key,
66092
+ shareScope: item.shareScope || shareScope || "default",
66093
+ shareKey: item.shareKey || key,
66094
+ requiredVersion: item.requiredVersion,
66095
+ strictVersion: "boolean" == typeof item.strictVersion ? item.strictVersion : false !== item.import && !item.singleton,
66096
+ packageName: item.packageName,
66097
+ singleton: !!item.singleton,
66098
+ eager: !!item.eager
66099
+ }));
66100
+ }
66210
66101
  class ConsumeSharedPlugin extends RspackBuiltinPlugin {
66211
66102
  raw(compiler) {
66212
66103
  new ShareRuntimePlugin(this._options.enhanced).apply(compiler);
@@ -66222,38 +66113,7 @@ class ConsumeSharedPlugin extends RspackBuiltinPlugin {
66222
66113
  constructor(options){
66223
66114
  super(), ConsumeSharedPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ConsumeSharedPlugin), ConsumeSharedPlugin_define_property(this, "_options", void 0);
66224
66115
  this._options = {
66225
- consumes: parseOptions(options.consumes, (item, key)=>{
66226
- if (Array.isArray(item)) throw new Error("Unexpected array in options");
66227
- const result = item !== key && isRequiredVersion(item) ? {
66228
- import: key,
66229
- shareScope: options.shareScope || "default",
66230
- shareKey: key,
66231
- requiredVersion: item,
66232
- strictVersion: true,
66233
- packageName: void 0,
66234
- singleton: false,
66235
- eager: false
66236
- } : {
66237
- import: key,
66238
- shareScope: options.shareScope || "default",
66239
- shareKey: key,
66240
- requiredVersion: void 0,
66241
- packageName: void 0,
66242
- strictVersion: false,
66243
- singleton: false,
66244
- eager: false
66245
- };
66246
- return result;
66247
- }, (item, key)=>({
66248
- import: false === item.import ? void 0 : item.import || key,
66249
- shareScope: item.shareScope || options.shareScope || "default",
66250
- shareKey: item.shareKey || key,
66251
- requiredVersion: item.requiredVersion,
66252
- strictVersion: "boolean" == typeof item.strictVersion ? item.strictVersion : false !== item.import && !item.singleton,
66253
- packageName: item.packageName,
66254
- singleton: !!item.singleton,
66255
- eager: !!item.eager
66256
- })),
66116
+ consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
66257
66117
  enhanced: options.enhanced ?? false
66258
66118
  };
66259
66119
  }
@@ -66268,6 +66128,34 @@ function ProvideSharedPlugin_define_property(obj, key, value) {
66268
66128
  else obj[key] = value;
66269
66129
  return obj;
66270
66130
  }
66131
+ function normalizeProvideShareOptions(options, shareScope, enhanced) {
66132
+ return parseOptions(options, (item)=>{
66133
+ if (Array.isArray(item)) throw new Error("Unexpected array of provides");
66134
+ return {
66135
+ shareKey: item,
66136
+ version: void 0,
66137
+ shareScope: shareScope || "default",
66138
+ eager: false
66139
+ };
66140
+ }, (item)=>{
66141
+ const raw = {
66142
+ shareKey: item.shareKey,
66143
+ version: item.version,
66144
+ shareScope: item.shareScope || shareScope || "default",
66145
+ eager: !!item.eager
66146
+ };
66147
+ if (enhanced) {
66148
+ const enhancedItem = item;
66149
+ return {
66150
+ ...raw,
66151
+ singleton: enhancedItem.singleton,
66152
+ requiredVersion: enhancedItem.requiredVersion,
66153
+ strictVersion: enhancedItem.strictVersion
66154
+ };
66155
+ }
66156
+ return raw;
66157
+ });
66158
+ }
66271
66159
  class ProvideSharedPlugin extends RspackBuiltinPlugin {
66272
66160
  raw(compiler) {
66273
66161
  new ShareRuntimePlugin(this._enhanced ?? false).apply(compiler);
@@ -66279,32 +66167,7 @@ class ProvideSharedPlugin extends RspackBuiltinPlugin {
66279
66167
  }
66280
66168
  constructor(options){
66281
66169
  super(), ProvideSharedPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ProvideSharedPlugin), ProvideSharedPlugin_define_property(this, "_provides", void 0), ProvideSharedPlugin_define_property(this, "_enhanced", void 0);
66282
- this._provides = parseOptions(options.provides, (item)=>{
66283
- if (Array.isArray(item)) throw new Error("Unexpected array of provides");
66284
- return {
66285
- shareKey: item,
66286
- version: void 0,
66287
- shareScope: options.shareScope || "default",
66288
- eager: false
66289
- };
66290
- }, (item)=>{
66291
- const raw = {
66292
- shareKey: item.shareKey,
66293
- version: item.version,
66294
- shareScope: item.shareScope || options.shareScope || "default",
66295
- eager: !!item.eager
66296
- };
66297
- if (options.enhanced) {
66298
- const enhancedItem = item;
66299
- return {
66300
- ...raw,
66301
- singleton: enhancedItem.singleton,
66302
- requiredVersion: enhancedItem.requiredVersion,
66303
- strictVersion: enhancedItem.strictVersion
66304
- };
66305
- }
66306
- return raw;
66307
- });
66170
+ this._provides = normalizeProvideShareOptions(options.provides, options.shareScope, options.enhanced);
66308
66171
  this._enhanced = options.enhanced;
66309
66172
  }
66310
66173
  }
@@ -66318,6 +66181,45 @@ function SharePlugin_define_property(obj, key, value) {
66318
66181
  else obj[key] = value;
66319
66182
  return obj;
66320
66183
  }
66184
+ function normalizeSharedOptions(shared) {
66185
+ return parseOptions(shared, (item, key)=>{
66186
+ if ("string" != typeof item) throw new Error("Unexpected array in shared");
66187
+ const config = item !== key && isRequiredVersion(item) ? {
66188
+ import: key,
66189
+ requiredVersion: item
66190
+ } : {
66191
+ import: item
66192
+ };
66193
+ return config;
66194
+ }, (item)=>item);
66195
+ }
66196
+ function createProvideShareOptions(normalizedSharedOptions) {
66197
+ return normalizedSharedOptions.filter(([, options])=>false !== options.import).map(([key, options])=>({
66198
+ [options.import || key]: {
66199
+ shareKey: options.shareKey || key,
66200
+ shareScope: options.shareScope,
66201
+ version: options.version,
66202
+ eager: options.eager,
66203
+ singleton: options.singleton,
66204
+ requiredVersion: options.requiredVersion,
66205
+ strictVersion: options.strictVersion
66206
+ }
66207
+ }));
66208
+ }
66209
+ function createConsumeShareOptions(normalizedSharedOptions) {
66210
+ return normalizedSharedOptions.map(([key, options])=>({
66211
+ [key]: {
66212
+ import: options.import,
66213
+ shareKey: options.shareKey || key,
66214
+ shareScope: options.shareScope,
66215
+ requiredVersion: options.requiredVersion,
66216
+ strictVersion: options.strictVersion,
66217
+ singleton: options.singleton,
66218
+ packageName: options.packageName,
66219
+ eager: options.eager
66220
+ }
66221
+ }));
66222
+ }
66321
66223
  class SharePlugin {
66322
66224
  apply(compiler) {
66323
66225
  new ConsumeSharedPlugin({
@@ -66336,8 +66238,416 @@ class SharePlugin {
66336
66238
  SharePlugin_define_property(this, "_consumes", void 0);
66337
66239
  SharePlugin_define_property(this, "_provides", void 0);
66338
66240
  SharePlugin_define_property(this, "_enhanced", void 0);
66339
- const sharedOptions = parseOptions(options.shared, (item, key)=>{
66340
- if ("string" != typeof item) throw new Error("Unexpected array in shared");
66241
+ SharePlugin_define_property(this, "_sharedOptions", void 0);
66242
+ const sharedOptions = normalizeSharedOptions(options.shared);
66243
+ const consumes = createConsumeShareOptions(sharedOptions);
66244
+ const provides = createProvideShareOptions(sharedOptions);
66245
+ this._shareScope = options.shareScope;
66246
+ this._consumes = consumes;
66247
+ this._provides = provides;
66248
+ this._enhanced = options.enhanced ?? false;
66249
+ this._sharedOptions = sharedOptions;
66250
+ }
66251
+ }
66252
+ function CollectSharedEntryPlugin_define_property(obj, key, value) {
66253
+ if (key in obj) Object.defineProperty(obj, key, {
66254
+ value: value,
66255
+ enumerable: true,
66256
+ configurable: true,
66257
+ writable: true
66258
+ });
66259
+ else obj[key] = value;
66260
+ return obj;
66261
+ }
66262
+ const SHARE_ENTRY_ASSET = "collect-shared-entries.json";
66263
+ class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
66264
+ getData() {
66265
+ return this._collectedEntries;
66266
+ }
66267
+ getFilename() {
66268
+ return SHARE_ENTRY_ASSET;
66269
+ }
66270
+ apply(compiler) {
66271
+ super.apply(compiler);
66272
+ compiler.hooks.thisCompilation.tap("Collect shared entry", (compilation)=>{
66273
+ compilation.hooks.processAssets.tapPromise({
66274
+ name: "CollectSharedEntry",
66275
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
66276
+ }, async ()=>{
66277
+ const filename = this.getFilename();
66278
+ const asset = compilation.getAsset(filename);
66279
+ if (!asset) throw new Error(`Can not get ${filename}`);
66280
+ this._collectedEntries = JSON.parse(asset.source.source().toString());
66281
+ compilation.deleteAsset(filename);
66282
+ });
66283
+ });
66284
+ }
66285
+ raw() {
66286
+ const consumeShareOptions = createConsumeShareOptions(this.sharedOptions);
66287
+ const normalizedConsumeShareOptions = normalizeConsumeShareOptions(consumeShareOptions);
66288
+ const rawOptions = {
66289
+ consumes: normalizedConsumeShareOptions.map(([key, v])=>({
66290
+ key,
66291
+ ...v
66292
+ })),
66293
+ filename: this.getFilename()
66294
+ };
66295
+ return createBuiltinPlugin(this.name, rawOptions);
66296
+ }
66297
+ constructor(options){
66298
+ super(), CollectSharedEntryPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.CollectSharedEntryPlugin), CollectSharedEntryPlugin_define_property(this, "sharedOptions", void 0), CollectSharedEntryPlugin_define_property(this, "_collectedEntries", void 0);
66299
+ const { sharedOptions } = options;
66300
+ this.sharedOptions = sharedOptions;
66301
+ this._collectedEntries = {};
66302
+ }
66303
+ }
66304
+ function ShareContainerPlugin_define_property(obj, key, value) {
66305
+ if (key in obj) Object.defineProperty(obj, key, {
66306
+ value: value,
66307
+ enumerable: true,
66308
+ configurable: true,
66309
+ writable: true
66310
+ });
66311
+ else obj[key] = value;
66312
+ return obj;
66313
+ }
66314
+ function assert(condition, msg) {
66315
+ if (!condition) throw new Error(msg);
66316
+ }
66317
+ const HOT_UPDATE_SUFFIX = ".hot-update";
66318
+ class ShareContainerPlugin extends RspackBuiltinPlugin {
66319
+ getData() {
66320
+ return [
66321
+ this.name,
66322
+ this._globalName
66323
+ ];
66324
+ }
66325
+ raw(compiler) {
66326
+ const { library } = this._options;
66327
+ if (!compiler.options.output.enabledLibraryTypes.includes(library.type)) compiler.options.output.enabledLibraryTypes.push(library.type);
66328
+ return createBuiltinPlugin(this.name, this._options);
66329
+ }
66330
+ apply(compiler) {
66331
+ super.apply(compiler);
66332
+ const shareName = this._shareName;
66333
+ compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
66334
+ compilation.hooks.processAssets.tapPromise({
66335
+ name: "getShareContainerFile"
66336
+ }, async ()=>{
66337
+ const remoteEntryPoint = compilation.entrypoints.get(shareName);
66338
+ assert(remoteEntryPoint, `Can not get shared ${shareName} entryPoint!`);
66339
+ const remoteEntryNameChunk = compilation.namedChunks.get(shareName);
66340
+ assert(remoteEntryNameChunk, `Can not get shared ${shareName} chunk!`);
66341
+ const files = Array.from(remoteEntryNameChunk.files).filter((f)=>!f.includes(HOT_UPDATE_SUFFIX) && !f.endsWith(".css"));
66342
+ assert(files.length > 0, `no files found for shared ${shareName} chunk`);
66343
+ assert(1 === files.length, `shared ${shareName} chunk should not have multiple files!, current files: ${files.join(",")}`);
66344
+ this.filename = files[0];
66345
+ });
66346
+ });
66347
+ }
66348
+ constructor(options){
66349
+ super(), ShareContainerPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ShareContainerPlugin), ShareContainerPlugin_define_property(this, "filename", ""), ShareContainerPlugin_define_property(this, "_options", void 0), ShareContainerPlugin_define_property(this, "_shareName", void 0), ShareContainerPlugin_define_property(this, "_globalName", void 0);
66350
+ const { shareName, library, request, independentShareFileName } = options;
66351
+ const version = options.version || "0.0.0";
66352
+ this._globalName = encodeName(`${options.mfName}_${shareName}_${version}`);
66353
+ const fileName = independentShareFileName || `${version}/share-entry.js`;
66354
+ this._shareName = shareName;
66355
+ this._options = {
66356
+ name: shareName,
66357
+ request: request,
66358
+ library: (library ? {
66359
+ ...library,
66360
+ name: this._globalName
66361
+ } : void 0) || {
66362
+ type: "var",
66363
+ name: this._globalName
66364
+ },
66365
+ version,
66366
+ fileName
66367
+ };
66368
+ }
66369
+ }
66370
+ function SharedUsedExportsOptimizerPlugin_define_property(obj, key, value) {
66371
+ if (key in obj) Object.defineProperty(obj, key, {
66372
+ value: value,
66373
+ enumerable: true,
66374
+ configurable: true,
66375
+ writable: true
66376
+ });
66377
+ else obj[key] = value;
66378
+ return obj;
66379
+ }
66380
+ class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
66381
+ buildOptions() {
66382
+ const shared = this.sharedOptions.map(([shareKey, config])=>({
66383
+ shareKey,
66384
+ treeshake: !!config.treeshake,
66385
+ usedExports: config.usedExports
66386
+ }));
66387
+ const { manifestFileName, statsFileName } = getFileName(this.manifestOptions);
66388
+ return {
66389
+ shared,
66390
+ injectUsedExports: this.injectUsedExports,
66391
+ manifestFileName,
66392
+ statsFileName
66393
+ };
66394
+ }
66395
+ raw() {
66396
+ if (!this.sharedOptions.length) return;
66397
+ return createBuiltinPlugin(this.name, this.buildOptions());
66398
+ }
66399
+ constructor(sharedOptions, injectUsedExports, manifestOptions){
66400
+ super(), SharedUsedExportsOptimizerPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.SharedUsedExportsOptimizerPlugin), SharedUsedExportsOptimizerPlugin_define_property(this, "sharedOptions", void 0), SharedUsedExportsOptimizerPlugin_define_property(this, "injectUsedExports", void 0), SharedUsedExportsOptimizerPlugin_define_property(this, "manifestOptions", void 0);
66401
+ this.sharedOptions = sharedOptions;
66402
+ this.injectUsedExports = injectUsedExports ?? true;
66403
+ this.manifestOptions = manifestOptions ?? {};
66404
+ }
66405
+ }
66406
+ function IndependentSharedPlugin_define_property(obj, key, value) {
66407
+ if (key in obj) Object.defineProperty(obj, key, {
66408
+ value: value,
66409
+ enumerable: true,
66410
+ configurable: true,
66411
+ writable: true
66412
+ });
66413
+ else obj[key] = value;
66414
+ return obj;
66415
+ }
66416
+ const VIRTUAL_ENTRY = "./virtual-entry.js";
66417
+ const VIRTUAL_ENTRY_NAME = "virtual-entry";
66418
+ const filterPlugin = (plugin)=>{
66419
+ if (!plugin) return true;
66420
+ const pluginName = plugin.name || plugin.constructor?.name;
66421
+ if (!pluginName) return true;
66422
+ return ![
66423
+ "TreeShakeSharedPlugin",
66424
+ "IndependentSharedPlugin",
66425
+ "ModuleFederationPlugin",
66426
+ "SharedUsedExportsOptimizerPlugin",
66427
+ "HtmlWebpackPlugin"
66428
+ ].includes(pluginName);
66429
+ };
66430
+ class VirtualEntryPlugin {
66431
+ createEntry() {
66432
+ const { sharedOptions } = this;
66433
+ const entryContent = sharedOptions.reduce((acc, cur, index)=>`${acc}import shared_${index} from '${cur[0]}';\n`, "");
66434
+ return entryContent;
66435
+ }
66436
+ static entry() {
66437
+ return {
66438
+ [VIRTUAL_ENTRY_NAME]: VIRTUAL_ENTRY
66439
+ };
66440
+ }
66441
+ apply(compiler) {
66442
+ new compiler.rspack.experiments.VirtualModulesPlugin({
66443
+ [VIRTUAL_ENTRY]: this.createEntry()
66444
+ }).apply(compiler);
66445
+ compiler.hooks.thisCompilation.tap("RemoveVirtualEntryAsset", (compilation)=>{
66446
+ compilation.hooks.processAssets.tapPromise({
66447
+ name: "RemoveVirtualEntryAsset",
66448
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
66449
+ }, async ()=>{
66450
+ try {
66451
+ const chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
66452
+ chunk?.files.forEach((f)=>{
66453
+ compilation.deleteAsset(f);
66454
+ });
66455
+ } catch (_e) {
66456
+ console.error("Failed to remove virtual entry file!");
66457
+ }
66458
+ });
66459
+ });
66460
+ }
66461
+ constructor(sharedOptions){
66462
+ IndependentSharedPlugin_define_property(this, "sharedOptions", void 0);
66463
+ this.sharedOptions = sharedOptions;
66464
+ }
66465
+ }
66466
+ class IndependentSharedPlugin {
66467
+ apply(compiler) {
66468
+ compiler.hooks.beforeRun.tapPromise("IndependentSharedPlugin", async (compiler)=>{
66469
+ await this.createIndependentCompilers(compiler);
66470
+ });
66471
+ compiler.hooks.shutdown.tapAsync("IndependentSharedPlugin", (callback)=>{
66472
+ this.cleanup();
66473
+ callback();
66474
+ });
66475
+ compiler.hooks.compilation.tap("IndependentSharedPlugin", (compilation)=>{
66476
+ compilation.hooks.processAssets.tapPromise({
66477
+ name: "injectBuildAssets",
66478
+ stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
66479
+ }, async ()=>{
66480
+ if (!this.manifest) return;
66481
+ const { statsFileName, manifestFileName } = getFileName(this.manifest);
66482
+ const injectBuildAssetsIntoStatsOrManifest = (filename)=>{
66483
+ const stats = compilation.getAsset(filename);
66484
+ if (!stats) return;
66485
+ const statsContent = JSON.parse(stats.source.source().toString());
66486
+ const { shared } = statsContent;
66487
+ Object.entries(this.buildAssets).forEach(([key, item])=>{
66488
+ const targetShared = shared.find((s)=>s.name === key);
66489
+ if (!targetShared) return;
66490
+ item.forEach(([entry, version, globalName])=>{
66491
+ if (version === targetShared.version) {
66492
+ targetShared.fallback = entry;
66493
+ targetShared.fallbackName = globalName;
66494
+ }
66495
+ });
66496
+ });
66497
+ compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
66498
+ };
66499
+ injectBuildAssetsIntoStatsOrManifest(statsFileName);
66500
+ injectBuildAssetsIntoStatsOrManifest(manifestFileName);
66501
+ });
66502
+ });
66503
+ }
66504
+ async createIndependentCompilers(parentCompiler) {
66505
+ const { sharedOptions, buildAssets } = this;
66506
+ console.log("🚀 Start creating a standalone compiler...");
66507
+ const parentOutputDir = parentCompiler.options.output.path ? (0, path_browserify.basename)(parentCompiler.options.output.path) : "";
66508
+ const shareRequestsMap = await this.createIndependentCompiler(parentCompiler, parentOutputDir);
66509
+ await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
66510
+ if (!shareConfig.treeshake || false === shareConfig.import) return;
66511
+ const shareRequests = shareRequestsMap[shareName].requests;
66512
+ await Promise.all(shareRequests.map(async ([request, version])=>{
66513
+ const sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1];
66514
+ const [shareFileName, globalName] = await this.createIndependentCompiler(parentCompiler, parentOutputDir, {
66515
+ shareRequestsMap,
66516
+ currentShare: {
66517
+ shareName,
66518
+ version,
66519
+ request,
66520
+ independentShareFileName: sharedConfig?.independentShareFileName
66521
+ }
66522
+ });
66523
+ if ("string" == typeof shareFileName) {
66524
+ buildAssets[shareName] ||= [];
66525
+ buildAssets[shareName].push([
66526
+ shareFileName,
66527
+ version,
66528
+ globalName
66529
+ ]);
66530
+ }
66531
+ }));
66532
+ }));
66533
+ console.log("✅ All independent packages have been compiled successfully");
66534
+ }
66535
+ async createIndependentCompiler(parentCompiler, parentOutputDir, extraOptions) {
66536
+ const { mfName, plugins, outputDir, outputFilePath, sharedOptions, treeshake, library } = this;
66537
+ const outputDirWithShareName = outputFilePath || (0, path_browserify.join)(outputDir, encodeName(extraOptions?.currentShare?.shareName || ""));
66538
+ const parentConfig = parentCompiler.options;
66539
+ const finalPlugins = [];
66540
+ const rspack = parentCompiler.rspack;
66541
+ let extraPlugin;
66542
+ extraPlugin = extraOptions ? new ShareContainerPlugin({
66543
+ mfName,
66544
+ library,
66545
+ ...extraOptions.currentShare
66546
+ }) : new CollectSharedEntryPlugin({
66547
+ sharedOptions,
66548
+ shareScope: "default"
66549
+ });
66550
+ (parentConfig.plugins || []).forEach((plugin)=>{
66551
+ if (void 0 !== plugin && "string" != typeof plugin && filterPlugin(plugin)) finalPlugins.push(plugin);
66552
+ });
66553
+ plugins.forEach((plugin)=>{
66554
+ finalPlugins.push(plugin);
66555
+ });
66556
+ finalPlugins.push(extraPlugin);
66557
+ finalPlugins.push(new ConsumeSharedPlugin({
66558
+ consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
66559
+ [key]: {
66560
+ import: extraOptions ? false : options.import,
66561
+ shareKey: options.shareKey || key,
66562
+ shareScope: options.shareScope,
66563
+ requiredVersion: options.requiredVersion,
66564
+ strictVersion: options.strictVersion,
66565
+ singleton: options.singleton,
66566
+ packageName: options.packageName,
66567
+ eager: options.eager
66568
+ }
66569
+ })),
66570
+ enhanced: true
66571
+ }));
66572
+ if (treeshake) finalPlugins.push(new SharedUsedExportsOptimizerPlugin(sharedOptions, this.injectUsedExports));
66573
+ finalPlugins.push(new VirtualEntryPlugin(sharedOptions));
66574
+ const fullOutputDir = (0, path_browserify.resolve)(parentCompiler.outputPath, outputDirWithShareName);
66575
+ const compilerConfig = {
66576
+ ...parentConfig,
66577
+ mode: parentConfig.mode || "development",
66578
+ entry: VirtualEntryPlugin.entry,
66579
+ output: {
66580
+ path: fullOutputDir,
66581
+ clean: true,
66582
+ publicPath: parentConfig.output?.publicPath || "auto"
66583
+ },
66584
+ plugins: finalPlugins,
66585
+ optimization: {
66586
+ ...parentConfig.optimization,
66587
+ splitChunks: false
66588
+ }
66589
+ };
66590
+ const compiler = rspack.rspack(compilerConfig);
66591
+ compiler.inputFileSystem = parentCompiler.inputFileSystem;
66592
+ compiler.outputFileSystem = parentCompiler.outputFileSystem;
66593
+ compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
66594
+ const { currentShare } = extraOptions || {};
66595
+ currentShare && this.compilers.set(`${currentShare.shareName}@${currentShare.version}`, compiler);
66596
+ return new Promise((resolve, reject)=>{
66597
+ compiler.run((err, stats)=>{
66598
+ if (err || stats?.hasErrors()) {
66599
+ const target = currentShare ? currentShare.shareName : "收集依赖";
66600
+ console.error(`❌ ${target} 编译失败:`, err || stats.toJson().errors.map((e)=>e.message).join("\n"));
66601
+ reject(err || new Error(`${target} 编译失败`));
66602
+ return;
66603
+ }
66604
+ currentShare && console.log(`✅ 独立包 ${currentShare.shareName} 编译成功`);
66605
+ if (stats) {
66606
+ currentShare && console.log(`📊 ${currentShare.shareName} 编译统计:`);
66607
+ console.log(stats.toString({
66608
+ colors: true,
66609
+ chunks: false,
66610
+ modules: false
66611
+ }));
66612
+ }
66613
+ resolve(extraPlugin.getData());
66614
+ });
66615
+ });
66616
+ }
66617
+ cleanup() {
66618
+ this.compilers.forEach((compiler)=>{
66619
+ if (compiler.watching) compiler.watching.close(()=>{
66620
+ console.log("👋 编译器已关闭");
66621
+ });
66622
+ });
66623
+ this.compilers.clear();
66624
+ }
66625
+ constructor(options){
66626
+ IndependentSharedPlugin_define_property(this, "mfName", void 0);
66627
+ IndependentSharedPlugin_define_property(this, "shared", void 0);
66628
+ IndependentSharedPlugin_define_property(this, "library", void 0);
66629
+ IndependentSharedPlugin_define_property(this, "sharedOptions", void 0);
66630
+ IndependentSharedPlugin_define_property(this, "outputDir", void 0);
66631
+ IndependentSharedPlugin_define_property(this, "outputFilePath", void 0);
66632
+ IndependentSharedPlugin_define_property(this, "plugins", void 0);
66633
+ IndependentSharedPlugin_define_property(this, "compilers", new Map());
66634
+ IndependentSharedPlugin_define_property(this, "treeshake", void 0);
66635
+ IndependentSharedPlugin_define_property(this, "manifest", void 0);
66636
+ IndependentSharedPlugin_define_property(this, "buildAssets", {});
66637
+ IndependentSharedPlugin_define_property(this, "injectUsedExports", void 0);
66638
+ IndependentSharedPlugin_define_property(this, "name", "IndependentSharedPlugin");
66639
+ const { outputDir, outputFilePath, plugins, treeshake, shared, name, manifest, injectUsedExports, library } = options;
66640
+ this.shared = shared;
66641
+ this.mfName = name;
66642
+ this.outputDir = outputFilePath ? "" : outputDir || "independent-packages";
66643
+ this.outputFilePath = outputFilePath;
66644
+ this.plugins = plugins || [];
66645
+ this.treeshake = treeshake;
66646
+ this.manifest = manifest;
66647
+ this.injectUsedExports = injectUsedExports ?? true;
66648
+ this.library = library;
66649
+ this.sharedOptions = parseOptions(shared, (item, key)=>{
66650
+ if ("string" != typeof item) throw new Error(`Unexpected array in shared configuration for key "${key}"`);
66341
66651
  const config = item !== key && isRequiredVersion(item) ? {
66342
66652
  import: key,
66343
66653
  requiredVersion: item
@@ -66346,35 +66656,220 @@ class SharePlugin {
66346
66656
  };
66347
66657
  return config;
66348
66658
  }, (item)=>item);
66349
- const consumes = sharedOptions.map(([key, options])=>({
66350
- [key]: {
66351
- import: options.import,
66352
- shareKey: options.shareKey || key,
66353
- shareScope: options.shareScope,
66354
- requiredVersion: options.requiredVersion,
66355
- strictVersion: options.strictVersion,
66356
- singleton: options.singleton,
66357
- packageName: options.packageName,
66358
- eager: options.eager
66359
- }
66360
- }));
66361
- const provides = sharedOptions.filter(([, options])=>false !== options.import).map(([key, options])=>({
66362
- [options.import || key]: {
66363
- shareKey: options.shareKey || key,
66364
- shareScope: options.shareScope,
66365
- version: options.version,
66366
- eager: options.eager,
66367
- singleton: options.singleton,
66368
- requiredVersion: options.requiredVersion,
66369
- strictVersion: options.strictVersion
66370
- }
66371
- }));
66372
- this._shareScope = options.shareScope;
66373
- this._consumes = consumes;
66374
- this._provides = provides;
66375
- this._enhanced = options.enhanced ?? false;
66376
66659
  }
66377
66660
  }
66661
+ function TreeShakeSharedPlugin_define_property(obj, key, value) {
66662
+ if (key in obj) Object.defineProperty(obj, key, {
66663
+ value: value,
66664
+ enumerable: true,
66665
+ configurable: true,
66666
+ writable: true
66667
+ });
66668
+ else obj[key] = value;
66669
+ return obj;
66670
+ }
66671
+ class TreeShakeSharedPlugin {
66672
+ apply(compiler) {
66673
+ const { mfConfig, outputDir, plugins, reshake } = this;
66674
+ const { name, shared, library } = mfConfig;
66675
+ if (!shared) return;
66676
+ const sharedOptions = normalizeSharedOptions(shared);
66677
+ if (!sharedOptions.length) return;
66678
+ if (!reshake) new SharedUsedExportsOptimizerPlugin(sharedOptions, mfConfig.injectUsedExports, mfConfig.manifest).apply(compiler);
66679
+ if (sharedOptions.some(([_, config])=>config.treeshake && false !== config.import)) {
66680
+ this._independentSharePlugin = new IndependentSharedPlugin({
66681
+ name: name,
66682
+ shared: shared,
66683
+ outputDir,
66684
+ plugins,
66685
+ treeshake: reshake,
66686
+ library,
66687
+ manifest: mfConfig.manifest
66688
+ });
66689
+ this._independentSharePlugin.apply(compiler);
66690
+ }
66691
+ }
66692
+ get buildAssets() {
66693
+ return this._independentSharePlugin?.buildAssets || {};
66694
+ }
66695
+ constructor(options){
66696
+ TreeShakeSharedPlugin_define_property(this, "mfConfig", void 0);
66697
+ TreeShakeSharedPlugin_define_property(this, "outputDir", void 0);
66698
+ TreeShakeSharedPlugin_define_property(this, "plugins", void 0);
66699
+ TreeShakeSharedPlugin_define_property(this, "reshake", void 0);
66700
+ TreeShakeSharedPlugin_define_property(this, "_independentSharePlugin", void 0);
66701
+ TreeShakeSharedPlugin_define_property(this, "name", "TreeShakeSharedPlugin");
66702
+ const { mfConfig, plugins, reshake } = options;
66703
+ this.mfConfig = mfConfig;
66704
+ this.outputDir = mfConfig.independentShareDir || "independent-packages";
66705
+ this.plugins = plugins;
66706
+ this.reshake = Boolean(reshake);
66707
+ }
66708
+ }
66709
+ const ModuleFederationRuntimePlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
66710
+ function ModuleFederationPlugin_define_property(obj, key, value) {
66711
+ if (key in obj) Object.defineProperty(obj, key, {
66712
+ value: value,
66713
+ enumerable: true,
66714
+ configurable: true,
66715
+ writable: true
66716
+ });
66717
+ else obj[key] = value;
66718
+ return obj;
66719
+ }
66720
+ class ModuleFederationPlugin {
66721
+ apply(compiler) {
66722
+ const { webpack } = compiler;
66723
+ const paths = getPaths(this._options);
66724
+ compiler.options.resolve.alias = {
66725
+ "@module-federation/runtime-tools": paths.runtimeTools,
66726
+ "@module-federation/runtime": paths.runtime,
66727
+ ...compiler.options.resolve.alias
66728
+ };
66729
+ const sharedOptions = getSharedOptions(this._options);
66730
+ const treeshakeEntries = sharedOptions.filter(([, config])=>config.treeshake);
66731
+ if (treeshakeEntries.length > 0) {
66732
+ this._treeShakeSharedPlugin = new TreeShakeSharedPlugin({
66733
+ mfConfig: this._options,
66734
+ reshake: false
66735
+ });
66736
+ this._treeShakeSharedPlugin.apply(compiler);
66737
+ }
66738
+ let runtimePluginApplied = false;
66739
+ compiler.hooks.beforeRun.tapPromise({
66740
+ name: "ModuleFederationPlugin",
66741
+ stage: 100
66742
+ }, async ()=>{
66743
+ if (runtimePluginApplied) return;
66744
+ runtimePluginApplied = true;
66745
+ const entryRuntime = getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakeSharedPlugin?.buildAssets || {});
66746
+ new ModuleFederationRuntimePlugin({
66747
+ entryRuntime
66748
+ }).apply(compiler);
66749
+ });
66750
+ new webpack.container.ModuleFederationPluginV1({
66751
+ ...this._options,
66752
+ enhanced: true
66753
+ }).apply(compiler);
66754
+ if (this._options.manifest) new ModuleFederationManifestPlugin(this._options).apply(compiler);
66755
+ }
66756
+ constructor(_options){
66757
+ ModuleFederationPlugin_define_property(this, "_options", void 0);
66758
+ ModuleFederationPlugin_define_property(this, "_treeShakeSharedPlugin", void 0);
66759
+ this._options = _options;
66760
+ }
66761
+ }
66762
+ function getRemoteInfos(options) {
66763
+ if (!options.remotes) return {};
66764
+ function extractUrlAndGlobal(urlAndGlobal) {
66765
+ const index = urlAndGlobal.indexOf("@");
66766
+ if (index <= 0 || index === urlAndGlobal.length - 1) return null;
66767
+ return [
66768
+ urlAndGlobal.substring(index + 1),
66769
+ urlAndGlobal.substring(0, index)
66770
+ ];
66771
+ }
66772
+ function getExternalTypeFromExternal(external) {
66773
+ if (/^[a-z0-9-]+ /.test(external)) {
66774
+ const idx = external.indexOf(" ");
66775
+ return [
66776
+ external.slice(0, idx),
66777
+ external.slice(idx + 1)
66778
+ ];
66779
+ }
66780
+ return null;
66781
+ }
66782
+ function getExternal(external) {
66783
+ const result = getExternalTypeFromExternal(external);
66784
+ if (null === result) return [
66785
+ remoteType,
66786
+ external
66787
+ ];
66788
+ return result;
66789
+ }
66790
+ const remoteType = options.remoteType || (options.library ? options.library.type : "script");
66791
+ const remotes = parseOptions(options.remotes, (item)=>({
66792
+ external: Array.isArray(item) ? item : [
66793
+ item
66794
+ ],
66795
+ shareScope: options.shareScope || "default"
66796
+ }), (item)=>({
66797
+ external: Array.isArray(item.external) ? item.external : [
66798
+ item.external
66799
+ ],
66800
+ shareScope: item.shareScope || options.shareScope || "default"
66801
+ }));
66802
+ const remoteInfos = {};
66803
+ for (const [key, config] of remotes)for (const external of config.external){
66804
+ const [externalType, externalRequest] = getExternal(external);
66805
+ remoteInfos[key] ??= [];
66806
+ if ("script" === externalType) {
66807
+ const [url, global] = extractUrlAndGlobal(externalRequest);
66808
+ remoteInfos[key].push({
66809
+ alias: key,
66810
+ name: global,
66811
+ entry: url,
66812
+ externalType,
66813
+ shareScope: config.shareScope
66814
+ });
66815
+ } else remoteInfos[key].push({
66816
+ alias: key,
66817
+ name: void 0,
66818
+ entry: void 0,
66819
+ externalType,
66820
+ shareScope: config.shareScope
66821
+ });
66822
+ }
66823
+ return remoteInfos;
66824
+ }
66825
+ function getRuntimePlugins(options) {
66826
+ return options.runtimePlugins ?? [];
66827
+ }
66828
+ function getSharedOptions(options) {
66829
+ if (!options.shared) return [];
66830
+ return parseOptions(options.shared, (item, key)=>{
66831
+ if ("string" != typeof item) throw new Error("Unexpected array in shared");
66832
+ return item !== key && isRequiredVersion(item) ? {
66833
+ import: key,
66834
+ requiredVersion: item
66835
+ } : {
66836
+ import: item
66837
+ };
66838
+ }, (item)=>item);
66839
+ }
66840
+ function getPaths(options) {
66841
+ return {
66842
+ runtimeTools: "@module-federation/runtime-tools",
66843
+ bundlerRuntime: "@module-federation/webpack-bundler-runtime",
66844
+ runtime: "@module-federation/runtime"
66845
+ };
66846
+ }
66847
+ function getDefaultEntryRuntime(paths, options, compiler, treeshakeShareFallbacks) {
66848
+ const runtimePlugins = getRuntimePlugins(options);
66849
+ const remoteInfos = getRemoteInfos(options);
66850
+ const runtimePluginImports = [];
66851
+ const runtimePluginVars = [];
66852
+ for(let i = 0; i < runtimePlugins.length; i++){
66853
+ const runtimePluginVar = `__module_federation_runtime_plugin_${i}__`;
66854
+ const pluginSpec = runtimePlugins[i];
66855
+ const pluginPath = Array.isArray(pluginSpec) ? pluginSpec[0] : pluginSpec;
66856
+ const pluginParams = Array.isArray(pluginSpec) ? pluginSpec[1] : void 0;
66857
+ runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
66858
+ const paramsCode = void 0 === pluginParams ? "undefined" : JSON.stringify(pluginParams);
66859
+ runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
66860
+ }
66861
+ const content = [
66862
+ `import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
66863
+ ...runtimePluginImports,
66864
+ `const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(", ")}]`,
66865
+ `const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
66866
+ `const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
66867
+ `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? "version-first")}`,
66868
+ `const __module_federation_share_fallbacks__ = ${JSON.stringify(treeshakeShareFallbacks)}`,
66869
+ 'if((__webpack_require__.initializeSharingData||__webpack_require__.initializeExposesData)&&__webpack_require__.federation){var __webpack_require___remotesLoadingData,__webpack_require___remotesLoadingData1,__webpack_require___initializeSharingData,__webpack_require___consumesLoadingData,__webpack_require___consumesLoadingData1,__webpack_require___initializeExposesData,__webpack_require___consumesLoadingData2;const override=(obj,key,value)=>{if(!obj)return;if(obj[key])obj[key]=value};const merge=(obj,key,fn)=>{const value=fn();if(Array.isArray(value)){var _obj,_key;var _;(_=(_obj=obj)[_key=key])!==null&&_!==void 0?_:_obj[_key]=[];obj[key].push(...value)}else if(typeof value==="object"&&value!==null){var _obj1,_key1;var _1;(_1=(_obj1=obj)[_key1=key])!==null&&_1!==void 0?_1:_obj1[_key1]={};Object.assign(obj[key],value)}};const early=(obj,key,initial)=>{var _obj,_key;var _;(_=(_obj=obj)[_key=key])!==null&&_!==void 0?_:_obj[_key]=initial()};var __webpack_require___remotesLoadingData_chunkMapping;const remotesLoadingChunkMapping=(__webpack_require___remotesLoadingData_chunkMapping=(__webpack_require___remotesLoadingData=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData===void 0?void 0:__webpack_require___remotesLoadingData.chunkMapping)!==null&&__webpack_require___remotesLoadingData_chunkMapping!==void 0?__webpack_require___remotesLoadingData_chunkMapping:{};var __webpack_require___remotesLoadingData_moduleIdToRemoteDataMapping;const remotesLoadingModuleIdToRemoteDataMapping=(__webpack_require___remotesLoadingData_moduleIdToRemoteDataMapping=(__webpack_require___remotesLoadingData1=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData1===void 0?void 0:__webpack_require___remotesLoadingData1.moduleIdToRemoteDataMapping)!==null&&__webpack_require___remotesLoadingData_moduleIdToRemoteDataMapping!==void 0?__webpack_require___remotesLoadingData_moduleIdToRemoteDataMapping:{};var __webpack_require___initializeSharingData_scopeToSharingDataMapping;const initializeSharingScopeToInitDataMapping=(__webpack_require___initializeSharingData_scopeToSharingDataMapping=(__webpack_require___initializeSharingData=__webpack_require__.initializeSharingData)===null||__webpack_require___initializeSharingData===void 0?void 0:__webpack_require___initializeSharingData.scopeToSharingDataMapping)!==null&&__webpack_require___initializeSharingData_scopeToSharingDataMapping!==void 0?__webpack_require___initializeSharingData_scopeToSharingDataMapping:{};var __webpack_require___consumesLoadingData_chunkMapping;const consumesLoadingChunkMapping=(__webpack_require___consumesLoadingData_chunkMapping=(__webpack_require___consumesLoadingData=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData===void 0?void 0:__webpack_require___consumesLoadingData.chunkMapping)!==null&&__webpack_require___consumesLoadingData_chunkMapping!==void 0?__webpack_require___consumesLoadingData_chunkMapping:{};var __webpack_require___consumesLoadingData_moduleIdToConsumeDataMapping;const consumesLoadingModuleToConsumeDataMapping=(__webpack_require___consumesLoadingData_moduleIdToConsumeDataMapping=(__webpack_require___consumesLoadingData1=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData1===void 0?void 0:__webpack_require___consumesLoadingData1.moduleIdToConsumeDataMapping)!==null&&__webpack_require___consumesLoadingData_moduleIdToConsumeDataMapping!==void 0?__webpack_require___consumesLoadingData_moduleIdToConsumeDataMapping:{};const consumesLoadinginstalledModules={};const initializeSharingInitPromises=[];const initializeSharingInitTokens={};const containerShareScope=(__webpack_require___initializeExposesData=__webpack_require__.initializeExposesData)===null||__webpack_require___initializeExposesData===void 0?void 0:__webpack_require___initializeExposesData.shareScope;const shareFallbacks=__module_federation_share_fallbacks__||{};for(const key in __module_federation_bundler_runtime__){__webpack_require__.federation[key]=__module_federation_bundler_runtime__[key]}early(__webpack_require__.federation,"consumesLoadingModuleToHandlerMapping",()=>{const consumesLoadingModuleToHandlerMapping={};for(let[moduleId,data]of Object.entries(consumesLoadingModuleToConsumeDataMapping)){consumesLoadingModuleToHandlerMapping[moduleId]={getter:data.fallback,shareInfo:{shareConfig:{fixedDependencies:false,requiredVersion:data.requiredVersion,strictVersion:data.strictVersion,singleton:data.singleton,eager:data.eager},scope:[data.shareScope]},shareKey:data.shareKey}}return consumesLoadingModuleToHandlerMapping});early(__webpack_require__.federation,"initOptions",()=>({}));early(__webpack_require__.federation.initOptions,"name",()=>__module_federation_container_name__);early(__webpack_require__.federation.initOptions,"shareStrategy",()=>__module_federation_share_strategy__);early(__webpack_require__.federation.initOptions,"shared",()=>{const shared={};for(let[scope,stages]of Object.entries(initializeSharingScopeToInitDataMapping)){for(let stage of stages){if(typeof stage==="object"&&stage!==null){const{name,version,factory,eager,singleton,requiredVersion,strictVersion}=stage;const shareConfig={};const isValidValue=function(val){return typeof val!=="undefined"};if(isValidValue(singleton)){shareConfig.singleton=singleton}if(isValidValue(requiredVersion)){shareConfig.requiredVersion=requiredVersion}if(isValidValue(eager)){shareConfig.eager=eager}if(isValidValue(strictVersion)){shareConfig.strictVersion=strictVersion}const options={version,scope:[scope],shareConfig,get:factory};const fallbackEntry=shareFallbacks[name];if(fallbackEntry){const fallbackUrl=(__webpack_require__.p||"")+fallbackEntry[1];options.fallbackName=fallbackEntry[0];shareConfig.fallback=fallbackUrl;options.fallback=function(){return __webpack_require__.federation.importExternal(fallbackUrl)}}if(shared[name]){shared[name].push(options)}else{shared[name]=[options]}}}}return shared});merge(__webpack_require__.federation.initOptions,"remotes",()=>Object.values(__module_federation_remote_infos__).flat().filter(remote=>remote.externalType==="script"));merge(__webpack_require__.federation.initOptions,"plugins",()=>__module_federation_runtime_plugins__);early(__webpack_require__.federation,"bundlerRuntimeOptions",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions,"remotes",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"chunkMapping",()=>remotesLoadingChunkMapping);early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"remoteInfos",()=>__module_federation_remote_infos__);early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToExternalAndNameMapping",()=>{const remotesLoadingIdToExternalAndNameMappingMapping={};for(let[moduleId,data]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){remotesLoadingIdToExternalAndNameMappingMapping[moduleId]=[data.shareScope,data.name,data.externalModuleId,data.remoteName]}return remotesLoadingIdToExternalAndNameMappingMapping});early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"webpackRequire",()=>__webpack_require__);if(Object.keys(shareFallbacks).length){early(__webpack_require__.federation.bundlerRuntimeOptions,"sharedEntries",()=>shareFallbacks)}merge(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToRemoteMap",()=>{const idToRemoteMap={};for(let[id,remoteData]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){const info=__module_federation_remote_infos__[remoteData.remoteName];if(info)idToRemoteMap[id]=info}return idToRemoteMap});override(__webpack_require__,"S",__webpack_require__.federation.bundlerRuntime.S);if(__webpack_require__.federation.attachShareScopeMap){__webpack_require__.federation.attachShareScopeMap(__webpack_require__)}override(__webpack_require__.f,"remotes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.remotes({chunkId,promises,chunkMapping:remotesLoadingChunkMapping,idToExternalAndNameMapping:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToExternalAndNameMapping,idToRemoteMap:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToRemoteMap,webpackRequire:__webpack_require__}));override(__webpack_require__.f,"consumes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.consumes({chunkId,promises,chunkMapping:consumesLoadingChunkMapping,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping,installedModules:consumesLoadinginstalledModules,webpackRequire:__webpack_require__}));override(__webpack_require__,"I",(name,initScope)=>__webpack_require__.federation.bundlerRuntime.I({shareScopeName:name,initScope,initPromises:initializeSharingInitPromises,initTokens:initializeSharingInitTokens,webpackRequire:__webpack_require__}));override(__webpack_require__,"initContainer",(shareScope,initScope,remoteEntryInitOptions)=>__webpack_require__.federation.bundlerRuntime.initContainerEntry({shareScope,initScope,remoteEntryInitOptions,shareScopeKey:containerShareScope,webpackRequire:__webpack_require__}));override(__webpack_require__,"getContainer",(module1,getScope)=>{var moduleMap=__webpack_require__.initializeExposesData.moduleMap;__webpack_require__.R=getScope;getScope=Object.prototype.hasOwnProperty.call(moduleMap,module1)?moduleMap[module1]():Promise.resolve().then(()=>{throw new Error(\'Module "\'+module1+\'" does not exist in container.\')});__webpack_require__.R=undefined;return getScope});__webpack_require__.federation.instance=__webpack_require__.federation.runtime.init(__webpack_require__.federation.initOptions);if((__webpack_require___consumesLoadingData2=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData2===void 0?void 0:__webpack_require___consumesLoadingData2.initialConsumes){__webpack_require__.federation.bundlerRuntime.installInitialConsumes({webpackRequire:__webpack_require__,installedModules:consumesLoadinginstalledModules,initialConsumes:__webpack_require__.consumesLoadingData.initialConsumes,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping})}}'
66870
+ ].join(";");
66871
+ return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
66872
+ }
66378
66873
  function ContainerPlugin_define_property(obj, key, value) {
66379
66874
  if (key in obj) Object.defineProperty(obj, key, {
66380
66875
  value: value,
@@ -66547,7 +67042,7 @@ function transformSync(source, options) {
66547
67042
  const _options = JSON.stringify(options || {});
66548
67043
  return external_rspack_wasi_browser_js_["default"].transformSync(source, _options);
66549
67044
  }
66550
- const exports_rspackVersion = "1.6.5-canary-e23badc4-20251124174040";
67045
+ const exports_rspackVersion = "1.6.5-canary-a27f526c-20251125032833";
66551
67046
  const exports_version = "5.75.0";
66552
67047
  const exports_WebpackError = Error;
66553
67048
  const sources = __webpack_require__("../../node_modules/.pnpm/webpack-sources@3.3.3_patch_hash=b2a26650f08a2359d0a3cd81fa6fa272aa7441a28dd7e601792da5ed5d2b4aee/node_modules/webpack-sources/lib/index.js");
@@ -66598,6 +67093,7 @@ const container = {
66598
67093
  };
66599
67094
  const sharing = {
66600
67095
  ProvideSharedPlugin: ProvideSharedPlugin,
67096
+ TreeShakeSharedPlugin: TreeShakeSharedPlugin,
66601
67097
  ConsumeSharedPlugin: ConsumeSharedPlugin,
66602
67098
  SharePlugin: SharePlugin
66603
67099
  };
@@ -66706,7 +67202,7 @@ function createCompiler(userOptions) {
66706
67202
  function isMultiRspackOptions(o) {
66707
67203
  return Array.isArray(o);
66708
67204
  }
66709
- function rspack(options, callback) {
67205
+ function rspack_rspack(options, callback) {
66710
67206
  try {
66711
67207
  if (isMultiRspackOptions(options)) for (const option of options)validateRspackConfig(option);
66712
67208
  else validateRspackConfig(options);
@@ -66756,7 +67252,7 @@ function rspack(options, callback) {
66756
67252
  return compiler;
66757
67253
  }
66758
67254
  }
66759
- const src_fn = Object.assign(rspack, exports_namespaceObject);
67255
+ const src_fn = Object.assign(rspack_rspack, exports_namespaceObject);
66760
67256
  src_fn.rspack = src_fn;
66761
67257
  src_fn.webpack = src_fn;
66762
67258
  const src_rspack_0 = src_fn;