@rspack-canary/core 1.7.3-canary-1138ed18-20260115124957 → 1.7.3-canary-fe1e14c1-20260116175137

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-1138ed18-20260115124957"), 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-fe1e14c1-20260116175137"), 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-1138ed18-20260115124957", 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-fe1e14c1-20260116175137", 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-1138ed18-20260115124957";
8709
+ object.version = "5.75.0", object.rspackVersion = "1.7.3-canary-fe1e14c1-20260116175137";
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_rspack(options, callback) {
10138
+ function 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-1138ed18-20260115124957", bindingVersionCheck_errorMessage = (coreVersion, expectedCoreVersion)=>process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
10434
+ let CORE_VERSION = "1.7.3-canary-fe1e14c1-20260116175137", 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_rspack(...params);
10755
+ return rspack(...params);
10756
10756
  }, exports_namespaceObject, {
10757
10757
  RuntimeGlobals: compilerRuntimeGlobals
10758
10758
  });
@@ -11847,7 +11847,69 @@ Help:
11847
11847
  });
11848
11848
  }
11849
11849
  }
11850
- let parseOptions = (options, normalizeSimple, normalizeOptions)=>{
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)=>{
11851
11913
  let items = [];
11852
11914
  var options1 = options, normalizeSimple1 = normalizeSimple, normalizeOptions1 = normalizeOptions, fn = (key, value)=>{
11853
11915
  items.push([
@@ -11866,7 +11928,63 @@ Help:
11866
11928
  } else if ('object' == typeof options1) object(options1);
11867
11929
  else throw Error('Unexpected options format');
11868
11930
  return items;
11869
- }, compilerSet = new WeakSet();
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();
11870
11988
  class ShareRuntimePlugin extends RspackBuiltinPlugin {
11871
11989
  enhanced;
11872
11990
  name = binding_.BuiltinPluginName.ShareRuntimePlugin;
@@ -11878,55 +11996,42 @@ Help:
11878
11996
  if (compiler1 = compiler, !compilerSet.has(compiler1)) return compiler2 = compiler, compilerSet.add(compiler2), createBuiltinPlugin(this.name, this.enhanced);
11879
11997
  }
11880
11998
  }
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
- }
11924
11999
  class ConsumeSharedPlugin extends RspackBuiltinPlugin {
11925
12000
  name = binding_.BuiltinPluginName.ConsumeSharedPlugin;
11926
12001
  _options;
11927
12002
  constructor(options){
11928
12003
  super(), this._options = {
11929
- consumes: normalizeConsumeShareOptions(options.consumes, options.shareScope),
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
+ })),
11930
12035
  enhanced: options.enhanced ?? !1
11931
12036
  };
11932
12037
  }
@@ -11947,30 +12052,28 @@ Help:
11947
12052
  _provides;
11948
12053
  _enhanced;
