@rspack-canary/core 1.7.3-canary-26c87d78-20260113175831 → 1.7.3-canary-58d41d16-20260115035302

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
@@ -5854,7 +5854,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
5854
5854
  }, applyExperimentsDefaults = (experiments, { development })=>{
5855
5855
  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);
5856
5856
  }, applybundlerInfoDefaults = (rspackFuture, library)=>{
5857
- 'object' == typeof rspackFuture && (D(rspackFuture, 'bundlerInfo', {}), 'object' == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, 'version', "1.7.3-canary-26c87d78-20260113175831"), D(rspackFuture.bundlerInfo, 'bundler', 'rspack'), D(rspackFuture.bundlerInfo, 'force', !library)));
5857
+ 'object' == typeof rspackFuture && (D(rspackFuture, 'bundlerInfo', {}), 'object' == typeof rspackFuture.bundlerInfo && (D(rspackFuture.bundlerInfo, 'version', "1.7.3-canary-58d41d16-20260115035302"), D(rspackFuture.bundlerInfo, 'bundler', 'rspack'), D(rspackFuture.bundlerInfo, 'force', !library)));
5858
5858
  }, applySnapshotDefaults = (_snapshot, _env)=>{}, applyCssGeneratorOptionsDefaults = (generatorOptions, { targetProperties })=>{
5859
5859
  D(generatorOptions, 'exportsOnly', !targetProperties || !1 === targetProperties.document), D(generatorOptions, 'esModule', !0);
5860
5860
  }, applyModuleDefaults = (module1, { cache, asyncWebAssembly, css, targetProperties, mode, uniqueName, deferImport })=>{
@@ -7422,7 +7422,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
7422
7422
  obj.children = this.stats.map((stat, idx)=>{
7423
7423
  let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
7424
7424
  return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
7425
- }), childOptions.version && (obj.rspackVersion = "1.7.3-canary-26c87d78-20260113175831", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
7425
+ }), childOptions.version && (obj.rspackVersion = "1.7.3-canary-58d41d16-20260115035302", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
7426
7426
  let mapError = (j, obj)=>({
7427
7427
  ...obj,
7428
7428
  compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
@@ -8678,7 +8678,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
8678
8678
  object.hash = context.getStatsCompilation(compilation).hash;
8679
8679
  },
8680
8680
  version: (object)=>{
8681
- object.version = "5.75.0", object.rspackVersion = "1.7.3-canary-26c87d78-20260113175831";
8681
+ object.version = "5.75.0", object.rspackVersion = "1.7.3-canary-58d41d16-20260115035302";
8682
8682
  },
8683
8683
  env: (object, _compilation, _context, { _env })=>{
8684
8684
  object.env = _env;
@@ -10107,7 +10107,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
10107
10107
  function isMultiRspackOptions(o) {
10108
10108
  return Array.isArray(o);
10109
10109
  }
10110
- function rspack(options, callback) {
10110
+ function rspack_rspack(options, callback) {
10111
10111
  try {
10112
10112
  if (isMultiRspackOptions(options)) for (let option of options)validateRspackConfig(option);
10113
10113
  else validateRspackConfig(options);
@@ -10403,7 +10403,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
10403
10403
  });
10404
10404
  }
10405
10405
  }
10406
- let CORE_VERSION = "1.7.3-canary-26c87d78-20260113175831", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
10406
+ let CORE_VERSION = "1.7.3-canary-58d41d16-20260115035302", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
10407
10407
 
10408
10408
  Help:
10409
10409
  Looks like you are using a custom binding (via environment variable 'RSPACK_BINDING=${process.env.RSPACK_BINDING}').
@@ -10724,7 +10724,7 @@ Help:
10724
10724
  additionalPass: new lite_tapable_namespaceObject.AsyncSeriesHook([])
10725
10725
  };
10726
10726
  const compilerRuntimeGlobals = createCompilerRuntimeGlobals(options), compilerRspack = Object.assign(function(...params) {
10727
- return rspack(...params);
10727
+ return rspack_rspack(...params);
10728
10728
  }, exports_namespaceObject, {
10729
10729
  RuntimeGlobals: compilerRuntimeGlobals
10730
10730
  });
@@ -11819,69 +11819,7 @@ Help:
11819
11819
  });
11820
11820
  }
11821
11821
  }
