@rspack-canary/browser 1.7.0-canary-22d591c5-20251222090400 → 1.7.0-canary-dcc2f8c9-20251223064055

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
@@ -53498,10 +53498,16 @@ function stringifyLoaderObject(o) {
53498
53498
  return o.path + o.query + o.fragment;
53499
53499
  }
53500
53500
  const unsupported = (name, issue)=>{
53501
- let s = `${name} is not supported by rspack.`;
53502
- if (issue) s += ` Please refer to issue ${issue} for more information.`;
53501
+ let s = `${name} is not supported by Rspack.`;
53502
+ if (issue) s += ` Refer to issue ${issue} for more information.`;
53503
53503
  throw new Error(s);
53504
53504
  };
53505
+ const warnedMessages = new Set();
53506
+ function deprecate(message) {
53507
+ if (warnedMessages.has(message)) return;
53508
+ warnedMessages.add(message);
53509
+ console.warn(`[Rspack Deprecation] ${message}`);
53510
+ }
53505
53511
  const WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/;
53506
53512
  const SEGMENTS_SPLIT_REGEXP = /([|!])/;
53507
53513
  const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
@@ -56355,23 +56361,9 @@ const lazyCompilationMiddleware = (compiler)=>{
56355
56361
  if (compiler instanceof MultiCompiler) {
56356
56362
  const middlewareByCompiler = new Map();
56357
56363
  let i = 0;
56358
- let isReportDeprecatedWarned = false;
56359
- let isReportRepeatWarned = false;
56360
56364
  for (const c of compiler.compilers){
56361
- if (c.options.experiments.lazyCompilation) {
56362
- if (c.name) console.warn(`The 'experiments.lazyCompilation' option in compiler named '${c.name}' is deprecated, please use the Configuration top level 'lazyCompilation' instead.`);
56363
- else if (!isReportDeprecatedWarned) {
56364
- console.warn(DEPRECATED_LAZY_COMPILATION_OPTIONS_WARN);
56365
- isReportDeprecatedWarned = true;
56366
- }
56367
- }
56368
- if (c.options.lazyCompilation && c.options.experiments.lazyCompilation) {
56369
- if (c.name) console.warn(`The top-level 'lazyCompilation' option in compiler named '${c.name}' will override the 'experiments.lazyCompilation' option.`);
56370
- else if (!isReportRepeatWarned) {
56371
- console.warn(REPEAT_LAZY_COMPILATION_OPTIONS_WARN);
56372
- isReportRepeatWarned = true;
56373
- }
56374
- }
56365
+ if (c.options.experiments.lazyCompilation) c.name ? deprecate(`The 'experiments.lazyCompilation' option in compiler named '${c.name}' is deprecated, please use the Configuration top level 'lazyCompilation' instead.`) : deprecate(DEPRECATED_LAZY_COMPILATION_OPTIONS_WARN);
56366
+ if (c.options.lazyCompilation && c.options.experiments.lazyCompilation) c.name ? deprecate(`The top-level 'lazyCompilation' option in compiler named '${c.name}' will override the 'experiments.lazyCompilation' option.`) : deprecate(REPEAT_LAZY_COMPILATION_OPTIONS_WARN);
56375
56367
  if (!c.options.lazyCompilation && !c.options.experiments.lazyCompilation) continue;
56376
56368
  const options = {
56377
56369
  ...c.options.experiments.lazyCompilation,
@@ -56394,8 +56386,8 @@ const lazyCompilationMiddleware = (compiler)=>{
56394
56386
  };
56395
56387
  }
56396
56388
  if (compiler.options.experiments.lazyCompilation) {
56397
- console.warn(DEPRECATED_LAZY_COMPILATION_OPTIONS_WARN);
56398
- if (compiler.options.lazyCompilation) console.warn(REPEAT_LAZY_COMPILATION_OPTIONS_WARN);
56389
+ deprecate(DEPRECATED_LAZY_COMPILATION_OPTIONS_WARN);
56390
+ if (compiler.options.lazyCompilation) deprecate(REPEAT_LAZY_COMPILATION_OPTIONS_WARN);
56399
56391
  }
56400
56392
  if (!compiler.options.lazyCompilation && !compiler.options.experiments.lazyCompilation) return noop;
56401
56393
  const activeModules = new Set();
@@ -58210,7 +58202,6 @@ const applyExperimentsDefaults = (experiments, { development })=>{
58210
58202
  D(experiments.incremental, "emitAssets", true);
58211
58203
  }
58212
58204
  D(experiments, "rspackFuture", {});
58213
- D(experiments, "parallelCodeSplitting", false);
58214
58205
  D(experiments, "parallelLoader", false);
58215
58206
  D(experiments, "useInputFileSystem", false);
58216
58207
  D(experiments, "inlineConst", true);
@@ -58222,7 +58213,7 @@ const applybundlerInfoDefaults = (rspackFuture, library)=>{
58222
58213
  if ("object" == typeof rspackFuture) {
58223
58214
  D(rspackFuture, "bundlerInfo", {});
58224
58215
  if ("object" == typeof rspackFuture.bundlerInfo) {
58225
- D(rspackFuture.bundlerInfo, "version", "1.7.0-canary-22d591c5-20251222090400");
58216
+ D(rspackFuture.bundlerInfo, "version", "1.7.0-canary-dcc2f8c9-20251223064055");
58226
58217
  D(rspackFuture.bundlerInfo, "bundler", "rspack");
58227
58218
  D(rspackFuture.bundlerInfo, "force", !library);
58228
58219
  }
@@ -58940,7 +58931,7 @@ const getNormalizedRspackOptions = (config)=>({
58940
58931
  main: {}
58941
58932
  } : "function" == typeof config.entry ? ((fn)=>()=>Promise.resolve().then(fn).then(getNormalizedEntryStatic))(config.entry) : getNormalizedEntryStatic(config.entry),
58942
58933
  output: nestedConfig(config.output, (output)=>{
58943
- if ("cssHeadDataCompression" in output) util_default().deprecate(()=>{}, "cssHeadDataCompression is not used now, see https://github.com/web-infra-dev/rspack/pull/8534, this option could be removed in the future")();
58934
+ if ("cssHeadDataCompression" in output) deprecate("cssHeadDataCompression is not used now, see https://github.com/web-infra-dev/rspack/pull/8534, this option could be removed in the future");
58944
58935
  const { library } = output;
58945
58936
  const libraryAsName = library;
58946
58937
  const libraryBase = "object" == typeof library && library && !Array.isArray(library) && "type" in library ? library : libraryAsName || output.libraryTarget ? {
@@ -59091,13 +59082,12 @@ const getNormalizedRspackOptions = (config)=>({
59091
59082
  ...p
59092
59083
  ]),
59093
59084
  experiments: nestedConfig(config.experiments, (experiments)=>{
59094
- if (experiments.layers) util_default().deprecate(()=>{}, "`experiments.layers` config has been deprecated and will be removed in Rspack v2.0. Feature layers will be always enabled. Please remove this option from your Rspack configuration.")();
59095
- if (false === experiments.topLevelAwait) util_default().deprecate(()=>{}, "`experiments.topLevelAwait` config has been deprecated and will be removed in Rspack v2.0. Top-level await will be always enabled. Please remove this option from your Rspack configuration.")();
59096
- if (experiments.parallelCodeSplitting) util_default().deprecate(()=>{}, "`experiments.parallelCodeSplitting` config has been deprecated and will be removed in next minor. It has huge regression in some edge cases where the chunk graph has lots of cycles, we'll improve the performance of build_chunk_graph in the future instead")();
59097
- if (experiments.lazyBarrel) util_default().deprecate(()=>{}, "`experiments.lazyBarrel` config has been deprecated and will be removed in Rspack v2.0. Lazy barrel is already stable and enabled by default. Please remove this option from your Rspack configuration.")();
59098
- if (experiments.inlineConst) util_default().deprecate(()=>{}, "`experiments.inlineConst` config has been deprecated and will be removed in Rspack v2.0. Inline Const is already stable and enabled by default. Please remove this option from your Rspack configuration.")();
59099
- if (experiments.inlineEnum) util_default().deprecate(()=>{}, "`experiments.inlineEnum` config has been deprecated and will be removed in Rspack v2.0. Inline Enum is already stable. Please remove this option from your Rspack configuration.")();
59100
- if (experiments.typeReexportsPresence) util_default().deprecate(()=>{}, "`experiments.typeReexportsPresence` config has been deprecated and will be removed in Rspack v2.0. typeReexportsPresence is already stable. Please remove this option from your Rspack configuration.")();
59085
+ if (experiments.layers) deprecate("`experiments.layers` config is deprecated and will be removed in Rspack v2.0. Feature layers will always be enabled. Remove this option from your Rspack configuration.");
59086
+ if (false === experiments.topLevelAwait) deprecate("`experiments.topLevelAwait` config is deprecated and will be removed in Rspack v2.0. Top-level await will always be enabled. Remove this option from your Rspack configuration.");
59087
+ if (experiments.lazyBarrel) deprecate("`experiments.lazyBarrel` config is deprecated and will be removed in Rspack v2.0. Lazy barrel is already stable and enabled by default. Remove this option from your Rspack configuration.");
59088
+ if (experiments.inlineConst) deprecate("`experiments.inlineConst` config is deprecated and will be removed in Rspack v2.0. Inline Const is already stable and enabled by default. Remove this option from your Rspack configuration.");
59089
+ if (experiments.inlineEnum) deprecate("`experiments.inlineEnum` config is deprecated and will be removed in Rspack v2.0. Inline Enum is already stable. Remove this option from your Rspack configuration.");
59090
+ if (experiments.typeReexportsPresence) deprecate("`experiments.typeReexportsPresence` config is deprecated and will be removed in Rspack v2.0. typeReexportsPresence is already stable. Remove this option from your Rspack configuration.");
59101
59091
  return {
59102
59092
  ...experiments,
59103
59093
  cache: optionalNestedConfig(experiments.cache, (cache)=>{
@@ -59129,7 +59119,6 @@ const getNormalizedRspackOptions = (config)=>({
59129
59119
  }),
59130
59120
  lazyCompilation: optionalNestedConfig(experiments.lazyCompilation, (options)=>true === options ? {} : options),
59131
59121
  incremental: optionalNestedConfig(experiments.incremental, (options)=>getNormalizedIncrementalOptions(options)),
59132
- parallelCodeSplitting: experiments.parallelCodeSplitting,
59133
59122
  buildHttp: experiments.buildHttp,
59134
59123
  parallelLoader: experiments.parallelLoader,
59135
59124
  useInputFileSystem: experiments.useInputFileSystem
@@ -62382,7 +62371,7 @@ class MultiStats {
62382
62371
  return obj;
62383
62372
  });
62384
62373
  if (childOptions.version) {
62385
- obj.rspackVersion = "1.7.0-canary-22d591c5-20251222090400";
62374
+ obj.rspackVersion = "1.7.0-canary-dcc2f8c9-20251223064055";
62386
62375
  obj.version = "5.75.0";
62387
62376
  }
62388
62377
  if (childOptions.hash) obj.hash = obj.children.map((j)=>j.hash).join("");
@@ -63698,7 +63687,7 @@ const SIMPLE_EXTRACTORS = {
63698
63687
  },
63699
63688
  version: (object)=>{
63700
63689
  object.version = "5.75.0";
63701
- object.rspackVersion = "1.7.0-canary-22d591c5-20251222090400";
63690
+ object.rspackVersion = "1.7.0-canary-dcc2f8c9-20251223064055";
63702
63691
  },
63703
63692
  env: (object, _compilation, _context, { _env })=>{
63704
63693
  object.env = _env;
@@ -66131,34 +66120,6 @@ const VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
66131
66120
  function isRequiredVersion(str) {
66132
66121
  return VERSION_PATTERN_REGEXP.test(str);
66133
66122
  }
66134
- const encodeName = function(name, prefix = "", withExt = false) {
66135
- const ext = withExt ? ".js" : "";
66136
- return `${prefix}${name.replace(/@/g, "scope_").replace(/-/g, "_").replace(/\//g, "__").replace(/\./g, "")}${ext}`;
66137
- };
66138
- const options_process = (options, normalizeSimple, normalizeOptions, fn)=>{
66139
- const array = (items)=>{
66140
- for (const item of items)if ("string" == typeof item) fn(item, normalizeSimple(item, item));
66141
- else if (item && "object" == typeof item) object(item);
66142
- else throw new Error("Unexpected options format");
66143
- };
66144
- const object = (obj)=>{
66145
- for (const [key, value] of Object.entries(obj))"string" == typeof value || Array.isArray(value) ? fn(key, normalizeSimple(value, key)) : fn(key, normalizeOptions(value, key));
66146
- };
66147
- if (!options) return;
66148
- if (Array.isArray(options)) array(options);
66149
- else if ("object" == typeof options) object(options);
66150
- else throw new Error("Unexpected options format");
66151
- };
66152
- const parseOptions = (options, normalizeSimple, normalizeOptions)=>{
66153
- const items = [];
66154
- options_process(options, normalizeSimple, normalizeOptions, (key, value)=>{
66155
- items.push([
66156
- key,
66157
- value
66158
- ]);
66159
- });
66160
- return items;
66161
- };
66162
66123
  var ModuleFederationManifestPlugin_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
66163
66124
  function ModuleFederationManifestPlugin_define_property(obj, key, value) {
66164
66125
  if (key in obj) Object.defineProperty(obj, key, {
@@ -66208,10 +66169,6 @@ function getBuildInfo(isDev, root) {
66208
66169
  }
66209
66170
  function getFileName(manifestOptions) {
66210
66171
  if (!manifestOptions) return {
66211
- statsFileName: "",
66212
- manifestFileName: ""
66213
- };
66214
- if ("boolean" == typeof manifestOptions) return {
66215
66172
  statsFileName: STATS_FILE_NAME,
66216
66173
  manifestFileName: MANIFEST_FILE_NAME
66217
66174
  };
@@ -66229,13 +66186,127 @@ function getFileName(manifestOptions) {
66229
66186
  manifestFileName: (0, path_browserify.join)(filePath, manifestFileName)
66230
66187
  };
66231
66188
  }
66232
- function resolveLibraryGlobalName(library) {
66233
- if (!library) return;
66234
- const libName = library.name;
66235
- if (!libName) return;
66236
- if ("string" == typeof libName) return libName;
66237
- if (Array.isArray(libName)) return libName[0];
66238
- if ("object" == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
66189
+ class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
66190
+ raw(compiler) {
66191
+ const { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts;
66192
+ const { statsFileName, manifestFileName } = getFileName(this.opts);
66193
+ const rawOptions = {
66194
+ name: this.opts.name,
66195
+ globalName: this.opts.globalName,
66196
+ fileName,
66197
+ filePath,
66198
+ manifestFileName,
66199
+ statsFileName,
66200
+ disableAssetsAnalyze,
66201
+ remoteAliasMap,
66202
+ exposes,
66203
+ shared,
66204
+ buildInfo: getBuildInfo("development" === compiler.options.mode, compiler.context)
66205
+ };
66206
+ return createBuiltinPlugin(this.name, rawOptions);
66207
+ }
66208
+ constructor(opts){
66209
+ super(), ModuleFederationManifestPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationManifestPlugin), ModuleFederationManifestPlugin_define_property(this, "opts", void 0);
66210
+ this.opts = opts;
66211
+ }
66212
+ }
66213
+ const ModuleFederationRuntimePlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
66214
+ const options_process = (options, normalizeSimple, normalizeOptions, fn)=>{
66215
+ const array = (items)=>{
66216
+ for (const item of items)if ("string" == typeof item) fn(item, normalizeSimple(item, item));
66217
+ else if (item && "object" == typeof item) object(item);
66218
+ else throw new Error("Unexpected options format");
66219
+ };
66220
+ const object = (obj)=>{
66221
+ for (const [key, value] of Object.entries(obj))"string" == typeof value || Array.isArray(value) ? fn(key, normalizeSimple(value, key)) : fn(key, normalizeOptions(value, key));
66222
+ };
66223
+ if (!options) return;
66224
+ if (Array.isArray(options)) array(options);
66225
+ else if ("object" == typeof options) object(options);
66226
+ else throw new Error("Unexpected options format");
66227
+ };
66228
+ const parseOptions = (options, normalizeSimple, normalizeOptions)=>{
66229
+ const items = [];
66230
+ options_process(options, normalizeSimple, normalizeOptions, (key, value)=>{
66231
+ items.push([
66232
+ key,
66233
+ value
66234
+ ]);
66235
+ });
66236
+ return items;
66237
+ };
66238
+ function ModuleFederationPlugin_define_property(obj, key, value) {
66239
+ if (key in obj) Object.defineProperty(obj, key, {
66240
+ value: value,
66241
+ enumerable: true,
66242
+ configurable: true,
66243
+ writable: true
66244
+ });
66245
+ else obj[key] = value;
66246
+ return obj;
66247
+ }
66248
+ class ModuleFederationPlugin {
66249
+ apply(compiler) {
66250
+ const { webpack } = compiler;
66251
+ const paths = getPaths(this._options);
66252
+ compiler.options.resolve.alias = {
66253
+ "@module-federation/runtime-tools": paths.runtimeTools,
66254
+ "@module-federation/runtime": paths.runtime,
66255
+ ...compiler.options.resolve.alias
66256
+ };
66257
+ const entryRuntime = getDefaultEntryRuntime(paths, this._options, compiler);
66258
+ const runtimeExperiments = {
66259
+ asyncStartup: this._options.experiments?.asyncStartup ?? false
66260
+ };
66261
+ new ModuleFederationRuntimePlugin({
66262
+ entryRuntime,
66263
+ experiments: runtimeExperiments
66264
+ }).apply(compiler);
66265
+ const v1Options = {
66266
+ name: this._options.name,
66267
+ exposes: this._options.exposes,
66268
+ filename: this._options.filename,
66269
+ library: this._options.library,
66270
+ remoteType: this._options.remoteType,
66271
+ remotes: this._options.remotes,
66272
+ runtime: this._options.runtime,
66273
+ shareScope: this._options.shareScope,
66274
+ shared: this._options.shared,
66275
+ enhanced: true
66276
+ };
66277
+ new webpack.container.ModuleFederationPluginV1(v1Options).apply(compiler);
66278
+ if (this._options.manifest) {
66279
+ const manifestOptions = true === this._options.manifest ? {} : {
66280
+ ...this._options.manifest
66281
+ };
66282
+ const containerName = manifestOptions.name ?? this._options.name;
66283
+ const globalName = manifestOptions.globalName ?? resolveLibraryGlobalName(this._options.library) ?? containerName;
66284
+ const remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
66285
+ if (cur[1].length > 1) return sum;
66286
+ const remoteInfo = cur[1][0];
66287
+ const { entry, alias, name } = remoteInfo;
66288
+ if (entry && name) sum[alias] = {
66289
+ name,
66290
+ entry
66291
+ };
66292
+ return sum;
66293
+ }, {});
66294
+ const manifestExposes = collectManifestExposes(this._options.exposes);
66295
+ if (void 0 === manifestOptions.exposes && manifestExposes) manifestOptions.exposes = manifestExposes;
66296
+ const manifestShared = collectManifestShared(this._options.shared);
66297
+ if (void 0 === manifestOptions.shared && manifestShared) manifestOptions.shared = manifestShared;
66298
+ new ModuleFederationManifestPlugin({
66299
+ ...manifestOptions,
66300
+ name: containerName,
66301
+ globalName,
66302
+ remoteAliasMap
66303
+ }).apply(compiler);
66304
+ }
66305
+ }
66306
+ constructor(_options){
66307
+ ModuleFederationPlugin_define_property(this, "_options", void 0);
66308
+ this._options = _options;
66309
+ }
66239
66310
  }
66240
66311
  function collectManifestExposes(exposes) {
66241
66312
  if (!exposes) return;
@@ -66283,56 +66354,111 @@ function collectManifestShared(shared) {
66283
66354
  });
66284
66355
  return result.length > 0 ? result : void 0;
66285
66356
  }
66286
- function normalizeManifestOptions(mfConfig) {
66287
- const manifestOptions = true === mfConfig.manifest ? {} : {
66288
- ...mfConfig.manifest
66289
- };
66290
- const containerName = mfConfig.name;
66291
- const globalName = resolveLibraryGlobalName(mfConfig.library) ?? containerName;
66292
- const remoteAliasMap = Object.entries(getRemoteInfos(mfConfig)).reduce((sum, cur)=>{
66293
- if (cur[1].length > 1) return sum;
66294
- const remoteInfo = cur[1][0];
66295
- const { entry, alias, name } = remoteInfo;
66296
- if (entry && name) sum[alias] = {
66297
- name,
66298
- entry
66299
- };
66300
- return sum;
66301
- }, {});
66302
- const manifestExposes = collectManifestExposes(mfConfig.exposes);
66303
- if (void 0 === manifestOptions.exposes && manifestExposes) manifestOptions.exposes = manifestExposes;
66304
- const manifestShared = collectManifestShared(mfConfig.shared);
66305
- if (void 0 === manifestOptions.shared && manifestShared) manifestOptions.shared = manifestShared;
66357
+ function resolveLibraryGlobalName(library) {
66358
+ if (!library) return;
66359
+ const libName = library.name;
66360
+ if (!libName) return;
66361
+ if ("string" == typeof libName) return libName;
66362
+ if (Array.isArray(libName)) return libName[0];
66363
+ if ("object" == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
66364
+ }
66365
+ function getRemoteInfos(options) {
66366
+ if (!options.remotes) return {};
66367
+ function extractUrlAndGlobal(urlAndGlobal) {
66368
+ const index = urlAndGlobal.indexOf("@");
66369
+ if (index <= 0 || index === urlAndGlobal.length - 1) return null;
66370
+ return [
66371
+ urlAndGlobal.substring(index + 1),
66372
+ urlAndGlobal.substring(0, index)
66373
+ ];
66374
+ }
66375
+ function getExternalTypeFromExternal(external) {
66376
+ if (/^[a-z0-9-]+ /.test(external)) {
66377
+ const idx = external.indexOf(" ");
66378
+ return [
66379
+ external.slice(0, idx),
66380
+ external.slice(idx + 1)
66381
+ ];
66382
+ }
66383
+ return null;
66384
+ }
66385
+ function getExternal(external) {
66386
+ const result = getExternalTypeFromExternal(external);
66387
+ if (null === result) return [
66388
+ remoteType,
66389
+ external
66390
+ ];
66391
+ return result;
66392
+ }
66393
+ const remoteType = options.remoteType || (options.library ? options.library.type : "script");
66394
+ const remotes = parseOptions(options.remotes, (item)=>({
66395
+ external: Array.isArray(item) ? item : [
66396
+ item
66397
+ ],
66398
+ shareScope: options.shareScope || "default"
66399
+ }), (item)=>({
66400
+ external: Array.isArray(item.external) ? item.external : [
66401
+ item.external
66402
+ ],
66403
+ shareScope: item.shareScope || options.shareScope || "default"
66404
+ }));
66405
+ const remoteInfos = {};
66406
+ for (const [key, config] of remotes)for (const external of config.external){
66407
+ const [externalType, externalRequest] = getExternal(external);
66408
+ remoteInfos[key] ??= [];
66409
+ if ("script" === externalType) {
66410
+ const [url, global] = extractUrlAndGlobal(externalRequest);
66411
+ remoteInfos[key].push({
66412
+ alias: key,
66413
+ name: global,
66414
+ entry: url,
66415
+ externalType,
66416
+ shareScope: config.shareScope
66417
+ });
66418
+ } else remoteInfos[key].push({
66419
+ alias: key,
66420
+ name: void 0,
66421
+ entry: void 0,
66422
+ externalType,
66423
+ shareScope: config.shareScope
66424
+ });
66425
+ }
66426
+ return remoteInfos;
66427
+ }
66428
+ function getRuntimePlugins(options) {
66429
+ return options.runtimePlugins ?? [];
66430
+ }
66431
+ function getPaths(options) {
66306
66432
  return {
66307
- ...manifestOptions,
66308
- remoteAliasMap,
66309
- globalName,
66310
- name: containerName
66433
+ runtimeTools: "@module-federation/runtime-tools",
66434
+ bundlerRuntime: "@module-federation/webpack-bundler-runtime",
66435
+ runtime: "@module-federation/runtime"
66311
66436
  };
66312
66437
  }
66313
- class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
66314
- raw(compiler) {
66315
- const { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts;
66316
- const { statsFileName, manifestFileName } = getFileName(this.opts);
66317
- const rawOptions = {
66318
- name: this.opts.name,
66319
- globalName: this.opts.globalName,
66320
- fileName,
66321
- filePath,
66322
- manifestFileName,
66323
- statsFileName,
66324
- disableAssetsAnalyze,
66325
- remoteAliasMap,
66326
- exposes,
66327
- shared,
66328
- buildInfo: getBuildInfo("development" === compiler.options.mode, compiler.context)
66329
- };
66330
- return createBuiltinPlugin(this.name, rawOptions);
66331
- }
66332
- constructor(opts){
66333
- super(), ModuleFederationManifestPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationManifestPlugin), ModuleFederationManifestPlugin_define_property(this, "opts", void 0);
66334
- this.opts = normalizeManifestOptions(opts);
66438
+ function getDefaultEntryRuntime(paths, options, compiler) {
66439
+ const runtimePlugins = getRuntimePlugins(options);
66440
+ const remoteInfos = getRemoteInfos(options);
66441
+ const runtimePluginImports = [];
66442
+ const runtimePluginVars = [];
66443
+ for(let i = 0; i < runtimePlugins.length; i++){
66444
+ const runtimePluginVar = `__module_federation_runtime_plugin_${i}__`;
66445
+ const pluginSpec = runtimePlugins[i];
66446
+ const pluginPath = Array.isArray(pluginSpec) ? pluginSpec[0] : pluginSpec;
66447
+ const pluginParams = Array.isArray(pluginSpec) ? pluginSpec[1] : void 0;
66448
+ runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
66449
+ const paramsCode = void 0 === pluginParams ? "undefined" : JSON.stringify(pluginParams);
66450
+ runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
66335
66451
  }
66452
+ const content = [
66453
+ `import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
66454
+ ...runtimePluginImports,
66455
+ `const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(", ")}]`,
66456
+ `const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
66457
+ `const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
66458
+ `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? "version-first")}`,
66459
+ '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 _ref;const remotesLoadingChunkMapping=(_ref=(__webpack_require___remotesLoadingData=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData===void 0?void 0:__webpack_require___remotesLoadingData.chunkMapping)!==null&&_ref!==void 0?_ref:{};var _ref1;const remotesLoadingModuleIdToRemoteDataMapping=(_ref1=(__webpack_require___remotesLoadingData1=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData1===void 0?void 0:__webpack_require___remotesLoadingData1.moduleIdToRemoteDataMapping)!==null&&_ref1!==void 0?_ref1:{};var _ref2;const initializeSharingScopeToInitDataMapping=(_ref2=(__webpack_require___initializeSharingData=__webpack_require__.initializeSharingData)===null||__webpack_require___initializeSharingData===void 0?void 0:__webpack_require___initializeSharingData.scopeToSharingDataMapping)!==null&&_ref2!==void 0?_ref2:{};var _ref3;const consumesLoadingChunkMapping=(_ref3=(__webpack_require___consumesLoadingData=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData===void 0?void 0:__webpack_require___consumesLoadingData.chunkMapping)!==null&&_ref3!==void 0?_ref3:{};var _ref4;const consumesLoadingModuleToConsumeDataMapping=(_ref4=(__webpack_require___consumesLoadingData1=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData1===void 0?void 0:__webpack_require___consumesLoadingData1.moduleIdToConsumeDataMapping)!==null&&_ref4!==void 0?_ref4:{};const consumesLoadinginstalledModules={};const initializeSharingInitPromises=[];const initializeSharingInitTokens={};const containerShareScope=(__webpack_require___initializeExposesData=__webpack_require__.initializeExposesData)===null||__webpack_require___initializeExposesData===void 0?void 0:__webpack_require___initializeExposesData.shareScope;for(const key in __module_federation_bundler_runtime__){__webpack_require__.federation[key]=__module_federation_bundler_runtime__[key]}early(__webpack_require__.federation,"consumesLoadingModuleToHandlerMapping",()=>{const consumesLoadingModuleToHandlerMapping={};for(let[moduleId,data]of Object.entries(consumesLoadingModuleToConsumeDataMapping)){consumesLoadingModuleToHandlerMapping[moduleId]={getter:data.fallback,shareInfo:{shareConfig:{fixedDependencies:false,requiredVersion:data.requiredVersion,strictVersion:data.strictVersion,singleton:data.singleton,eager:data.eager},scope:[data.shareScope]},shareKey:data.shareKey}}return consumesLoadingModuleToHandlerMapping});early(__webpack_require__.federation,"initOptions",()=>({}));early(__webpack_require__.federation.initOptions,"name",()=>__module_federation_container_name__);early(__webpack_require__.federation.initOptions,"shareStrategy",()=>__module_federation_share_strategy__);early(__webpack_require__.federation.initOptions,"shared",()=>{const shared={};for(let[scope,stages]of Object.entries(initializeSharingScopeToInitDataMapping)){for(let stage of stages){if(typeof stage==="object"&&stage!==null){const{name,version,factory,eager,singleton,requiredVersion,strictVersion}=stage;const shareConfig={};const isValidValue=function(val){return typeof val!=="undefined"};if(isValidValue(singleton)){shareConfig.singleton=singleton}if(isValidValue(requiredVersion)){shareConfig.requiredVersion=requiredVersion}if(isValidValue(eager)){shareConfig.eager=eager}if(isValidValue(strictVersion)){shareConfig.strictVersion=strictVersion}const options={version,scope:[scope],shareConfig,get:factory};if(shared[name]){shared[name].push(options)}else{shared[name]=[options]}}}}return shared});merge(__webpack_require__.federation.initOptions,"remotes",()=>Object.values(__module_federation_remote_infos__).flat().filter(remote=>remote.externalType==="script"));merge(__webpack_require__.federation.initOptions,"plugins",()=>__module_federation_runtime_plugins__);early(__webpack_require__.federation,"bundlerRuntimeOptions",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions,"remotes",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"chunkMapping",()=>remotesLoadingChunkMapping);early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"remoteInfos",()=>__module_federation_remote_infos__);early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToExternalAndNameMapping",()=>{const remotesLoadingIdToExternalAndNameMappingMapping={};for(let[moduleId,data]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){remotesLoadingIdToExternalAndNameMappingMapping[moduleId]=[data.shareScope,data.name,data.externalModuleId,data.remoteName]}return remotesLoadingIdToExternalAndNameMappingMapping});early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"webpackRequire",()=>__webpack_require__);merge(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToRemoteMap",()=>{const idToRemoteMap={};for(let[id,remoteData]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){const info=__module_federation_remote_infos__[remoteData.remoteName];if(info)idToRemoteMap[id]=info}return idToRemoteMap});override(__webpack_require__,"S",__webpack_require__.federation.bundlerRuntime.S);if(__webpack_require__.federation.attachShareScopeMap){__webpack_require__.federation.attachShareScopeMap(__webpack_require__)}override(__webpack_require__.f,"remotes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.remotes({chunkId,promises,chunkMapping:remotesLoadingChunkMapping,idToExternalAndNameMapping:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToExternalAndNameMapping,idToRemoteMap:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToRemoteMap,webpackRequire:__webpack_require__}));override(__webpack_require__.f,"consumes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.consumes({chunkId,promises,chunkMapping:consumesLoadingChunkMapping,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping,installedModules:consumesLoadinginstalledModules,webpackRequire:__webpack_require__}));override(__webpack_require__,"I",(name,initScope)=>__webpack_require__.federation.bundlerRuntime.I({shareScopeName:name,initScope,initPromises:initializeSharingInitPromises,initTokens:initializeSharingInitTokens,webpackRequire:__webpack_require__}));override(__webpack_require__,"initContainer",(shareScope,initScope,remoteEntryInitOptions)=>__webpack_require__.federation.bundlerRuntime.initContainerEntry({shareScope,initScope,remoteEntryInitOptions,shareScopeKey:containerShareScope,webpackRequire:__webpack_require__}));override(__webpack_require__,"getContainer",(module1,getScope)=>{var moduleMap=__webpack_require__.initializeExposesData.moduleMap;__webpack_require__.R=getScope;getScope=Object.prototype.hasOwnProperty.call(moduleMap,module1)?moduleMap[module1]():Promise.resolve().then(()=>{throw new Error(\'Module "\'+module1+\'" does not exist in container.\')});__webpack_require__.R=undefined;return getScope});__webpack_require__.federation.instance=__webpack_require__.federation.runtime.init(__webpack_require__.federation.initOptions);if((__webpack_require___consumesLoadingData2=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData2===void 0?void 0:__webpack_require___consumesLoadingData2.initialConsumes){__webpack_require__.federation.bundlerRuntime.installInitialConsumes({webpackRequire:__webpack_require__,installedModules:consumesLoadinginstalledModules,initialConsumes:__webpack_require__.consumesLoadingData.initialConsumes,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping})}}'
66460
+ ].join(";");
66461
+ return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
66336
66462
  }
66337
66463
  function ShareRuntimePlugin_define_property(obj, key, value) {
66338
66464
  if (key in obj) Object.defineProperty(obj, key, {
@@ -66371,43 +66497,6 @@ function ConsumeSharedPlugin_define_property(obj, key, value) {
66371
66497
  else obj[key] = value;
66372
66498
  return obj;
66373
66499
  }
66374
- function normalizeConsumeShareOptions(consumes, shareScope) {
66375
- return parseOptions(consumes, (item, key)=>{
66376
- if (Array.isArray(item)) throw new Error("Unexpected array in options");
66377
- const result = item !== key && isRequiredVersion(item) ? {
66378
- import: key,
66379
- shareScope: shareScope || "default",
66380
- shareKey: key,
66381
- requiredVersion: item,
66382
- strictVersion: true,
66383
- packageName: void 0,
66384
- singleton: false,
66385
- eager: false,
66386
- treeshakeStrategy: void 0
66387
- } : {
66388
- import: key,
66389
- shareScope: shareScope || "default",
66390
- shareKey: key,
66391
- requiredVersion: void 0,
66392
- packageName: void 0,
66393
- strictVersion: false,
66394
- singleton: false,
66395
- eager: false,
66396
- treeshakeStrategy: void 0
66397
- };
66398
- return result;
66399
- }, (item, key)=>({
66400
- import: false === item.import ? void 0 : item.import || key,
66401
- shareScope: item.shareScope || shareScope || "default",
66402
- shareKey: item.shareKey || key,
66403
- requiredVersion: item.requiredVersion,
66404
- strictVersion: "boolean" == typeof item.strictVersion ? item.strictVersion : false !== item.import && !item.singleton,
66405
- packageName: item.packageName,
66406
- singleton: !!item.singleton,
66407
- eager: !!item.eager,
66408
- treeshakeStrategy: item.treeshakeStrategy
66409
- }));
66410
- }
66411
66500
  class ConsumeSharedPlugin extends RspackBuiltinPlugin {
66412
66501
  raw(compiler) {
66413
66502
  new ShareRuntimePlugin(this._options.enhanced).apply(compiler);
@@ -66423,7 +66512,38 @@ class ConsumeSharedPlugin extends RspackBuiltinPlugin {
66423
66512
  constructor(options){
66424
66513
  super(), ConsumeSharedPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.ConsumeSharedPlugin), ConsumeSharedPlugin_define_property(this, "_options", void 0);
66425
66514
  this._options = {
66426
- consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
66515
+ consumes: parseOptions(options.consumes, (item, key)=>{
66516
+ if (Array.isArray(item)) throw new Error("Unexpected array in options");
66517
+ const result = item !== key && isRequiredVersion(item) ? {
66518
+ import: key,
66519
+ shareScope: options.shareScope || "default",
66520
+ shareKey: key,
66521
+ requiredVersion: item,
66522
+ strictVersion: true,
66523
+ packageName: void 0,
66524
+ singleton: false,
66525
+ eager: false
66526
+ } : {
66527
+ import: key,
66528
+ shareScope: options.shareScope || "default",
66529
+ shareKey: key,
66530
+ requiredVersion: void 0,
66531
+ packageName: void 0,
66532
+ strictVersion: false,
66533
+ singleton: false,
66534
+ eager: false
66535
+ };
66536
+ return result;
66537
+ }, (item, key)=>({
66538
+ import: false === item.import ? void 0 : item.import || key,
66539
+ shareScope: item.shareScope || options.shareScope || "default",
66540
+ shareKey: item.shareKey || key,
66541
+ requiredVersion: item.requiredVersion,
66542
+ strictVersion: "boolean" == typeof item.strictVersion ? item.strictVersion : false !== item.import && !item.singleton,
66543
+ packageName: item.packageName,
66544
+ singleton: !!item.singleton,
66545
+ eager: !!item.eager
66546
+ })),
66427
66547
  enhanced: options.enhanced ?? false
66428
66548
  };
66429
66549
  }
@@ -66438,35 +66558,6 @@ function ProvideSharedPlugin_define_property(obj, key, value) {
66438
66558
  else obj[key] = value;
66439
66559
  return obj;
66440
66560
  }
66441
- function normalizeProvideShareOptions(options, shareScope, enhanced) {
66442
- return parseOptions(options, (item)=>{
66443
- if (Array.isArray(item)) throw new Error("Unexpected array of provides");
66444
- return {
66445
- shareKey: item,
66446
- version: void 0,
66447
- shareScope: shareScope || "default",
66448
- eager: false
66449
- };
66450
- }, (item)=>{
66451
- const raw = {
66452
- shareKey: item.shareKey,
66453
- version: item.version,
66454
- shareScope: item.shareScope || shareScope || "default",
66455
- eager: !!item.eager
66456
- };
66457
- if (enhanced) {
66458
- const enhancedItem = item;
66459
- return {
66460
- ...raw,
66461
- singleton: enhancedItem.singleton,
66462
- requiredVersion: enhancedItem.requiredVersion,
66463
- strictVersion: enhancedItem.strictVersion,
66464
- treeshakeStrategy: enhancedItem.treeshakeStrategy
66465
- };
66466
- }
66467
- return raw;
66468
- });
66469
- }
66470
66561
  class ProvideSharedPlugin extends RspackBuiltinPlugin {
66471
66562
  raw(compiler) {
66472
66563
  new ShareRuntimePlugin(this._enhanced ?? false).apply(compiler);
@@ -66478,7 +66569,32 @@ class ProvideSharedPlugin extends RspackBuiltinPlugin {
66478
66569
  }
66479
66570
  constructor(options){
66480
66571
  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);
66481
- this._provides = normalizeProvideShareOptions(options.provides, options.shareScope, options.enhanced);
66572
+ this._provides = parseOptions(options.provides, (item)=>{
66573
+ if (Array.isArray(item)) throw new Error("Unexpected array of provides");
66574
+ return {
66575
+ shareKey: item,
66576
+ version: void 0,
66577
+ shareScope: options.shareScope || "default",
66578
+ eager: false
66579
+ };
66580
+ }, (item)=>{
66581
+ const raw = {
66582
+ shareKey: item.shareKey,
66583
+ version: item.version,
66584
+ shareScope: item.shareScope || options.shareScope || "default",
66585
+ eager: !!item.eager
66586
+ };
66587
+ if (options.enhanced) {
66588
+ const enhancedItem = item;
66589
+ return {
66590
+ ...raw,
66591
+ singleton: enhancedItem.singleton,
66592
+ requiredVersion: enhancedItem.requiredVersion,
66593
+ strictVersion: enhancedItem.strictVersion
66594
+ };
66595
+ }
66596
+ return raw;
66597
+ });
66482
66598
  this._enhanced = options.enhanced;
66483
66599
  }
66484
66600
  }
@@ -66492,47 +66608,6 @@ function SharePlugin_define_property(obj, key, value) {
66492
66608
  else obj[key] = value;
66493
66609
  return obj;
66494
66610
  }
66495
- function normalizeSharedOptions(shared) {
66496
- return parseOptions(shared, (item, key)=>{
66497
- if ("string" != typeof item) throw new Error("Unexpected array in shared");
66498
- const config = item !== key && isRequiredVersion(item) ? {
66499
- import: key,
66500
- requiredVersion: item
66501
- } : {
66502
- import: item
66503
- };
66504
- return config;
66505
- }, (item)=>item);
66506
- }
66507
- function createProvideShareOptions(normalizedSharedOptions) {
66508
- return normalizedSharedOptions.filter(([, options])=>false !== options.import).map(([key, options])=>({
66509
- [options.import || key]: {
66510
- shareKey: options.shareKey || key,
66511
- shareScope: options.shareScope,
66512
- version: options.version,
66513
- eager: options.eager,
66514
- singleton: options.singleton,
66515
- requiredVersion: options.requiredVersion,
66516
- strictVersion: options.strictVersion,
66517
- treeshakeStrategy: options.treeshake?.strategy
66518
- }
66519
- }));
66520
- }
66521
- function createConsumeShareOptions(normalizedSharedOptions) {
66522
- return normalizedSharedOptions.map(([key, options])=>({
66523
- [key]: {
66524
- import: options.import,
66525
- shareKey: options.shareKey || key,
66526
- shareScope: options.shareScope,
66527
- requiredVersion: options.requiredVersion,
66528
- strictVersion: options.strictVersion,
66529
- singleton: options.singleton,
66530
- packageName: options.packageName,
66531
- eager: options.eager,
66532
- treeshakeStrategy: options.treeshake?.strategy
66533
- }
66534
- }));
66535
- }
66536
66611
  class SharePlugin {
66537
66612
  apply(compiler) {
66538
66613
  new ConsumeSharedPlugin({
@@ -66551,438 +66626,8 @@ class SharePlugin {
66551
66626
  SharePlugin_define_property(this, "_consumes", void 0);
66552
66627
  SharePlugin_define_property(this, "_provides", void 0);
66553
66628
  SharePlugin_define_property(this, "_enhanced", void 0);
66554
- SharePlugin_define_property(this, "_sharedOptions", void 0);
66555
- const sharedOptions = normalizeSharedOptions(options.shared);
66556
- const consumes = createConsumeShareOptions(sharedOptions);
66557
- const provides = createProvideShareOptions(sharedOptions);
66558
- this._shareScope = options.shareScope;
66559
- this._consumes = consumes;
66560
- this._provides = provides;
66561
- this._enhanced = options.enhanced ?? false;
66562
- this._sharedOptions = sharedOptions;
66563
- }
66564
- }
66565
- function CollectSharedEntryPlugin_define_property(obj, key, value) {
66566
- if (key in obj) Object.defineProperty(obj, key, {
66567
- value: value,
66568
- enumerable: true,
66569
- configurable: true,
66570
- writable: true
66571
- });
66572
- else obj[key] = value;
66573
- return obj;
66574
- }
66575
- const SHARE_ENTRY_ASSET = "collect-shared-entries.json";
66576
- class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
66577
- getData() {
66578
- return this._collectedEntries;
66579
- }
66580
- getFilename() {
66581
- return SHARE_ENTRY_ASSET;
66582
- }
66583
- apply(compiler) {
66584
- super.apply(compiler);
66585
- compiler.hooks.thisCompilation.tap("Collect shared entry", (compilation)=>{
66586
- compilation.hooks.processAssets.tapPromise({
66587
- name: "CollectSharedEntry",
66588
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
66589
- }, async ()=>{
66590
- compilation.getAssets().forEach((asset)=>{
66591
- if (asset.name === SHARE_ENTRY_ASSET) this._collectedEntries = JSON.parse(asset.source.source().toString());
66592
- compilation.deleteAsset(asset.name);
66593
- });
66594
- });
66595
- });
66596
- }
66597
- raw() {
66598
- const consumeShareOptions = createConsumeShareOptions(this.sharedOptions);
66599
- const normalizedConsumeShareOptions = normalizeConsumeShareOptions(consumeShareOptions);
66600
- const rawOptions = {
66601
- consumes: normalizedConsumeShareOptions.map(([key, v])=>({
66602
- key,
66603
- ...v
66604
- })),
66605
- filename: this.getFilename()
66606
- };
66607
- return createBuiltinPlugin(this.name, rawOptions);
66608
- }
66609
- constructor(options){
66610
- 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);
66611
- const { sharedOptions } = options;
66612
- this.sharedOptions = sharedOptions;
66613
- this._collectedEntries = {};
66614
- }
66615
- }
66616
- function SharedContainerPlugin_define_property(obj, key, value) {
66617
- if (key in obj) Object.defineProperty(obj, key, {
66618
- value: value,
66619
- enumerable: true,
66620
- configurable: true,
66621
- writable: true
66622
- });
66623
- else obj[key] = value;
66624
- return obj;
66625
- }
66626
- function assert(condition, msg) {
66627
- if (!condition) throw new Error(msg);
66628
- }
66629
- const HOT_UPDATE_SUFFIX = ".hot-update";
66630
- class SharedContainerPlugin extends RspackBuiltinPlugin {
66631
- getData() {
66632
- return [
66633
- this._options.fileName,
66634
- this._globalName,
66635
- this._options.version
66636
- ];
66637
- }
66638
- raw(compiler) {
66639
- const { library } = this._options;
66640
- if (!compiler.options.output.enabledLibraryTypes.includes(library.type)) compiler.options.output.enabledLibraryTypes.push(library.type);
66641
- return createBuiltinPlugin(this.name, this._options);
66642
- }
66643
- apply(compiler) {
66644
- super.apply(compiler);
66645
- const shareName = this._shareName;
66646
- compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
66647
- compilation.hooks.processAssets.tapPromise({
66648
- name: "getShareContainerFile"
66649
- }, async ()=>{
66650
- const remoteEntryPoint = compilation.entrypoints.get(shareName);
66651
- assert(remoteEntryPoint, `Can not get shared ${shareName} entryPoint!`);
66652
- const remoteEntryNameChunk = compilation.namedChunks.get(shareName);
66653
- assert(remoteEntryNameChunk, `Can not get shared ${shareName} chunk!`);
66654
- const files = Array.from(remoteEntryNameChunk.files).filter((f)=>!f.includes(HOT_UPDATE_SUFFIX) && !f.endsWith(".css"));
66655
- assert(files.length > 0, `no files found for shared ${shareName} chunk`);
66656
- assert(1 === files.length, `shared ${shareName} chunk should not have multiple files!, current files: ${files.join(",")}`);
66657
- this.filename = files[0];
66658
- });
66659
- });
66660
- }
66661
- constructor(options){
66662
- super(), SharedContainerPlugin_define_property(this, "name", external_rspack_wasi_browser_js_.BuiltinPluginName.SharedContainerPlugin), SharedContainerPlugin_define_property(this, "filename", ""), SharedContainerPlugin_define_property(this, "_options", void 0), SharedContainerPlugin_define_property(this, "_shareName", void 0), SharedContainerPlugin_define_property(this, "_globalName", void 0);
66663
- const { shareName, library, request, independentShareFileName, mfName } = options;
66664
- const version = options.version || "0.0.0";
66665
- this._globalName = encodeName(`${mfName}_${shareName}_${version}`);
66666
- const fileName = independentShareFileName || `${version}/share-entry.js`;
66667
- this._shareName = shareName;
66668
- this._options = {
66669
- name: shareName,
66670
- request: request,
66671
- library: (library ? {
66672
- ...library,
66673
- name: this._globalName
66674
- } : void 0) || {
66675
- type: "global",
66676
- name: this._globalName
66677
- },
66678
- version,
66679
- fileName
66680
- };
66681
- }
66682
- }
66683
- function SharedUsedExportsOptimizerPlugin_define_property(obj, key, value) {
66684
- if (key in obj) Object.defineProperty(obj, key, {
66685
- value: value,
66686
- enumerable: true,
66687
- configurable: true,
66688
- writable: true
66689
- });
66690
- else obj[key] = value;
66691
- return obj;
66692
- }
66693
- class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
66694
- buildOptions() {
66695
- const shared = this.sharedOptions.map(([shareKey, config])=>({
66696
- shareKey,
66697
- treeshake: !!config.treeshake,
66698
- usedExports: config.treeshake?.usedExports
66699
- }));
66700
- const { manifestFileName, statsFileName } = getFileName(this.manifestOptions);
66701
- return {
66702
- shared,
66703
- injectUsedExports: this.injectUsedExports,
66704
- manifestFileName,
66705
- statsFileName
66706
- };
66707
- }
66708
- raw() {
66709
- if (!this.sharedOptions.length) return;
66710
- return createBuiltinPlugin(this.name, this.buildOptions());
66711
- }
66712
- constructor(sharedOptions, injectUsedExports, manifestOptions){
66713
- 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);
66714
- this.sharedOptions = sharedOptions;
66715
- this.injectUsedExports = injectUsedExports ?? true;
66716
- this.manifestOptions = manifestOptions ?? {};
66717
- }
66718
- }
66719
- function IndependentSharedPlugin_define_property(obj, key, value) {
66720
- if (key in obj) Object.defineProperty(obj, key, {
66721
- value: value,
66722
- enumerable: true,
66723
- configurable: true,
66724
- writable: true
66725
- });
66726
- else obj[key] = value;
66727
- return obj;
66728
- }
66729
- const VIRTUAL_ENTRY = "./virtual-entry.js";
66730
- const VIRTUAL_ENTRY_NAME = "virtual-entry";
66731
- const filterPlugin = (plugin, excludedPlugins = [])=>{
66732
- if (!plugin) return true;
66733
- const pluginName = plugin.name || plugin.constructor?.name;
66734
- if (!pluginName) return true;
66735
- return ![
66736
- "TreeShakeSharedPlugin",
66737
- "IndependentSharedPlugin",
66738
- "ModuleFederationPlugin",
66739
- "SharedUsedExportsOptimizerPlugin",
66740
- "HtmlWebpackPlugin",
66741
- "HtmlRspackPlugin",
66742
- "RsbuildHtmlPlugin",
66743
- ...excludedPlugins
66744
- ].includes(pluginName);
66745
- };
66746
- class VirtualEntryPlugin {
66747
- createEntry() {
66748
- const { sharedOptions, collectShared } = this;
66749
- const entryContent = sharedOptions.reduce((acc, cur, index)=>{
66750
- const importLine = `import shared_${index} from '${cur[0]}';\n`;
66751
- const logLine = collectShared ? `console.log(shared_${index});\n` : "";
66752
- return acc + importLine + logLine;
66753
- }, "");
66754
- return entryContent;
66755
- }
66756
- static entry() {
66757
- return {
66758
- [VIRTUAL_ENTRY_NAME]: VIRTUAL_ENTRY
66759
- };
66760
- }
66761
- apply(compiler) {
66762
- new compiler.rspack.experiments.VirtualModulesPlugin({
66763
- [VIRTUAL_ENTRY]: this.createEntry()
66764
- }).apply(compiler);
66765
- compiler.hooks.thisCompilation.tap("RemoveVirtualEntryAsset", (compilation)=>{
66766
- compilation.hooks.processAssets.tapPromise({
66767
- name: "RemoveVirtualEntryAsset",
66768
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
66769
- }, async ()=>{
66770
- try {
66771
- const chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
66772
- chunk?.files.forEach((f)=>{
66773
- compilation.deleteAsset(f);
66774
- });
66775
- } catch (_e) {
66776
- console.error("Failed to remove virtual entry file!");
66777
- }
66778
- });
66779
- });
66780
- }
66781
- constructor(sharedOptions, collectShared){
66782
- IndependentSharedPlugin_define_property(this, "sharedOptions", void 0);
66783
- IndependentSharedPlugin_define_property(this, "collectShared", false);
66784
- this.sharedOptions = sharedOptions;
66785
- this.collectShared = collectShared;
66786
- }
66787
- }
66788
- const resolveOutputDir = (outputDir, shareName)=>shareName ? (0, path_browserify.join)(outputDir, encodeName(shareName)) : outputDir;
66789
- class IndependentSharedPlugin {
66790
- apply(compiler) {
66791
- const { manifest } = this;
66792
- let runCount = 0;
66793
- compiler.hooks.beforeRun.tapPromise("IndependentSharedPlugin", async ()=>{
66794
- if (runCount) return;
66795
- await this.createIndependentCompilers(compiler);
66796
- runCount++;
66797
- });
66798
- compiler.hooks.watchRun.tapPromise("IndependentSharedPlugin", async ()=>{
66799
- if (runCount) return;
66800
- await this.createIndependentCompilers(compiler);
66801
- runCount++;
66802
- });
66803
- compiler.hooks.shutdown.tapAsync("IndependentSharedPlugin", (callback)=>{
66804
- callback();
66805
- });
66806
- if (manifest) compiler.hooks.compilation.tap("IndependentSharedPlugin", (compilation)=>{
66807
- compilation.hooks.processAssets.tapPromise({
66808
- name: "injectBuildAssets",
66809
- stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
66810
- }, async ()=>{
66811
- const { statsFileName, manifestFileName } = getFileName(manifest);
66812
- const injectBuildAssetsIntoStatsOrManifest = (filename)=>{
66813
- const stats = compilation.getAsset(filename);
66814
- if (!stats) return;
66815
- const statsContent = JSON.parse(stats.source.source().toString());
66816
- const { shared } = statsContent;
66817
- Object.entries(this.buildAssets).forEach(([key, item])=>{
66818
- const targetShared = shared.find((s)=>s.name === key);
66819
- if (!targetShared) return;
66820
- item.forEach(([entry, version, globalName])=>{
66821
- if (version === targetShared.version) {
66822
- targetShared.fallback = entry;
66823
- targetShared.fallbackName = globalName;
66824
- }
66825
- });
66826
- });
66827
- compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
66828
- };
66829
- injectBuildAssetsIntoStatsOrManifest(statsFileName);
66830
- injectBuildAssetsIntoStatsOrManifest(manifestFileName);
66831
- });
66832
- });
66833
- }
66834
- async createIndependentCompilers(parentCompiler) {
66835
- const { sharedOptions, buildAssets, outputDir } = this;
66836
- console.log("🚀 Start creating a standalone compiler...");
66837
- const shareRequestsMap = await this.createIndependentCompiler(parentCompiler);
66838
- await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
66839
- if (!shareConfig.treeshake || false === shareConfig.import) return;
66840
- const shareRequests = shareRequestsMap[shareName].requests;
66841
- await Promise.all(shareRequests.map(async ([request, version])=>{
66842
- const sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1];
66843
- const [shareFileName, globalName, sharedVersion] = await this.createIndependentCompiler(parentCompiler, {
66844
- shareRequestsMap,
66845
- currentShare: {
66846
- shareName,
66847
- version,
66848
- request,
66849
- independentShareFileName: sharedConfig?.treeshake?.filename
66850
- }
66851
- });
66852
- if ("string" == typeof shareFileName) {
66853
- buildAssets[shareName] ||= [];
66854
- buildAssets[shareName].push([
66855
- (0, path_browserify.join)(resolveOutputDir(outputDir, shareName), shareFileName),
66856
- sharedVersion,
66857
- globalName
66858
- ]);
66859
- }
66860
- }));
66861
- }));
66862
- console.log("✅ All independent packages have been compiled successfully");
66863
- }
66864
- async createIndependentCompiler(parentCompiler, extraOptions) {
66865
- const { mfName, plugins, outputDir, sharedOptions, treeshake, library, treeshakeSharedExcludedPlugins } = this;
66866
- const outputDirWithShareName = resolveOutputDir(outputDir, extraOptions?.currentShare?.shareName || "");
66867
- const parentConfig = parentCompiler.options;
66868
- const finalPlugins = [];
66869
- const rspack = parentCompiler.rspack;
66870
- let extraPlugin;
66871
- extraPlugin = extraOptions ? new SharedContainerPlugin({
66872
- mfName,
66873
- library,
66874
- ...extraOptions.currentShare
66875
- }) : new CollectSharedEntryPlugin({
66876
- sharedOptions,
66877
- shareScope: "default"
66878
- });
66879
- (parentConfig.plugins || []).forEach((plugin)=>{
66880
- if (void 0 !== plugin && "string" != typeof plugin && filterPlugin(plugin, treeshakeSharedExcludedPlugins)) finalPlugins.push(plugin);
66881
- });
66882
- plugins.forEach((plugin)=>{
66883
- finalPlugins.push(plugin);
66884
- });
66885
- finalPlugins.push(extraPlugin);
66886
- finalPlugins.push(new ConsumeSharedPlugin({
66887
- consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
66888
- [key]: {
66889
- import: extraOptions ? false : options.import,
66890
- shareKey: options.shareKey || key,
66891
- shareScope: options.shareScope,
66892
- requiredVersion: options.requiredVersion,
66893
- strictVersion: options.strictVersion,
66894
- singleton: options.singleton,
66895
- packageName: options.packageName,
66896
- eager: options.eager
66897
- }
66898
- })),
66899
- enhanced: true
66900
- }));
66901
- if (treeshake) finalPlugins.push(new SharedUsedExportsOptimizerPlugin(sharedOptions, this.injectUsedExports));
66902
- finalPlugins.push(new VirtualEntryPlugin(sharedOptions, !extraOptions));
66903
- const fullOutputDir = (0, path_browserify.resolve)(parentCompiler.outputPath, outputDirWithShareName);
66904
- const compilerConfig = {
66905
- ...parentConfig,
66906
- module: {
66907
- ...parentConfig.module,
66908
- rules: [
66909
- {
66910
- test: /virtual-entry\.js$/,
66911
- type: "javascript/auto",
66912
- resolve: {
66913
- fullySpecified: false
66914
- },
66915
- use: {
66916
- loader: "builtin:swc-loader"
66917
- }
66918
- },
66919
- ...parentConfig.module?.rules || []
66920
- ]
66921
- },
66922
- mode: parentConfig.mode || "development",
66923
- entry: VirtualEntryPlugin.entry,
66924
- output: {
66925
- path: fullOutputDir,
66926
- clean: true,
66927
- publicPath: parentConfig.output?.publicPath || "auto"
66928
- },
66929
- plugins: finalPlugins,
66930
- optimization: {
66931
- ...parentConfig.optimization,
66932
- splitChunks: false
66933
- }
66934
- };
66935
- const compiler = rspack.rspack(compilerConfig);
66936
- compiler.inputFileSystem = parentCompiler.inputFileSystem;
66937
- compiler.outputFileSystem = parentCompiler.outputFileSystem;
66938
- compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
66939
- const { currentShare } = extraOptions || {};
66940
- return new Promise((resolve, reject)=>{
66941
- compiler.run((err, stats)=>{
66942
- if (err || stats?.hasErrors()) {
66943
- const target = currentShare ? currentShare.shareName : "收集依赖";
66944
- console.error(`❌ ${target} 编译失败:`, err || stats.toJson().errors.map((e)=>e.message).join("\n"));
66945
- reject(err || new Error(`${target} 编译失败`));
66946
- return;
66947
- }
66948
- currentShare && console.log(`✅ 独立包 ${currentShare.shareName} 编译成功`);
66949
- if (stats) {
66950
- currentShare && console.log(`📊 ${currentShare.shareName} 编译统计:`);
66951
- console.log(stats.toString({
66952
- colors: true,
66953
- chunks: false,
66954
- modules: false
66955
- }));
66956
- }
66957
- resolve(extraPlugin.getData());
66958
- });
66959
- });
66960
- }
66961
- constructor(options){
66962
- IndependentSharedPlugin_define_property(this, "mfName", void 0);
66963
- IndependentSharedPlugin_define_property(this, "shared", void 0);
66964
- IndependentSharedPlugin_define_property(this, "library", void 0);
66965
- IndependentSharedPlugin_define_property(this, "sharedOptions", void 0);
66966
- IndependentSharedPlugin_define_property(this, "outputDir", void 0);
66967
- IndependentSharedPlugin_define_property(this, "plugins", void 0);
66968
- IndependentSharedPlugin_define_property(this, "treeshake", void 0);
66969
- IndependentSharedPlugin_define_property(this, "manifest", void 0);
66970
- IndependentSharedPlugin_define_property(this, "buildAssets", {});
66971
- IndependentSharedPlugin_define_property(this, "injectUsedExports", void 0);
66972
- IndependentSharedPlugin_define_property(this, "treeshakeSharedExcludedPlugins", void 0);
66973
- IndependentSharedPlugin_define_property(this, "name", "IndependentSharedPlugin");
66974
- const { outputDir, plugins, treeshake, shared, name, manifest, injectUsedExports, library, treeshakeSharedExcludedPlugins } = options;
66975
- this.shared = shared;
66976
- this.mfName = name;
66977
- this.outputDir = outputDir || "independent-packages";
66978
- this.plugins = plugins || [];
66979
- this.treeshake = treeshake;
66980
- this.manifest = manifest;
66981
- this.injectUsedExports = injectUsedExports ?? true;
66982
- this.library = library;
66983
- this.treeshakeSharedExcludedPlugins = treeshakeSharedExcludedPlugins || [];
66984
- this.sharedOptions = parseOptions(shared, (item, key)=>{
66985
- if ("string" != typeof item) throw new Error(`Unexpected array in shared configuration for key "${key}"`);
66629
+ const sharedOptions = parseOptions(options.shared, (item, key)=>{
66630
+ if ("string" != typeof item) throw new Error("Unexpected array in shared");
66986
66631
  const config = item !== key && isRequiredVersion(item) ? {
66987
66632
  import: key,
66988
66633
  requiredVersion: item
@@ -66991,234 +66636,35 @@ class IndependentSharedPlugin {
66991
66636
  };
66992
66637
  return config;
66993
66638
  }, (item)=>item);
66639
+ const consumes = sharedOptions.map(([key, options])=>({
66640
+ [key]: {
66641
+ import: options.import,
66642
+ shareKey: options.shareKey || key,
66643
+ shareScope: options.shareScope,
66644
+ requiredVersion: options.requiredVersion,
66645
+ strictVersion: options.strictVersion,
66646
+ singleton: options.singleton,
66647
+ packageName: options.packageName,
66648
+ eager: options.eager
66649
+ }
66650
+ }));
66651
+ const provides = sharedOptions.filter(([, options])=>false !== options.import).map(([key, options])=>({
66652
+ [options.import || key]: {
66653
+ shareKey: options.shareKey || key,
66654
+ shareScope: options.shareScope,
66655
+ version: options.version,
66656
+ eager: options.eager,
66657
+ singleton: options.singleton,
66658
+ requiredVersion: options.requiredVersion,
66659
+ strictVersion: options.strictVersion
66660
+ }
66661
+ }));
66662
+ this._shareScope = options.shareScope;
66663
+ this._consumes = consumes;
66664
+ this._provides = provides;
66665
+ this._enhanced = options.enhanced ?? false;
66994
66666
  }
66995
66667
  }
66996
- function TreeShakeSharedPlugin_define_property(obj, key, value) {
66997
- if (key in obj) Object.defineProperty(obj, key, {
66998
- value: value,
66999
- enumerable: true,
67000
- configurable: true,
67001
- writable: true
67002
- });
67003
- else obj[key] = value;
67004
- return obj;
67005
- }
67006
- class TreeShakeSharedPlugin {
67007
- apply(compiler) {
67008
- const { mfConfig, outputDir, plugins, reshake } = this;
67009
- const { name, shared, library } = mfConfig;
67010
- if (!shared) return;
67011
- const sharedOptions = normalizeSharedOptions(shared);
67012
- if (!sharedOptions.length) return;
67013
- if (sharedOptions.some(([_, config])=>config.treeshake && false !== config.import)) {
67014
- if (!reshake) new SharedUsedExportsOptimizerPlugin(sharedOptions, mfConfig.injectUsedExports, mfConfig.manifest).apply(compiler);
67015
- this._independentSharePlugin = new IndependentSharedPlugin({
67016
- name: name,
67017
- shared: shared,
67018
- outputDir,
67019
- plugins,
67020
- treeshake: reshake,
67021
- library,
67022
- manifest: mfConfig.manifest,
67023
- treeshakeSharedExcludedPlugins: mfConfig.treeshakeSharedExcludedPlugins
67024
- });
67025
- this._independentSharePlugin.apply(compiler);
67026
- }
67027
- }
67028
- get buildAssets() {
67029
- return this._independentSharePlugin?.buildAssets || {};
67030
- }
67031
- constructor(options){
67032
- TreeShakeSharedPlugin_define_property(this, "mfConfig", void 0);
67033
- TreeShakeSharedPlugin_define_property(this, "outputDir", void 0);
67034
- TreeShakeSharedPlugin_define_property(this, "plugins", void 0);
67035
- TreeShakeSharedPlugin_define_property(this, "reshake", void 0);
67036
- TreeShakeSharedPlugin_define_property(this, "_independentSharePlugin", void 0);
67037
- TreeShakeSharedPlugin_define_property(this, "name", "TreeShakeSharedPlugin");
67038
- const { mfConfig, plugins, reshake } = options;
67039
- this.mfConfig = mfConfig;
67040
- this.outputDir = mfConfig.independentShareDir || "independent-packages";
67041
- this.plugins = plugins;
67042
- this.reshake = Boolean(reshake);
67043
- }
67044
- }
67045
- const ModuleFederationRuntimePlugin = base_create(external_rspack_wasi_browser_js_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
67046
- function ModuleFederationPlugin_define_property(obj, key, value) {
67047
- if (key in obj) Object.defineProperty(obj, key, {
67048
- value: value,
67049
- enumerable: true,
67050
- configurable: true,
67051
- writable: true
67052
- });
67053
- else obj[key] = value;
67054
- return obj;
67055
- }
67056
- class ModuleFederationPlugin {
67057
- apply(compiler) {
67058
- const { webpack } = compiler;
67059
- const paths = getPaths(this._options);
67060
- compiler.options.resolve.alias = {
67061
- "@module-federation/runtime-tools": paths.runtimeTools,
67062
- "@module-federation/runtime": paths.runtime,
67063
- ...compiler.options.resolve.alias
67064
- };
67065
- const sharedOptions = getSharedOptions(this._options);
67066
- const treeshakeEntries = sharedOptions.filter(([, config])=>config.treeshake);
67067
- if (treeshakeEntries.length > 0) {
67068
- this._treeShakeSharedPlugin = new TreeShakeSharedPlugin({
67069
- mfConfig: this._options,
67070
- reshake: false
67071
- });
67072
- this._treeShakeSharedPlugin.apply(compiler);
67073
- }
67074
- let runtimePluginApplied = false;
67075
- compiler.hooks.beforeRun.tapPromise({
67076
- name: "ModuleFederationPlugin",
67077
- stage: 100
67078
- }, async ()=>{
67079
- if (runtimePluginApplied) return;
67080
- runtimePluginApplied = true;
67081
- const entryRuntime = getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakeSharedPlugin?.buildAssets || {});
67082
- new ModuleFederationRuntimePlugin({
67083
- entryRuntime
67084
- }).apply(compiler);
67085
- });
67086
- compiler.hooks.watchRun.tapPromise({
67087
- name: "ModuleFederationPlugin",
67088
- stage: 100
67089
- }, async ()=>{
67090
- if (runtimePluginApplied) return;
67091
- runtimePluginApplied = true;
67092
- const entryRuntime = getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakeSharedPlugin?.buildAssets || {});
67093
- new ModuleFederationRuntimePlugin({
67094
- entryRuntime
67095
- }).apply(compiler);
67096
- });
67097
- new webpack.container.ModuleFederationPluginV1({
67098
- ...this._options,
67099
- enhanced: true
67100
- }).apply(compiler);
67101
- if (this._options.manifest) new ModuleFederationManifestPlugin(this._options).apply(compiler);
67102
- }
67103
- constructor(_options){
67104
- ModuleFederationPlugin_define_property(this, "_options", void 0);
67105
- ModuleFederationPlugin_define_property(this, "_treeShakeSharedPlugin", void 0);
67106
- this._options = _options;
67107
- }
67108
- }
67109
- function getRemoteInfos(options) {
67110
- if (!options.remotes) return {};
67111
- function extractUrlAndGlobal(urlAndGlobal) {
67112
- const index = urlAndGlobal.indexOf("@");
67113
- if (index <= 0 || index === urlAndGlobal.length - 1) return null;
67114
- return [
67115
- urlAndGlobal.substring(index + 1),
67116
- urlAndGlobal.substring(0, index)
67117
- ];
67118
- }
67119
- function getExternalTypeFromExternal(external) {
67120
- if (/^[a-z0-9-]+ /.test(external)) {
67121
- const idx = external.indexOf(" ");
67122
- return [
67123
- external.slice(0, idx),
67124
- external.slice(idx + 1)
67125
- ];
67126
- }
67127
- return null;
67128
- }
67129
- function getExternal(external) {
67130
- const result = getExternalTypeFromExternal(external);
67131
- if (null === result) return [
67132
- remoteType,
67133
- external
67134
- ];
67135
- return result;
67136
- }
67137
- const remoteType = options.remoteType || (options.library ? options.library.type : "script");
67138
- const remotes = parseOptions(options.remotes, (item)=>({
67139
- external: Array.isArray(item) ? item : [
67140
- item
67141
- ],
67142
- shareScope: options.shareScope || "default"
67143
- }), (item)=>({
67144
- external: Array.isArray(item.external) ? item.external : [
67145
- item.external
67146
- ],
67147
- shareScope: item.shareScope || options.shareScope || "default"
67148
- }));
67149
- const remoteInfos = {};
67150
- for (const [key, config] of remotes)for (const external of config.external){
67151
- const [externalType, externalRequest] = getExternal(external);
67152
- remoteInfos[key] ??= [];
67153
- if ("script" === externalType) {
67154
- const [url, global] = extractUrlAndGlobal(externalRequest);
67155
- remoteInfos[key].push({
67156
- alias: key,
67157
- name: global,
67158
- entry: url,
67159
- externalType,
67160
- shareScope: config.shareScope
67161
- });
67162
- } else remoteInfos[key].push({
67163
- alias: key,
67164
- name: void 0,
67165
- entry: void 0,
67166
- externalType,
67167
- shareScope: config.shareScope
67168
- });
67169
- }
67170
- return remoteInfos;
67171
- }
67172
- function getRuntimePlugins(options) {
67173
- return options.runtimePlugins ?? [];
67174
- }
67175
- function getSharedOptions(options) {
67176
- if (!options.shared) return [];
67177
- return parseOptions(options.shared, (item, key)=>{
67178
- if ("string" != typeof item) throw new Error("Unexpected array in shared");
67179
- return item !== key && isRequiredVersion(item) ? {
67180
- import: key,
67181
- requiredVersion: item
67182
- } : {
67183
- import: item
67184
- };
67185
- }, (item)=>item);
67186
- }
67187
- function getPaths(options) {
67188
- return {
67189
- runtimeTools: "@module-federation/runtime-tools",
67190
- bundlerRuntime: "@module-federation/webpack-bundler-runtime",
67191
- runtime: "@module-federation/runtime"
67192
- };
67193
- }
67194
- function getDefaultEntryRuntime(paths, options, compiler, treeshakeShareFallbacks) {
67195
- const runtimePlugins = getRuntimePlugins(options);
67196
- const remoteInfos = getRemoteInfos(options);
67197
- const runtimePluginImports = [];
67198
- const runtimePluginVars = [];
67199
- const libraryType = options.library?.type || "var";
67200
- for(let i = 0; i < runtimePlugins.length; i++){
67201
- const runtimePluginVar = `__module_federation_runtime_plugin_${i}__`;
67202
- const pluginSpec = runtimePlugins[i];
67203
- const pluginPath = Array.isArray(pluginSpec) ? pluginSpec[0] : pluginSpec;
67204
- const pluginParams = Array.isArray(pluginSpec) ? pluginSpec[1] : void 0;
67205
- runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
67206
- const paramsCode = void 0 === pluginParams ? "undefined" : JSON.stringify(pluginParams);
67207
- runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
67208
- }
67209
- const content = [
67210
- `import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
67211
- ...runtimePluginImports,
67212
- `const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(", ")}]`,
67213
- `const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
67214
- `const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
67215
- `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? "version-first")}`,
67216
- `const __module_federation_share_fallbacks__ = ${JSON.stringify(treeshakeShareFallbacks)}`,
67217
- `const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
67218
- '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 _ref;const remotesLoadingChunkMapping=(_ref=(__webpack_require___remotesLoadingData=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData===void 0?void 0:__webpack_require___remotesLoadingData.chunkMapping)!==null&&_ref!==void 0?_ref:{};var _ref1;const remotesLoadingModuleIdToRemoteDataMapping=(_ref1=(__webpack_require___remotesLoadingData1=__webpack_require__.remotesLoadingData)===null||__webpack_require___remotesLoadingData1===void 0?void 0:__webpack_require___remotesLoadingData1.moduleIdToRemoteDataMapping)!==null&&_ref1!==void 0?_ref1:{};var _ref2;const initializeSharingScopeToInitDataMapping=(_ref2=(__webpack_require___initializeSharingData=__webpack_require__.initializeSharingData)===null||__webpack_require___initializeSharingData===void 0?void 0:__webpack_require___initializeSharingData.scopeToSharingDataMapping)!==null&&_ref2!==void 0?_ref2:{};var _ref3;const consumesLoadingChunkMapping=(_ref3=(__webpack_require___consumesLoadingData=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData===void 0?void 0:__webpack_require___consumesLoadingData.chunkMapping)!==null&&_ref3!==void 0?_ref3:{};var _ref4;const consumesLoadingModuleToConsumeDataMapping=(_ref4=(__webpack_require___consumesLoadingData1=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData1===void 0?void 0:__webpack_require___consumesLoadingData1.moduleIdToConsumeDataMapping)!==null&&_ref4!==void 0?_ref4:{};const consumesLoadinginstalledModules={};const initializeSharingInitPromises=[];const initializeSharingInitTokens={};const containerShareScope=(__webpack_require___initializeExposesData=__webpack_require__.initializeExposesData)===null||__webpack_require___initializeExposesData===void 0?void 0:__webpack_require___initializeExposesData.shareScope;for(const key in __module_federation_bundler_runtime__){__webpack_require__.federation[key]=__module_federation_bundler_runtime__[key]}early(__webpack_require__.federation,"libraryType",()=>__module_federation_library_type__);early(__webpack_require__.federation,"sharedFallback",()=>__module_federation_share_fallbacks__);const sharedFallback=__webpack_require__.federation.sharedFallback;early(__webpack_require__.federation,"consumesLoadingModuleToHandlerMapping",()=>{const consumesLoadingModuleToHandlerMapping={};for(let[moduleId,data]of Object.entries(consumesLoadingModuleToConsumeDataMapping)){var __webpack_require___federation_bundlerRuntime;consumesLoadingModuleToHandlerMapping[moduleId]={getter:sharedFallback?(__webpack_require___federation_bundlerRuntime=__webpack_require__.federation.bundlerRuntime)===null||__webpack_require___federation_bundlerRuntime===void 0?void 0:__webpack_require___federation_bundlerRuntime.getSharedFallbackGetter({shareKey:data.shareKey,factory:data.fallback,webpackRequire:__webpack_require__,libraryType:__webpack_require__.federation.libraryType}):data.fallback,treeshakeGetter:sharedFallback?data.fallback:undefined,shareInfo:{shareConfig:{fixedDependencies:false,requiredVersion:data.requiredVersion,strictVersion:data.strictVersion,singleton:data.singleton,eager:data.eager},scope:[data.shareScope]},shareKey:data.shareKey,treeshake:__webpack_require__.federation.sharedFallback?{get:data.fallback,strategy:data.treeshakeStrategy}:undefined}}return consumesLoadingModuleToHandlerMapping});early(__webpack_require__.federation,"initOptions",()=>({}));early(__webpack_require__.federation.initOptions,"name",()=>__module_federation_container_name__);early(__webpack_require__.federation.initOptions,"shareStrategy",()=>__module_federation_share_strategy__);early(__webpack_require__.federation.initOptions,"shared",()=>{const shared={};for(let[scope,stages]of Object.entries(initializeSharingScopeToInitDataMapping)){for(let stage of stages){if(typeof stage==="object"&&stage!==null){const{name,version,factory,eager,singleton,requiredVersion,strictVersion,treeshakeStrategy}=stage;const shareConfig={};const isValidValue=function(val){return typeof val!=="undefined"};if(isValidValue(singleton)){shareConfig.singleton=singleton}if(isValidValue(requiredVersion)){shareConfig.requiredVersion=requiredVersion}if(isValidValue(eager)){shareConfig.eager=eager}if(isValidValue(strictVersion)){shareConfig.strictVersion=strictVersion}const options={version,scope:[scope],shareConfig,get:factory,treeshake:treeshakeStrategy?{strategy:treeshakeStrategy}:undefined};if(shared[name]){shared[name].push(options)}else{shared[name]=[options]}}}}return shared});merge(__webpack_require__.federation.initOptions,"remotes",()=>Object.values(__module_federation_remote_infos__).flat().filter(remote=>remote.externalType==="script"));merge(__webpack_require__.federation.initOptions,"plugins",()=>__module_federation_runtime_plugins__);early(__webpack_require__.federation,"bundlerRuntimeOptions",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions,"remotes",()=>({}));early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"chunkMapping",()=>remotesLoadingChunkMapping);early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"remoteInfos",()=>__module_federation_remote_infos__);early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToExternalAndNameMapping",()=>{const remotesLoadingIdToExternalAndNameMappingMapping={};for(let[moduleId,data]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){remotesLoadingIdToExternalAndNameMappingMapping[moduleId]=[data.shareScope,data.name,data.externalModuleId,data.remoteName]}return remotesLoadingIdToExternalAndNameMappingMapping});early(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"webpackRequire",()=>__webpack_require__);merge(__webpack_require__.federation.bundlerRuntimeOptions.remotes,"idToRemoteMap",()=>{const idToRemoteMap={};for(let[id,remoteData]of Object.entries(remotesLoadingModuleIdToRemoteDataMapping)){const info=__module_federation_remote_infos__[remoteData.remoteName];if(info)idToRemoteMap[id]=info}return idToRemoteMap});override(__webpack_require__,"S",__webpack_require__.federation.bundlerRuntime.S);if(__webpack_require__.federation.attachShareScopeMap){__webpack_require__.federation.attachShareScopeMap(__webpack_require__)}override(__webpack_require__.f,"remotes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.remotes({chunkId,promises,chunkMapping:remotesLoadingChunkMapping,idToExternalAndNameMapping:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToExternalAndNameMapping,idToRemoteMap:__webpack_require__.federation.bundlerRuntimeOptions.remotes.idToRemoteMap,webpackRequire:__webpack_require__}));override(__webpack_require__.f,"consumes",(chunkId,promises)=>__webpack_require__.federation.bundlerRuntime.consumes({chunkId,promises,chunkMapping:consumesLoadingChunkMapping,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping,installedModules:consumesLoadinginstalledModules,webpackRequire:__webpack_require__}));override(__webpack_require__,"I",(name,initScope)=>__webpack_require__.federation.bundlerRuntime.I({shareScopeName:name,initScope,initPromises:initializeSharingInitPromises,initTokens:initializeSharingInitTokens,webpackRequire:__webpack_require__}));override(__webpack_require__,"initContainer",(shareScope,initScope,remoteEntryInitOptions)=>__webpack_require__.federation.bundlerRuntime.initContainerEntry({shareScope,initScope,remoteEntryInitOptions,shareScopeKey:containerShareScope,webpackRequire:__webpack_require__}));override(__webpack_require__,"getContainer",(module1,getScope)=>{var moduleMap=__webpack_require__.initializeExposesData.moduleMap;__webpack_require__.R=getScope;getScope=Object.prototype.hasOwnProperty.call(moduleMap,module1)?moduleMap[module1]():Promise.resolve().then(()=>{throw new Error(\'Module "\'+module1+\'" does not exist in container.\')});__webpack_require__.R=undefined;return getScope});__webpack_require__.federation.instance=__webpack_require__.federation.bundlerRuntime.init({webpackRequire:__webpack_require__});if((__webpack_require___consumesLoadingData2=__webpack_require__.consumesLoadingData)===null||__webpack_require___consumesLoadingData2===void 0?void 0:__webpack_require___consumesLoadingData2.initialConsumes){__webpack_require__.federation.bundlerRuntime.installInitialConsumes({webpackRequire:__webpack_require__,installedModules:consumesLoadinginstalledModules,initialConsumes:__webpack_require__.consumesLoadingData.initialConsumes,moduleToHandlerMapping:__webpack_require__.federation.consumesLoadingModuleToHandlerMapping})}}'
67219
- ].join(";");
67220
- return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
67221
- }
67222
66668
  function ContainerPlugin_define_property(obj, key, value) {
67223
66669
  if (key in obj) Object.defineProperty(obj, key, {
67224
66670
  value: value,
@@ -67254,7 +66700,7 @@ class ContainerPlugin extends RspackBuiltinPlugin {
67254
66700
  name: options.name,
67255
66701
  shareScope: options.shareScope || "default",
67256
66702
  library: options.library || {
67257
- type: "global",
66703
+ type: "var",
67258
66704
  name: options.name
67259
66705
  },
67260
66706
  runtime: options.runtime,
@@ -67288,14 +66734,19 @@ class ContainerReferencePlugin extends RspackBuiltinPlugin {
67288
66734
  raw(compiler) {
67289
66735
  const { remoteType, remotes } = this._options;
67290
66736
  const remoteExternals = {};
66737
+ const importExternals = {};
67291
66738
  for (const [key, config] of remotes){
67292
66739
  let i = 0;
67293
- for (const external of config.external)if (!external.startsWith("internal ")) {
67294
- remoteExternals[`webpack/container/reference/${key}${i ? `/fallback-${i}` : ""}`] = external;
66740
+ for (const external of config.external){
66741
+ if (external.startsWith("internal ")) continue;
66742
+ const request = `webpack/container/reference/${key}${i ? `/fallback-${i}` : ""}`;
66743
+ if (("module" === remoteType || "module-import" === remoteType) && external.startsWith(".")) importExternals[request] = external;
66744
+ else remoteExternals[request] = external;
67295
66745
  i++;
67296
66746
  }
67297
66747
  }
67298
66748
  new ExternalsPlugin(remoteType, remoteExternals, true).apply(compiler);
66749
+ if (Object.keys(importExternals).length > 0) new ExternalsPlugin("import", importExternals, true).apply(compiler);
67299
66750
  new ShareRuntimePlugin(this._options.enhanced).apply(compiler);
67300
66751
  const rawOptions = {
67301
66752
  remoteType: this._options.remoteType,
@@ -67391,7 +66842,7 @@ function transformSync(source, options) {
67391
66842
  const _options = JSON.stringify(options || {});
67392
66843
  return external_rspack_wasi_browser_js_["default"].transformSync(source, _options);
67393
66844
  }
67394
- const exports_rspackVersion = "1.7.0-canary-22d591c5-20251222090400";
66845
+ const exports_rspackVersion = "1.7.0-canary-dcc2f8c9-20251223064055";
67395
66846
  const exports_version = "5.75.0";
67396
66847
  const exports_WebpackError = Error;
67397
66848
  const sources = __webpack_require__("../../node_modules/.pnpm/webpack-sources@3.3.3_patch_hash=b2a26650f08a2359d0a3cd81fa6fa272aa7441a28dd7e601792da5ed5d2b4aee/node_modules/webpack-sources/lib/index.js");
@@ -67442,7 +66893,6 @@ const container = {
67442
66893
  };
67443
66894
  const sharing = {
67444
66895
  ProvideSharedPlugin: ProvideSharedPlugin,
67445
- TreeShakeSharedPlugin: TreeShakeSharedPlugin,
67446
66896
  ConsumeSharedPlugin: ConsumeSharedPlugin,
67447
66897
  SharePlugin: SharePlugin
67448
66898
  };
@@ -67551,7 +67001,7 @@ function createCompiler(userOptions) {
67551
67001
  function isMultiRspackOptions(o) {
67552
67002
  return Array.isArray(o);
67553
67003
  }
67554
- function rspack_rspack(options, callback) {
67004
+ function rspack(options, callback) {
67555
67005
  try {
67556
67006
  if (isMultiRspackOptions(options)) for (const option of options)validateRspackConfig(option);
67557
67007
  else validateRspackConfig(options);
@@ -67597,11 +67047,11 @@ function rspack_rspack(options, callback) {
67597
67047
  }
67598
67048
  {
67599
67049
  const { compiler, watch } = create();
67600
- if (watch) util_default().deprecate(()=>{}, "A 'callback' argument needs to be provided to the 'rspack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.")();
67050
+ if (watch) deprecate("A 'callback' argument needs to be provided to the 'rspack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.");
67601
67051
  return compiler;
67602
67052
  }
67603
67053
  }
67604
- const src_fn = Object.assign(rspack_rspack, exports_namespaceObject);
67054
+ const src_fn = Object.assign(rspack, exports_namespaceObject);
67605
67055
  src_fn.rspack = src_fn;
67606
67056
  src_fn.webpack = src_fn;
67607
67057
  const src_rspack_0 = src_fn;