@rspack-canary/core 1.7.0-canary-4941195f-20251224083309 → 1.7.0-canary-c8f933e3-20251224124051

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -289,9 +289,7 @@ for(var __rspack_i in (()=>{
289
289
  ContextModule: ()=>binding_.ContextModule,
290
290
  DllPlugin: ()=>DllPlugin,
291
291
  WarnCaseSensitiveModulesPlugin: ()=>WarnCaseSensitiveModulesPlugin,
292
- Coordinator: ()=>Coordinator,
293
292
  ProvidePlugin: ()=>ProvidePlugin,
294
- RscClientPlugin: ()=>RscClientPlugin,
295
293
  Template: ()=>Template,
296
294
  container: ()=>container,
297
295
  HtmlRspackPlugin: ()=>HtmlRspackPlugin,
@@ -303,7 +301,6 @@ for(var __rspack_i in (()=>{
303
301
  EnvironmentPlugin: ()=>EnvironmentPlugin,
304
302
  HotModuleReplacementPlugin: ()=>HotModuleReplacementPlugin,
305
303
  Compilation: ()=>Compilation,
306
- RscServerPlugin: ()=>RscServerPlugin,
307
304
  experiments: ()=>exports_experiments,
308
305
  CircularDependencyRspackPlugin: ()=>CircularDependencyRspackPlugin,
309
306
  EvalSourceMapDevToolPlugin: ()=>EvalSourceMapDevToolPlugin,
@@ -369,7 +366,6 @@ for(var __rspack_i in (()=>{
369
366
  ConcatenatedModule: ()=>binding_.ConcatenatedModule,
370
367
  ContextModule: ()=>binding_.ContextModule,
371
368
  ContextReplacementPlugin: ()=>ContextReplacementPlugin,
372
- Coordinator: ()=>Coordinator,
373
369
  CopyRspackPlugin: ()=>CopyRspackPlugin,
374
370
  CssExtractRspackPlugin: ()=>CssExtractRspackPlugin,
375
371
  DefinePlugin: ()=>DefinePlugin,
@@ -400,8 +396,6 @@ for(var __rspack_i in (()=>{
400
396
  NormalModuleReplacementPlugin: ()=>NormalModuleReplacementPlugin,
401
397
  ProgressPlugin: ()=>ProgressPlugin,
402
398
  ProvidePlugin: ()=>ProvidePlugin,
403
- RscClientPlugin: ()=>RscClientPlugin,
404
- RscServerPlugin: ()=>RscServerPlugin,
405
399
  RspackOptionsApply: ()=>RspackOptionsApply,
406
400
  RuntimeGlobals: ()=>DefaultRuntimeGlobals,
407
401
  RuntimeModule: ()=>RuntimeModule,
@@ -4622,64 +4616,6 @@ Plugins which provide custom chunk loading types must call EnableChunkLoadingPlu
4622
4616
  ])
4623
4617
  }, RuntimePlugin_compilationHooksMap.set(compilation, hooks)), hooks;
4624
4618
  };
4625
- let Coordinator_PLUGIN_NAME = "RscPlugin", GET_OR_INIT_BINDING = Symbol("GET_OR_INIT_BINDING");
4626
- class Coordinator {
4627
- #serverCompiler;
4628
- #clientCompiler;
4629
- #clientLastCompilation;
4630
- #binding;
4631
- constructor(){
4632
- Object.defineProperty(this, GET_OR_INIT_BINDING, {
4633
- enumerable: !1,
4634
- configurable: !1,
4635
- writable: !1,
4636
- value: ()=>(this.#binding || (this.#binding = new binding_.JsCoordinator(()=>{
4637
- if (!this.#serverCompiler) throw Error("[RscPlugin] Coordinator.getOrInitBinding() called before the server compiler was attached. Call coordinator.applyServerCompiler(serverCompiler) first.");
4638
- return this.#serverCompiler[GET_COMPILER_ID]();
4639
- })), this.#binding)
4640
- });
4641
- }
4642
- applyServerCompiler(serverCompiler) {
4643
- this.#serverCompiler = serverCompiler, serverCompiler.hooks.done.tap(Coordinator_PLUGIN_NAME, (stats)=>{
4644
- this.#clientLastCompilation && (stats.compilation.fileDependencies.addAll(this.#clientLastCompilation.fileDependencies), stats.compilation.contextDependencies.addAll(this.#clientLastCompilation.contextDependencies), stats.compilation.missingDependencies.addAll(this.#clientLastCompilation.missingDependencies));
4645
- }), serverCompiler.hooks.watchRun.tap(Coordinator_PLUGIN_NAME, ()=>{
4646
- this.#clientCompiler.watching.invalidateWithChangesAndRemovals(new Set(this.#serverCompiler.modifiedFiles), new Set(this.#serverCompiler.removedFiles));
4647
- });
4648
- }
4649
- applyClientCompiler(clientCompiler) {
4650
- this.#clientCompiler = clientCompiler;
4651
- let originalWatch = clientCompiler.watch;
4652
- clientCompiler.watch = function(watchOptions, handler) {
4653
- return watchOptions.ignored = ()=>!0, originalWatch.call(this, watchOptions, handler);
4654
- }, clientCompiler.hooks.done.tap(Coordinator_PLUGIN_NAME, (stats)=>{
4655
- this.#clientLastCompilation = stats.compilation;
4656
- });
4657
- }
4658
- }
4659
- class RscClientPlugin extends RspackBuiltinPlugin {
4660
- name = "RscClientPlugin";
4661
- #coordinator;
4662
- constructor(coordinator){
4663
- super(), this.#coordinator = coordinator;
4664
- }
4665
- raw(compiler) {
4666
- return this.#coordinator.applyClientCompiler(compiler), createBuiltinPlugin(this.name, this.#coordinator[GET_OR_INIT_BINDING]());
4667
- }
4668
- }
4669
- class RscServerPlugin extends RspackBuiltinPlugin {
4670
- name = "RscServerPlugin";
4671
- #coordinator;
4672
- constructor(coordinator){
4673
- super(), this.#coordinator = coordinator;
4674
- }
4675
- #resolve(serverCompiler) {
4676
- return this.#coordinator.applyServerCompiler(serverCompiler), this.#coordinator[GET_OR_INIT_BINDING]();
4677
- }
4678
- raw(compiler) {
4679
- let bindingOptions = this.#resolve(compiler);
4680
- return createBuiltinPlugin(this.name, bindingOptions);
4681
- }
4682
- }
4683
4619
  let SideEffectsFlagPlugin = base_create(binding_.BuiltinPluginName.SideEffectsFlagPlugin, ()=>{}, "compilation"), SizeLimitsPlugin = base_create(binding_.BuiltinPluginName.SizeLimitsPlugin, (options)=>{
4684
4620
  let hints = !1 === options.hints ? void 0 : options.hints;
4685
4621
  return {
@@ -5894,9 +5830,9 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
5894
5830
  let tty = infrastructureLogging.stream?.isTTY && "dumb" !== process.env.TERM;
5895
5831
  D(infrastructureLogging, "level", "info"), D(infrastructureLogging, "debug", !1), D(infrastructureLogging, "colors", tty), D(infrastructureLogging, "appendOnly", !tty);
5896
5832
  }, applyExperimentsDefaults = (experiments, { development })=>{
5897
- F(experiments, "cache", ()=>development), D(experiments, "futureDefaults", !1), D(experiments, "lazyCompilation", !1), D(experiments, "asyncWebAssembly", experiments.futureDefaults), D(experiments, "css", !!experiments.futureDefaults || void 0), D(experiments, "topLevelAwait", !0), D(experiments, "deferImport", !1), D(experiments, "buildHttp", void 0), experiments.buildHttp && "object" == typeof experiments.buildHttp && D(experiments.buildHttp, "upgrade", !1), D(experiments, "incremental", {}), "object" == typeof experiments.incremental && (D(experiments.incremental, "silent", !0), D(experiments.incremental, "make", !0), D(experiments.incremental, "inferAsyncModules", !0), D(experiments.incremental, "providedExports", !0), D(experiments.incremental, "dependenciesDiagnostics", !0), D(experiments.incremental, "sideEffects", !0), D(experiments.incremental, "buildChunkGraph", !1), D(experiments.incremental, "moduleIds", !0), D(experiments.incremental, "chunkIds", !0), D(experiments.incremental, "modulesHashes", !0), D(experiments.incremental, "modulesCodegen", !0), D(experiments.incremental, "modulesRuntimeRequirements", !0), D(experiments.incremental, "chunksRuntimeRequirements", !0), D(experiments.incremental, "chunksHashes", !0), D(experiments.incremental, "chunksRender", !0), D(experiments.incremental, "emitAssets", !0)), D(experiments, "rspackFuture", {}), D(experiments, "parallelLoader", !1), D(experiments, "useInputFileSystem", !1), D(experiments, "inlineConst", !0), D(experiments, "inlineEnum", !1), D(experiments, "typeReexportsPresence", !1), D(experiments, "lazyBarrel", !0);
5833
+ F(experiments, "cache", ()=>development), D(experiments, "futureDefaults", !1), D(experiments, "lazyCompilation", !1), D(experiments, "asyncWebAssembly", experiments.futureDefaults), D(experiments, "css", !!experiments.futureDefaults || void 0), D(experiments, "topLevelAwait", !0), D(experiments, "deferImport", !1), D(experiments, "buildHttp", void 0), experiments.buildHttp && "object" == typeof experiments.buildHttp && D(experiments.buildHttp, "upgrade", !1), D(experiments, "incremental", {}), "object" == typeof experiments.incremental && (D(experiments.incremental, "silent", !0), D(experiments.incremental, "make", !0), D(experiments.incremental, "inferAsyncModules", !0), D(experiments.incremental, "providedExports", !0), D(experiments.incremental, "dependenciesDiagnostics", !0), D(experiments.incremental, "sideEffects", !0), D(experiments.incremental, "buildChunkGraph", !1), D(experiments.incremental, "moduleIds", !0), D(experiments.incremental, "chunkIds", !0), D(experiments.incremental, "modulesHashes", !0), D(experiments.incremental, "modulesCodegen", !0), D(experiments.incremental, "modulesRuntimeRequirements", !0), D(experiments.incremental, "chunksRuntimeRequirements", !0), D(experiments.incremental, "chunksHashes", !0), D(experiments.incremental, "chunksRender", !0), D(experiments.incremental, "emitAssets", !0)), D(experiments, "rspackFuture", {}), D(experiments, "parallelCodeSplitting", !1), D(experiments, "parallelLoader", !1), D(experiments, "useInputFileSystem", !1), D(experiments, "inlineConst", !0), D(experiments, "inlineEnum", !1), D(experiments, "typeReexportsPresence", !1), D(experiments, "lazyBarrel", !0);
5898
5834
  }, applybundlerInfoDefaults = (rspackFuture, library)=>{
5899
- "object" == typeof rspackFuture && (D(rspackFuture, "bundlerInfo", {}), "object" == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, "version", "1.7.0-canary-4941195f-20251224083309"), D(rspackFuture.bundlerInfo, "bundler", "rspack"), D(rspackFuture.bundlerInfo, "force", !library)));
5835
+ "object" == typeof rspackFuture && (D(rspackFuture, "bundlerInfo", {}), "object" == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, "version", "1.7.0-canary-c8f933e3-20251224124051"), D(rspackFuture.bundlerInfo, "bundler", "rspack"), D(rspackFuture.bundlerInfo, "force", !library)));
5900
5836
  }, applySnapshotDefaults = (_snapshot, _env)=>{}, applyModuleDefaults = (module1, { cache, asyncWebAssembly, css, targetProperties, mode, uniqueName, deferImport })=>{
5901
5837
  if (assertNotNill(module1.parser), assertNotNill(module1.generator), cache ? D(module1, "unsafeCache", /[\\/]node_modules[\\/]/) : D(module1, "unsafeCache", !1), F(module1.parser, "asset", ()=>({})), assertNotNill(module1.parser.asset), F(module1.parser.asset, "dataUrlCondition", ()=>({})), "object" == typeof module1.parser.asset.dataUrlCondition && D(module1.parser.asset.dataUrlCondition, "maxSize", 8096), F(module1.parser, "javascript", ()=>({})), assertNotNill(module1.parser.javascript), ((parserOptions, { deferImport })=>{
5902
5838
  D(parserOptions, "dynamicImportMode", "lazy"), D(parserOptions, "dynamicImportPrefetch", !1), D(parserOptions, "dynamicImportPreload", !1), D(parserOptions, "url", !0), D(parserOptions, "exprContextCritical", !0), D(parserOptions, "unknownContextCritical", !0), D(parserOptions, "wrappedContextCritical", !1), D(parserOptions, "wrappedContextRegExp", /.*/), D(parserOptions, "strictExportPresence", !1), D(parserOptions, "requireAsExpression", !0), D(parserOptions, "requireDynamic", !0), D(parserOptions, "requireResolve", !0), D(parserOptions, "commonjs", !0), D(parserOptions, "importDynamic", !0), D(parserOptions, "worker", [
@@ -6515,7 +6451,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6515
6451
  plugins: nestedArray(config.plugins, (p)=>[
6516
6452
  ...p
6517
6453
  ]),
6518
- experiments: nestedConfig(config.experiments, (experiments)=>(experiments.layers && external_node_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.")(), !1 === experiments.topLevelAwait && external_node_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.")(), experiments.lazyBarrel && external_node_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.")(), experiments.inlineConst && external_node_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.")(), experiments.inlineEnum && external_node_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.")(), experiments.typeReexportsPresence && external_node_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.")(), {
6454
+ experiments: nestedConfig(config.experiments, (experiments)=>(experiments.layers && external_node_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.")(), !1 === experiments.topLevelAwait && external_node_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.")(), experiments.parallelCodeSplitting && external_node_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")(), experiments.lazyBarrel && external_node_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.")(), experiments.inlineConst && external_node_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.")(), experiments.inlineEnum && external_node_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.")(), experiments.typeReexportsPresence && external_node_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.")(), {
6519
6455
  ...experiments,
6520
6456
  cache: optionalNestedConfig(experiments.cache, (cache)=>{
6521
6457
  if ("boolean" == typeof cache || "memory" === cache.type) return cache;
@@ -6545,6 +6481,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6545
6481
  }),
6546
6482
  lazyCompilation: optionalNestedConfig(experiments.lazyCompilation, (options)=>!0 === options ? {} : options),
6547
6483
  incremental: optionalNestedConfig(experiments.incremental, (options)=>getNormalizedIncrementalOptions(options)),
6484
+ parallelCodeSplitting: experiments.parallelCodeSplitting,
6548
6485
  buildHttp: experiments.buildHttp,
6549
6486
  parallelLoader: experiments.parallelLoader,
6550
6487
  useInputFileSystem: experiments.useInputFileSystem
@@ -7662,7 +7599,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
7662
7599
  });
7663
7600
  }
7664
7601
  }
7665
- let CORE_VERSION = "1.7.0-canary-4941195f-20251224083309", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
7602
+ let CORE_VERSION = "1.7.0-canary-c8f933e3-20251224124051", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
7666
7603
 
7667
7604
  Help:
7668
7605
  Looks like you are using a custom binding (via environment variable 'RSPACK_BINDING=${process.env.RSPACK_BINDING}').
@@ -7890,21 +7827,21 @@ Help:
7890
7827
  let startTime = this.startTime;
7891
7828
  this.startTime = void 0, compilation.startTime = startTime, compilation.endTime = Date.now();
7892
7829
  let cbs = this.callbacks;
7893
- this.callbacks = [], this.compiler.hooks.done.callAsync(stats, (err)=>{
7830
+ this.callbacks = [];
7831
+ let fileDependencies = new Set([
7832
+ ...compilation.fileDependencies
7833
+ ]);
7834
+ fileDependencies.added = new Set(compilation.__internal__addedFileDependencies), fileDependencies.removed = new Set(compilation.__internal__removedFileDependencies);
7835
+ let contextDependencies = new Set([
7836
+ ...compilation.contextDependencies
7837
+ ]);
7838
+ contextDependencies.added = new Set(compilation.__internal__addedContextDependencies), contextDependencies.removed = new Set(compilation.__internal__removedContextDependencies);
7839
+ let missingDependencies = new Set([
7840
+ ...compilation.missingDependencies
7841
+ ]);
7842
+ missingDependencies.added = new Set(compilation.__internal__addedMissingDependencies), missingDependencies.removed = new Set(compilation.__internal__removedMissingDependencies), this.compiler.hooks.done.callAsync(stats, (err)=>{
7894
7843
  if (err) return handleError(err, cbs);
7895
- this.handler(null, stats);
7896
- let fileDependencies = new Set([
7897
- ...compilation.fileDependencies
7898
- ]);
7899
- fileDependencies.added = new Set(compilation.__internal__addedFileDependencies), fileDependencies.removed = new Set(compilation.__internal__removedFileDependencies);
7900
- let contextDependencies = new Set([
7901
- ...compilation.contextDependencies
7902
- ]);
7903
- contextDependencies.added = new Set(compilation.__internal__addedContextDependencies), contextDependencies.removed = new Set(compilation.__internal__removedContextDependencies);
7904
- let missingDependencies = new Set([
7905
- ...compilation.missingDependencies
7906
- ]);
7907
- for (let cb of (missingDependencies.added = new Set(compilation.__internal__addedMissingDependencies), missingDependencies.removed = new Set(compilation.__internal__removedMissingDependencies), process.nextTick(()=>{
7844
+ for (let cb of (this.handler(null, stats), process.nextTick(()=>{
7908
7845
  this.#closed || this.watch(fileDependencies, contextDependencies, missingDependencies);
7909
7846
  }), cbs))cb(null);
7910
7847
  this.compiler.hooks.afterDone.call(stats);
@@ -7925,7 +7862,7 @@ Help:
7925
7862
  this.suspended && (this.suspended = !1, this.#invalidate());
7926
7863
  }
7927
7864
  }
7928
- let COMPILATION_WEAK_MAP = new WeakMap(), GET_COMPILER_ID = Symbol("getCompilerId");
7865
+ let COMPILATION_WEAK_MAP = new WeakMap();
7929
7866
  class Compiler {
7930
7867
  #instance;
7931
7868
  #initial;
@@ -8062,12 +7999,7 @@ Help:
8062
7999
  RuntimeGlobals: compilerRuntimeGlobals
8063
8000
  }, this.root = this, this.outputPath = "", this.inputFileSystem = null, this.intermediateFileSystem = null, this.outputFileSystem = null, this.watchFileSystem = null, this.records = {}, this.options = options, this.context = context, this.cache = new Cache(), this.compilerPath = "", this.running = !1, this.idle = !1, this.watchMode = !1, this.__internal_browser_require = ()=>{
8064
8001
  throw Error("Cannot execute user defined code in browser without `BrowserRequirePlugin`");
8065
- }, this.resolverFactory = new ResolverFactory(options.resolve.pnp ?? getPnpDefault(), options.resolve, options.resolveLoader), new JsLoaderRspackPlugin(this).apply(this), new ExecuteModulePlugin().apply(this), new TraceHookPlugin().apply(this), Object.defineProperty(this, GET_COMPILER_ID, {
8066
- writable: !1,
8067
- configurable: !1,
8068
- enumerable: !1,
8069
- value: ()=>this.#instance.getCompilerId()
8070
- });
8002
+ }, this.resolverFactory = new ResolverFactory(options.resolve.pnp ?? getPnpDefault(), options.resolve, options.resolveLoader), new JsLoaderRspackPlugin(this).apply(this), new ExecuteModulePlugin().apply(this), new TraceHookPlugin().apply(this);
8071
8003
  }
8072
8004
  get recordsInputPath() {
8073
8005
  return unsupported("Compiler.recordsInputPath");
@@ -8976,7 +8908,7 @@ Help:
8976
8908
  obj.children = this.stats.map((stat, idx)=>{
8977
8909
  let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
8978
8910
  return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
8979
- }), childOptions.version && (obj.rspackVersion = "1.7.0-canary-4941195f-20251224083309", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(""));
8911
+ }), childOptions.version && (obj.rspackVersion = "1.7.0-canary-c8f933e3-20251224124051", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(""));
8980
8912
  let mapError = (j, obj)=>({
8981
8913
  ...obj,
8982
8914
  compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
@@ -9886,7 +9818,7 @@ Help:
9886
9818
  object.hash = context.getStatsCompilation(compilation).hash;
9887
9819
  },
9888
9820
  version: (object)=>{
9889
- object.version = "5.75.0", object.rspackVersion = "1.7.0-canary-4941195f-20251224083309";
9821
+ object.version = "5.75.0", object.rspackVersion = "1.7.0-canary-c8f933e3-20251224124051";
9890
9822
  },
9891
9823
  env: (object, _compilation, _context, { _env })=>{
9892
9824
  object.env = _env;
@@ -11727,69 +11659,7 @@ Help:
11727
11659
  });
11728
11660
  }
11729
11661
  }
11730
- let VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
11731
- function isRequiredVersion(str) {
11732
- return VERSION_PATTERN_REGEXP.test(str);
11733
- }
11734
- let MANIFEST_FILE_NAME = "mf-manifest.json", STATS_FILE_NAME = "mf-stats.json", JSON_EXT = ".json";
11735
- function isPlainObject(value) {
11736
- return !!value && "object" == typeof value && !Array.isArray(value);
11737
- }
11738
- class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
11739
- name = binding_.BuiltinPluginName.ModuleFederationManifestPlugin;
11740
- opts;
11741
- constructor(opts){
11742
- super(), this.opts = opts;
11743
- }
11744
- raw(compiler) {
11745
- var isDev;
11746
- let pkg, buildVersion, { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts, { statsFileName, manifestFileName } = function(manifestOptions) {
11747
- var name;
11748
- if (!manifestOptions) return {
11749
- statsFileName: STATS_FILE_NAME,
11750
- manifestFileName: MANIFEST_FILE_NAME
11751
- };
11752
- let filePath = "boolean" == typeof manifestOptions ? "" : manifestOptions.filePath || "", fileName = "boolean" == typeof manifestOptions ? "" : manifestOptions.fileName || "", manifestFileName = fileName ? (name = fileName).endsWith(JSON_EXT) ? name : `${name}${JSON_EXT}` : MANIFEST_FILE_NAME, statsFileName = fileName ? manifestFileName.replace(JSON_EXT, `-stats${JSON_EXT}`) : STATS_FILE_NAME;
11753
- return {
11754
- statsFileName: (0, external_node_path_namespaceObject.join)(filePath, statsFileName),
11755
- manifestFileName: (0, external_node_path_namespaceObject.join)(filePath, manifestFileName)
11756
- };
11757
- }(this.opts), rawOptions = {
11758
- name: this.opts.name,
11759
- globalName: this.opts.globalName,
11760
- fileName,
11761
- filePath,
11762
- manifestFileName,
11763
- statsFileName,
11764
- disableAssetsAnalyze,
11765
- remoteAliasMap,
11766
- exposes,
11767
- shared,
11768
- buildInfo: (isDev = "development" === compiler.options.mode, pkg = function(root) {
11769
- let base = root ? (0, external_node_path_namespaceObject.resolve)(root) : process.cwd(), pkgPath = (0, external_node_path_namespaceObject.join)(base, "package.json");
11770
- try {
11771
- let content = (0, external_node_fs_namespaceObject.readFileSync)(pkgPath, "utf-8"), parsed = function(input, guard) {
11772
- try {
11773
- let parsed = JSON.parse(input);
11774
- if (guard(parsed)) return parsed;
11775
- } catch {}
11776
- }(content, isPlainObject);
11777
- if (parsed) {
11778
- let filtered = {};
11779
- for (let [key, value] of Object.entries(parsed))"string" == typeof value && (filtered[key] = value);
11780
- if (Object.keys(filtered).length > 0) return filtered;
11781
- }
11782
- } catch {}
11783
- return {};
11784
- }(compiler.context || process.cwd()), buildVersion = isDev ? "local" : pkg?.version, {
11785
- buildVersion: process.env.MF_BUILD_VERSION || buildVersion || "UNKNOWN",
11786
- buildName: process.env.MF_BUILD_NAME || pkg?.name || "UNKNOWN"
11787
- })
11788
- };
11789
- return createBuiltinPlugin(this.name, rawOptions);
11790
- }
11791
- }
11792
- let ModuleFederationRuntimePlugin = base_create(binding_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options), parseOptions = (options, normalizeSimple, normalizeOptions)=>{
11662
+ let parseOptions = (options, normalizeSimple, normalizeOptions)=>{
11793
11663
  let items = [];
11794
11664
  var options1 = options, normalizeSimple1 = normalizeSimple, normalizeOptions1 = normalizeOptions, fn = (key, value)=>{
11795
11665
  items.push([
@@ -11808,63 +11678,7 @@ Help:
11808
11678
  } else if ("object" == typeof options1) object(options1);
11809
11679
  else throw Error("Unexpected options format");
11810
11680
  return items;
11811
- };
11812
- function getRemoteInfos(options) {
11813
- if (!options.remotes) return {};
11814
- let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
11815
- external: Array.isArray(item) ? item : [
11816
- item
11817
- ],
11818
- shareScope: options.shareScope || "default"
11819
- }), (item)=>({
11820
- external: Array.isArray(item.external) ? item.external : [
11821
- item.external
11822
- ],
11823
- shareScope: item.shareScope || options.shareScope || "default"
11824
- })), remoteInfos = {};
11825
- for (let [key, config] of remotes)for (let external of config.external){
11826
- let [externalType, externalRequest] = function(external) {
11827
- let result = function(external) {
11828
- if (/^[a-z0-9-]+ /.test(external)) {
11829
- let idx = external.indexOf(" ");
11830
- return [
11831
- external.slice(0, idx),
11832
- external.slice(idx + 1)
11833
- ];
11834
- }
11835
- return null;
11836
- }(external);
11837
- return null === result ? [
11838
- remoteType,
11839
- external
11840
- ] : result;
11841
- }(external);
11842
- if (remoteInfos[key] ??= [], "script" === externalType) {
11843
- let [url, global] = function(urlAndGlobal) {
11844
- let index = urlAndGlobal.indexOf("@");
11845
- return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
11846
- urlAndGlobal.substring(index + 1),
11847
- urlAndGlobal.substring(0, index)
11848
- ];
11849
- }(externalRequest);
11850
- remoteInfos[key].push({
11851
- alias: key,
11852
- name: global,
11853
- entry: url,
11854
- externalType,
11855
- shareScope: config.shareScope
11856
- });
11857
- } else remoteInfos[key].push({
11858
- alias: key,
11859
- name: void 0,
11860
- entry: void 0,
11861
- externalType,
11862
- shareScope: config.shareScope
11863
- });
11864
- }
11865
- return remoteInfos;
11866
- }
11867
- let compilerSet = new WeakSet();
11681
+ }, compilerSet = new WeakSet();
11868
11682
  class ShareRuntimePlugin extends RspackBuiltinPlugin {
11869
11683
  enhanced;
11870
11684
  name = binding_.BuiltinPluginName.ShareRuntimePlugin;
@@ -11876,42 +11690,55 @@ Help:
11876
11690
  if (compiler1 = compiler, !compilerSet.has(compiler1)) return compiler2 = compiler, compilerSet.add(compiler2), createBuiltinPlugin(this.name, this.enhanced);
11877
11691
  }
11878
11692
  }
11693
+ let VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
11694
+ function isRequiredVersion(str) {
11695
+ return VERSION_PATTERN_REGEXP.test(str);
11696
+ }
11697
+ let encodeName = function(name, prefix = "", withExt = !1) {
11698
+ return `${prefix}${name.replace(/@/g, "scope_").replace(/-/g, "_").replace(/\//g, "__").replace(/\./g, "")}${withExt ? ".js" : ""}`;
11699
+ };
11700
+ function normalizeConsumeShareOptions(consumes, shareScope) {
11701
+ return parseOptions(consumes, (item, key)=>{
11702
+ if (Array.isArray(item)) throw Error("Unexpected array in options");
11703
+ return item !== key && isRequiredVersion(item) ? {
11704
+ import: key,
11705
+ shareScope: shareScope || "default",
11706
+ shareKey: key,
11707
+ requiredVersion: item,
11708
+ strictVersion: !0,
11709
+ packageName: void 0,
11710
+ singleton: !1,
11711
+ eager: !1,
11712
+ treeshakeStrategy: void 0
11713
+ } : {
11714
+ import: key,
11715
+ shareScope: shareScope || "default",
11716
+ shareKey: key,
11717
+ requiredVersion: void 0,
11718
+ packageName: void 0,
11719
+ strictVersion: !1,
11720
+ singleton: !1,
11721
+ eager: !1,
11722
+ treeshakeStrategy: void 0
11723
+ };
11724
+ }, (item, key)=>({
11725
+ import: !1 === item.import ? void 0 : item.import || key,
11726
+ shareScope: item.shareScope || shareScope || "default",
11727
+ shareKey: item.shareKey || key,
11728
+ requiredVersion: item.requiredVersion,
11729
+ strictVersion: "boolean" == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
11730
+ packageName: item.packageName,
11731
+ singleton: !!item.singleton,
11732
+ eager: !!item.eager,
11733
+ treeshakeStrategy: item.treeshakeStrategy
11734
+ }));
11735
+ }
11879
11736
  class ConsumeSharedPlugin extends RspackBuiltinPlugin {
11880
11737
  name = binding_.BuiltinPluginName.ConsumeSharedPlugin;
11881
11738
  _options;
11882
11739
  constructor(options){
11883
11740
  super(), this._options = {
11884
- consumes: parseOptions(options.consumes, (item, key)=>{
11885
- if (Array.isArray(item)) throw Error("Unexpected array in options");
11886
- return item !== key && isRequiredVersion(item) ? {
11887
- import: key,
11888
- shareScope: options.shareScope || "default",
11889
- shareKey: key,
11890
- requiredVersion: item,
11891
- strictVersion: !0,
11892
- packageName: void 0,
11893
- singleton: !1,
11894
- eager: !1
11895
- } : {
11896
- import: key,
11897
- shareScope: options.shareScope || "default",
11898
- shareKey: key,
11899
- requiredVersion: void 0,
11900
- packageName: void 0,
11901
- strictVersion: !1,
11902
- singleton: !1,
11903
- eager: !1
11904
- };
11905
- }, (item, key)=>({
11906
- import: !1 === item.import ? void 0 : item.import || key,
11907
- shareScope: item.shareScope || options.shareScope || "default",
11908
- shareKey: item.shareKey || key,
11909
- requiredVersion: item.requiredVersion,
11910
- strictVersion: "boolean" == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
11911
- packageName: item.packageName,
11912
- singleton: !!item.singleton,
11913
- eager: !!item.eager
11914
- })),
11741
+ consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
11915
11742
  enhanced: options.enhanced ?? !1
11916
11743
  };
11917
11744
  }
@@ -11932,28 +11759,30 @@ Help:
11932
11759
  _provides;
11933
11760
  _enhanced;
11934
11761
  constructor(options){
11935
- super(), this._provides = parseOptions(options.provides, (item)=>{
11762
+ var options1, shareScope, enhanced;
11763
+ super(), this._provides = (options1 = options.provides, shareScope = options.shareScope, enhanced = options.enhanced, parseOptions(options1, (item)=>{
11936
11764
  if (Array.isArray(item)) throw Error("Unexpected array of provides");
11937
11765
  return {
11938
11766
  shareKey: item,
11939
11767
  version: void 0,
11940
- shareScope: options.shareScope || "default",
11768
+ shareScope: shareScope || "default",
11941
11769
  eager: !1
11942
11770
  };
11943
11771
  }, (item)=>{
11944
11772
  let raw = {
11945
11773
  shareKey: item.shareKey,
11946
11774
  version: item.version,
11947
- shareScope: item.shareScope || options.shareScope || "default",
11775
+ shareScope: item.shareScope || shareScope || "default",
11948
11776
  eager: !!item.eager
11949
11777
  };
11950
- return options.enhanced ? {
11778
+ return enhanced ? {
11951
11779
  ...raw,
11952
11780
  singleton: item.singleton,
11953
11781
  requiredVersion: item.requiredVersion,
11954
- strictVersion: item.strictVersion
11782
+ strictVersion: item.strictVersion,
11783
+ treeshakeStrategy: item.treeshakeStrategy
11955
11784
  } : raw;
11956
- }), this._enhanced = options.enhanced;
11785
+ })), this._enhanced = options.enhanced;
11957
11786
  }
11958
11787
  raw(compiler) {
11959
11788
  new ShareRuntimePlugin(this._enhanced ?? !1).apply(compiler);
@@ -11964,32 +11793,40 @@ Help:
11964
11793
  return createBuiltinPlugin(this.name, rawOptions);
11965
11794
  }
11966
11795
  }
11796
+ function normalizeSharedOptions(shared) {
11797
+ return parseOptions(shared, (item, key)=>{
11798
+ if ("string" != typeof item) throw Error("Unexpected array in shared");
11799
+ return item !== key && isRequiredVersion(item) ? {
11800
+ import: key,
11801
+ requiredVersion: item
11802
+ } : {
11803
+ import: item
11804
+ };
11805
+ }, (item)=>item);
11806
+ }
11807
+ function createConsumeShareOptions(normalizedSharedOptions) {
11808
+ return normalizedSharedOptions.map(([key, options])=>({
11809
+ [key]: {
11810
+ import: options.import,
11811
+ shareKey: options.shareKey || key,
11812
+ shareScope: options.shareScope,
11813
+ requiredVersion: options.requiredVersion,
11814
+ strictVersion: options.strictVersion,
11815
+ singleton: options.singleton,
11816
+ packageName: options.packageName,
11817
+ eager: options.eager,
11818
+ treeshakeStrategy: options.treeshake?.strategy
11819
+ }
11820
+ }));
11821
+ }
11967
11822
  class SharePlugin {
11968
11823
  _shareScope;
11969
11824
  _consumes;
11970
11825
  _provides;
11971
11826
  _enhanced;
11827
+ _sharedOptions;
11972
11828
  constructor(options){
11973
- const sharedOptions = parseOptions(options.shared, (item, key)=>{
11974
- if ("string" != typeof item) throw Error("Unexpected array in shared");
11975
- return item !== key && isRequiredVersion(item) ? {
11976
- import: key,
11977
- requiredVersion: item
11978
- } : {
11979
- import: item
11980
- };
11981
- }, (item)=>item), consumes = sharedOptions.map(([key, options])=>({
11982
- [key]: {
11983
- import: options.import,
11984
- shareKey: options.shareKey || key,
11985
- shareScope: options.shareScope,
11986
- requiredVersion: options.requiredVersion,
11987
- strictVersion: options.strictVersion,
11988
- singleton: options.singleton,
11989
- packageName: options.packageName,
11990
- eager: options.eager
11991
- }
11992
- })), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
11829
+ const sharedOptions = normalizeSharedOptions(options.shared), consumes = createConsumeShareOptions(sharedOptions), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
11993
11830
  [options.import || key]: {
11994
11831
  shareKey: options.shareKey || key,
11995
11832
  shareScope: options.shareScope,
@@ -11997,10 +11834,11 @@ Help:
11997
11834
  eager: options.eager,
11998
11835
  singleton: options.singleton,
11999
11836
  requiredVersion: options.requiredVersion,
12000
- strictVersion: options.strictVersion
11837
+ strictVersion: options.strictVersion,
11838
+ treeshakeStrategy: options.treeshake?.strategy
12001
11839
  }
12002
11840
  }));
12003
- this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1;
11841
+ this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1, this._sharedOptions = sharedOptions;
12004
11842
  }