11822
- let VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
11823
- function isRequiredVersion(str) {
11824
- return VERSION_PATTERN_REGEXP.test(str);
11825
- }
11826
- let MANIFEST_FILE_NAME = 'mf-manifest.json', STATS_FILE_NAME = 'mf-stats.json', JSON_EXT = '.json';
11827
- function isPlainObject(value) {
11828
- return !!value && 'object' == typeof value && !Array.isArray(value);
11829
- }
11830
- class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
11831
- name = binding_.BuiltinPluginName.ModuleFederationManifestPlugin;
11832
- opts;
11833
- constructor(opts){
11834
- super(), this.opts = opts;
11835
- }
11836
- raw(compiler) {
11837
- var isDev;
11838
- let pkg, buildVersion, { fileName, filePath, disableAssetsAnalyze, remoteAliasMap, exposes, shared } = this.opts, { statsFileName, manifestFileName } = function(manifestOptions) {
11839
- var name;
11840
- if (!manifestOptions) return {
11841
- statsFileName: STATS_FILE_NAME,
11842
- manifestFileName: MANIFEST_FILE_NAME
11843
- };
11844
- 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;
11845
- return {
11846
- statsFileName: (0, external_node_path_namespaceObject.join)(filePath, statsFileName),
11847
- manifestFileName: (0, external_node_path_namespaceObject.join)(filePath, manifestFileName)
11848
- };
11849
- }(this.opts), rawOptions = {
11850
- name: this.opts.name,
11851
- globalName: this.opts.globalName,
11852
- fileName,
11853
- filePath,
11854
- manifestFileName,
11855
- statsFileName,
11856
- disableAssetsAnalyze,
11857
- remoteAliasMap,
11858
- exposes,
11859
- shared,
11860
- buildInfo: (isDev = 'development' === compiler.options.mode, pkg = function(root) {
11861
- let base = root ? (0, external_node_path_namespaceObject.resolve)(root) : process.cwd(), pkgPath = (0, external_node_path_namespaceObject.join)(base, 'package.json');
11862
- try {
11863
- let content = (0, external_node_fs_namespaceObject.readFileSync)(pkgPath, 'utf-8'), parsed = function(input, guard) {
11864
- try {
11865
- let parsed = JSON.parse(input);
11866
- if (guard(parsed)) return parsed;
11867
- } catch {}
11868
- }(content, isPlainObject);
11869
- if (parsed) {
11870
- let filtered = {};
11871
- for (let [key, value] of Object.entries(parsed))'string' == typeof value && (filtered[key] = value);
11872
- if (Object.keys(filtered).length > 0) return filtered;
11873
- }
11874
- } catch {}
11875
- return {};
11876
- }(compiler.context || process.cwd()), buildVersion = isDev ? 'local' : pkg?.version, {
11877
- buildVersion: process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
11878
- buildName: process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
11879
- })
11880
- };
11881
- return createBuiltinPlugin(this.name, rawOptions);
11882
- }
11883
- }
11884
- let ModuleFederationRuntimePlugin = base_create(binding_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options), parseOptions = (options, normalizeSimple, normalizeOptions)=>{
11822
+ let parseOptions = (options, normalizeSimple, normalizeOptions)=>{
11885
11823
  let items = [];
11886
11824
  var options1 = options, normalizeSimple1 = normalizeSimple, normalizeOptions1 = normalizeOptions, fn = (key, value)=>{
11887
11825
  items.push([
@@ -11900,63 +11838,7 @@ Help:
11900
11838
  } else if ('object' == typeof options1) object(options1);
11901
11839
  else throw Error('Unexpected options format');
11902
11840
  return items;
11903
- };
11904
- function getRemoteInfos(options) {
11905
- if (!options.remotes) return {};
11906
- let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
11907
- external: Array.isArray(item) ? item : [
11908
- item
11909
- ],
11910
- shareScope: options.shareScope || 'default'
11911
- }), (item)=>({
11912
- external: Array.isArray(item.external) ? item.external : [
11913
- item.external
11914
- ],
11915
- shareScope: item.shareScope || options.shareScope || 'default'
11916
- })), remoteInfos = {};
11917
- for (let [key, config] of remotes)for (let external of config.external){
11918
- let [externalType, externalRequest] = function(external) {
11919
- let result = function(external) {
11920
- if (/^[a-z0-9-]+ /.test(external)) {
11921
- let idx = external.indexOf(' ');
11922
- return [
11923
- external.slice(0, idx),
11924
- external.slice(idx + 1)
11925
- ];
11926
- }
11927
- return null;
11928
- }(external);
11929
- return null === result ? [
11930
- remoteType,
11931
- external
11932
- ] : result;
11933
- }(external);
11934
- if (remoteInfos[key] ??= [], "script" === externalType) {
11935
- let [url, global] = function(urlAndGlobal) {
11936
- let index = urlAndGlobal.indexOf('@');
11937
- return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
11938
- urlAndGlobal.substring(index + 1),
11939
- urlAndGlobal.substring(0, index)
11940
- ];
11941
- }(externalRequest);
11942
- remoteInfos[key].push({
11943
- alias: key,
11944
- name: global,
11945
- entry: url,
11946
- externalType,
11947
- shareScope: config.shareScope
11948
- });
11949
- } else remoteInfos[key].push({
11950
- alias: key,
11951
- name: void 0,
11952
- entry: void 0,
11953
- externalType,
11954
- shareScope: config.shareScope
11955
- });
11956
- }
11957
- return remoteInfos;
11958
- }
11959
- let compilerSet = new WeakSet();
11841
+ }, compilerSet = new WeakSet();
11960
11842
  class ShareRuntimePlugin extends RspackBuiltinPlugin {
11961
11843
  enhanced;
11962
11844
  name = binding_.BuiltinPluginName.ShareRuntimePlugin;
@@ -11968,42 +11850,55 @@ Help:
11968
11850
  if (compiler1 = compiler, !compilerSet.has(compiler1)) return compiler2 = compiler, compilerSet.add(compiler2), createBuiltinPlugin(this.name, this.enhanced);
11969
11851
  }
11970
11852
  }
