@rspack/core 2.0.0-beta.4 → 2.0.0-beta.6

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.
@@ -2,13 +2,14 @@ import { type BuiltinPlugin, BuiltinPluginName } from '@rspack/binding';
2
2
  import { RspackBuiltinPlugin } from '../builtin-plugin/base.js';
3
3
  import type { Compiler } from '../Compiler.js';
4
4
  import type { EntryRuntime, FilenameTemplate, LibraryOptions } from '../config/index.js';
5
+ import { type ShareScope } from '../sharing/SharePlugin.js';
5
6
  export type ContainerPluginOptions = {
6
7
  exposes: Exposes;
7
8
  filename?: FilenameTemplate;
8
9
  library?: LibraryOptions;
9
10
  name: string;
10
11
  runtime?: EntryRuntime;
11
- shareScope?: string;
12
+ shareScope?: ShareScope;
12
13
  enhanced?: boolean;
13
14
  };
14
15
  export type Exposes = (ExposesItem | ExposesObject)[] | ExposesObject;
@@ -25,7 +26,7 @@ export declare class ContainerPlugin extends RspackBuiltinPlugin {
25
26
  name: BuiltinPluginName;
26
27
  _options: {
27
28
  name: string;
28
- shareScope: string;
29
+ shareScope: ShareScope;
29
30
  library: LibraryOptions;
30
31
  runtime: EntryRuntime | undefined;
31
32
  filename: string | undefined;
@@ -2,10 +2,11 @@ import { type BuiltinPlugin, BuiltinPluginName } from '@rspack/binding';
2
2
  import { RspackBuiltinPlugin } from '../builtin-plugin/base.js';
3
3
  import type { Compiler } from '../Compiler.js';
4
4
  import type { ExternalsType } from '../config/index.js';
5
+ import { type ShareScope } from '../sharing/SharePlugin.js';
5
6
  export type ContainerReferencePluginOptions = {
6
7
  remoteType: ExternalsType;
7
8
  remotes: Remotes;
8
- shareScope?: string;
9
+ shareScope?: ShareScope;
9
10
  enhanced?: boolean;
10
11
  };
11
12
  export type Remotes = (RemotesItem | RemotesObject)[] | RemotesObject;
@@ -16,7 +17,7 @@ export type RemotesObject = {
16
17
  };
17
18
  export type RemotesConfig = {
18
19
  external: RemotesItem | RemotesItems;
19
- shareScope?: string;
20
+ shareScope?: ShareScope;
20
21
  };
21
22
  export declare class ContainerReferencePlugin extends RspackBuiltinPlugin {
22
23
  name: BuiltinPluginName;
@@ -24,7 +25,7 @@ export declare class ContainerReferencePlugin extends RspackBuiltinPlugin {
24
25
  remoteType: ExternalsType;
25
26
  remotes: [string, {
26
27
  external: string[];
27
- shareScope: string;
28
+ shareScope: ShareScope;
28
29
  }][];
29
30
  enhanced: boolean;
30
31
  };
@@ -1,5 +1,6 @@
1
1
  import type { Compiler } from '../Compiler.js';
2
2
  import type { ExternalsType } from '../config/index.js';
3
+ import type { ShareScope } from '../sharing/SharePlugin.js';
3
4
  import { type ModuleFederationManifestPluginOptions } from './ModuleFederationManifestPlugin.js';
4
5
  import type { ModuleFederationPluginV1Options } from './ModuleFederationPluginV1.js';
5
6
  import { type ModuleFederationRuntimeExperimentsOptions } from './ModuleFederationRuntimePlugin.js';
@@ -26,7 +27,7 @@ interface RemoteInfo {
26
27
  name?: string;
27
28
  entry?: string;
28
29
  externalType: ExternalsType;
29
- shareScope: string;
30
+ shareScope: ShareScope;
30
31
  }
31
32
  type RemoteInfos = Record<string, RemoteInfo[]>;
32
33
  export declare function getRemoteInfos(options: ModuleFederationPluginOptions): RemoteInfos;
@@ -1,6 +1,6 @@
1
1
  import type { Compiler } from '../Compiler.js';
2
2
  import type { EntryRuntime, ExternalsType, LibraryOptions } from '../config/index.js';
3
- import { type Shared } from '../sharing/SharePlugin.js';
3
+ import { type Shared, type ShareScope } from '../sharing/SharePlugin.js';
4
4
  import { type Exposes } from './ContainerPlugin.js';
5
5
  import { type Remotes } from './ContainerReferencePlugin.js';
6
6
  export interface ModuleFederationPluginV1Options {
@@ -11,7 +11,7 @@ export interface ModuleFederationPluginV1Options {
11
11
  remoteType?: ExternalsType;
12
12
  remotes?: Remotes;
13
13
  runtime?: EntryRuntime;
14
- shareScope?: string;
14
+ shareScope?: ShareScope;
15
15
  shared?: Shared;
16
16
  enhanced?: boolean;
17
17
  }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import './checkNodeVersion.js';
1
2
  import * as rspackExports from './exports.js';
2
3
  import { rspack as rspackFn } from './rspack.js';
3
4
  type Rspack = typeof rspackFn & typeof rspackExports & {
package/dist/index.js CHANGED
@@ -298,7 +298,12 @@ __webpack_require__.r(ModuleFilenameHelpers_namespaceObject), __webpack_require_
298
298
  asRegExp: ()=>asRegExp,
299
299
  matchObject: ()=>matchObject,
300
300
  matchPart: ()=>matchPart
301
- });
301
+ }), !function() {
302
+ let { node, bun, deno } = process.versions;
303
+ if (!node || bun || deno) return;
304
+ let [majorStr, minorStr] = node.split('.'), major = parseInt(majorStr, 10), minor = parseInt(minorStr || '0', 10);
305
+ 20 === major && minor >= 19 || 22 === major && minor >= 12 || major > 22 || console.error(`Unsupported Node.js version "${node}". Rspack requires Node.js 20.19+ or 22.12+. Please upgrade your Node.js version.\n`);
306
+ }();
302
307
  let binding_namespaceObject = __rspack_createRequire_require(process.env.RSPACK_BINDING ? process.env.RSPACK_BINDING : "@rspack/binding");
303
308
  var binding_default = __webpack_require__.n(binding_namespaceObject);
304
309
  function _define_property(obj, key, value) {
@@ -2864,6 +2869,11 @@ let unsupported = (name, issue)=>{
2864
2869
  query: match[2] ? match[2].replace(/\u200b(.)/g, '$1') : ''
2865
2870
  };
2866
2871
  });