11949
12054
  constructor(options){
11950
- var options1, shareScope, enhanced;
11951
- super(), this._provides = (options1 = options.provides, shareScope = options.shareScope, enhanced = options.enhanced, parseOptions(options1, (item)=>{
12055
+ super(), this._provides = parseOptions(options.provides, (item)=>{
11952
12056
  if (Array.isArray(item)) throw Error('Unexpected array of provides');
11953
12057
  return {
11954
12058
  shareKey: item,
11955
12059
  version: void 0,
11956
- shareScope: shareScope || 'default',
12060
+ shareScope: options.shareScope || 'default',
11957
12061
  eager: !1
11958
12062
  };
11959
12063
  }, (item)=>{
11960
12064
  let raw = {
11961
12065
  shareKey: item.shareKey,
11962
12066
  version: item.version,
11963
- shareScope: item.shareScope || shareScope || 'default',
12067
+ shareScope: item.shareScope || options.shareScope || 'default',
11964
12068
  eager: !!item.eager
11965
12069
  };
11966
- return enhanced ? {
12070
+ return options.enhanced ? {
11967
12071
  ...raw,
11968
12072
  singleton: item.singleton,
11969
12073
  requiredVersion: item.requiredVersion,
11970
- strictVersion: item.strictVersion,
11971
- treeShakingMode: item.treeShakingMode
12074
+ strictVersion: item.strictVersion
11972
12075
  } : raw;
11973
- })), this._enhanced = options.enhanced;
12076
+ }), this._enhanced = options.enhanced;
11974
12077
  }
11975
12078
  raw(compiler) {
11976
12079
  new ShareRuntimePlugin(this._enhanced ?? !1).apply(compiler);
@@ -11981,40 +12084,32 @@ Help:
11981
12084
  return createBuiltinPlugin(this.name, rawOptions);
11982
12085
  }
11983
12086
  }
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
- }
12010
12087
  class SharePlugin {
12011
12088
  _shareScope;
12012
12089
  _consumes;
12013
12090
  _provides;
12014
12091
  _enhanced;
12015
- _sharedOptions;
12016
12092
  constructor(options){
12017
- const sharedOptions = normalizeSharedOptions(options.shared), consumes = createConsumeShareOptions(sharedOptions), provides = sharedOptions.filter(([, options])=>!1 !== options.import).map(([key, 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])=>({
12018
12113
  [options.import || key]: {
12019
12114
  shareKey: options.shareKey || key,
12020
12115
  shareScope: options.shareScope,
@@ -12022,11 +12117,10 @@ Help:
12022
12117
  eager: options.eager,
12023
12118
  singleton: options.singleton,
12024
12119
  requiredVersion: options.requiredVersion,
12025
- strictVersion: options.strictVersion,
12026
- treeShakingMode: options.treeShaking?.mode
12120
+ strictVersion: options.strictVersion
12027
12121
  }
12028
12122
  }));
12029
- this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1, this._sharedOptions = sharedOptions;
12123
+ this._shareScope = options.shareScope, this._consumes = consumes, this._provides = provides, this._enhanced = options.enhanced ?? !1;
12030
12124
  }
12031
12125
  apply(compiler) {
12032
12126
  new ConsumeSharedPlugin({
@@ -12040,560 +12134,6 @@ Help:
12040
12134
  }).apply(compiler);
12041
12135
  }
12042
12136
  }
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
- }), compiler.hooks.shutdown.tapAsync('IndependentSharedPlugin', (callback)=>{
12359
- callback();
12360
- }), manifest && compiler.hooks.compilation.tap('IndependentSharedPlugin', (compilation)=>{
12361
- compilation.hooks.processAssets.tap({
12362
- name: 'injectBuildAssets',
12363
- stage: compilation.constructor.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER
12364
- }, ()=>{
12365
- let { statsFileName, manifestFileName } = getFileName(manifest), injectBuildAssetsIntoStatsOrManifest = (filename)=>{
12366
- let stats = compilation.getAsset(filename);
12367
- if (!stats) return;
12368
- let statsContent = JSON.parse(stats.source.source().toString()), { shared } = statsContent;
12369
- Object.entries(this.buildAssets).forEach(([key, item])=>{
12370
- let targetShared = shared.find((s)=>s.name === key);
12371
- targetShared && item.forEach(([entry, version, globalName])=>{
12372
- version === targetShared.version && (targetShared.fallback = entry, targetShared.fallbackName = globalName);
12373
- });
12374
- }), compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
12375
- };
12376
- injectBuildAssetsIntoStatsOrManifest(statsFileName), injectBuildAssetsIntoStatsOrManifest(manifestFileName);
12377
- });
12378
- });
12379
- }
12380
- async createIndependentCompilers(parentCompiler) {
12381
- let { sharedOptions, buildAssets, outputDir } = this;
12382
- console.log('Start building shared fallback resources ...');
12383
- let shareRequestsMap = await this.createIndependentCompiler(parentCompiler);
12384
- await Promise.all(sharedOptions.map(async ([shareName, shareConfig])=>{
12385
- if (!shareConfig.treeShaking || !1 === shareConfig.import) return;
12386
- let shareRequests = shareRequestsMap[shareName].requests;
12387
- await Promise.all(shareRequests.map(async ([request, version])=>{
12388
- let sharedConfig = sharedOptions.find(([name])=>name === shareName)?.[1], [shareFileName, globalName, sharedVersion] = await this.createIndependentCompiler(parentCompiler, {
12389
- shareRequestsMap,
12390
- currentShare: {
12391
- shareName,
12392
- version,
12393
- request,
12394
- independentShareFileName: sharedConfig?.treeShaking?.filename
12395
- }
12396
- });
12397
- 'string' == typeof shareFileName && (buildAssets[shareName] ||= [], buildAssets[shareName].push([
12398
- (0, external_node_path_namespaceObject.join)(resolveOutputDir(outputDir, shareName), shareFileName),
12399
- sharedVersion,
12400
- globalName
12401
- ]));
12402
- }));
12403
- })), console.log('All shared fallback have been compiled successfully!');
12404
- }
12405
- async createIndependentCompiler(parentCompiler, extraOptions) {
12406
- let extraPlugin, { mfName, plugins, outputDir, sharedOptions, treeShaking, library, treeShakingSharedExcludePlugins } = this, outputDirWithShareName = resolveOutputDir(outputDir, extraOptions?.currentShare?.shareName || ''), parentConfig = parentCompiler.options, finalPlugins = [], rspack = parentCompiler.rspack;
12407
- extraPlugin = extraOptions ? new SharedContainerPlugin({
12408
- mfName,
12409
- library,
12410
- ...extraOptions.currentShare
12411
- }) : new CollectSharedEntryPlugin({
12412
- sharedOptions,
12413
- shareScope: 'default'
12414
- }), (parentConfig.plugins || []).forEach((plugin)=>{
12415
- void 0 !== plugin && 'string' != typeof plugin && ((plugin, excludedPlugins = [])=>{
12416
- if (!plugin) return !0;
12417
- let pluginName = plugin.name || plugin.constructor?.name;
12418
- return !pluginName || ![
12419
- 'TreeShakingSharedPlugin',
12420
- 'IndependentSharedPlugin',
12421
- 'ModuleFederationPlugin',
12422
- 'SharedUsedExportsOptimizerPlugin',
12423
- 'HtmlWebpackPlugin',
12424
- 'HtmlRspackPlugin',
12425
- 'RsbuildHtmlPlugin',
12426
- ...excludedPlugins
12427
- ].includes(pluginName);
12428
- })(plugin, treeShakingSharedExcludePlugins) && finalPlugins.push(plugin);
12429
- }), plugins.forEach((plugin)=>{
12430
- finalPlugins.push(plugin);
12431
- }), finalPlugins.push(extraPlugin), finalPlugins.push(new ConsumeSharedPlugin({
12432
- consumes: sharedOptions.filter(([key, options])=>extraOptions?.currentShare.shareName !== (options.shareKey || key)).map(([key, options])=>({
12433
- [key]: {
12434
- import: !extraOptions && options.import,
12435
- shareKey: options.shareKey || key,
12436
- shareScope: options.shareScope,
12437
- requiredVersion: options.requiredVersion,
12438
- strictVersion: options.strictVersion,
12439
- singleton: options.singleton,
12440
- packageName: options.packageName,
12441
- eager: options.eager
12442
- }
12443
- })),
12444
- enhanced: !0
12445
- })), treeShaking && finalPlugins.push(new SharedUsedExportsOptimizerPlugin(sharedOptions, this.injectTreeShakingUsedExports)), finalPlugins.push(new VirtualEntryPlugin(sharedOptions, !extraOptions));
12446
- let fullOutputDir = (0, external_node_path_namespaceObject.resolve)(parentCompiler.outputPath, outputDirWithShareName), compilerConfig = {
12447
- ...parentConfig,
12448
- module: {
12449
- ...parentConfig.module,
12450
- rules: [
12451
- {
12452
- test: /virtual-entry\.js$/,
12453
- type: "javascript/auto",
12454
- resolve: {
12455
- fullySpecified: !1
12456
- },
12457
- use: {
12458
- loader: 'builtin:swc-loader'
12459
- }
12460
- },
12461
- ...parentConfig.module?.rules || []
12462
- ]
12463
- },
12464
- mode: parentConfig.mode || 'development',
12465
- entry: VirtualEntryPlugin.entry,
12466
- output: {
12467
- path: fullOutputDir,
12468
- clean: !0,
12469
- publicPath: parentConfig.output?.publicPath || 'auto'
12470
- },
12471
- plugins: finalPlugins,
12472
- optimization: {
12473
- ...parentConfig.optimization,
12474
- splitChunks: !1
12475
- }
12476
- }, compiler = rspack.rspack(compilerConfig);
12477
- compiler.inputFileSystem = parentCompiler.inputFileSystem, compiler.outputFileSystem = parentCompiler.outputFileSystem, compiler.intermediateFileSystem = parentCompiler.intermediateFileSystem;
12478
- let { currentShare } = extraOptions || {};
12479
- return new Promise((resolve, reject)=>{
12480
- compiler.run((err, stats)=>{
12481
- if (err || stats?.hasErrors()) {
12482
- let target = currentShare ? currentShare.shareName : 'Collect deps';
12483
- console.error(`${target} Compile failed:`, err || stats.toJson().errors.map((e)=>e.message).join('\n')), reject(err || Error(`${target} Compile failed`));
12484
- return;
12485
- }
12486
- currentShare && console.log(`${currentShare.shareName} Compile success`), resolve(extraPlugin.getData());
12487
- });
12488
- });
12489
- }
12490
- }
12491
- class TreeShakingSharedPlugin {
12492
- mfConfig;
12493
- outputDir;
12494
- secondary;
12495
- _independentSharePlugin;
12496
- name = 'TreeShakingSharedPlugin';
12497
- constructor(options){
12498
- const { mfConfig, secondary } = options;
12499
- this.mfConfig = mfConfig, this.outputDir = mfConfig.treeShakingSharedDir || 'independent-packages', this.secondary = !!secondary;
12500
- }
12501
- apply(compiler) {
12502
- let { mfConfig, outputDir, secondary } = this, { name, shared, library, treeShakingSharedPlugins } = mfConfig;
12503
- if (!shared) return;
12504
- let sharedOptions = normalizeSharedOptions(shared);
12505
- sharedOptions.length && sharedOptions.some(([_, config])=>config.treeShaking && !1 !== config.import) && (secondary || new SharedUsedExportsOptimizerPlugin(sharedOptions, mfConfig.injectTreeShakingUsedExports, mfConfig.manifest).apply(compiler), this._independentSharePlugin = new IndependentSharedPlugin({
12506
- name: name,
12507
- shared: shared,
12508
- outputDir,
12509
- plugins: treeShakingSharedPlugins?.map((p)=>new (require(p))()) || [],
12510
- treeShaking: secondary,
12511
- library,
12512
- manifest: mfConfig.manifest,
12513
- treeShakingSharedExcludePlugins: mfConfig.treeShakingSharedExcludePlugins
12514
- }), this._independentSharePlugin.apply(compiler));
12515
- }
12516
- get buildAssets() {
12517
- return this._independentSharePlugin?.buildAssets || {};
12518
- }
12519
- }
12520
- let ModuleFederationRuntimePlugin = base_create(binding_.BuiltinPluginName.ModuleFederationRuntimePlugin, (options = {})=>options);
12521
- function getRemoteInfos(options) {
12522
- if (!options.remotes) return {};
12523
- let remoteType = options.remoteType || (options.library ? options.library.type : "script"), remotes = parseOptions(options.remotes, (item)=>({
12524
- external: Array.isArray(item) ? item : [
12525
- item
12526
- ],
12527
- shareScope: options.shareScope || 'default'
12528
- }), (item)=>({
12529
- external: Array.isArray(item.external) ? item.external : [
12530
- item.external
12531
- ],
12532
- shareScope: item.shareScope || options.shareScope || 'default'
12533
- })), remoteInfos = {};
12534
- for (let [key, config] of remotes)for (let external of config.external){
12535
- let [externalType, externalRequest] = function(external) {
12536
- let result = function(external) {
12537
- if (/^[a-z0-9-]+ /.test(external)) {
12538
- let idx = external.indexOf(' ');
12539
- return [
12540
- external.slice(0, idx),
12541
- external.slice(idx + 1)
12542
- ];
12543
- }
12544
- return null;
12545
- }(external);
12546
- return null === result ? [
12547
- remoteType,
12548
- external
12549
- ] : result;
12550
- }(external);
12551
- if (remoteInfos[key] ??= [], "script" === externalType) {
12552
- let [url, global] = function(urlAndGlobal) {
12553
- let index = urlAndGlobal.indexOf('@');
12554
- return index <= 0 || index === urlAndGlobal.length - 1 ? null : [
12555
- urlAndGlobal.substring(index + 1),
12556
- urlAndGlobal.substring(0, index)
12557
- ];
12558
- }(externalRequest);
12559
- remoteInfos[key].push({
12560
- alias: key,
12561
- name: global,
12562
- entry: url,
12563
- externalType,
12564
- shareScope: config.shareScope
12565
- });
12566
- } else remoteInfos[key].push({
12567
- alias: key,
12568
- name: void 0,
12569
- entry: void 0,
12570
- externalType,
12571
- shareScope: config.shareScope
12572
- });
12573
- }
12574
- return remoteInfos;
12575
- }
12576
- function getDefaultEntryRuntime(paths, options, compiler, treeShakingShareFallbacks) {
12577
- let runtimePlugins = options.runtimePlugins ?? [], remoteInfos = getRemoteInfos(options), runtimePluginImports = [], runtimePluginVars = [], libraryType = options.library?.type || 'var';
12578
- for(let i = 0; i < runtimePlugins.length; i++){
12579
- 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;
12580
- runtimePluginImports.push(`import ${runtimePluginVar} from ${JSON.stringify(pluginPath)}`);
12581
- let paramsCode = void 0 === pluginParams ? 'undefined' : JSON.stringify(pluginParams);
12582
- runtimePluginVars.push(`${runtimePluginVar}(${paramsCode})`);
12583
- }
12584
- let content = [
12585
- `import __module_federation_bundler_runtime__ from ${JSON.stringify(paths.bundlerRuntime)}`,
12586
- ...runtimePluginImports,
12587
- `const __module_federation_runtime_plugins__ = [${runtimePluginVars.join(', ')}]`,
12588
- `const __module_federation_remote_infos__ = ${JSON.stringify(remoteInfos)}`,
12589
- `const __module_federation_container_name__ = ${JSON.stringify(options.name ?? compiler.options.output.uniqueName)}`,
12590
- `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? 'version-first')}`,
12591
- `const __module_federation_share_fallbacks__ = ${JSON.stringify(treeShakingShareFallbacks)}`,
12592
- `const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
12593
- compiler.webpack.Template.getFunctionContent(__webpack_require__("./moduleFederationDefaultRuntime.js"))
12594
- ].join(';');
12595
- return `@module-federation/runtime/rspack.js!=!data:text/javascript,${content}`;
12596
- }
12597
12137
  class ContainerPlugin extends RspackBuiltinPlugin {
12598
12138
  name = binding_.BuiltinPluginName.ContainerPlugin;
12599
12139
  _options;
@@ -12602,7 +12142,7 @@ Help:
12602
12142
  name: options.name,
12603
12143
  shareScope: options.shareScope || 'default',
12604
12144
  library: options.library || {
12605
- type: 'global',
12145
+ type: 'var',
12606
12146
  name: options.name
12607
12147
  },
12608
12148
  runtime: options.runtime,
@@ -12685,7 +12225,7 @@ Help:
12685
12225
  let _options = JSON.stringify(options || {});
12686
12226
  return binding_default().transform(source, _options);
12687
12227
  }
12688
- let exports_rspackVersion = "1.7.3-canary-1138ed18-20260115124957", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
12228
+ let exports_rspackVersion = "1.7.3-canary-fe1e14c1-20260116175137", exports_version = "5.75.0", exports_WebpackError = Error, sources = __webpack_require__("webpack-sources"), exports_config = {
12689
12229
  getNormalizedRspackOptions: getNormalizedRspackOptions,
12690
12230
  applyRspackOptionsDefaults: applyRspackOptionsDefaults,
12691
12231
  getNormalizedWebpackOptions: getNormalizedRspackOptions,
@@ -12728,12 +12268,11 @@ Help:
12728
12268
  ContainerReferencePlugin: ContainerReferencePlugin,
12729
12269
  ModuleFederationPlugin: class {
12730
12270
  _options;
12731
- _treeShakingSharedPlugin;
12732
12271
  constructor(_options){
12733
12272
  this._options = _options;
12734
12273
  }
12735
12274
  apply(compiler) {
12736
- var options, options1;
12275
+ var options;
12737
12276
  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', {
12738
12277
  paths: [
12739
12278
  runtimeToolsPath
@@ -12747,41 +12286,101 @@ Help:
12747
12286
  bundlerRuntime: bundlerRuntimePath,
12748
12287
  runtime: runtimePath
12749
12288
  });
12750
- compiler.options.resolve.alias = {
12289
+ if (compiler.options.resolve.alias = {
12751
12290
  '@module-federation/runtime-tools': paths.runtimeTools,
12752
12291
  '@module-federation/runtime': paths.runtime,
12753
12292
  ...compiler.options.resolve.alias
12754
- }, ((options1 = this._options).shared ? parseOptions(options1.shared, (item, key)=>{
12755
- if ('string' != typeof item) throw Error('Unexpected array in shared');
12756
- return item !== key && isRequiredVersion(item) ? {
12757
- import: key,
12758
- requiredVersion: item
12759
- } : {
12760
- import: item
12761
- };
12762
- }, (item)=>item) : []).filter(([, config])=>config.treeShaking).length > 0 && (this._treeShakingSharedPlugin = new TreeShakingSharedPlugin({
12763
- mfConfig: this._options,
12764
- secondary: !1
12765
- }), this._treeShakingSharedPlugin.apply(compiler));
12766
- let runtimePluginApplied = !1;
12767
- compiler.hooks.beforeRun.tap({
12768
- name: 'ModuleFederationPlugin',
12769
- stage: 100
12770
- }, ()=>{
12771
- runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
12772
- entryRuntime: getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets)
12773
- }).apply(compiler));
12774
- }), compiler.hooks.watchRun.tap({
12775
- name: 'ModuleFederationPlugin',
12776
- stage: 100
12777
- }, ()=>{
12778
- runtimePluginApplied || (runtimePluginApplied = !0, new ModuleFederationRuntimePlugin({
12779
- entryRuntime: getDefaultEntryRuntime(paths, this._options, compiler, this._treeShakingSharedPlugin?.buildAssets || {})
12780
- }).apply(compiler));
12781
- }), new webpack.container.ModuleFederationPluginV1({
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({
12782
12314
  ...this._options,
12783
12315
  enhanced: !0
12784
- }).apply(compiler), this._options.manifest && new ModuleFederationManifestPlugin(this._options).apply(compiler);
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
+ }
12785
12384
  }
12786
12385
  },
12787
12386
  ModuleFederationPluginV1: class {
@@ -12818,7 +12417,6 @@ Help:
12818
12417
  }
12819
12418
  }, sharing = {
12820
12419
  ProvideSharedPlugin: ProvideSharedPlugin,
12821
- TreeShakingSharedPlugin: TreeShakingSharedPlugin,
12822
12420
  ConsumeSharedPlugin: ConsumeSharedPlugin,
12823
12421
  SharePlugin: SharePlugin
12824
12422
  }, exports_experiments = {
@@ -12861,7 +12459,7 @@ Help:
12861
12459
  return base_create(name, resolve, affectedHooks);
12862
12460
  },
12863
12461
  VirtualModulesPlugin: VirtualModulesPlugin
12864
- }, src_fn = Object.assign(rspack_rspack, exports_namespaceObject);
12462
+ }, src_fn = Object.assign(rspack, exports_namespaceObject);
12865
12463
  src_fn.rspack = src_fn, src_fn.webpack = src_fn;
12866
12464
  let src_rspack_0 = src_fn, src_0 = src_rspack_0;
12867
12465
  })(), 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 === [