12005
11843
  apply(compiler) {
12006
11844
  new ConsumeSharedPlugin({
@@ -12014,6 +11852,565 @@ Help:
12014
11852
  }).apply(compiler);
12015
11853
  }
12016
11854
  }
11855
+ let MANIFEST_FILE_NAME = "mf-manifest.json", STATS_FILE_NAME = "mf-stats.json", JSON_EXT = ".json";
11856
+ function isPlainObject(value) {
11857
+ return !!value && "object" == typeof value && !Array.isArray(value);
11858
+ }
11859
+ function getFileName(manifestOptions) {
11860
+ var name;
11861
+ if (!manifestOptions) return {
11862
+ statsFileName: "",
11863
+ manifestFileName: ""
11864
+ };
11865
+ if ("boolean" == typeof manifestOptions) return {
11866
+ statsFileName: STATS_FILE_NAME,
11867
+ manifestFileName: MANIFEST_FILE_NAME
11868
+ };
11869
+ let filePath = "boolean" == typeof manifestOptions ? "" : manifestOptions.filePath || "", fileName = "boolean" == typeof manifestOptions ? "" : manifestOptions.fileName || "", manifestFileName = fileName ? (name = fileName).endsWith(JSON_EXT) ? name : `${name}${JSON_EXT}` : MANIFEST_FILE_NAME, statsFileName = fileName ? manifestFileName.replace(JSON_EXT, `-stats${JSON_EXT}`) : STATS_FILE_NAME;
11870
+ return {
11871
+ statsFileName: (0, external_node_path_namespaceObject.join)(filePath, statsFileName),
11872
+ manifestFileName: (0, external_node_path_namespaceObject.join)(filePath, manifestFileName)
11873
+ };
11874
+ }
11875
+ class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
11876
+ name = binding_.BuiltinPluginName.ModuleFederationManifestPlugin;
11877
+ rawOpts;
11878
+ constructor(opts){
11879
+ super(), this.rawOpts = opts;
11880
+ }
11881
+ raw(compiler) {
11882
+ var mfConfig, isDev, compiler1, mfConfig1;
11883
+ let manifestOptions, containerName, globalName, remoteAliasMap, manifestExposes, manifestShared, pkg, buildVersion, statsBuildInfo, opts = (manifestOptions = !0 === (mfConfig = this.rawOpts).manifest ? {} : {
11884
+ ...mfConfig.manifest
11885
+ }, containerName = mfConfig.name, globalName = function(library) {
11886
+ if (!library) return;
11887
+ let libName = library.name;
11888
+ if (libName) {
11889
+ if ("string" == typeof libName) return libName;
11890
+ if (Array.isArray(libName)) return libName[0];
11891
+ if ("object" == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
11892
+ }
11893
+ }(mfConfig.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(mfConfig)).reduce((sum, cur)=>{
11894
+ if (cur[1].length > 1) return sum;
11895
+ let { entry, alias, name } = cur[1][0];
11896
+ return entry && name && (sum[alias] = {
11897
+ name,
11898
+ entry
11899
+ }), sum;
11900
+ }, {}), manifestExposes = function(exposes) {
11901
+ if (!exposes) return;
11902
+ let result = parseOptions(exposes, (value)=>({
11903
+ import: Array.isArray(value) ? value : [
11904
+ value
11905
+ ],
11906
+ name: void 0
11907
+ }), (value)=>({
11908
+ import: Array.isArray(value.import) ? value.import : [
11909
+ value.import
11910
+ ],
11911
+ name: value.name ?? void 0
11912
+ })).map(([exposeKey, info])=>{
11913
+ let exposeName = info.name ?? exposeKey.replace(/^\.\//, "");
11914
+ return {
11915
+ path: exposeKey,
11916
+ name: exposeName
11917
+ };
11918
+ });
11919
+ return result.length > 0 ? result : void 0;
11920
+ }(mfConfig.exposes), void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes), manifestShared = function(shared) {
11921
+ if (!shared) return;
11922
+ let result = parseOptions(shared, (item, key)=>{
11923
+ if ("string" != typeof item) throw Error("Unexpected array in shared");
11924
+ return item !== key && isRequiredVersion(item) ? {
11925
+ import: key,
11926
+ requiredVersion: item
11927
+ } : {
11928
+ import: item
11929
+ };
11930
+ }, (item)=>item).map(([key, config])=>{
11931
+ let name = config.shareKey || key, version = "string" == typeof config.version ? config.version : void 0;
11932
+ return {
11933
+ name,
11934
+ version,
11935
+ requiredVersion: "string" == typeof config.requiredVersion ? config.requiredVersion : void 0,
11936
+ singleton: config.singleton
11937
+ };
11938
+ });
11939
+ return result.length > 0 ? result : void 0;
11940
+ }(mfConfig.shared), void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), {
11941
+ ...manifestOptions,
11942
+ remoteAliasMap,
11943
+ globalName,
11944
+ name: containerName
11945
+ }), { fileName, filePath, disableAssetsAnalyze, remoteAliasMap: remoteAliasMap1, exposes, shared } = opts, { statsFileName, manifestFileName } = getFileName(opts), rawOptions = {
11946
+ name: opts.name,
11947
+ globalName: opts.globalName,
11948
+ fileName,
11949
+ filePath,
11950
+ manifestFileName,
11951
+ statsFileName,
11952
+ disableAssetsAnalyze,
11953
+ remoteAliasMap: remoteAliasMap1,
11954
+ exposes,
11955
+ shared,
11956
+ buildInfo: (isDev = "development" === compiler.options.mode, compiler1 = compiler, mfConfig1 = this.rawOpts, pkg = function(root) {
11957
+ let base = root ? (0, external_node_path_namespaceObject.resolve)(root) : process.cwd(), pkgPath = (0, external_node_path_namespaceObject.join)(base, "package.json");
11958
+ try {
11959
+ let content = (0, external_node_fs_namespaceObject.readFileSync)(pkgPath, "utf-8"), parsed = function(input, guard) {
11960
+ try {
11961
+ let parsed = JSON.parse(input);
11962
+ if (guard(parsed)) return parsed;
11963
+ } catch {}
11964
+ }(content, isPlainObject);
11965
+ if (parsed) {
11966
+ let filtered = {};
11967
+ for (let [key, value] of Object.entries(parsed))"string" == typeof value && (filtered[key] = value);
11968
+ if (Object.keys(filtered).length > 0) return filtered;
11969
+ }
11970
+ } catch {}
11971
+ return {};
11972
+ }(compiler1.options.context || process.cwd()), buildVersion = isDev ? "local" : pkg?.version, statsBuildInfo = {
11973
+ buildVersion: process.env.MF_BUILD_VERSION || buildVersion || "UNKNOWN",
11974
+ buildName: process.env.MF_BUILD_NAME || pkg?.name || "UNKNOWN"
11975
+ }, Object.values(normalizeSharedOptions(mfConfig1.shared || {})).some((config)=>config[1].treeshake) && (statsBuildInfo.target = Array.isArray(compiler1.options.target) ? compiler1.options.target : [], statsBuildInfo.plugins = mfConfig1.treeshakeSharedExcludedPlugins || []), statsBuildInfo)
11976
+ };
11977
+ return createBuiltinPlugin(this.name, rawOptions);
11978
+ }
11979
+ }
11980
+ let SHARE_ENTRY_ASSET = "collect-shared-entries.json";
11981
+ class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
11982
+ name = binding_.BuiltinPluginName.CollectSharedEntryPlugin;
11983
+ sharedOptions;
11984
+ _collectedEntries;
11985
+ constructor(options){
11986
+ super();
11987
+ const { sharedOptions } = options;
11988
+ this.sharedOptions = sharedOptions, this._collectedEntries = {};
11989
+ }
11990
+ getData() {
11991
+ return this._collectedEntries;
11992
+ }
11993
+ getFilename() {
11994
+ return SHARE_ENTRY_ASSET;
11995
+ }
11996
+ apply(compiler) {
11997
+ super.apply(compiler), compiler.hooks.thisCompilation.tap("Collect shared entry", (compilation)=>{
11998
+ compilation.hooks.processAssets.tapPromise({
11999
+ name: "CollectSharedEntry",
12000
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
12001
+ }, async ()=>{
12002
+ compilation.getAssets().forEach((asset)=>{
12003
+ asset.name === SHARE_ENTRY_ASSET && (this._collectedEntries = JSON.parse(asset.source.source().toString())), compilation.deleteAsset(asset.name);
12004
+ });
12005
+ });
12006
+ });
12007
+ }
12008
+ raw() {
12009
+ let rawOptions = {
12010
+ consumes: normalizeConsumeShareOptions(createConsumeShareOptions(this.sharedOptions)).map(([key, v])=>({
12011
+ key,
12012
+ ...v
12013
+ })),
12014
+ filename: this.getFilename()
12015
+ };
12016
+ return createBuiltinPlugin(this.name, rawOptions);
12017
+ }
12018
+ }
12019
+ function assert(condition, msg) {
12020
+ if (!condition) throw Error(msg);
12021
+ }
12022
+ class SharedContainerPlugin extends RspackBuiltinPlugin {
12023
+ name = binding_.BuiltinPluginName.SharedContainerPlugin;
12024
+ filename = "";
12025
+ _options;
12026
+ _shareName;
12027
+ _globalName;
12028
+ constructor(options){
12029
+ super();
12030
+ const { shareName, library, request, independentShareFileName, mfName } = options, version = options.version || "0.0.0";
12031
+ this._globalName = encodeName(`${mfName}_${shareName}_${version}`);
12032
+ const fileName = independentShareFileName || `${version}/share-entry.js`;
12033
+ this._shareName = shareName, this._options = {
12034
+ name: shareName,
12035
+ request: request,
12036
+ library: (library ? {
12037
+ ...library,
12038
+ name: this._globalName
12039
+ } : void 0) || {
12040
+ type: "global",
12041
+ name: this._globalName
12042
+ },
12043
+ version,
12044
+ fileName
12045
+ };
12046
+ }
12047
+ getData() {
12048
+ return [
12049
+ this._options.fileName,
12050
+ this._globalName,
12051
+ this._options.version
12052
+ ];
12053
+ }
12054
+ raw(compiler) {
12055
+ let { library } = this._options;
12056
+ return compiler.options.output.enabledLibraryTypes.includes(library.type) || compiler.options.output.enabledLibraryTypes.push(library.type), createBuiltinPlugin(this.name, this._options);
12057
+ }
12058
+ apply(compiler) {
12059
+ super.apply(compiler);
12060
+ let shareName = this._shareName;
12061
+ compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
12062
+ compilation.hooks.processAssets.tapPromise({
12063
+ name: "getShareContainerFile"
12064
+ }, async ()=>{
12065
+ assert(compilation.entrypoints.get(shareName), `Can not get shared ${shareName} entryPoint!`);
12066
+ let remoteEntryNameChunk = compilation.namedChunks.get(shareName);
12067
+ assert(remoteEntryNameChunk, `Can not get shared ${shareName} chunk!`);
12068
+ let files = Array.from(remoteEntryNameChunk.files).filter((f)=>!f.includes(".hot-update") && !f.endsWith(".css"));
12069
+ assert(files.length > 0, `no files found for shared ${shareName} chunk`), assert(1 === files.length, `shared ${shareName} chunk should not have multiple files!, current files: ${files.join(",")}`), this.filename = files[0];
12070
+ });
12071
+ });
12072
+ }
12073
+ }
12074
+ class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
12075
+ name = binding_.BuiltinPluginName.SharedUsedExportsOptimizerPlugin;
12076
+ sharedOptions;
12077
+ injectUsedExports;
12078
+ manifestOptions;
12079
+ constructor(sharedOptions, injectUsedExports, manifestOptions){
12080
+ super(), this.sharedOptions = sharedOptions, this.injectUsedExports = injectUsedExports ?? !0, this.manifestOptions = manifestOptions ?? {};
12081
+ }
12082
+ buildOptions() {
12083
+ let shared = this.sharedOptions.map(([shareKey, config])=>({
12084
+ shareKey,
12085
+ treeshake: !!config.treeshake,
12086
+ usedExports: config.treeshake?.usedExports
12087
+ })), { manifestFileName, statsFileName } = getFileName(this.manifestOptions);
12088
+ return {
12089
+ shared,
12090
+ injectUsedExports: this.injectUsedExports,
12091
+ manifestFileName,
12092
+ statsFileName
12093
+ };
12094
+ }
12095
+ raw() {
12096
+ if (this.sharedOptions.length) return createBuiltinPlugin(this.name, this.buildOptions());
12097
+ }
12098
+ }
12099
+ let VIRTUAL_ENTRY = "./virtual-entry.js", VIRTUAL_ENTRY_NAME = "virtual-entry";
12100
+ class VirtualEntryPlugin {
12101
+ sharedOptions;
12102
+ collectShared = !1;
12103
+ constructor(sharedOptions, collectShared){
12104
+ this.sharedOptions = sharedOptions, this.collectShared = collectShared;
12105
+ }
12106
+ createEntry() {
12107
+ let { sharedOptions, collectShared } = this;
12108
+ return sharedOptions.reduce((acc, cur, index)=>{
12109
+ let importLine = `import shared_${index} from '${cur[0]}';\n`;
12110
+ return acc + importLine + (collectShared ? `console.log(shared_${index});\n` : "");
12111
+ }, "");
12112
+ }
12113
+ static entry() {
12114
+ return {
12115
+ [VIRTUAL_ENTRY_NAME]: VIRTUAL_ENTRY
12116
+ };
12117
+ }
12118
+ apply(compiler) {
12119
+ new compiler.rspack.experiments.VirtualModulesPlugin({
12120
+ [VIRTUAL_ENTRY]: this.createEntry()
12121
+ }).apply(compiler), compiler.hooks.thisCompilation.tap("RemoveVirtualEntryAsset", (compilation)=>{
12122
+ compilation.hooks.processAssets.tapPromise({
12123
+ name: "RemoveVirtualEntryAsset",
12124
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
12125
+ }, async ()=>{
12126
+ try {
12127
+ let chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
12128
+ chunk?.files.forEach((f)=>{
12129
+ compilation.deleteAsset(f);
12130
+ });
12131
+ } catch (_e) {
12132
+ console.error("Failed to remove virtual entry file!");
12133
+ }
12134
+ });
12135
+ });
12136
+ }
12137
+ }
12138
+ let resolveOutputDir = (outputDir, shareName)=>shareName ? (0, external_node_path_namespaceObject.join)(outputDir, encodeName(shareName)) : outputDir;
12139
+ class IndependentSharedPlugin {
12140
+ mfName;
12141
+ shared;
12142
+ library;
12143
+ sharedOptions;
12144
+ outputDir;
12145
+ plugins;
12146
+ treeshake;
12147
+ manifest;
12148
+ buildAssets = {};
12149
+ injectUsedExports;
12150
+ treeshakeSharedExcludedPlugins;
12151
+ name = "IndependentSharedPlugin";
12152
+ constructor(options){
12153
+ const { outputDir, plugins, treeshake, shared, name, manifest, injectUsedExports, library, treeshakeSharedExcludedPlugins } = options;
12154
+ this.shared = shared, this.mfName = name, this.outputDir = outputDir || "independent-packages", this.plugins = plugins || [], this.treeshake = treeshake, this.manifest = manifest, this.injectUsedExports = injectUsedExports ?? !0, this.library = library, this.treeshakeSharedExcludedPlugins = treeshakeSharedExcludedPlugins || [], this.sharedOptions = parseOptions(shared, (item, key)=>{
12155
+ if ("string" != typeof item) throw Error(`Unexpected array in shared configuration for key "${key}"`);
12156
+ return item !== key && isRequiredVersion(item) ? {
12157
+ import: key,
12158
+ requiredVersion: item
12159
+ } : {
12160
+ import: item
12161
+ };
12162
+ }, (item)=>item);
12163
+ }
12164
+ apply(compiler) {
12165
+ let { manifest } = this, runCount = 0;
12166
+ compiler.hooks.beforeRun.tapPromise("IndependentSharedPlugin", async ()=>{
12167
+ !runCount && (await this.createIndependentCompilers(compiler), runCount++);
12168
+ }), compiler.hooks.watchRun.tapPromise("IndependentSharedPlugin", async ()=>{
12169
+ !runCount && (await this.createIndependentCompilers(compiler), runCount++);
12170
+ }), compiler.hooks.shutdown.tapAsync("IndependentSharedPlugin", (callback)=>{
12171
+ callback();
12172
+ }), manifest && compiler.hooks.compilation.tap("IndependentSharedPlugin", (compilation)=>{
12173
+ compilation.hooks.processAssets.tapPromise({
12174
+ name: "injectBuildAssets",
12175
+ stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
12176
+ }, async ()=>{
12177
+ let { statsFileName, manifestFileName } = getFileName(manifest), injectBuildAssetsIntoStatsOrManifest = (filename)=>{
12178
+ let stats = compilation.getAsset(filename);
12179
+ if (!stats) return;
12180
+ let statsContent = JSON.parse(stats.source.source().toString()), { shared } = statsContent;
12181
+ Object.entries(this.buildAssets).forEach(([key, item])=>{
12182
+ let targetShared = shared.find((s)=>s.name === key);
12183
+ targetShared && item.forEach(([entry, version, globalName])=>{
12184
+ version === targetShared.version && (targetShared.fallback = entry, targetShared.fallbackName = globalName);
12185
+ });
12186
+ }), compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
12187
+ };
12188
+ injectBuildAssetsIntoStatsOrManifest(statsFileName), injectBuildAssetsIntoStatsOrManifest(manifestFileName);
12189
+ });
12190
+ });
12191
+ }
12192
+ async createIndependentCompilers(parentCompiler) {
12193
+ let { sharedOptions, buildAssets, outputDir } = this;
12194
+ console.log("🚀 Start creating a standalone compiler...");
12195
+ let shareRequestsMap = await this.createIndependentCompiler(parentCompiler);
12196
+ await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
12197
+ if (!shareConfig.treeshake || !1 === shareConfig.import) return;
12198
+ let shareRequests = shareRequestsMap[shareName].requests;
12199
+ await Promise.all(shareRequests.map(async ([request, version])=>{
12200
+ let sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1], [shareFileName, globalName, sharedVersion] = await this.createIndependentCompiler(parentCompiler, {
12201
+ shareRequestsMap,
12202
+ currentShare: {
12203
+ shareName,
12204
+ version,
12205
+ request,
12206
+ independentShareFileName: sharedConfig?.treeshake?.filename
12207
+ }
12208
+ });
12209
+ "string" == typeof shareFileName && (buildAssets[shareName] ||= [], buildAssets[shareName].push([
12210
+ (0, external_node_path_namespaceObject.join)(resolveOutputDir(outputDir, shareName), shareFileName),
12211
+ sharedVersion,
12212
+ globalName
12213
+ ]));
12214
+ }));
12215
+ })), console.log("✅ All independent packages have been compiled successfully");
12216
+ }
12217
+ async createIndependentCompiler(parentCompiler, extraOptions) {
12218
+ let extraPlugin, { mfName, plugins, outputDir, sharedOptions, treeshake, library, treeshakeSharedExcludedPlugins } = this, outputDirWithShareName = resolveOutputDir(outputDir, extraOptions?.currentShare?.shareName || ""), parentConfig = parentCompiler.options, finalPlugins = [], rspack = parentCompiler.rspack;
12219
+ extraPlugin = extraOptions ? new SharedContainerPlugin({
12220
+ mfName,
12221
+ library,
12222
+ ...extraOptions.currentShare
12223
+ }) : new CollectSharedEntryPlugin({
12224
+ sharedOptions,
12225
+ shareScope: "default"
12226
+ }), (parentConfig.plugins || []).forEach((plugin)=>{
12227
+ void 0 !== plugin && "string" != typeof plugin && ((plugin, excludedPlugins = [])=>{
12228
+ if (!plugin) return !0;
12229
+ let pluginName = plugin.name || plugin.constructor?.name;
12230
+ return !pluginName || ![
12231
+ "TreeShakeSharedPlugin",
12232
+ "IndependentSharedPlugin",
12233
+ "ModuleFederationPlugin",
12234
+ "SharedUsedExportsOptimizerPlugin",
12235
+ "HtmlWebpackPlugin",
12236
+ "HtmlRspackPlugin",
12237
+ "RsbuildHtmlPlugin",
12238
+ ...excludedPlugins
12239
+ ].includes(pluginName);
12240
+ })(plugin, treeshakeSharedExcludedPlugins) && finalPlugins.push(plugin);
12241
+ }), plugins.forEach((plugin)=>{
12242
+ finalPlugins.push(plugin);
12243
+ }), finalPlugins.push(extraPlugin), finalPlugins.push(new ConsumeSharedPlugin({
12244
+ consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
12245
+ [key]: {
12246
+ import: !extraOptions && options.import,
12247
+ shareKey: options.shareKey || key,
12248
+ shareScope: options.shareScope,
12249
+ requiredVersion: options.requiredVersion,
12250
+ strictVersion: options.strictVersion,
12251
+ singleton: options.singleton,
12252
+ packageName: options.packageName,
12253
+ eager: options.eager
12254
+ }
12255
+ })),
12256
+ enhanced: !0
12257
+ })), treeshake && finalPlugins.push(new SharedUsedExportsOptimizerPlugin(sharedOptions, this.injectUsedExports)), finalPlugins.push(new VirtualEntryPlugin(sharedOptions, !extraOptions));
12258
+ let fullOutputDir = (0, external_node_path_namespaceObject.resolve)(parentCompiler.outputPath, outputDirWithShareName), compilerConfig = {
12259
+ ...parentConfig,
12260
+ module: {
12261
+ ...parentConfig.module,
12262
+ rules: [
12263
+ {
12264
+ test: /virtual-entry\.js$/,
12265
+ type: "javascript/auto",
12266
+ resolve: {
12267
+ fullySpecified: !1
12268
+ },
12269
+ use: {
12270
+ loader: "builtin:swc-loader"
12271
+ }
12272
+ },
12273
+ ...parentConfig.module?.rules || []
12274
+ ]
12275
+ },
12276
+ mode: parentConfig.mode || "development",
12277
+ entry: VirtualEntryPlugin.entry,
12278
+ output: {
12279
+ path: fullOutputDir,
12280
+ clean: !0,
12281
+ publicPath: parentConfig.output?.publicPath || "auto"
12282
+ },
12283
+ plugins: finalPlugins,
12284
+ optimization: {
12285
+ ...parentConfig.optimization,
12286
+ splitChunks: !1
12287
+ }
12288
+ }, compiler = rspack.rspack(compilerConfig);
12289
+ compiler.inputFileSystem = parentCompiler.inputFileSystem, compiler.outputFileSystem = parentCompiler.outputFileSystem, compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
12290
+ let { currentShare } = extraOptions || {};
12291
+ return new Promise((resolve, reject)=>{
12292
+ compiler.run((err, stats)=>{
12293
+ if (err || stats?.hasErrors()) {
12294
+ let target = currentShare ? currentShare.shareName : "收集依赖";
12295
+ console.error(`❌ ${target} 编译失败:`, err || stats.toJson().errors.map((e)=>e.message).join("\n")), reject(err || Error(`${target} 编译失败`));
12296
+ return;
12297
+ }
12298
+ currentShare && console.log(`✅ 独立包 ${currentShare.shareName} 编译成功`), stats && (currentShare && console.log(`📊 ${currentShare.shareName} 编译统计:`), console.log(stats.toString({
12299
+ colors: !0,
12300
+ chunks: !1,
12301
+ modules: !1
12302
+ }))), resolve(extraPlugin.getData());
12303
+ });
12304
+ });
12305
+ }
12306
+ }
12307
+ class TreeShakeSharedPlugin {
12308
+ mfConfig;
12309
+ outputDir;
12310
+ plugins;
12311
+ reShake;
12312
+ _independentSharePlugin;
12313
+ name = "TreeShakeSharedPlugin";
12314
+ constructor(options){
12315
+ const { mfConfig, plugins, reShake } = options;
12316
+ this.mfConfig = mfConfig, this.outputDir = mfConfig.independentShareDir || "independent-packages", this.plugins = plugins, this.reShake = !!reShake;
12317
+ }
12318
+ apply(compiler) {
12319
+ let { mfConfig, outputDir, plugins, reShake } = this, { name, shared, library } = mfConfig;
12320
+ if (!shared) return;
12321
+ let sharedOptions = normalizeSharedOptions(shared);
12322
+ sharedOptions.length && sharedOptions.some(([_, config])=>config.treeshake && !1 !== config.import) && (reShake || new SharedUsedExportsOptimizerPlugin(sharedOptions, mfConfig.injectUsedExports, mfConfig.manifest).apply(compiler), this._independentSharePlugin = new IndependentSharedPlugin({
12323
+ name: name,
12324
+ shared: shared,
12325
+ outputDir,
12326
+ plugins,
12327
+ treeshake: reShake,
12328
+ library,
12329
+ manifest: mfConfig.manifest,
12330
+ treeshakeSharedExcludedPlugins: mfConfig.treeshakeSharedExcludedPlugins
12331
+ }), this._independentSharePlugin.apply(compiler));
12332
+ }
12333
+ get buildAssets() {
12334
+ return this._independentSharePlugin?.buildAssets || {};
12335
+ }
12336
+ }
12337
+ let ModuleFederationRuntimePlugin = base_create(binding_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
12338
+ function getRemoteInfos(options) {
12339
+ if (!options.remotes) return {};
12340
+ let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
12341
+ external: Array.isArray(item) ? item : [
12342
+ item
12343
+ ],
12344
+ shareScope: options.shareScope || "default"
12345
+ }), (item)=>({
12346
+ external: Array.isArray(item.external) ? item.external : [
12347
+ item.external
12348
+ ],
12349
+ shareScope: item.shareScope || options.shareScope || "default"
12350
+ })), remoteInfos = {};
12351
+ for (let [key, config] of remotes)for (let external of config.external){
12352
+ let [externalType, externalRequest] = function(external) {
12353
+ let result = function(external) {
12354
+ if (/^[a-z0-9-]+ /.test(external)) {
12355
+ let idx = external.indexOf(" ");
12356
+ return [
12357
+ external.slice(0, idx),
12358
+ external.slice(idx + 1)
12359
+ ];
12360
+ }
12361
+ return null;
12362
+ }(external);
12363
+ return null === result ? [
12364
+ remoteType,
12365
+ external
12366
+ ] : result;
12367
+ }(external);
12368
+ if (remoteInfos[key] ??= [], "script" === externalType) {
12369
+ let [url, global] = function(urlAndGlobal) {
12370
+ let index = urlAndGlobal.indexOf("@");
12371
+ return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
12372
+ urlAndGlobal.substring(index + 1),
12373
+ urlAndGlobal.substring(0, index)
12374
+ ];
12375
+ }(externalRequest);
12376
+ remoteInfos[key].push({
12377
+ alias: key,
12378
+ name: global,
12379
+ entry: url,
12380
+ externalType,
12381
+ shareScope: config.shareScope
12382
+ });
12383
+ } else remoteInfos[key].push({
12384
+ alias: key,
12385
+ name: void 0,
12386
+ entry: void 0,
12387
+ externalType,
12388
+ shareScope: config.shareScope
12389
+ });
12390
+ }
12391
+ return remoteInfos;
12392
+ }
12393
+ function getDefaultEntryRuntime(paths, options, compiler, treeshakeShareFallbacks) {
12394
+ let runtimePlugins = options.runtimePlugins ?? [], remoteInfos = getRemoteInfos(options), runtimePluginImports = [], runtimePluginVars = [], libraryType = options.library?.type || "var";
12395
+ for(let i = 0; i < runtimePlugins.length; i++){
12396
+ let runtimePluginVar = `__module_federation_runtime_plugin_${i}__`, pluginSpec = runtimePlugins[i], pluginPath = Array.isArray(pluginSpec) ? pluginSpec[0] : pluginSpec, pluginParams = Array.isArray(pluginSpec) ? pluginSpec[1] : void 0;
12397
+ runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
12398
+ let paramsCode = void 0 === pluginParams ? "undefined" : JSON.stringify(pluginParams);
12399
+ runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
12400
+ }
12401
+ let content = [
12402
+ `import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
12403
+ ...runtimePluginImports,
12404
+ `const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(", ")}]`,
12405
+ `const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
12406
+ `const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
12407
+ `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? "version-first")}`,
12408
+ `const __module_federation_share_fallbacks__ = ${JSON.stringify(treeshakeShareFallbacks)}`,
12409
+ `const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
12410
+ compiler.webpack.Template.getFunctionContent(__webpack_require__("./moduleFederationDefaultRuntime.js"))
12411
+ ].join(";");
12412
+ return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
12413
+ }
12017
12414
  class ContainerPlugin extends RspackBuiltinPlugin {
12018
12415
  name = binding_.BuiltinPluginName.ContainerPlugin;
12019
12416
  _options;
@@ -12022,7 +12419,7 @@ Help:
12022
12419
  name: options.name,
12023
12420
  shareScope: options.shareScope || "default",
12024
12421
  library: options.library || {
12025
- type: "var",
12422
+ type: "global",
12026
12423
  name: options.name
12027
12424
  },
12028
12425
  runtime: options.runtime,
@@ -12105,7 +12502,7 @@ Help:
12105
12502
  let _options = JSON.stringify(options || {});
12106
12503
  return binding_default().transform(source, _options);
12107
12504
  }