11853
+ let VERSION_PATTERN_REGEXP = /^([\d^=v<>~]|[*xX]$)/;
11854
+ function isRequiredVersion(str) {
11855
+ return VERSION_PATTERN_REGEXP.test(str);
11856
+ }
11857
+ let encodeName = function(name, prefix = '', withExt = !1) {
11858
+ return `${prefix}${name.replace(/@/g, 'scope_').replace(/-/g, '_').replace(/\//g, '__').replace(/\./g, '')}${withExt ? '.js' : ''}`;
11859
+ };
11860
+ function normalizeConsumeShareOptions(consumes, shareScope) {
11861
+ return parseOptions(consumes, (item, key)=>{
11862
+ if (Array.isArray(item)) throw Error('Unexpected array in options');
11863
+ return item !== key && isRequiredVersion(item) ? {
11864
+ import: key,
11865
+ shareScope: shareScope || 'default',
11866
+ shareKey: key,
11867
+ requiredVersion: item,
11868
+ strictVersion: !0,
11869
+ packageName: void 0,
11870
+ singleton: !1,
11871
+ eager: !1,
11872
+ treeShakingMode: void 0
11873
+ } : {
11874
+ import: key,
11875
+ shareScope: shareScope || 'default',
11876
+ shareKey: key,
11877
+ requiredVersion: void 0,
11878
+ packageName: void 0,
11879
+ strictVersion: !1,
11880
+ singleton: !1,
11881
+ eager: !1,
11882
+ treeShakingMode: void 0
11883
+ };
11884
+ }, (item, key)=>({
11885
+ import: !1 === item.import ? void 0 : item.import || key,
11886
+ shareScope: item.shareScope || shareScope || 'default',
11887
+ shareKey: item.shareKey || key,
11888
+ requiredVersion: item.requiredVersion,
11889
+ strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
11890
+ packageName: item.packageName,
11891
+ singleton: !!item.singleton,
11892
+ eager: !!item.eager,
11893
+ treeShakingMode: item.treeShakingMode
11894
+ }));
11895
+ }
11971
11896
  class ConsumeSharedPlugin extends RspackBuiltinPlugin {
11972
11897
  name = binding_.BuiltinPluginName.ConsumeSharedPlugin;
11973
11898
  _options;
11974
11899
  constructor(options){
11975
11900
  super(), this._options = {
11976
- consumes: parseOptions(options.consumes, (item, key)=>{
11977
- if (Array.isArray(item)) throw Error('Unexpected array in options');
11978
- return item !== key && isRequiredVersion(item) ? {
11979
- import: key,
11980
- shareScope: options.shareScope || 'default',
11981
- shareKey: key,
11982
- requiredVersion: item,
11983
- strictVersion: !0,
11984
- packageName: void 0,
11985
- singleton: !1,
11986
- eager: !1
11987
- } : {
11988
- import: key,
11989
- shareScope: options.shareScope || 'default',
11990
- shareKey: key,
11991
- requiredVersion: void 0,
11992
- packageName: void 0,
11993
- strictVersion: !1,
11994
- singleton: !1,
11995
- eager: !1
11996
- };
11997
- }, (item, key)=>({
11998
- import: !1 === item.import ? void 0 : item.import || key,
11999
- shareScope: item.shareScope || options.shareScope || 'default',
12000
- shareKey: item.shareKey || key,
12001
- requiredVersion: item.requiredVersion,
12002
- strictVersion: 'boolean' == typeof item.strictVersion ? item.strictVersion : !1 !== item.import && !item.singleton,
12003
- packageName: item.packageName,
12004
- singleton: !!item.singleton,
12005
- eager: !!item.eager
12006
- })),
11901
+ consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
12007
11902
  enhanced: options.enhanced ?? !1
12008
11903
  };
12009
11904
  }
@@ -12024,28 +11919,30 @@ Help:
12024
11919
  _provides;
12025
11920
  _enhanced;
12026
11921
  constructor(options){
12027
- super(), this._provides = parseOptions(options.provides, (item)=>{
11922
+ var options1, shareScope, enhanced;
11923
+ super(), this._provides = (options1 = options.provides, shareScope = options.shareScope, enhanced = options.enhanced, parseOptions(options1, (item)=>{
12028
11924
  if (Array.isArray(item)) throw Error('Unexpected array of provides');
12029
11925
  return {
12030
11926
  shareKey: item,
12031
11927
  version: void 0,
12032
- shareScope: options.shareScope || 'default',
11928
+ shareScope: shareScope || 'default',
12033
11929
  eager: !1
12034
11930
  };
12035
11931
  }, (item)=>{
12036
11932
  let raw = {
12037
11933
  shareKey: item.shareKey,
12038
11934
  version: item.version,
12039
- shareScope: item.shareScope || options.shareScope || 'default',
11935
+ shareScope: item.shareScope || shareScope || 'default',
12040
11936
  eager: !!item.eager
12041
11937
  };
12042
- return options.enhanced ? {
11938
+ return enhanced ? {
12043
11939
  ...raw,
12044
11940
  singleton: item.singleton,
12045
11941
  requiredVersion: item.requiredVersion,
12046
- strictVersion: item.strictVersion
11942
+ strictVersion: item.strictVersion,
11943
+ treeShakingMode: item.treeShakingMode
12047
11944
  } : raw;
12048
- }), this._enhanced = options.enhanced;
11945
+ })), this._enhanced = options.enhanced;
12049
11946
  }
12050
11947
  raw(compiler) {
12051
11948
  new ShareRuntimePlugin(this._enhanced ?? !1).apply(compiler);
@@ -12056,32 +11953,40 @@ Help:
12056
11953
  return createBuiltinPlugin(this.name, rawOptions);
12057
11954
  }
12058
11955
  }
11956
+ function normalizeSharedOptions(shared) {
11957
+ return parseOptions(shared, (item, key)=>{
11958
+ if ('string' != typeof item) throw Error('Unexpected array in shared');
11959
+ return item !== key && isRequiredVersion(item) ? {
11960
+ import: key,
11961
+ requiredVersion: item
11962
+ } : {
11963
+ import: item
11964
+ };
11965
+ }, (item)=>item);
11966
+ }
11967
+ function createConsumeShareOptions(normalizedSharedOptions) {
11968
+ return normalizedSharedOptions.map(([key, options])=>({
11969
+ [key]: {
11970
+ import: options.import,
11971
+ shareKey: options.shareKey || key,
11972
+ shareScope: options.shareScope,
11973
+ requiredVersion: options.requiredVersion,
11974
+ strictVersion: options.strictVersion,
11975
+ singleton: options.singleton,
11976
+ packageName: options.packageName,
11977
+ eager: options.eager,
11978
+ treeShakingMode: options.treeShaking?.mode
11979
+ }
11980
+ }));
11981
+ }
12059
11982
  class SharePlugin {
12060
11983
  _shareScope;
12061
11984
  _consumes;
12062
11985
  _provides;
12063
11986
  _enhanced;
11987
+ _sharedOptions;
12064
11988
  constructor(options){
12065
- const sharedOptions = parseOptions(options.shared, (item, key)=>{
12066
- if ('string' != typeof item) throw Error('Unexpected array in shared');
12067
- return item !== key && isRequiredVersion(item) ? {
12068
- import: key,
12069
- requiredVersion: item
12070
- } : {
12071
- import: item
12072
- };
12073
- }, (item)=>item), consumes = sharedOptions.map(([key, options])=>({
12074
- [key]: {
12075
- import: options.import,
12076
- shareKey: options.shareKey || key,
12077
- shareScope: options.shareScope,
12078
- requiredVersion: options.requiredVersion,
12079
- strictVersion: options.strictVersion,
12080
- singleton: options.singleton,
12081
- packageName: options.packageName,
12082
- eager: options.eager
12083
- }
12084
- })), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
11989
+ const sharedOptions = normalizeSharedOptions(options.shared), consumes = createConsumeShareOptions(sharedOptions), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, options])=>({
12085
11990
  [options.import || key]: {
12086
11991
  shareKey: options.shareKey || key,
12087
11992
  shareScope: options.shareScope,
@@ -12089,10 +11994,11 @@ Help:
12089
11994
  eager: options.eager,
12090
11995
  singleton: options.singleton,
12091
11996
  requiredVersion: options.requiredVersion,
12092
- strictVersion: options.strictVersion
11997
+ strictVersion: options.strictVersion,
11998
+ treeShakingMode: options.treeShaking?.mode
12093
11999
  }
12094
12000
  }));
12095
- this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1;
12001
+ this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1, this._sharedOptions = sharedOptions;
12096
12002
  }
12097
12003
  apply(compiler) {
12098
12004
  new ConsumeSharedPlugin({
@@ -12106,6 +12012,560 @@ Help:
12106
12012
  }).apply(compiler);
12107
12013
  }
12108
12014
  }