2872
+ function isStatsColorSupported() {
2873
+ if ("u" < typeof process) return !1;
2874
+ let env = process.env ?? {}, argv = process.argv ?? [];
2875
+ return !('NO_COLOR' in env || argv.includes('--no-color')) && ('FORCE_COLOR' in env || argv.includes('--color') || 'win32' === process.platform || process.stdout?.isTTY && 'dumb' !== env.TERM || 'CI' in env);
2876
+ }
2867
2877
  function encodeVersion(version) {
2868
2878
  let [major, minor = 0, patch = 0] = version.split('-')[0].split('.').map((v)=>parseInt(v, 10));
2869
2879
  return Number.isNaN(major) || Number.isNaN(minor) || Number.isNaN(patch) ? null : major << 16 | minor << 8 | patch;
@@ -4418,11 +4428,12 @@ function getRawJavascriptParserOptions(parser) {
4418
4428
  dynamicImportPreload: parser.dynamicImportPreload?.toString(),
4419
4429
  dynamicImportPrefetch: parser.dynamicImportPrefetch?.toString(),
4420
4430
  dynamicImportFetchPriority: parser.dynamicImportFetchPriority,
4421
- importMeta: parser.importMeta,
4431
+ importMeta: 'boolean' == typeof parser.importMeta ? String(parser.importMeta) : parser.importMeta,
4422
4432
  url: parser.url?.toString(),
4423
4433
  exprContextCritical: parser.exprContextCritical,
4424
4434
  unknownContextCritical: parser.unknownContextCritical,
4425
4435
  wrappedContextCritical: parser.wrappedContextCritical,
4436
+ strictThisContextOnImports: parser.strictThisContextOnImports,
4426
4437
  wrappedContextRegExp: parser.wrappedContextRegExp,
4427
4438
  exportsPresence: !1 === parser.exportsPresence ? 'false' : parser.exportsPresence,
4428
4439
  importExportsPresence: !1 === parser.importExportsPresence ? 'false' : parser.importExportsPresence,
@@ -5220,13 +5231,11 @@ class SubresourceIntegrityPlugin extends NativeSubresourceIntegrityPlugin {
5220
5231
  }
5221
5232
  let src = '';
5222
5233
  if (isUrlSrc) {
5223
- if (!publicPath) return;
5234
+ if (!publicPath || '/' === publicPath || './' === publicPath) return;
5224
5235
  let protocolRelativePublicPath = publicPath.replace(HTTP_PROTOCOL_REGEX, ''), protocolRelativeTagSrc = tagSrc.replace(HTTP_PROTOCOL_REGEX, '');
5225
5236
  if (!protocolRelativeTagSrc.startsWith(protocolRelativePublicPath)) return;
5226
- {
5227
- let tagSrcWithScheme = `http:${protocolRelativeTagSrc}`;
5228
- src = relative(protocolRelativePublicPath.startsWith('//') ? `http:${protocolRelativePublicPath}` : protocolRelativePublicPath, decodeURIComponent(tagSrcWithScheme));
5229
- }
5237
+ let tagSrcWithScheme = `http:${protocolRelativeTagSrc}`;
5238
+ src = relative(protocolRelativePublicPath.startsWith('//') ? `http:${protocolRelativePublicPath}` : protocolRelativePublicPath, decodeURIComponent(tagSrcWithScheme));
5230
5239
  } else src = relative(publicPath, decodeURIComponent(tagSrc));
5231
5240
  tag.attributes.integrity = this.getIntegrityChecksumForAsset(src) || function(hashFuncNames, source) {
5232
5241
  let { createHash } = SubresourceIntegrityPlugin_require('node:crypto');
@@ -5290,23 +5299,37 @@ let SwcJsMinimizerRspackPlugin = base_create(binding_namespaceObject.BuiltinPlug
5290
5299
  exclude: options?.exclude,
5291
5300
  extractComments: function(extractComments) {
5292
5301
  let type, conditionStr = (condition)=>{
5293
- if (void 0 === condition || !0 === condition) return '@preserve|@lic|@cc_on|^\\**!';
5302
+ if (void 0 === condition || !0 === condition) return {
5303
+ source: '@preserve|@lic|@cc_on|^\\**!',
5304
+ flags: ''
5305
+ };
5294
5306
  if (!1 === condition) throw Error('unreachable');
5295
- return condition.source;
5307
+ return {
5308
+ source: condition.source,
5309
+ flags: condition.flags
5310
+ };
5296
5311
  };
5297
5312
  if ('boolean' == typeof extractComments) {
5298
5313
  if (!extractComments) return;
5314
+ let { source, flags } = conditionStr(extractComments);
5299
5315
  return {
5300
- condition: conditionStr(extractComments)
5316
+ condition: source,
5317
+ conditionFlags: flags
5318
+ };
5319
+ }
5320
+ if (extractComments instanceof RegExp) {
5321
+ let { source, flags } = conditionStr(extractComments);
5322
+ return {
5323
+ condition: source,
5324
+ conditionFlags: flags
5301
5325
  };
5302
5326
  }
5303
- if (extractComments instanceof RegExp) return {
5304
- condition: extractComments.source
5305
- };
5306
5327
  if (type = typeof extractComments, null != extractComments && ('object' === type || 'function' === type)) {
5307
5328
  if (!1 === extractComments.condition) return;
5329
+ let { source, flags } = conditionStr(extractComments.condition);
5308
5330
  return {
5309
- condition: conditionStr(extractComments.condition),
5331
+ condition: source,
5332
+ conditionFlags: flags,
5310
5333
  banner: extractComments.banner
5311
5334
  };
5312
5335
  }
@@ -6471,7 +6494,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6471
6494
  targetProperties,
6472
6495
  mode: options.mode,
6473
6496
  uniqueName: options.output.uniqueName,
6474
- deferImport: options.experiments.deferImport
6497
+ deferImport: options.experiments.deferImport,
6498
+ outputModule: options.output.module
6475
6499
  }), applyOutputDefaults(options, {
6476
6500
  context: options.context,
6477
6501
  targetProperties,
@@ -6511,13 +6535,14 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6511
6535
  D(options, 'incremental', {}), 'object' == typeof options.incremental && (D(options.incremental, 'silent', !0), D(options.incremental, 'buildModuleGraph', !0), D(options.incremental, 'finishModules', !0), D(options.incremental, 'optimizeDependencies', !0), D(options.incremental, 'buildChunkGraph', !0), D(options.incremental, 'optimizeChunkModules', !0), D(options.incremental, 'moduleIds', !0), D(options.incremental, 'chunkIds', !0), D(options.incremental, 'modulesHashes', !0), D(options.incremental, 'modulesCodegen', !0), D(options.incremental, 'modulesRuntimeRequirements', !0), D(options.incremental, 'chunksRuntimeRequirements', !0), D(options.incremental, 'chunksHashes', !0), D(options.incremental, 'chunkAsset', !0), D(options.incremental, 'emitAssets', !0));
6512
6536
  }, applySnapshotDefaults = (_snapshot, _env)=>{}, applyCssGeneratorOptionsDefaults = (generatorOptions, { targetProperties })=>{
6513
6537
  D(generatorOptions, 'exportsOnly', !targetProperties || !1 === targetProperties.document), D(generatorOptions, 'esModule', !0);
6514
- }, applyModuleDefaults = (module, { asyncWebAssembly, targetProperties, mode, uniqueName, deferImport })=>{
6515
- assertNotNill(module.parser), assertNotNill(module.generator), F(module.parser, "asset", ()=>({})), assertNotNill(module.parser.asset), F(module.parser.asset, 'dataUrlCondition', ()=>({})), 'object' == typeof module.parser.asset.dataUrlCondition && D(module.parser.asset.dataUrlCondition, 'maxSize', 8096), F(module.parser, "javascript", ()=>({})), assertNotNill(module.parser.javascript), ((parserOptions, { deferImport })=>{
6516
- D(parserOptions, 'dynamicImportMode', 'lazy'), D(parserOptions, 'dynamicImportPrefetch', !1), D(parserOptions, 'dynamicImportPreload', !1), D(parserOptions, 'url', !0), D(parserOptions, 'exprContextCritical', !0), D(parserOptions, 'unknownContextCritical', !0), D(parserOptions, 'wrappedContextCritical', !1), D(parserOptions, 'wrappedContextRegExp', /.*/), D(parserOptions, 'exportsPresence', 'error'), D(parserOptions, 'requireAsExpression', !0), D(parserOptions, 'requireAlias', !1), D(parserOptions, 'requireDynamic', !0), D(parserOptions, 'requireResolve', !0), D(parserOptions, 'commonjs', !0), D(parserOptions, 'importDynamic', !0), D(parserOptions, 'worker', [
6538
+ }, applyModuleDefaults = (module, { asyncWebAssembly, targetProperties, mode, uniqueName, deferImport, outputModule })=>{
6539
+ assertNotNill(module.parser), assertNotNill(module.generator), F(module.parser, "asset", ()=>({})), assertNotNill(module.parser.asset), F(module.parser.asset, 'dataUrlCondition', ()=>({})), 'object' == typeof module.parser.asset.dataUrlCondition && D(module.parser.asset.dataUrlCondition, 'maxSize', 8096), F(module.parser, "javascript", ()=>({})), assertNotNill(module.parser.javascript), ((parserOptions, { deferImport, outputModule })=>{
6540
+ D(parserOptions, 'dynamicImportMode', 'lazy'), D(parserOptions, 'dynamicImportPrefetch', !1), D(parserOptions, 'dynamicImportPreload', !1), D(parserOptions, 'url', !0), D(parserOptions, 'exprContextCritical', !0), D(parserOptions, 'unknownContextCritical', !0), D(parserOptions, 'wrappedContextCritical', !1), D(parserOptions, 'strictThisContextOnImports', !1), D(parserOptions, 'wrappedContextRegExp', /.*/), D(parserOptions, 'exportsPresence', 'error'), D(parserOptions, 'requireAsExpression', !0), D(parserOptions, 'requireAlias', !1), D(parserOptions, 'requireDynamic', !0), D(parserOptions, 'requireResolve', !0), D(parserOptions, 'commonjs', !0), D(parserOptions, 'importDynamic', !0), D(parserOptions, 'worker', [
6517
6541
  '...'
6518
- ]), D(parserOptions, 'importMeta', !0), D(parserOptions, 'typeReexportsPresence', 'no-tolerant'), D(parserOptions, 'jsx', !1), D(parserOptions, 'deferImport', deferImport);
6542
+ ]), D(parserOptions, 'importMeta', !outputModule || 'preserve-unknown'), D(parserOptions, 'typeReexportsPresence', 'no-tolerant'), D(parserOptions, 'jsx', !1), D(parserOptions, 'deferImport', deferImport);
6519
6543
  })(module.parser.javascript, {
6520
- deferImport
6544
+ deferImport,
6545
+ outputModule
6521
6546
  }), F(module.parser, "json", ()=>({})), assertNotNill(module.parser.json), D(module.parser.json, 'exportsDepth', 'development' === mode ? 1 : Number.MAX_SAFE_INTEGER), F(module.generator, 'json', ()=>({})), assertNotNill(module.generator.json), D(module.generator.json, 'JSONParse', !0), F(module.parser, 'css', ()=>({})), assertNotNill(module.parser.css), D(module.parser.css, 'namedExports', !0), D(module.parser.css, 'url', !0), F(module.parser, 'css/auto', ()=>({})), assertNotNill(module.parser['css/auto']), D(module.parser['css/auto'], 'namedExports', !0), D(module.parser['css/auto'], 'url', !0), F(module.parser, 'css/module', ()=>({})), assertNotNill(module.parser['css/module']), D(module.parser['css/module'], 'namedExports', !0), D(module.parser['css/module'], 'url', !0), F(module.generator, 'css', ()=>({})), assertNotNill(module.generator.css), applyCssGeneratorOptionsDefaults(module.generator.css, {
6522
6547
  targetProperties
6523
6548
  }), F(module.generator, 'css/auto', ()=>({})), assertNotNill(module.generator['css/auto']), applyCssGeneratorOptionsDefaults(module.generator['css/auto'], {
@@ -6544,7 +6569,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6544
6569
  type: "javascript/auto"
6545
6570
  },
6546
6571
  {
6547
- test: /\.json$/i,
6572
+ test: /\.json$/,
6548
6573
  type: 'json'
6549
6574
  },
6550
6575
  {
@@ -6552,22 +6577,22 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6552
6577
  type: 'json'
6553
6578
  },
6554
6579
  {
6555
- test: /\.mjs$/i,
6580
+ test: /\.mjs$/,
6556
6581
  ...esm
6557
6582
  },
6558
6583
  {
6559
- test: /\.js$/i,
6584
+ test: /\.js$/,
6560
6585
  descriptionData: {
6561
6586
  type: 'module'
6562
6587
  },
6563
6588
  ...esm
6564
6589
  },
6565
6590
  {
6566
- test: /\.cjs$/i,
6591
+ test: /\.cjs$/,
6567
6592
  ...commonjs
6568
6593
  },
6569
6594
  {
6570
- test: /\.js$/i,
6595
+ test: /\.js$/,
6571
6596
  descriptionData: {
6572
6597
  type: 'commonjs'
6573
6598
  },
@@ -6598,7 +6623,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6598
6623
  ]
6599
6624
  };
6600
6625
  rules.push({
6601
- test: /\.wasm$/i,
6626
+ test: /\.wasm$/,
6602
6627
  ...wasm
6603
6628
  }), rules.push({
6604
6629
  mimetype: 'application/wasm',
@@ -6785,7 +6810,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6785
6810
  return output.wasmLoading && enabledWasmLoadingTypes.add(output.wasmLoading), output.workerWasmLoading && enabledWasmLoadingTypes.add(output.workerWasmLoading), forEachEntry((desc)=>{
6786
6811
  desc.wasmLoading && enabledWasmLoadingTypes.add(desc.wasmLoading);
6787
6812
  }), Array.from(enabledWasmLoadingTypes);
6788
- }), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-beta.4"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !output.library));
6813
+ }), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-beta.6"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !output.library));
6789
6814
  }, applyExternalsPresetsDefaults = (externalsPresets, { targetProperties, buildHttp, outputModule })=>{
6790
6815
  let isUniversal = (key)=>!!(outputModule && targetProperties && null === targetProperties[key]);
6791
6816
  D(externalsPresets, 'web', !buildHttp && targetProperties && (targetProperties.web || isUniversal('node'))), D(externalsPresets, 'node', targetProperties && (targetProperties.node || isUniversal('node'))), D(externalsPresets, 'electron', targetProperties && targetProperties.electron || isUniversal('electron')), D(externalsPresets, 'electronMain', targetProperties && !!targetProperties.electron && (targetProperties.electronMain || isUniversal('electronMain'))), D(externalsPresets, 'electronPreload', targetProperties && !!targetProperties.electron && (targetProperties.electronPreload || isUniversal('electronPreload'))), D(externalsPresets, 'electronRenderer', targetProperties && !!targetProperties.electron && (targetProperties.electronRenderer || isUniversal('electronRenderer'))), D(externalsPresets, 'nwjs', targetProperties && (targetProperties.nwjs || isUniversal('nwjs')));
@@ -6823,7 +6848,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6823
6848
  })), F(cacheGroups, 'defaultVendors', ()=>({
6824
6849
  idHint: 'vendors',
6825
6850
  reuseExistingChunk: !0,
6826
- test: /[\\/]node_modules[\\/]/i,
6851
+ test: /[\\/]node_modules[\\/]/,
6827
6852
  priority: -10
6828
6853
  })));
6829
6854
  }