12108
- let exports_rspackVersion = "1.7.0-canary-4941195f-20251224083309", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
12505
+ let exports_rspackVersion = "1.7.0-canary-c8f933e3-20251224124051", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
12109
12506
  getNormalizedRspackOptions: getNormalizedRspackOptions,
12110
12507
  applyRspackOptionsDefaults: applyRspackOptionsDefaults,
12111
12508
  getNormalizedWebpackOptions: getNormalizedRspackOptions,
@@ -12148,11 +12545,12 @@ Help:
12148
12545
  ContainerReferencePlugin: ContainerReferencePlugin,
12149
12546
  ModuleFederationPlugin: class {
12150
12547
  _options;
12548
+ _treeShakeSharedPlugin;
12151
12549
  constructor(_options){
12152
12550
  this._options = _options;
12153
12551
  }
12154
12552
  apply(compiler) {
12155
- var options;
12553
+ var options, options1;
12156
12554
  let runtimeToolsPath, bundlerRuntimePath, runtimePath, { webpack } = compiler, paths = (runtimeToolsPath = (options = this._options).implementation ?? require.resolve("@module-federation/runtime-tools"), bundlerRuntimePath = require.resolve("@module-federation/webpack-bundler-runtime", {
12157
12555
  paths: [
12158
12556
  runtimeToolsPath
@@ -12166,101 +12564,41 @@ Help:
12166
12564
  bundlerRuntime: bundlerRuntimePath,
12167
12565
  runtime: runtimePath
12168
12566
  });
12169
- if (compiler.options.resolve.alias = {
12567
+ compiler.options.resolve.alias = {
12170
12568
  "@module-federation/runtime-tools": paths.runtimeTools,
12171
12569
  "@module-federation/runtime": paths.runtime,
12172
12570
  ...compiler.options.resolve.alias
12173
- }, new ModuleFederationRuntimePlugin({
12174
- entryRuntime: function(paths, options, compiler) {
12175
- let runtimePlugins = options.runtimePlugins ?? [], remoteInfos = getRemoteInfos(options), runtimePluginImports = [], runtimePluginVars = [];
12176
- for(let i = 0; i < runtimePlugins.length; i++){
12177
- let runtimePluginVar = `__module_federation_runtime_plugin_${i}__`, pluginSpec = runtimePlugins[i], pluginPath = Array.isArray(pluginSpec) ? pluginSpec[0] : pluginSpec, pluginParams = Array.isArray(pluginSpec) ? pluginSpec[1] : void 0;
12178
- runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
12179
- let paramsCode = void 0 === pluginParams ? "undefined" : JSON.stringify(pluginParams);
12180
- runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
12181
- }
12182
- let content = [
12183
- `import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
12184
- ...runtimePluginImports,
12185
- `const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(", ")}]`,
12186
- `const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
12187
- `const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
12188
- `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? "version-first")}`,
12189
- compiler.webpack.Template.getFunctionContent(__webpack_require__("./moduleFederationDefaultRuntime.js"))
12190
- ].join(";");
12191
- return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
12192
- }(paths, this._options, compiler)
12193
- }).apply(compiler), new webpack.container.ModuleFederationPluginV1({
12571
+ }, ((options1 = this._options).shared ? parseOptions(options1.shared, (item, key)=>{
12572
+ if ("string" != typeof item) throw Error("Unexpected array in shared");
12573
+ return item !== key && isRequiredVersion(item) ? {
12574
+ import: key,
12575
+ requiredVersion: item
12576
+ } : {
12577
+ import: item
12578
+ };
12579
+ }, (item)=>item) : []).filter(([, config])=>config.treeshake).length > 0 && (this._treeShakeSharedPlugin = new TreeShakeSharedPlugin({
12580
+ mfConfig: this._options,
12581
+ reShake: !1
12582
+ }), this._treeShakeSharedPlugin.apply(compiler));
12583
+ let runtimePluginApplied = !1;
12584
+ compiler.hooks.beforeRun.tapPromise({
12585
+ name: "ModuleFederationPlugin",
12586
+ stage: 100
12587
+ }, async ()=>{
12588
+ runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
12589
+ entryRuntime: getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakeSharedPlugin?.buildAssets || {})
12590
+ }).apply(compiler));
12591
+ }), compiler.hooks.watchRun.tapPromise({
12592
+ name: "ModuleFederationPlugin",
12593
+ stage: 100
12594
+ }, async ()=>{
12595
+ runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
12596
+ entryRuntime: getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakeSharedPlugin?.buildAssets || {})
12597
+ }).apply(compiler));
12598
+ }), new webpack.container.ModuleFederationPluginV1({
12194
12599
  ...this._options,
12195
12600
  enhanced: !0
12196
- }).apply(compiler), this._options.manifest) {
12197
- let manifestOptions = !0 === this._options.manifest ? {} : {
12198
- ...this._options.manifest
12199
- }, containerName = manifestOptions.name ?? this._options.name, globalName = manifestOptions.globalName ?? function(library) {
12200
- if (!library) return;
12201
- let libName = library.name;
12202
- if (libName) {
12203
- if ("string" == typeof libName) return libName;
12204
- if (Array.isArray(libName)) return libName[0];
12205
- if ("object" == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
12206
- }
12207
- }(this._options.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
12208
- if (cur[1].length > 1) return sum;
12209
- let { entry, alias, name } = cur[1][0];
12210
- return entry && name && (sum[alias] = {
12211
- name,
12212
- entry
12213
- }), sum;
12214
- }, {}), manifestExposes = function(exposes) {
12215
- if (!exposes) return;
12216
- let result = parseOptions(exposes, (value)=>({
12217
- import: Array.isArray(value) ? value : [
12218
- value
12219
- ],
12220
- name: void 0
12221
- }), (value)=>({
12222
- import: Array.isArray(value.import) ? value.import : [
12223
- value.import
12224
- ],
12225
- name: value.name ?? void 0
12226
- })).map(([exposeKey, info])=>{
12227
- let exposeName = info.name ?? exposeKey.replace(/^\.\//, "");
12228
- return {
12229
- path: exposeKey,
12230
- name: exposeName
12231
- };
12232
- });
12233
- return result.length > 0 ? result : void 0;
12234
- }(this._options.exposes);
12235
- void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes);
12236
- let manifestShared = function(shared) {
12237
- if (!shared) return;
12238
- let result = parseOptions(shared, (item, key)=>{
12239
- if ("string" != typeof item) throw Error("Unexpected array in shared");
12240
- return item !== key && isRequiredVersion(item) ? {
12241
- import: key,
12242
- requiredVersion: item
12243
- } : {
12244
- import: item
12245
- };
12246
- }, (item)=>item).map(([key, config])=>{
12247
- let name = config.shareKey || key, version = "string" == typeof config.version ? config.version : void 0;
12248
- return {
12249
- name,
12250
- version,
12251
- requiredVersion: "string" == typeof config.requiredVersion ? config.requiredVersion : void 0,
12252
- singleton: config.singleton
12253
- };
12254
- });
12255
- return result.length > 0 ? result : void 0;
12256
- }(this._options.shared);
12257
- void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), new ModuleFederationManifestPlugin({
12258
- ...manifestOptions,
12259
- name: containerName,
12260
- globalName,
12261
- remoteAliasMap
12262
- }).apply(compiler);
12263
- }
12601
+ }).apply(compiler), this._options.manifest && new ModuleFederationManifestPlugin(this._options).apply(compiler);
12264
12602
  }
12265
12603
  },
12266
12604
  ModuleFederationPluginV1: class {
@@ -12297,6 +12635,7 @@ Help:
12297
12635
  }
12298
12636
  }, sharing = {
12299
12637
  ProvideSharedPlugin: ProvideSharedPlugin,
12638
+ TreeShakeSharedPlugin: TreeShakeSharedPlugin,
12300
12639
  ConsumeSharedPlugin: ConsumeSharedPlugin,
12301
12640
  SharePlugin: SharePlugin
12302
12641
  }, exports_experiments = {
@@ -12338,27 +12677,7 @@ Help:
12338
12677
  if (INTERNAL_PLUGIN_NAMES.includes(name)) throw Error(`Cannot register native plugin with name '${name}', it conflicts with internal plugin names.`);
12339
12678
  return base_create(name, resolve, affectedHooks);
12340
12679
  },
12341
- VirtualModulesPlugin: VirtualModulesPlugin,
12342
- createRscPlugins: function() {
12343
- let coordinator = new Coordinator();
12344
- return {
12345
- ServerPlugin: class extends RscServerPlugin {
12346
- constructor(){
12347
- super(coordinator);
12348
- }
12349
- },
12350
- ClientPlugin: class extends RscClientPlugin {
12351
- constructor(){
12352
- super(coordinator);
12353
- }
12354
- }
12355
- };
12356
- },
12357
- RSC_LAYERS_NAMES: {
12358
- REACT_SERVER_COMPONENTS: "react-server-components",
12359
- SERVER_SIDE_RENDERING: "server-side-rendering",
12360
- ACTION_BROWSER: "action-browser"
12361
- }
12680
+ VirtualModulesPlugin: VirtualModulesPlugin
12362
12681
  }, ERROR_PREFIX = "Invalid Rspack configuration:";
12363
12682
  function validateRspackConfig(config) {
12364
12683
  (({ context })=>{
@@ -12444,7 +12763,7 @@ Help:
12444
12763
  }, exports_namespaceObject);
12445
12764
  src_fn.rspack = src_fn, src_fn.webpack = src_fn;
12446
12765
  let src_rspack_0 = src_fn, src_0 = src_rspack_0;
12447
- })(), exports.AsyncDependenciesBlock = __webpack_exports__.AsyncDependenciesBlock, exports.BannerPlugin = __webpack_exports__.BannerPlugin, exports.CircularDependencyRspackPlugin = __webpack_exports__.CircularDependencyRspackPlugin, exports.Compilation = __webpack_exports__.Compilation, exports.Compiler = __webpack_exports__.Compiler, exports.ConcatenatedModule = __webpack_exports__.ConcatenatedModule, exports.ContextModule = __webpack_exports__.ContextModule, exports.ContextReplacementPlugin = __webpack_exports__.ContextReplacementPlugin, exports.Coordinator = __webpack_exports__.Coordinator, exports.CopyRspackPlugin = __webpack_exports__.CopyRspackPlugin, exports.CssExtractRspackPlugin = __webpack_exports__.CssExtractRspackPlugin, exports.DefinePlugin = __webpack_exports__.DefinePlugin, exports.Dependency = __webpack_exports__.Dependency, exports.DllPlugin = __webpack_exports__.DllPlugin, exports.DllReferencePlugin = __webpack_exports__.DllReferencePlugin, exports.DynamicEntryPlugin = __webpack_exports__.DynamicEntryPlugin, exports.EntryDependency = __webpack_exports__.EntryDependency, exports.EntryOptionPlugin = __webpack_exports__.EntryOptionPlugin, exports.EntryPlugin = __webpack_exports__.EntryPlugin, exports.EnvironmentPlugin = __webpack_exports__.EnvironmentPlugin, exports.EvalDevToolModulePlugin = __webpack_exports__.EvalDevToolModulePlugin, exports.EvalSourceMapDevToolPlugin = __webpack_exports__.EvalSourceMapDevToolPlugin, exports.ExternalModule = __webpack_exports__.ExternalModule, exports.ExternalsPlugin = __webpack_exports__.ExternalsPlugin, exports.HotModuleReplacementPlugin = __webpack_exports__.HotModuleReplacementPlugin, exports.HtmlRspackPlugin = __webpack_exports__.HtmlRspackPlugin, exports.IgnorePlugin = __webpack_exports__.IgnorePlugin, exports.LightningCssMinimizerRspackPlugin = __webpack_exports__.LightningCssMinimizerRspackPlugin, exports.LoaderOptionsPlugin = __webpack_exports__.LoaderOptionsPlugin, exports.LoaderTargetPlugin = __webpack_exports__.LoaderTargetPlugin, exports.Module = __webpack_exports__.Module, exports.ModuleFilenameHelpers = __webpack_exports__.ModuleFilenameHelpers, exports.MultiCompiler = __webpack_exports__.MultiCompiler, exports.MultiStats = __webpack_exports__.MultiStats, exports.NoEmitOnErrorsPlugin = __webpack_exports__.NoEmitOnErrorsPlugin, exports.NormalModule = __webpack_exports__.NormalModule, exports.NormalModuleReplacementPlugin = __webpack_exports__.NormalModuleReplacementPlugin, exports.ProgressPlugin = __webpack_exports__.ProgressPlugin, exports.ProvidePlugin = __webpack_exports__.ProvidePlugin, exports.RscClientPlugin = __webpack_exports__.RscClientPlugin, exports.RscServerPlugin = __webpack_exports__.RscServerPlugin, exports.RspackOptionsApply = __webpack_exports__.RspackOptionsApply, exports.RuntimeGlobals = __webpack_exports__.RuntimeGlobals, exports.RuntimeModule = __webpack_exports__.RuntimeModule, exports.RuntimePlugin = __webpack_exports__.RuntimePlugin, exports.SourceMapDevToolPlugin = __webpack_exports__.SourceMapDevToolPlugin, exports.Stats = __webpack_exports__.Stats, exports.StatsErrorCode = __webpack_exports__.StatsErrorCode, exports.SubresourceIntegrityPlugin = __webpack_exports__.SubresourceIntegrityPlugin, exports.SwcJsMinimizerRspackPlugin = __webpack_exports__.SwcJsMinimizerRspackPlugin, exports.Template = __webpack_exports__.Template, exports.ValidationError = __webpack_exports__.ValidationError, exports.WarnCaseSensitiveModulesPlugin = __webpack_exports__.WarnCaseSensitiveModulesPlugin, exports.WebpackError = __webpack_exports__.WebpackError, exports.WebpackOptionsApply = __webpack_exports__.WebpackOptionsApply, exports.config = __webpack_exports__.config, exports.container = __webpack_exports__.container, exports.default = __webpack_exports__.default, exports.electron = __webpack_exports__.electron, exports.experiments = __webpack_exports__.experiments, exports.javascript = __webpack_exports__.javascript, exports.lazyCompilationMiddleware = __webpack_exports__.lazyCompilationMiddleware, exports.library = __webpack_exports__.library, exports.node = __webpack_exports__.node, exports.optimize = __webpack_exports__.optimize, exports.rspack = __webpack_exports__.rspack, exports.rspackVersion = __webpack_exports__.rspackVersion, exports.sharing = __webpack_exports__.sharing, exports.sources = __webpack_exports__.sources, exports.util = __webpack_exports__.util, exports.version = __webpack_exports__.version, exports.wasm = __webpack_exports__.wasm, exports.web = __webpack_exports__.web, exports.webworker = __webpack_exports__.webworker, __webpack_exports__)-1 === [
12766
+ })(), exports.AsyncDependenciesBlock = __webpack_exports__.AsyncDependenciesBlock, exports.BannerPlugin = __webpack_exports__.BannerPlugin, exports.CircularDependencyRspackPlugin = __webpack_exports__.CircularDependencyRspackPlugin, exports.Compilation = __webpack_exports__.Compilation, exports.Compiler = __webpack_exports__.Compiler, exports.ConcatenatedModule = __webpack_exports__.ConcatenatedModule, exports.ContextModule = __webpack_exports__.ContextModule, exports.ContextReplacementPlugin = __webpack_exports__.ContextReplacementPlugin, exports.CopyRspackPlugin = __webpack_exports__.CopyRspackPlugin, exports.CssExtractRspackPlugin = __webpack_exports__.CssExtractRspackPlugin, exports.DefinePlugin = __webpack_exports__.DefinePlugin, exports.Dependency = __webpack_exports__.Dependency, exports.DllPlugin = __webpack_exports__.DllPlugin, exports.DllReferencePlugin = __webpack_exports__.DllReferencePlugin, exports.DynamicEntryPlugin = __webpack_exports__.DynamicEntryPlugin, exports.EntryDependency = __webpack_exports__.EntryDependency, exports.EntryOptionPlugin = __webpack_exports__.EntryOptionPlugin, exports.EntryPlugin = __webpack_exports__.EntryPlugin, exports.EnvironmentPlugin = __webpack_exports__.EnvironmentPlugin, exports.EvalDevToolModulePlugin = __webpack_exports__.EvalDevToolModulePlugin, exports.EvalSourceMapDevToolPlugin = __webpack_exports__.EvalSourceMapDevToolPlugin, exports.ExternalModule = __webpack_exports__.ExternalModule, exports.ExternalsPlugin = __webpack_exports__.ExternalsPlugin, exports.HotModuleReplacementPlugin = __webpack_exports__.HotModuleReplacementPlugin, exports.HtmlRspackPlugin = __webpack_exports__.HtmlRspackPlugin, exports.IgnorePlugin = __webpack_exports__.IgnorePlugin, exports.LightningCssMinimizerRspackPlugin = __webpack_exports__.LightningCssMinimizerRspackPlugin, exports.LoaderOptionsPlugin = __webpack_exports__.LoaderOptionsPlugin, exports.LoaderTargetPlugin = __webpack_exports__.LoaderTargetPlugin, exports.Module = __webpack_exports__.Module, exports.ModuleFilenameHelpers = __webpack_exports__.ModuleFilenameHelpers, exports.MultiCompiler = __webpack_exports__.MultiCompiler, exports.MultiStats = __webpack_exports__.MultiStats, exports.NoEmitOnErrorsPlugin = __webpack_exports__.NoEmitOnErrorsPlugin, exports.NormalModule = __webpack_exports__.NormalModule, exports.NormalModuleReplacementPlugin = __webpack_exports__.NormalModuleReplacementPlugin, exports.ProgressPlugin = __webpack_exports__.ProgressPlugin, exports.ProvidePlugin = __webpack_exports__.ProvidePlugin, exports.RspackOptionsApply = __webpack_exports__.RspackOptionsApply, exports.RuntimeGlobals = __webpack_exports__.RuntimeGlobals, exports.RuntimeModule = __webpack_exports__.RuntimeModule, exports.RuntimePlugin = __webpack_exports__.RuntimePlugin, exports.SourceMapDevToolPlugin = __webpack_exports__.SourceMapDevToolPlugin, exports.Stats = __webpack_exports__.Stats, exports.StatsErrorCode = __webpack_exports__.StatsErrorCode, exports.SubresourceIntegrityPlugin = __webpack_exports__.SubresourceIntegrityPlugin, exports.SwcJsMinimizerRspackPlugin = __webpack_exports__.SwcJsMinimizerRspackPlugin, exports.Template = __webpack_exports__.Template, exports.ValidationError = __webpack_exports__.ValidationError, exports.WarnCaseSensitiveModulesPlugin = __webpack_exports__.WarnCaseSensitiveModulesPlugin, exports.WebpackError = __webpack_exports__.WebpackError, exports.WebpackOptionsApply = __webpack_exports__.WebpackOptionsApply, exports.config = __webpack_exports__.config, exports.container = __webpack_exports__.container, exports.default = __webpack_exports__.default, exports.electron = __webpack_exports__.electron, exports.experiments = __webpack_exports__.experiments, exports.javascript = __webpack_exports__.javascript, exports.lazyCompilationMiddleware = __webpack_exports__.lazyCompilationMiddleware, exports.library = __webpack_exports__.library, exports.node = __webpack_exports__.node, exports.optimize = __webpack_exports__.optimize, exports.rspack = __webpack_exports__.rspack, exports.rspackVersion = __webpack_exports__.rspackVersion, exports.sharing = __webpack_exports__.sharing, exports.sources = __webpack_exports__.sources, exports.util = __webpack_exports__.util, exports.version = __webpack_exports__.version, exports.wasm = __webpack_exports__.wasm, exports.web = __webpack_exports__.web, exports.webworker = __webpack_exports__.webworker, __webpack_exports__)-1 === [
12448
12767
  "AsyncDependenciesBlock",
12449
12768
  "BannerPlugin",
12450
12769
  "CircularDependencyRspackPlugin",
@@ -12453,7 +12772,6 @@ Help:
12453
12772
  "ConcatenatedModule",
12454
12773
  "ContextModule",
12455
12774
  "ContextReplacementPlugin",
12456
- "Coordinator",
12457
12775
  "CopyRspackPlugin",
12458
12776
  "CssExtractRspackPlugin",
12459
12777
  "DefinePlugin",
@@ -12484,8 +12802,6 @@ Help:
12484
12802
  "NormalModuleReplacementPlugin",
12485
12803
  "ProgressPlugin",
12486
12804
  "ProvidePlugin",
12487
- "RscClientPlugin",
12488
- "RscServerPlugin",
12489
12805
  "RspackOptionsApply",
12490
12806
  "RuntimeGlobals",
12491
12807
  "RuntimeModule",