12015
+ let MANIFEST_FILE_NAME = 'mf-manifest.json', STATS_FILE_NAME = 'mf-stats.json', JSON_EXT = '.json';
12016
+ function isPlainObject(value) {
12017
+ return !!value && 'object' == typeof value && !Array.isArray(value);
12018
+ }
12019
+ function getFileName(manifestOptions) {
12020
+ var name;
12021
+ if (!manifestOptions) return {
12022
+ statsFileName: '',
12023
+ manifestFileName: ''
12024
+ };
12025
+ if ('boolean' == typeof manifestOptions) return {
12026
+ statsFileName: STATS_FILE_NAME,
12027
+ manifestFileName: MANIFEST_FILE_NAME
12028
+ };
12029
+ 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;
12030
+ return {
12031
+ statsFileName: (0, external_node_path_namespaceObject.join)(filePath, statsFileName),
12032
+ manifestFileName: (0, external_node_path_namespaceObject.join)(filePath, manifestFileName)
12033
+ };
12034
+ }
12035
+ class ModuleFederationManifestPlugin extends RspackBuiltinPlugin {
12036
+ name = binding_.BuiltinPluginName.ModuleFederationManifestPlugin;
12037
+ rawOpts;
12038
+ constructor(opts){
12039
+ super(), this.rawOpts = opts;
12040
+ }
12041
+ raw(compiler) {
12042
+ var mfConfig, isDev, compiler1, mfConfig1;
12043
+ let manifestOptions, containerName, globalName, remoteAliasMap, manifestExposes, manifestShared, pkg, buildVersion, statsBuildInfo, opts = (manifestOptions = !0 === (mfConfig = this.rawOpts).manifest ? {} : {
12044
+ ...mfConfig.manifest
12045
+ }, containerName = mfConfig.name, globalName = function(library) {
12046
+ if (!library) return;
12047
+ let libName = library.name;
12048
+ if (libName) {
12049
+ if ('string' == typeof libName) return libName;
12050
+ if (Array.isArray(libName)) return libName[0];
12051
+ if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
12052
+ }
12053
+ }(mfConfig.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(mfConfig)).reduce((sum, cur)=>{
12054
+ if (cur[1].length > 1) return sum;
12055
+ let { entry, alias, name } = cur[1][0];
12056
+ return entry && name && (sum[alias] = {
12057
+ name,
12058
+ entry
12059
+ }), sum;
12060
+ }, {}), manifestExposes = function(exposes) {
12061
+ if (!exposes) return;
12062
+ let result = parseOptions(exposes, (value)=>({
12063
+ import: Array.isArray(value) ? value : [
12064
+ value
12065
+ ],
12066
+ name: void 0
12067
+ }), (value)=>({
12068
+ import: Array.isArray(value.import) ? value.import : [
12069
+ value.import
12070
+ ],
12071
+ name: value.name ?? void 0
12072
+ })).map(([exposeKey, info])=>{
12073
+ let exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
12074
+ return {
12075
+ path: exposeKey,
12076
+ name: exposeName
12077
+ };
12078
+ });
12079
+ return result.length > 0 ? result : void 0;
12080
+ }(mfConfig.exposes), void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes), manifestShared = function(shared) {
12081
+ if (!shared) return;
12082
+ let result = parseOptions(shared, (item, key)=>{
12083
+ if ('string' != typeof item) throw Error('Unexpected array in shared');
12084
+ return item !== key && isRequiredVersion(item) ? {
12085
+ import: key,
12086
+ requiredVersion: item
12087
+ } : {
12088
+ import: item
12089
+ };
12090
+ }, (item)=>item).map(([key, config])=>{
12091
+ let name = config.shareKey || key, version = 'string' == typeof config.version ? config.version : void 0;
12092
+ return {
12093
+ name,
12094
+ version,
12095
+ requiredVersion: 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0,
12096
+ singleton: config.singleton
12097
+ };
12098
+ });
12099
+ return result.length > 0 ? result : void 0;
12100
+ }(mfConfig.shared), void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), {
12101
+ ...manifestOptions,
12102
+ remoteAliasMap,
12103
+ globalName,
12104
+ name: containerName
12105
+ }), { fileName, filePath, disableAssetsAnalyze, remoteAliasMap: remoteAliasMap1, exposes, shared } = opts, { statsFileName, manifestFileName } = getFileName(opts), rawOptions = {
12106
+ name: opts.name,
12107
+ globalName: opts.globalName,
12108
+ fileName,
12109
+ filePath,
12110
+ manifestFileName,
12111
+ statsFileName,
12112
+ disableAssetsAnalyze,
12113
+ remoteAliasMap: remoteAliasMap1,
12114
+ exposes,
12115
+ shared,
12116
+ buildInfo: (isDev = 'development' === compiler.options.mode, compiler1 = compiler, mfConfig1 = this.rawOpts, pkg = function(root) {
12117
+ let base = root ? (0, external_node_path_namespaceObject.resolve)(root) : process.cwd(), pkgPath = (0, external_node_path_namespaceObject.join)(base, 'package.json');
12118
+ try {
12119
+ let content = (0, external_node_fs_namespaceObject.readFileSync)(pkgPath, 'utf-8'), parsed = function(input, guard) {
12120
+ try {
12121
+ let parsed = JSON.parse(input);
12122
+ if (guard(parsed)) return parsed;
12123
+ } catch {}
12124
+ }(content, isPlainObject);
12125
+ if (parsed) {
12126
+ let filtered = {};
12127
+ for (let [key, value] of Object.entries(parsed))'string' == typeof value && (filtered[key] = value);
12128
+ if (Object.keys(filtered).length > 0) return filtered;
12129
+ }
12130
+ } catch {}
12131
+ return {};
12132
+ }(compiler1.options.context || process.cwd()), buildVersion = isDev ? 'local' : pkg?.version, statsBuildInfo = {
12133
+ buildVersion: process.env.MF_BUILD_VERSION || buildVersion || 'UNKNOWN',
12134
+ buildName: process.env.MF_BUILD_NAME || pkg?.name || 'UNKNOWN'
12135
+ }, Object.values(normalizeSharedOptions(mfConfig1.shared || {})).some((config)=>config[1].treeShaking) && (statsBuildInfo.target = Array.isArray(compiler1.options.target) ? compiler1.options.target : [], statsBuildInfo.plugins = mfConfig1.treeShakingSharedPlugins || [], statsBuildInfo.excludePlugins = mfConfig1.treeShakingSharedExcludePlugins || []), statsBuildInfo)
12136
+ };
12137
+ return createBuiltinPlugin(this.name, rawOptions);
12138
+ }
12139
+ }
12140
+ let SHARE_ENTRY_ASSET = 'collect-shared-entries.json';
12141
+ class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
12142
+ name = binding_.BuiltinPluginName.CollectSharedEntryPlugin;
12143
+ sharedOptions;
12144
+ _collectedEntries;
12145
+ constructor(options){
12146
+ super();
12147
+ const { sharedOptions } = options;
12148
+ this.sharedOptions = sharedOptions, this._collectedEntries = {};
12149
+ }
12150
+ getData() {
12151
+ return this._collectedEntries;
12152
+ }
12153
+ getFilename() {
12154
+ return SHARE_ENTRY_ASSET;
12155
+ }
12156
+ apply(compiler) {
12157
+ super.apply(compiler), compiler.hooks.thisCompilation.tap('Collect shared entry', (compilation)=>{
12158
+ compilation.hooks.processAssets.tap({
12159
+ name: 'CollectSharedEntry',
12160
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
12161
+ }, ()=>{
12162
+ compilation.getAssets().forEach((asset)=>{
12163
+ asset.name === SHARE_ENTRY_ASSET && (this._collectedEntries = JSON.parse(asset.source.source().toString())), compilation.deleteAsset(asset.name);
12164
+ });
12165
+ });
12166
+ });
12167
+ }
12168
+ raw() {
12169
+ let rawOptions = {
12170
+ consumes: normalizeConsumeShareOptions(createConsumeShareOptions(this.sharedOptions)).map(([key, v])=>({
12171
+ key,
12172
+ ...v
12173
+ })),
12174
+ filename: this.getFilename()
12175
+ };
12176
+ return createBuiltinPlugin(this.name, rawOptions);
12177
+ }
12178
+ }
12179
+ function assert(condition, msg) {
12180
+ if (!condition) throw Error(msg);
12181
+ }
12182
+ class SharedContainerPlugin extends RspackBuiltinPlugin {
12183
+ name = binding_.BuiltinPluginName.SharedContainerPlugin;
12184
+ filename = '';
12185
+ _options;
12186
+ _shareName;
12187
+ _globalName;
12188
+ constructor(options){
12189
+ super();
12190
+ const { shareName, library, request, independentShareFileName, mfName } = options, version = options.version || '0.0.0';
12191
+ this._globalName = encodeName(`${mfName}_${shareName}_${version}`);
12192
+ const fileName = independentShareFileName || `${version}/share-entry.js`;
12193
+ this._shareName = shareName, this._options = {
12194
+ name: shareName,
12195
+ request: request,
12196
+ library: (library ? {
12197
+ ...library,
12198
+ name: this._globalName
12199
+ } : void 0) || {
12200
+ type: 'global',
12201
+ name: this._globalName
12202
+ },
12203
+ version,
12204
+ fileName
12205
+ };
12206
+ }
12207
+ getData() {
12208
+ return [
12209
+ this._options.fileName,
12210
+ this._globalName,
12211
+ this._options.version
12212
+ ];
12213
+ }
12214
+ raw(compiler) {
12215
+ let { library } = this._options;
12216
+ return compiler.options.output.enabledLibraryTypes.includes(library.type) || compiler.options.output.enabledLibraryTypes.push(library.type), createBuiltinPlugin(this.name, this._options);
12217
+ }
12218
+ apply(compiler) {
12219
+ super.apply(compiler);
12220
+ let shareName = this._shareName;
12221
+ compiler.hooks.thisCompilation.tap(this.name, (compilation)=>{
12222
+ compilation.hooks.processAssets.tap({
12223
+ name: 'getShareContainerFile'
12224
+ }, ()=>{
12225
+ assert(compilation.entrypoints.get(shareName), `Can not get shared ${shareName} entryPoint!`);
12226
+ let remoteEntryNameChunk = compilation.namedChunks.get(shareName);
12227
+ assert(remoteEntryNameChunk, `Can not get shared ${shareName} chunk!`);
12228
+ let files = Array.from(remoteEntryNameChunk.files).filter((f)=>!f.includes('.hot-update') && !f.endsWith('.css'));
12229
+ 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];
12230
+ });
12231
+ });
12232
+ }
12233
+ }
12234
+ class SharedUsedExportsOptimizerPlugin extends RspackBuiltinPlugin {
12235
+ name = binding_.BuiltinPluginName.SharedUsedExportsOptimizerPlugin;
12236
+ sharedOptions;
12237
+ injectTreeShakingUsedExports;
12238
+ manifestOptions;
12239
+ constructor(sharedOptions, injectTreeShakingUsedExports, manifestOptions){
12240
+ super(), this.sharedOptions = sharedOptions, this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? !0, this.manifestOptions = manifestOptions ?? {};
12241
+ }
12242
+ buildOptions() {
12243
+ let shared = this.sharedOptions.map(([shareKey, config])=>({
12244
+ shareKey,
12245
+ treeShaking: !!config.treeShaking,
12246
+ usedExports: config.treeShaking?.usedExports
12247
+ })), { manifestFileName, statsFileName } = getFileName(this.manifestOptions);
12248
+ return {
12249
+ shared,
12250
+ injectTreeShakingUsedExports: this.injectTreeShakingUsedExports,
12251
+ manifestFileName,
12252
+ statsFileName
12253
+ };
12254
+ }
12255
+ raw() {
12256
+ if (this.sharedOptions.length) return createBuiltinPlugin(this.name, this.buildOptions());
12257
+ }
12258
+ }
12259
+ let VIRTUAL_ENTRY = './virtual-entry.js', VIRTUAL_ENTRY_NAME = 'virtual-entry';
12260
+ class VirtualEntryPlugin {
12261
+ sharedOptions;
12262
+ collectShared = !1;
12263
+ constructor(sharedOptions, collectShared){
12264
+ this.sharedOptions = sharedOptions, this.collectShared = collectShared;
12265
+ }
12266
+ createEntry() {
12267
+ let { sharedOptions, collectShared } = this;
12268
+ return sharedOptions.reduce((acc, cur, index)=>{
12269
+ let importLine = `import shared_${index} from '${cur[0]}';\n`;
12270
+ return acc + importLine + (collectShared ? `console.log(shared_${index});\n` : '');
12271
+ }, '');
12272
+ }
12273
+ static entry() {
12274
+ return {
12275
+ [VIRTUAL_ENTRY_NAME]: VIRTUAL_ENTRY
12276
+ };
12277
+ }
12278
+ apply(compiler) {
12279
+ new compiler.rspack.experiments.VirtualModulesPlugin({
12280
+ [VIRTUAL_ENTRY]: this.createEntry()
12281
+ }).apply(compiler), compiler.hooks.thisCompilation.tap('RemoveVirtualEntryAsset', (compilation)=>{
12282
+ compilation.hooks.processAssets.tap({
12283
+ name: 'RemoveVirtualEntryAsset',
12284
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
12285
+ }, ()=>{
12286
+ try {
12287
+ let chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
12288
+ chunk?.files.forEach((f)=>{
12289
+ compilation.deleteAsset(f);
12290
+ });
12291
+ } catch (_e) {
12292
+ console.error('Failed to remove virtual entry file!');
12293
+ }
12294
+ });
12295
+ });
12296
+ }
12297
+ }
12298
+ let resolveOutputDir = (outputDir, shareName)=>shareName ? (0, external_node_path_namespaceObject.join)(outputDir, encodeName(shareName)) : outputDir;
12299
+ class IndependentSharedPlugin {
12300
+ mfName;
12301
+ shared;
12302
+ library;
12303
+ sharedOptions;
12304
+ outputDir;
12305
+ plugins;
12306
+ treeShaking;
12307
+ manifest;
12308
+ buildAssets = {};
12309
+ injectTreeShakingUsedExports;
12310
+ treeShakingSharedExcludePlugins;
12311
+ name = 'IndependentSharedPlugin';
12312
+ constructor(options){
12313
+ const { outputDir, plugins, treeShaking, shared, name, manifest, injectTreeShakingUsedExports, library, treeShakingSharedExcludePlugins } = options;
12314
+ this.shared = shared, this.mfName = name, this.outputDir = outputDir || 'independent-packages', this.plugins = plugins || [], this.treeShaking = treeShaking, this.manifest = manifest, this.injectTreeShakingUsedExports = injectTreeShakingUsedExports ?? !0, this.library = library, this.treeShakingSharedExcludePlugins = treeShakingSharedExcludePlugins || [], this.sharedOptions = parseOptions(shared, (item, key)=>{
12315
+ if ('string' != typeof item) throw Error(`Unexpected array in shared configuration for key "${key}"`);
12316
+ return item !== key && isRequiredVersion(item) ? {
12317
+ import: key,
12318
+ requiredVersion: item
12319
+ } : {
12320
+ import: item
12321
+ };
12322
+ }, (item)=>item);
12323
+ }
12324
+ apply(compiler) {
12325
+ let { manifest } = this, runCount = 0;
12326
+ compiler.hooks.beforeRun.tapPromise('IndependentSharedPlugin', async ()=>{
12327
+ !runCount && (await this.createIndependentCompilers(compiler), runCount++);
12328
+ }), compiler.hooks.watchRun.tapPromise('IndependentSharedPlugin', async ()=>{
12329
+ !runCount && (await this.createIndependentCompilers(compiler), runCount++);
12330
+ }), compiler.hooks.shutdown.tapAsync('IndependentSharedPlugin', (callback)=>{
12331
+ callback();
12332
+ }), manifest && compiler.hooks.compilation.tap('IndependentSharedPlugin', (compilation)=>{
12333
+ compilation.hooks.processAssets.tap({
12334
+ name: 'injectBuildAssets',
12335
+ stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
12336
+ }, ()=>{
12337
+ let { statsFileName, manifestFileName } = getFileName(manifest), injectBuildAssetsIntoStatsOrManifest = (filename)=>{
12338
+ let stats = compilation.getAsset(filename);
12339
+ if (!stats) return;
12340
+ let statsContent = JSON.parse(stats.source.source().toString()), { shared } = statsContent;
12341
+ Object.entries(this.buildAssets).forEach(([key, item])=>{
12342
+ let targetShared = shared.find((s)=>s.name === key);
12343
+ targetShared && item.forEach(([entry, version, globalName])=>{
12344
+ version === targetShared.version && (targetShared.fallback = entry, targetShared.fallbackName = globalName);
12345
+ });
12346
+ }), compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
12347
+ };
12348
+ injectBuildAssetsIntoStatsOrManifest(statsFileName), injectBuildAssetsIntoStatsOrManifest(manifestFileName);
12349
+ });
12350
+ });
12351
+ }
12352
+ async createIndependentCompilers(parentCompiler) {
12353
+ let { sharedOptions, buildAssets, outputDir } = this;
12354
+ console.log('Start building shared fallback resources ...');
12355
+ let shareRequestsMap = await this.createIndependentCompiler(parentCompiler);
12356
+ await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
12357
+ if (!shareConfig.treeShaking || !1 === shareConfig.import) return;
12358
+ let shareRequests = shareRequestsMap[shareName].requests;
12359
+ await Promise.all(shareRequests.map(async ([request, version])=>{
12360
+ let sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1], [shareFileName, globalName, sharedVersion] = await this.createIndependentCompiler(parentCompiler, {
12361
+ shareRequestsMap,
12362
+ currentShare: {
12363
+ shareName,
12364
+ version,
12365
+ request,
12366
+ independentShareFileName: sharedConfig?.treeShaking?.filename
12367
+ }
12368
+ });
12369
+ 'string' == typeof shareFileName && (buildAssets[shareName] ||= [], buildAssets[shareName].push([
12370
+ (0, external_node_path_namespaceObject.join)(resolveOutputDir(outputDir, shareName), shareFileName),
12371
+ sharedVersion,
12372
+ globalName
12373
+ ]));
12374
+ }));
12375
+ })), console.log('All shared fallback have been compiled successfully!');
12376
+ }
12377
+ async createIndependentCompiler(parentCompiler, extraOptions) {
12378
+ let extraPlugin, { mfName, plugins, outputDir, sharedOptions, treeShaking, library, treeShakingSharedExcludePlugins } = this, outputDirWithShareName = resolveOutputDir(outputDir, extraOptions?.currentShare?.shareName || ''), parentConfig = parentCompiler.options, finalPlugins = [], rspack = parentCompiler.rspack;
12379
+ extraPlugin = extraOptions ? new SharedContainerPlugin({
12380
+ mfName,
12381
+ library,
12382
+ ...extraOptions.currentShare
12383
+ }) : new CollectSharedEntryPlugin({
12384
+ sharedOptions,
12385
+ shareScope: 'default'
12386
+ }), (parentConfig.plugins || []).forEach((plugin)=>{
12387
+ void 0 !== plugin && 'string' != typeof plugin && ((plugin, excludedPlugins = [])=>{
12388
+ if (!plugin) return !0;
12389
+ let pluginName = plugin.name || plugin.constructor?.name;
12390
+ return !pluginName || ![
12391
+ 'TreeShakingSharedPlugin',
12392
+ 'IndependentSharedPlugin',
12393
+ 'ModuleFederationPlugin',
12394
+ 'SharedUsedExportsOptimizerPlugin',
12395
+ 'HtmlWebpackPlugin',
12396
+ 'HtmlRspackPlugin',
12397
+ 'RsbuildHtmlPlugin',
12398
+ ...excludedPlugins
12399
+ ].includes(pluginName);
12400
+ })(plugin, treeShakingSharedExcludePlugins) && finalPlugins.push(plugin);
12401
+ }), plugins.forEach((plugin)=>{
12402
+ finalPlugins.push(plugin);
12403
+ }), finalPlugins.push(extraPlugin), finalPlugins.push(new ConsumeSharedPlugin({
12404
+ consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
12405
+ [key]: {
12406
+ import: !extraOptions && options.import,
12407
+ shareKey: options.shareKey || key,
12408
+ shareScope: options.shareScope,
12409
+ requiredVersion: options.requiredVersion,
12410
+ strictVersion: options.strictVersion,
12411
+ singleton: options.singleton,
12412
+ packageName: options.packageName,
12413
+ eager: options.eager
12414
+ }
12415
+ })),
12416
+ enhanced: !0
12417
+ })), treeShaking && finalPlugins.push(new SharedUsedExportsOptimizerPlugin(sharedOptions, this.injectTreeShakingUsedExports)), finalPlugins.push(new VirtualEntryPlugin(sharedOptions, !extraOptions));
12418
+ let fullOutputDir = (0, external_node_path_namespaceObject.resolve)(parentCompiler.outputPath, outputDirWithShareName), compilerConfig = {
12419
+ ...parentConfig,
12420
+ module: {
12421
+ ...parentConfig.module,
12422
+ rules: [
12423
+ {
12424
+ test: /virtual-entry\.js$/,
12425
+ type: "javascript/auto",
12426
+ resolve: {
12427
+ fullySpecified: !1
12428
+ },
12429
+ use: {
12430
+ loader: 'builtin:swc-loader'
12431
+ }
12432
+ },
12433
+ ...parentConfig.module?.rules || []
12434
+ ]
12435
+ },
12436
+ mode: parentConfig.mode || 'development',
12437
+ entry: VirtualEntryPlugin.entry,
12438
+ output: {
12439
+ path: fullOutputDir,
12440
+ clean: !0,
12441
+ publicPath: parentConfig.output?.publicPath || 'auto'
12442
+ },
12443
+ plugins: finalPlugins,
12444
+ optimization: {
12445
+ ...parentConfig.optimization,
12446
+ splitChunks: !1
12447
+ }
12448
+ }, compiler = rspack.rspack(compilerConfig);
12449
+ compiler.inputFileSystem = parentCompiler.inputFileSystem, compiler.outputFileSystem = parentCompiler.outputFileSystem, compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
12450
+ let { currentShare } = extraOptions || {};
12451
+ return new Promise((resolve, reject)=>{
12452
+ compiler.run((err, stats)=>{
12453
+ if (err || stats?.hasErrors()) {
12454
+ let target = currentShare ? currentShare.shareName : 'Collect deps';
12455
+ console.error(`${target} Compile failed:`, err || stats.toJson().errors.map((e)=>e.message).join('\n')), reject(err || Error(`${target} Compile failed`));
12456
+ return;
12457
+ }
12458
+ currentShare && console.log(`${currentShare.shareName} Compile success`), resolve(extraPlugin.getData());
12459
+ });
12460
+ });
12461
+ }
12462
+ }
12463
+ class TreeShakingSharedPlugin {
12464
+ mfConfig;
12465
+ outputDir;
12466
+ secondary;
12467
+ _independentSharePlugin;
12468
+ name = 'TreeShakingSharedPlugin';
12469
+ constructor(options){
12470
+ const { mfConfig, secondary } = options;
12471
+ this.mfConfig = mfConfig, this.outputDir = mfConfig.treeShakingSharedDir || 'independent-packages', this.secondary = !!secondary;
12472
+ }
12473
+ apply(compiler) {
12474
+ let { mfConfig, outputDir, secondary } = this, { name, shared, library, treeShakingSharedPlugins } = mfConfig;
12475
+ if (!shared) return;
12476
+ let sharedOptions = normalizeSharedOptions(shared);
12477
+ sharedOptions.length && sharedOptions.some(([_, config])=>config.treeShaking && !1 !== config.import) && (secondary || new SharedUsedExportsOptimizerPlugin(sharedOptions, mfConfig.injectTreeShakingUsedExports, mfConfig.manifest).apply(compiler), this._independentSharePlugin = new IndependentSharedPlugin({
12478
+ name: name,
12479
+ shared: shared,
12480
+ outputDir,
12481
+ plugins: treeShakingSharedPlugins?.map((p)=>new (require(p))()) || [],
12482
+ treeShaking: secondary,
12483
+ library,
12484
+ manifest: mfConfig.manifest,
12485
+ treeShakingSharedExcludePlugins: mfConfig.treeShakingSharedExcludePlugins
12486
+ }), this._independentSharePlugin.apply(compiler));
12487
+ }
12488
+ get buildAssets() {
12489
+ return this._independentSharePlugin?.buildAssets || {};
12490
+ }
12491
+ }
12492
+ let ModuleFederationRuntimePlugin = base_create(binding_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
12493
+ function getRemoteInfos(options) {
12494
+ if (!options.remotes) return {};
12495
+ let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
12496
+ external: Array.isArray(item) ? item : [
12497
+ item
12498
+ ],
12499
+ shareScope: options.shareScope || 'default'
12500
+ }), (item)=>({
12501
+ external: Array.isArray(item.external) ? item.external : [
12502
+ item.external
12503
+ ],
12504
+ shareScope: item.shareScope || options.shareScope || 'default'
12505
+ })), remoteInfos = {};
12506
+ for (let [key, config] of remotes)for (let external of config.external){
12507
+ let [externalType, externalRequest] = function(external) {
12508
+ let result = function(external) {
12509
+ if (/^[a-z0-9-]+ /.test(external)) {
12510
+ let idx = external.indexOf(' ');
12511
+ return [
12512
+ external.slice(0, idx),
12513
+ external.slice(idx + 1)
12514
+ ];
12515
+ }
12516
+ return null;
12517
+ }(external);
12518
+ return null === result ? [
12519
+ remoteType,
12520
+ external
12521
+ ] : result;
12522
+ }(external);
12523
+ if (remoteInfos[key] ??= [], "script" === externalType) {
12524
+ let [url, global] = function(urlAndGlobal) {
12525
+ let index = urlAndGlobal.indexOf('@');
12526
+ return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
12527
+ urlAndGlobal.substring(index + 1),
12528
+ urlAndGlobal.substring(0, index)
12529
+ ];
12530
+ }(externalRequest);
12531
+ remoteInfos[key].push({
12532
+ alias: key,
12533
+ name: global,
12534
+ entry: url,
12535
+ externalType,
12536
+ shareScope: config.shareScope
12537
+ });
12538
+ } else remoteInfos[key].push({
12539
+ alias: key,
12540
+ name: void 0,
12541
+ entry: void 0,
12542
+ externalType,
12543
+ shareScope: config.shareScope
12544
+ });
12545
+ }
12546
+ return remoteInfos;
12547
+ }
12548
+ function getDefaultEntryRuntime(paths, options, compiler, treeShakingShareFallbacks) {
12549
+ let runtimePlugins = options.runtimePlugins ?? [], remoteInfos = getRemoteInfos(options), runtimePluginImports = [], runtimePluginVars = [], libraryType = options.library?.type || 'var';
12550
+ for(let i = 0; i < runtimePlugins.length; i++){
12551
+ 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;
12552
+ runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
12553
+ let paramsCode = void 0 === pluginParams ? 'undefined' : JSON.stringify(pluginParams);
12554
+ runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
12555
+ }
12556
+ let content = [
12557
+ `import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
12558
+ ...runtimePluginImports,
12559
+ `const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(', ')}]`,
12560
+ `const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
12561
+ `const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
12562
+ `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? 'version-first')}`,
12563
+ `const __module_federation_share_fallbacks__ = ${JSON.stringify(treeShakingShareFallbacks)}`,
12564
+ `const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
12565
+ compiler.webpack.Template.getFunctionContent(__webpack_require__("./moduleFederationDefaultRuntime.js"))
12566
+ ].join(';');
12567
+ return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
12568
+ }
12109
12569
  class ContainerPlugin extends RspackBuiltinPlugin {
12110
12570
  name = binding_.BuiltinPluginName.ContainerPlugin;
12111
12571
  _options;
@@ -12114,7 +12574,7 @@ Help:
12114
12574
  name: options.name,
12115
12575
  shareScope: options.shareScope || 'default',
12116
12576
  library: options.library || {
12117
- type: 'var',
12577
+ type: 'global',
12118
12578
  name: options.name
12119
12579
  },
12120
12580
  runtime: options.runtime,
@@ -12197,7 +12657,7 @@ Help:
12197
12657
  let _options = JSON.stringify(options || {});
12198
12658
  return binding_default().transform(source, _options);
12199
12659
  }