@@ -8039,7 +8064,7 @@ class MultiStats {
8039
8064
  obj.children = this.stats.map((stat, idx)=>{
8040
8065
  let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
8041
8066
  return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
8042
- }), childOptions.version && (obj.rspackVersion = "2.0.0-beta.4", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
8067
+ }), childOptions.version && (obj.rspackVersion = "2.0.0-beta.6", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
8043
8068
  let mapError = (j, obj)=>({
8044
8069
  ...obj,
8045
8070
  compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
@@ -9298,7 +9323,7 @@ let iterateConfig = (config, options, fn)=>{
9298
9323
  object.hash = context.getStatsCompilation(compilation).hash;
9299
9324
  },
9300
9325
  version: (object)=>{
9301
- object.version = "5.75.0", object.rspackVersion = "2.0.0-beta.4";
9326
+ object.version = "5.75.0", object.rspackVersion = "2.0.0-beta.6";
9302
9327
  },
9303
9328
  env: (object, _compilation, _context, { _env })=>{
9304
9329
  object.env = _env;
@@ -9770,7 +9795,7 @@ let applyDefaults = (options, defaults)=>{
9770
9795
  chunksSort: ()=>!1,
9771
9796
  assetsSort: ()=>'!size',
9772
9797
  outputPath: OFF_FOR_TO_STRING,
9773
- colors: ()=>!1
9798
+ colors: ()=>isStatsColorSupported()
9774
9799
  }, normalizeFilter = (item)=>{
9775
9800
  if ('string' == typeof item) {
9776
9801
  let regExp = RegExp(`[\\\\/]${item.replace(/[-[\]{}()*+?.\\^$|]/g, '\\$&')}([\\\\/]|$|!|\\?)`);
@@ -10963,7 +10988,7 @@ class TraceHookPlugin {
10963
10988
  });
10964
10989
  }
10965
10990
  }
10966
- let CORE_VERSION = "2.0.0-beta.4", VFILES_BY_COMPILER = new WeakMap();
10991
+ let CORE_VERSION = "2.0.0-beta.6", VFILES_BY_COMPILER = new WeakMap();
10967
10992
  class VirtualModulesPlugin {
10968
10993
  #staticModules;
10969
10994
  #compiler;
@@ -11505,7 +11530,7 @@ class Compiler {
11505
11530
  }
11506
11531
  #getInstance(callback) {
11507
11532
  var output;
11508
- let coreVersion, expectedCoreVersion, mode, experiments, error = CORE_VERSION === binding_default().EXPECTED_RSPACK_CORE_VERSION || CORE_VERSION.includes('canary') ? null : Error((coreVersion = CORE_VERSION, expectedCoreVersion = binding_default().EXPECTED_RSPACK_CORE_VERSION, process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
11533
+ let coreVersion, expectedCoreVersion, statsOptions, mode, experiments, error = CORE_VERSION === binding_default().EXPECTED_RSPACK_CORE_VERSION || CORE_VERSION.includes('canary') ? null : Error((coreVersion = CORE_VERSION, expectedCoreVersion = binding_default().EXPECTED_RSPACK_CORE_VERSION, process.env.RSPACK_BINDING ? `Unmatched version @rspack/core@${coreVersion} and binding version.
11509
11534
 
11510
11535
  Help:
11511
11536
  Looks like you are using a custom binding (via environment variable 'RSPACK_BINDING=${process.env.RSPACK_BINDING}').
@@ -11576,7 +11601,7 @@ Help:
11576
11601
  }),
11577
11602
  optimization: options.optimization,
11578
11603
  stats: {
11579
- colors: !!function(options) {
11604
+ colors: void 0 === (statsOptions = function(options) {
11580
11605
  if ('boolean' == typeof options || 'string' == typeof options) return presetToOptions(options);
11581
11606
  if (!options) return {};
11582
11607
  let obj = {
@@ -11584,7 +11609,7 @@ Help:
11584
11609
  ...options
11585
11610
  };
11586
11611
  return delete obj.preset, obj;
11587
- }(options.stats).colors
11612
+ }(options.stats)).colors ? isStatsColorSupported() : !!statsOptions.colors
11588
11613
  },
11589
11614
  cache: options.cache || !1,
11590
11615
  experiments,
@@ -12544,6 +12569,9 @@ class ProvideSharedPlugin extends RspackBuiltinPlugin {
12544
12569
  return createBuiltinPlugin(this.name, rawOptions);
12545
12570
  }
12546
12571
  }
12572
+ function validateShareScope(shareScope, enhanced, pluginName) {
12573
+ if (Array.isArray(shareScope) && shareScope.length > 1 && !enhanced) throw Error(`[${pluginName}] shareScope as an array with multiple entries requires enhanced=true, got: ${JSON.stringify(shareScope)}`);
12574
+ }
12547
12575
  function normalizeSharedOptions(shared) {
12548
12576
  return parseOptions(shared, (item, key)=>{
12549
12577
  if ('string' != typeof item) throw Error('Unexpected array in shared');
@@ -12747,7 +12775,7 @@ class CollectSharedEntryPlugin extends RspackBuiltinPlugin {
12747
12775
  super.apply(compiler), compiler.hooks.thisCompilation.tap('Collect shared entry', (compilation)=>{
12748
12776
  compilation.hooks.processAssets.tap({
12749
12777
  name: 'CollectSharedEntry',
12750
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
12778
+ stage: compiler.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE
12751
12779
  }, ()=>{
12752
12780
  compilation.getAssets().forEach((asset)=>{
12753
12781
  asset.name === SHARE_ENTRY_ASSET && (this._collectedEntries = JSON.parse(asset.source.source().toString())), compilation.deleteAsset(asset.name);
@@ -12868,7 +12896,7 @@ class VirtualEntryPlugin {
12868
12896
  }).apply(compiler), compiler.hooks.thisCompilation.tap('RemoveVirtualEntryAsset', (compilation)=>{
12869
12897
  compilation.hooks.processAssets.tap({
12870
12898
  name: 'RemoveVirtualEntryAsset',
12871
- stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
12899
+ stage: compiler.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE
12872
12900
  }, ()=>{
12873
12901
  try {
12874
12902
  let chunk = compilation.namedChunks.get(VIRTUAL_ENTRY_NAME);
@@ -12928,7 +12956,7 @@ class IndependentSharedPlugin {
12928
12956
  targetShared && item.forEach(([entry, version, globalName])=>{
12929
12957
  version === targetShared.version && (targetShared.fallback = entry, targetShared.fallbackName = globalName);
12930
12958
  });
12931
- }), compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(JSON.stringify(statsContent)));
12959
+ }), compilation.updateAsset(filename, new compiler.rspack.sources.RawSource(JSON.stringify(statsContent)));
12932
12960
  };
12933
12961
  injectBuildAssetsIntoStatsOrManifest(statsFileName), injectBuildAssetsIntoStatsOrManifest(manifestFileName);
12934
12962
  });
@@ -13082,7 +13110,7 @@ function getRemoteInfos(options) {
13082
13110
  external: Array.isArray(item) ? item : [
13083
13111
  item
13084
13112
  ],
13085
- shareScope: options.shareScope || 'default'
13113
+ shareScope: options.shareScope ?? 'default'
13086
13114
  }), (item)=>({
13087
13115
  external: Array.isArray(item.external) ? item.external : [
13088
13116
  item.external
@@ -13148,7 +13176,7 @@ function getDefaultEntryRuntime(paths, options, compiler, treeShakingShareFallba
13148
13176
  `const __module_federation_share_strategy__ = ${JSON.stringify(options.shareStrategy ?? 'version-first')}`,
13149
13177
  `const __module_federation_share_fallbacks__ = ${JSON.stringify(treeShakingShareFallbacks)}`,
13150
13178
  `const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
13151
- compiler.webpack.Template.getFunctionContent(ModuleFederationPlugin_require('./moduleFederationDefaultRuntime.js').default)
13179
+ compiler.rspack.Template.getFunctionContent(ModuleFederationPlugin_require('./moduleFederationDefaultRuntime.js').default)
13152
13180
  ].join(';');
13153
13181
  return `@module-federation/runtime/rspack.js!=!data:text/javascript,${encodeURIComponent(content)}`;
13154
13182
  }
@@ -13156,9 +13184,11 @@ class ContainerPlugin extends RspackBuiltinPlugin {
13156
13184
  name = binding_namespaceObject.BuiltinPluginName.ContainerPlugin;
13157
13185
  _options;
13158
13186
  constructor(options){
13159
- super(), this._options = {
13187
+ super();
13188
+ let shareScope = options.shareScope || 'default', enhanced = options.enhanced ?? !1;
13189
+ validateShareScope(shareScope, enhanced, 'ContainerPlugin'), this._options = {
13160
13190
  name: options.name,
13161
- shareScope: options.shareScope || 'default',
13191
+ shareScope,
13162
13192
  library: options.library || {
13163
13193
  type: 'global',
13164
13194
  name: options.name
@@ -13176,7 +13206,7 @@ class ContainerPlugin extends RspackBuiltinPlugin {
13176
13206
  ],
13177
13207
  name: item.name || void 0
13178
13208
  })),
13179
- enhanced: options.enhanced ?? !1
13209
+ enhanced
13180
13210
  };
13181
13211
  }
13182
13212
  raw(compiler) {
@@ -13201,20 +13231,25 @@ class ContainerReferencePlugin extends RspackBuiltinPlugin {
13201
13231
  name = binding_namespaceObject.BuiltinPluginName.ContainerReferencePlugin;
13202
13232
  _options;
13203
13233
  constructor(options){
13204
- super(), this._options = {
13234
+ super();
13235
+ let enhanced = options.enhanced ?? !1;
13236
+ options.shareScope && validateShareScope(options.shareScope, enhanced, 'ContainerReferencePlugin');
13237
+ let remotes = parseOptions(options.remotes, (item)=>({
13238
+ external: Array.isArray(item) ? item : [
13239
+ item
13240
+ ],
13241
+ shareScope: options.shareScope || 'default'
13242
+ }), (item)=>({
13243
+ external: Array.isArray(item.external) ? item.external : [
13244
+ item.external
13245
+ ],
13246
+ shareScope: item.shareScope || options.shareScope || 'default'
13247
+ }));
13248
+ for (let [, config] of remotes)validateShareScope(config.shareScope, enhanced, 'ContainerReferencePlugin');
13249
+ this._options = {
13205
13250
  remoteType: options.remoteType,
13206
- remotes: parseOptions(options.remotes, (item)=>({
13207
- external: Array.isArray(item) ? item : [
13208
- item
13209
- ],
13210
- shareScope: options.shareScope || 'default'
13211
- }), (item)=>({
13212
- external: Array.isArray(item.external) ? item.external : [
13213
- item.external
13214
- ],
13215
- shareScope: item.shareScope || options.shareScope || 'default'
13216
- })),
13217
- enhanced: options.enhanced ?? !1
13251
+ remotes,
13252
+ enhanced
13218
13253
  };
13219
13254
  }
13220
13255
  raw(compiler) {
@@ -13247,7 +13282,7 @@ async function transform(source, options) {
13247
13282
  let _options = JSON.stringify(options || {});
13248
13283
  return binding_default().transform(source, _options);
13249
13284
  }
13250
- let exports_rspackVersion = "2.0.0-beta.4", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
13285
+ let exports_rspackVersion = "2.0.0-beta.6", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
13251
13286
  getNormalizedRspackOptions: getNormalizedRspackOptions,
13252
13287
  applyRspackOptionsDefaults: applyRspackOptionsDefaults,
13253
13288
  getNormalizedWebpackOptions: getNormalizedRspackOptions,
@@ -1,10 +1,10 @@
1
1
  import { type BuiltinPlugin, BuiltinPluginName } from '@rspack/binding';
2
2
  import { RspackBuiltinPlugin } from '../builtin-plugin/base.js';
3
3
  import type { Compiler } from '../Compiler.js';
4
- import { type NormalizedSharedOptions } from './SharePlugin.js';
4
+ import { type NormalizedSharedOptions, type ShareScope } from './SharePlugin.js';
5
5
  export type CollectSharedEntryPluginOptions = {
6
6
  sharedOptions: NormalizedSharedOptions;
7
- shareScope?: string;
7
+ shareScope?: ShareScope;
8
8
  };
9
9
  export type ShareRequestsMap = Record<string, {
10
10
  shareScope: string;
@@ -3,7 +3,7 @@ import { RspackBuiltinPlugin } from '../builtin-plugin/base.js';
3
3
  import type { Compiler } from '../Compiler.js';
4
4
  export type ConsumeSharedPluginOptions = {
5
5
  consumes: Consumes;
6
- shareScope?: string;
6
+ shareScope?: string | string[];
7
7
  enhanced?: boolean;
8
8
  };
9
9
  export type Consumes = (ConsumesItem | ConsumesObject)[] | ConsumesObject;
@@ -17,14 +17,14 @@ export type ConsumesConfig = {
17
17
  packageName?: string;
18
18
  requiredVersion?: false | string;
19
19
  shareKey?: string;
20
- shareScope?: string;
20
+ shareScope?: string | string[];
21
21
  singleton?: boolean;
22
22
  strictVersion?: boolean;
23
23
  treeShakingMode?: 'server-calc' | 'runtime-infer';
24
24
  };
25
- export declare function normalizeConsumeShareOptions(consumes: Consumes, shareScope?: string): [string, {
25
+ export declare function normalizeConsumeShareOptions(consumes: Consumes, shareScope?: string | string[]): [string, {
26
26
  import: string | undefined;
27
- shareScope: string;
27
+ shareScope: string | string[];
28
28
  shareKey: string;
29
29
  requiredVersion: string | false | undefined;
30
30
  strictVersion: boolean;
@@ -38,7 +38,7 @@ export declare class ConsumeSharedPlugin extends RspackBuiltinPlugin {
38
38
  _options: {
39
39
  consumes: [string, {
40
40
  import: string | undefined;
41
- shareScope: string;
41
+ shareScope: string | string[];
42
42
  shareKey: string;
43
43
  requiredVersion: string | false | undefined;
44
44
  strictVersion: boolean;
@@ -1,9 +1,10 @@
1
1
  import { type BuiltinPlugin, BuiltinPluginName, type RawProvideOptions } from '@rspack/binding';
2
2
  import { RspackBuiltinPlugin } from '../builtin-plugin/base.js';
3
3
  import type { Compiler } from '../Compiler.js';
4
+ import type { ShareScope } from './SharePlugin.js';
4
5
  export type ProvideSharedPluginOptions<Enhanced extends boolean = false> = {
5
6
  provides: Provides<Enhanced>;
6
- shareScope?: string;
7
+ shareScope?: ShareScope;
7
8
  enhanced?: Enhanced;
8
9
  };
9
10
  export type Provides<Enhanced extends boolean> = (ProvidesItem | ProvidesObject<Enhanced>)[] | ProvidesObject<Enhanced>;
@@ -15,7 +16,7 @@ export type ProvidesConfig<Enhanced extends boolean> = Enhanced extends true ? P
15
16
  type ProvidesV1Config = {
16
17
  eager?: boolean;
17
18
  shareKey: string;
18
- shareScope?: string;
19
+ shareScope?: ShareScope;
19
20
  version?: false | string;
20
21
  };
21
22
  type ProvidesEnhancedConfig = ProvidesV1Config & ProvidesEnhancedExtraConfig;
@@ -28,10 +29,10 @@ type ProvidesEnhancedExtraConfig = {
28
29
  */
29
30
  treeShakingMode?: 'server-calc' | 'runtime-infer';
30
31
  };
31
- export declare function normalizeProvideShareOptions<Enhanced extends boolean = false>(options: Provides<Enhanced>, shareScope?: string, enhanced?: boolean): [string, {
32
+ export declare function normalizeProvideShareOptions<Enhanced extends boolean = false>(options: Provides<Enhanced>, shareScope?: ShareScope, enhanced?: boolean): [string, {
32
33
  shareKey: string;
33
34
  version: string | false | undefined;
34
- shareScope: string;
35
+ shareScope: ShareScope;
35
36
  eager: boolean;
36
37
  } | {
37
38
  singleton: boolean | undefined;
@@ -40,7 +41,7 @@ export declare function normalizeProvideShareOptions<Enhanced extends boolean =
40
41
  treeShakingMode: "server-calc" | "runtime-infer" | undefined;
41
42
  shareKey: string;
42
43
  version: string | false | undefined;
43
- shareScope: string;
44
+ shareScope: ShareScope;
44
45
  eager: boolean;
45
46
  }][];
46
47
  export declare class ProvideSharedPlugin<Enhanced extends boolean = false> extends RspackBuiltinPlugin {
@@ -1,6 +1,8 @@
1
1
  import type { Compiler } from '../Compiler.js';
2
+ export type ShareScope = string | string[];
3
+ export declare function validateShareScope(shareScope: ShareScope, enhanced: boolean, pluginName: string): void;
2
4
  export type SharePluginOptions = {
3
- shareScope?: string;
5
+ shareScope?: ShareScope;
4
6
  shared: Shared;
5
7
  enhanced: boolean;
6
8
  };
@@ -20,7 +22,7 @@ export type SharedConfig = {
20
22
  packageName?: string;
21
23
  requiredVersion?: false | string;
22
24
  shareKey?: string;
23
- shareScope?: string;
25
+ shareScope?: ShareScope;
24
26
  singleton?: boolean;
25
27
  strictVersion?: boolean;
26
28
  version?: false | string;
@@ -31,7 +33,7 @@ export declare function normalizeSharedOptions(shared: Shared): NormalizedShared
31
33
  export declare function createProvideShareOptions(normalizedSharedOptions: NormalizedSharedOptions): {
32
34
  [x: string]: {
33
35
  shareKey: string;
34
- shareScope: string | undefined;
36
+ shareScope: ShareScope | undefined;
35
37
  version: string | false | undefined;
36
38
  eager: boolean | undefined;
37
39
  singleton: boolean | undefined;
@@ -44,7 +46,7 @@ export declare function createConsumeShareOptions(normalizedSharedOptions: Norma
44
46
  [x: string]: {
45
47
  import: string | false | undefined;
46
48
  shareKey: string;
47
- shareScope: string | undefined;
49
+ shareScope: ShareScope | undefined;
48
50
  requiredVersion: string | false | undefined;
49
51
  strictVersion: boolean | undefined;
50
52
  singleton: boolean | undefined;
@@ -54,12 +56,12 @@ export declare function createConsumeShareOptions(normalizedSharedOptions: Norma
54
56
  };
55
57
  }[];
56
58
  export declare class SharePlugin {
57
- _shareScope: string | undefined;
59
+ _shareScope: ShareScope | undefined;
58
60
  _consumes: {
59
61
  [x: string]: {
60
62
  import: string | false | undefined;
61
63
  shareKey: string;
62
- shareScope: string | undefined;
64
+ shareScope: ShareScope | undefined;
63
65
  requiredVersion: string | false | undefined;
64
66
  strictVersion: boolean | undefined;
65
67
  singleton: boolean | undefined;
@@ -71,7 +73,7 @@ export declare class SharePlugin {
71
73
  _provides: {
72
74
  [x: string]: {
73
75
  shareKey: string;
74
- shareScope: string | undefined;
76
+ shareScope: ShareScope | undefined;
75
77
  version: string | false | undefined;
76
78
  eager: boolean | undefined;
77
79
  singleton: boolean | undefined;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Whether the current environment supports color output (TTY, FORCE_COLOR, NO_COLOR, etc.).
3
+ * Used as the default for stats.colors when not explicitly set.
4
+ * @see https://github.com/web-infra-dev/rspack/issues/9353
5
+ */
6
+ export declare function isStatsColorSupported(): boolean;