@rspack-canary/core 1.7.3-canary-2f0bc179-20260118174706 → 1.7.3-canary-467a44da-20260119082229

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