12200
- let exports_rspackVersion = "1.7.3-canary-26c87d78-20260113175831", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
12660
+ let exports_rspackVersion = "1.7.3-canary-58d41d16-20260115035302", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
12201
12661
  getNormalizedRspackOptions: getNormalizedRspackOptions,
12202
12662
  applyRspackOptionsDefaults: applyRspackOptionsDefaults,
12203
12663
  getNormalizedWebpackOptions: getNormalizedRspackOptions,
@@ -12240,11 +12700,12 @@ Help:
12240
12700
  ContainerReferencePlugin: ContainerReferencePlugin,
12241
12701
  ModuleFederationPlugin: class {
12242
12702
  _options;
12703
+ _treeShakingSharedPlugin;
12243
12704
  constructor(_options){
12244
12705
  this._options = _options;
12245
12706
  }
12246
12707
  apply(compiler) {
12247
- var options;
12708
+ var options, options1;
12248
12709
  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', {
12249
12710
  paths: [
12250
12711
  runtimeToolsPath
@@ -12258,101 +12719,41 @@ Help:
12258
12719
  bundlerRuntime: bundlerRuntimePath,
12259
12720
  runtime: runtimePath
12260
12721
  });
12261
- if (compiler.options.resolve.alias = {
12722
+ compiler.options.resolve.alias = {
12262
12723
  '@module-federation/runtime-tools': paths.runtimeTools,
12263
12724
  '@module-federation/runtime': paths.runtime,
12264
12725
  ...compiler.options.resolve.alias
12265
- }, new ModuleFederationRuntimePlugin({
12266
- entryRuntime: function(paths, options, compiler) {
12267
- let runtimePlugins = options.runtimePlugins ?? [], remoteInfos = getRemoteInfos(options), runtimePluginImports = [], runtimePluginVars = [];
12268
- for(let i = 0; i < runtimePlugins.length; i++){
12269
- 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;
12270
- runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
12271
- let paramsCode = void 0 === pluginParams ? 'undefined' : JSON.stringify(pluginParams);
12272
- runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
12273
- }
12274
- let content = [
12275
- `import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
12276
- ...runtimePluginImports,
12277
- `const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(', ')}]`,
12278
- `const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
12279
- `const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
12280
- `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? 'version-first')}`,
12281
- compiler.webpack.Template.getFunctionContent(__webpack_require__("./moduleFederationDefaultRuntime.js"))
12282
- ].join(';');
12283
- return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
12284
- }(paths, this._options, compiler)
12285
- }).apply(compiler), new webpack.container.ModuleFederationPluginV1({
12726
+ }, ((options1 = this._options).shared ? parseOptions(options1.shared, (item, key)=>{
12727
+ if ('string' != typeof item) throw Error('Unexpected array in shared');
12728
+ return item !== key && isRequiredVersion(item) ? {
12729
+ import: key,
12730
+ requiredVersion: item
12731
+ } : {
12732
+ import: item
12733
+ };
12734
+ }, (item)=>item) : []).filter(([, config])=>config.treeShaking).length > 0 && (this._treeShakingSharedPlugin = new TreeShakingSharedPlugin({
12735
+ mfConfig: this._options,
12736
+ secondary: !1
12737
+ }), this._treeShakingSharedPlugin.apply(compiler));
12738
+ let runtimePluginApplied = !1;
12739
+ compiler.hooks.beforeRun.tap({
12740
+ name: 'ModuleFederationPlugin',
12741
+ stage: 100
12742
+ }, ()=>{
12743
+ runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
12744
+ entryRuntime: getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets)
12745
+ }).apply(compiler));
12746
+ }), compiler.hooks.watchRun.tap({
12747
+ name: 'ModuleFederationPlugin',
12748
+ stage: 100
12749
+ }, ()=>{
12750
+ runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
12751
+ entryRuntime: getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets || {})
12752
+ }).apply(compiler));
12753
+ }), new webpack.container.ModuleFederationPluginV1({
12286
12754
  ...this._options,
12287
12755
  enhanced: !0
12288
- }).apply(compiler), this._options.manifest) {
12289
- let manifestOptions = !0 === this._options.manifest ? {} : {
12290
- ...this._options.manifest
12291
- }, containerName = manifestOptions.name ?? this._options.name, globalName = manifestOptions.globalName ?? function(library) {
12292
- if (!library) return;
12293
- let libName = library.name;
12294
- if (libName) {
12295
- if ('string' == typeof libName) return libName;
12296
- if (Array.isArray(libName)) return libName[0];
12297
- if ('object' == typeof libName) return libName.root?.[0] ?? libName.amd ?? libName.commonjs ?? void 0;
12298
- }
12299
- }(this._options.library) ?? containerName, remoteAliasMap = Object.entries(getRemoteInfos(this._options)).reduce((sum, cur)=>{
12300
- if (cur[1].length > 1) return sum;
12301
- let { entry, alias, name } = cur[1][0];
12302
- return entry && name && (sum[alias] = {
12303
- name,
12304
- entry
12305
- }), sum;
12306
- }, {}), manifestExposes = function(exposes) {
12307
- if (!exposes) return;
12308
- let result = parseOptions(exposes, (value)=>({
12309
- import: Array.isArray(value) ? value : [
12310
- value
12311
- ],
12312
- name: void 0
12313
- }), (value)=>({
12314
- import: Array.isArray(value.import) ? value.import : [
12315
- value.import
12316
- ],
12317
- name: value.name ?? void 0
12318
- })).map(([exposeKey, info])=>{
12319
- let exposeName = info.name ?? exposeKey.replace(/^\.\//, '');
12320
- return {
12321
- path: exposeKey,
12322
- name: exposeName
12323
- };
12324
- });
12325
- return result.length > 0 ? result : void 0;
12326
- }(this._options.exposes);
12327
- void 0 === manifestOptions.exposes && manifestExposes && (manifestOptions.exposes = manifestExposes);
12328
- let manifestShared = function(shared) {
12329
- if (!shared) return;
12330
- let result = parseOptions(shared, (item, key)=>{
12331
- if ('string' != typeof item) throw Error('Unexpected array in shared');
12332
- return item !== key && isRequiredVersion(item) ? {
12333
- import: key,
12334
- requiredVersion: item
12335
- } : {
12336
- import: item
12337
- };
12338
- }, (item)=>item).map(([key, config])=>{
12339
- let name = config.shareKey || key, version = 'string' == typeof config.version ? config.version : void 0;
12340
- return {
12341
- name,
12342
- version,
12343
- requiredVersion: 'string' == typeof config.requiredVersion ? config.requiredVersion : void 0,
12344
- singleton: config.singleton
12345
- };
12346
- });
12347
- return result.length > 0 ? result : void 0;
12348
- }(this._options.shared);
12349
- void 0 === manifestOptions.shared && manifestShared && (manifestOptions.shared = manifestShared), new ModuleFederationManifestPlugin({
12350
- ...manifestOptions,
12351
- name: containerName,
12352
- globalName,
12353
- remoteAliasMap
12354
- }).apply(compiler);
12355
- }
12756
+ }).apply(compiler), this._options.manifest && new ModuleFederationManifestPlugin(this._options).apply(compiler);
12356
12757
  }
12357
12758
  },
12358
12759
  ModuleFederationPluginV1: class {
@@ -12389,6 +12790,7 @@ Help:
12389
12790
  }
12390
12791
  }, sharing = {
12391
12792
  ProvideSharedPlugin: ProvideSharedPlugin,
12793
+ TreeShakingSharedPlugin: TreeShakingSharedPlugin,
12392
12794
  ConsumeSharedPlugin: ConsumeSharedPlugin,
12393
12795
  SharePlugin: SharePlugin
12394
12796
  }, exports_experiments = {
@@ -12431,7 +12833,7 @@ Help:
12431
12833
  return base_create(name, resolve, affectedHooks);
12432
12834
  },
12433
12835
  VirtualModulesPlugin: VirtualModulesPlugin
12434
- }, src_fn = Object.assign(rspack, exports_namespaceObject);
12836
+ }, src_fn = Object.assign(rspack_rspack, exports_namespaceObject);
12435
12837
  src_fn.rspack = src_fn, src_fn.webpack = src_fn;
12436
12838
  let src_rspack_0 = src_fn, src_0 = src_rspack_0;
12437
12839
  })(), exports.AsyncDependenciesBlock = __webpack_exports__.AsyncDependenciesBlock, exports.BannerPlugin = __webpack_exports__.BannerPlugin, exports.CaseSensitivePlugin = __webpack_exports__.CaseSensitivePlugin, 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 === [