@rspack/core 2.0.0-beta.5 → 2.0.0-beta.7

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.
Files changed (33) hide show
  1. package/README.md +1 -1
  2. package/compiled/connect-next/index.d.ts +56 -0
  3. package/compiled/connect-next/license +26 -0
  4. package/compiled/connect-next/package.json +1 -0
  5. package/compiled/http-proxy-middleware/index.d.ts +544 -0
  6. package/compiled/http-proxy-middleware/license +22 -0
  7. package/compiled/http-proxy-middleware/package.json +1 -0
  8. package/compiled/open/index.d.ts +161 -0
  9. package/compiled/open/package.json +1 -0
  10. package/dist/builtin-loader/swc/types.d.ts +17 -1
  11. package/dist/builtin-plugin/RsdoctorPlugin.d.ts +2 -2
  12. package/dist/builtin-plugin/WorkerPlugin.d.ts +1 -0
  13. package/dist/builtin-plugin/lazy-compilation/middleware.d.ts +2 -2
  14. package/dist/builtin-plugin/rsc/RscServerPlugin.d.ts +25 -0
  15. package/dist/checkNodeVersion.d.ts +1 -0
  16. package/dist/config/devServer.d.ts +102 -237
  17. package/dist/config/types.d.ts +2 -5
  18. package/dist/container/ContainerPlugin.d.ts +3 -2
  19. package/dist/container/ContainerReferencePlugin.d.ts +4 -3
  20. package/dist/container/ModuleFederationPlugin.d.ts +2 -1
  21. package/dist/container/ModuleFederationPluginV1.d.ts +2 -2
  22. package/dist/index.d.ts +1 -0
  23. package/dist/index.js +109 -74
  24. package/dist/rslib-runtime.js +3 -3
  25. package/dist/sharing/CollectSharedEntryPlugin.d.ts +2 -2
  26. package/dist/sharing/ConsumeSharedPlugin.d.ts +5 -5
  27. package/dist/sharing/ProvideSharedPlugin.d.ts +6 -5
  28. package/dist/sharing/SharePlugin.d.ts +9 -7
  29. package/hot/dev-server.js +1 -1
  30. package/hot/emitter.js +0 -2
  31. package/hot/log.js +0 -2
  32. package/hot/only-dev-server.js +1 -1
  33. package/package.json +12 -11
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import node_path, { isAbsolute, join, relative, resolve as external_node_path_re
8
8
  import node_querystring from "node:querystring";
9
9
  import node_fs, { readFileSync } from "node:fs";
10
10
  __webpack_require__.add({
11
- "../../node_modules/.pnpm/enhanced-resolve@5.19.0/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js" (module, __unused_rspack_exports, __webpack_require__) {
11
+ "../../node_modules/.pnpm/enhanced-resolve@5.20.0/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js" (module, __unused_rspack_exports, __webpack_require__) {
12
12
  let { nextTick } = __webpack_require__("process"), dirname = (path)=>{
13
13
  let idx = path.length - 1;
14
14
  for(; idx >= 0;){
@@ -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) {
@@ -1549,7 +1554,8 @@ class MergeCaller {
1549
1554
  return this.callArgs;
1550
1555
  }
1551
1556
  push(...data) {
1552
- 0 === this.callArgs.length && queueMicrotask(this.finalCall), this.callArgs.push(...data);
1557
+ 0 === this.callArgs.length && queueMicrotask(this.finalCall);
1558
+ for(let i = 0; i < data.length; i++)this.callArgs.push(data[i]);
1553
1559
  }
1554
1560
  }
1555
1561
  function createFakeCompilationDependencies(getDeps, addDeps) {
@@ -2977,6 +2983,25 @@ function toFeatures(featureOptions) {
2977
2983
  }
2978
2984
  return feature;
2979
2985
  }
2986
+ function resolvePluginImport(pluginImport) {
2987
+ if (pluginImport) return pluginImport.map((config)=>{
2988
+ let rawConfig = {
2989
+ ...config,
2990
+ style: {}
2991
+ };
2992
+ if ('boolean' == typeof config.style) rawConfig.style.bool = config.style;
2993
+ else if ('string' == typeof config.style) {
2994
+ let isTpl = config.style.includes('{{');
2995
+ rawConfig.style[isTpl ? 'custom' : 'css'] = config.style;
2996
+ } else {
2997
+ var val;
2998
+ val = config.style, '[object Object]' === Object.prototype.toString.call(val) && (rawConfig.style = config.style);
2999
+ }
3000
+ return config.styleLibraryDirectory && (rawConfig.style = {
3001
+ styleLibraryDirectory: config.styleLibraryDirectory
3002
+ }), rawConfig;
3003
+ });
3004
+ }
2980
3005
  let $assets = Symbol('assets');
2981
3006
  Object.defineProperty(binding_default().KnownBuildInfo.prototype, node_util.inspect.custom, {
2982
3007
  enumerable: !0,
@@ -4175,27 +4200,9 @@ function createRawModuleRuleUses(uses, path, options) {
4175
4200
  options.collectTypeScriptInfo && (options.collectTypeScriptInfo = {
4176
4201
  typeExports: (options1 = options.collectTypeScriptInfo).typeExports,
4177
4202
  exportedEnum: !0 === options1.exportedEnum ? 'all' : !1 === options1.exportedEnum || void 0 === options1.exportedEnum ? 'none' : 'const-only'
4178
- });
4203
+ }), options.transformImport && (options.transformImport = resolvePluginImport(options.transformImport));
4179
4204
  let { rspackExperiments } = options;
4180
- rspackExperiments && (rspackExperiments.import || rspackExperiments.pluginImport) && (rspackExperiments.import = function(pluginImport) {
4181
- if (pluginImport) return pluginImport.map((config)=>{
4182
- let rawConfig = {
4183
- ...config,
4184
- style: {}
4185
- };
4186
- if ('boolean' == typeof config.style) rawConfig.style.bool = config.style;
4187
- else if ('string' == typeof config.style) {
4188
- let isTpl = config.style.includes('{{');
4189
- rawConfig.style[isTpl ? 'custom' : 'css'] = config.style;
4190
- } else {
4191
- var val;
4192
- val = config.style, '[object Object]' === Object.prototype.toString.call(val) && (rawConfig.style = config.style);
4193
- }
4194
- return config.styleLibraryDirectory && (rawConfig.style = {
4195
- styleLibraryDirectory: config.styleLibraryDirectory
4196
- }), rawConfig;
4197
- });
4198
- }(rspackExperiments.import || rspackExperiments.pluginImport));
4205
+ rspackExperiments && (rspackExperiments.import || rspackExperiments.pluginImport) && (rspackExperiments.import = resolvePluginImport(rspackExperiments.import || rspackExperiments.pluginImport));
4199
4206
  }
4200
4207
  return options;
4201
4208
  })(o, options);
@@ -5144,9 +5151,13 @@ class RscServerPlugin extends RspackBuiltinPlugin {
5144
5151
  super(), this.#options = options;
5145
5152
  }
5146
5153
  raw(compiler) {
5147
- return this.#options.coordinator.applyServerCompiler(compiler), createBuiltinPlugin(this.name, {
5148
- coordinator: this.#options.coordinator[GET_OR_INIT_BINDING](),
5149
- onServerComponentChanges: this.#options.onServerComponentChanges
5154
+ let onManifest;
5155
+ this.#options.coordinator.applyServerCompiler(compiler);
5156
+ let { coordinator, onServerComponentChanges } = this.#options;
5157
+ return this.#options.onManifest && (onManifest = (json)=>Promise.resolve(this.#options.onManifest(JSON.parse(json)))), createBuiltinPlugin(this.name, {
5158
+ coordinator: coordinator[GET_OR_INIT_BINDING](),
5159
+ onServerComponentChanges,
5160
+ onManifest
5150
5161
  });
5151
5162
  }
5152
5163
  }
@@ -5294,23 +5305,37 @@ let SwcJsMinimizerRspackPlugin = base_create(binding_namespaceObject.BuiltinPlug
5294
5305
  exclude: options?.exclude,
5295
5306
  extractComments: function(extractComments) {
5296
5307
  let type, conditionStr = (condition)=>{
5297
- if (void 0 === condition || !0 === condition) return '@preserve|@lic|@cc_on|^\\**!';
5308
+ if (void 0 === condition || !0 === condition) return {
5309
+ source: '@preserve|@lic|@cc_on|^\\**!',
5310
+ flags: ''
5311
+ };
5298
5312
  if (!1 === condition) throw Error('unreachable');
5299
- return condition.source;
5313
+ return {
5314
+ source: condition.source,
5315
+ flags: condition.flags
5316
+ };
5300
5317
  };
5301
5318
  if ('boolean' == typeof extractComments) {
5302
5319
  if (!extractComments) return;
5320
+ let { source, flags } = conditionStr(extractComments);
5303
5321
  return {
5304
- condition: conditionStr(extractComments)
5322
+ condition: source,
5323
+ conditionFlags: flags
5324
+ };
5325
+ }
5326
+ if (extractComments instanceof RegExp) {
5327
+ let { source, flags } = conditionStr(extractComments);
5328
+ return {
5329
+ condition: source,
5330
+ conditionFlags: flags
5305
5331
  };
5306
5332
  }
5307
- if (extractComments instanceof RegExp) return {
5308
- condition: extractComments.source
5309
- };
5310
5333
  if (type = typeof extractComments, null != extractComments && ('object' === type || 'function' === type)) {
5311
5334
  if (!1 === extractComments.condition) return;
5335
+ let { source, flags } = conditionStr(extractComments.condition);
5312
5336
  return {
5313
- condition: conditionStr(extractComments.condition),
5337
+ condition: source,
5338
+ conditionFlags: flags,
5314
5339
  banner: extractComments.banner
5315
5340
  };
5316
5341
  }
@@ -5337,6 +5362,7 @@ class WorkerPlugin extends RspackBuiltinPlugin {
5337
5362
  module;
5338
5363
  workerPublicPath;
5339
5364
  name = binding_namespaceObject.BuiltinPluginName.WorkerPlugin;
5365
+ affectedHooks = 'compilation';
5340
5366
  constructor(chunkLoading, wasmLoading, module, workerPublicPath){
5341
5367
  super(), this.chunkLoading = chunkLoading, this.wasmLoading = wasmLoading, this.module = module, this.workerPublicPath = workerPublicPath;
5342
5368
  }
@@ -6495,7 +6521,6 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6495
6521
  }), F(options, 'performance', ()=>!!production && !!targetProperties && (!!targetProperties.browser || null === targetProperties.browser) && {}), applyPerformanceDefaults(options.performance, {
6496
6522
  production
6497
6523
  }), options.resolve = cleverMerge(getResolveDefaults({
6498
- context: options.context,
6499
6524
  targetProperties,
6500
6525
  mode: options.mode
6501
6526
  }), options.resolve), options.resolveLoader = cleverMerge(getResolveLoaderDefaults(), options.resolveLoader), !1 === targetProperties ? targetProperties : {
@@ -6550,7 +6575,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6550
6575
  type: "javascript/auto"
6551
6576
  },
6552
6577
  {
6553
- test: /\.json$/i,
6578
+ test: /\.json$/,
6554
6579
  type: 'json'
6555
6580
  },
6556
6581
  {
@@ -6558,22 +6583,22 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6558
6583
  type: 'json'
6559
6584
  },
6560
6585
  {
6561
- test: /\.mjs$/i,
6586
+ test: /\.mjs$/,
6562
6587
  ...esm
6563
6588
  },
6564
6589
  {
6565
- test: /\.js$/i,
6590
+ test: /\.js$/,
6566
6591
  descriptionData: {
6567
6592
  type: 'module'
6568
6593
  },
6569
6594
  ...esm
6570
6595
  },
6571
6596
  {
6572
- test: /\.cjs$/i,
6597
+ test: /\.cjs$/,
6573
6598
  ...commonjs
6574
6599
  },
6575
6600
  {
6576
- test: /\.js$/i,
6601
+ test: /\.js$/,
6577
6602
  descriptionData: {
6578
6603
  type: 'commonjs'
6579
6604
  },
@@ -6604,7 +6629,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6604
6629
  ]
6605
6630
  };
6606
6631
  rules.push({
6607
- test: /\.wasm$/i,
6632
+ test: /\.wasm$/,
6608
6633
  ...wasm
6609
6634
  }), rules.push({
6610
6635
  mimetype: 'application/wasm',
@@ -6791,7 +6816,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6791
6816
  return output.wasmLoading && enabledWasmLoadingTypes.add(output.wasmLoading), output.workerWasmLoading && enabledWasmLoadingTypes.add(output.workerWasmLoading), forEachEntry((desc)=>{
6792
6817
  desc.wasmLoading && enabledWasmLoadingTypes.add(desc.wasmLoading);
6793
6818
  }), Array.from(enabledWasmLoadingTypes);
6794
- }), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-beta.5"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !output.library));
6819
+ }), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.0.0-beta.7"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !output.library));
6795
6820
  }, applyExternalsPresetsDefaults = (externalsPresets, { targetProperties, buildHttp, outputModule })=>{
6796
6821
  let isUniversal = (key)=>!!(outputModule && targetProperties && null === targetProperties[key]);
6797
6822
  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')));
@@ -6809,7 +6834,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6809
6834
  }, applyPerformanceDefaults = (performance, { production })=>{
6810
6835
  !1 !== performance && (D(performance, 'maxAssetSize', 250000), D(performance, 'maxEntrypointSize', 250000), F(performance, 'hints', ()=>!!production && 'warning'));
6811
6836
  }, applyOptimizationDefaults = (optimization, { production, development })=>{
6812
- D(optimization, 'removeAvailableModules', !0), D(optimization, 'removeEmptyChunks', !0), D(optimization, 'mergeDuplicateChunks', !0), F(optimization, 'moduleIds', ()=>production ? 'deterministic' : development ? 'named' : 'natural'), F(optimization, 'chunkIds', ()=>production ? 'deterministic' : development ? 'named' : 'natural'), F(optimization, 'sideEffects', ()=>!!production || 'flag'), D(optimization, 'mangleExports', production), D(optimization, 'inlineExports', production), D(optimization, 'providedExports', !0), D(optimization, 'usedExports', production), D(optimization, 'innerGraph', production), D(optimization, 'emitOnErrors', !production), D(optimization, 'runtimeChunk', !1), D(optimization, 'realContentHash', production), D(optimization, 'avoidEntryIife', !1), D(optimization, 'minimize', production), D(optimization, 'concatenateModules', production), A(optimization, 'minimizer', ()=>[
6837
+ D(optimization, 'removeEmptyChunks', !0), D(optimization, 'mergeDuplicateChunks', !0), F(optimization, 'moduleIds', ()=>production ? 'deterministic' : development ? 'named' : 'natural'), F(optimization, 'chunkIds', ()=>production ? 'deterministic' : development ? 'named' : 'natural'), F(optimization, 'sideEffects', ()=>!!production || 'flag'), D(optimization, 'mangleExports', production), D(optimization, 'inlineExports', production), D(optimization, 'providedExports', !0), D(optimization, 'usedExports', production), D(optimization, 'innerGraph', production), D(optimization, 'emitOnErrors', !production), D(optimization, 'runtimeChunk', !1), D(optimization, 'realContentHash', production), D(optimization, 'avoidEntryIife', !1), D(optimization, 'minimize', production), D(optimization, 'concatenateModules', production), A(optimization, 'minimizer', ()=>[
6813
6838
  new SwcJsMinimizerRspackPlugin(),
6814
6839
  new LightningCssMinimizerRspackPlugin()
6815
6840
  ]), F(optimization, 'nodeEnv', ()=>production ? 'production' : !!development && 'development');
@@ -6829,7 +6854,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6829
6854
  })), F(cacheGroups, 'defaultVendors', ()=>({
6830
6855
  idHint: 'vendors',
6831
6856
  reuseExistingChunk: !0,
6832
- test: /[\\/]node_modules[\\/]/i,
6857
+ test: /[\\/]node_modules[\\/]/,
6833
6858
  priority: -10
6834
6859
  })));
6835
6860
  }
@@ -6852,15 +6877,14 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6852
6877
  mainFiles: [
6853
6878
  'index'
6854
6879
  ]
6855
- }), getResolveDefaults = ({ context, targetProperties, mode })=>{
6880
+ }), getResolveDefaults = ({ targetProperties, mode })=>{
6856
6881
  let conditions = [
6857
6882
  'webpack'
6858
6883
  ];
6859
6884
  conditions.push('development' === mode ? 'development' : 'production'), targetProperties && (targetProperties.webworker && conditions.push('worker'), targetProperties.node && conditions.push('node'), targetProperties.web && conditions.push('browser'), targetProperties.electron && conditions.push('electron'), targetProperties.nwjs && conditions.push('nwjs'));
6860
6885
  let jsExtensions = [
6861
6886
  '.js',
6862
- '.json',
6863
- '.wasm'
6887
+ '.json'
6864
6888
  ], browserField = targetProperties && targetProperties.web && (!targetProperties.node || targetProperties.electron && targetProperties.electronRenderer), aliasFields = browserField ? [
6865
6889
  'browser'
6866
6890
  ] : [], mainFields = browserField ? [
@@ -6906,9 +6930,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6906
6930
  exportsFields: [
6907
6931
  'exports'
6908
6932
  ],
6909
- roots: [
6910
- context
6911
- ],
6933
+ roots: [],
6912
6934
  mainFields: [
6913
6935
  'main'
6914
6936
  ],
@@ -6931,14 +6953,17 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6931
6953
  loader: cjsDeps(),
6932
6954
  unknown: cjsDeps()
6933
6955
  }
6934
- }, styleConditions = [];
6935
- return styleConditions.push('webpack'), styleConditions.push('development' === mode ? 'development' : 'production'), styleConditions.push('style'), resolveOptions.byDependency['css-import'] = {
6956
+ };
6957
+ return resolveOptions.byDependency['css-import'] = {
6936
6958
  mainFiles: [],
6937
6959
  mainFields: [
6938
6960
  'style',
6939
6961
  '...'
6940
6962
  ],
6941
- conditionNames: styleConditions,
6963
+ conditionNames: [
6964
+ 'development' === mode ? 'development' : 'production',
6965
+ 'style'
6966
+ ],
6942
6967
  extensions: [
6943
6968
  '.css'
6944
6969
  ],
@@ -8045,7 +8070,7 @@ class MultiStats {
8045
8070
  obj.children = this.stats.map((stat, idx)=>{
8046
8071
  let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
8047
8072
  return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
8048
- }), childOptions.version && (obj.rspackVersion = "2.0.0-beta.5", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
8073
+ }), childOptions.version && (obj.rspackVersion = "2.0.0-beta.7", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
8049
8074
  let mapError = (j, obj)=>({
8050
8075
  ...obj,
8051
8076
  compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
@@ -8542,7 +8567,7 @@ let arraySum = (array)=>{
8542
8567
  let str = `${a}`, length = lengths[i];
8543
8568
  return str.length === length ? str : length > 5 ? `...${str.slice(-length + 3)}` : length > 0 ? str.slice(-length) : '';
8544
8569
  });
8545
- }, CachedInputFileSystem = __webpack_require__("../../node_modules/.pnpm/enhanced-resolve@5.19.0/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js");
8570
+ }, CachedInputFileSystem = __webpack_require__("../../node_modules/.pnpm/enhanced-resolve@5.20.0/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js");
8546
8571
  var CachedInputFileSystem_default = __webpack_require__.n(CachedInputFileSystem);
8547
8572
  class NodeEnvironmentPlugin {
8548
8573
  options;
@@ -9304,7 +9329,7 @@ let iterateConfig = (config, options, fn)=>{
9304
9329
  object.hash = context.getStatsCompilation(compilation).hash;
9305
9330
  },
9306
9331
  version: (object)=>{
9307
- object.version = "5.75.0", object.rspackVersion = "2.0.0-beta.5";
9332
+ object.version = "5.75.0", object.rspackVersion = "2.0.0-beta.7";
9308
9333
  },
9309
9334
  env: (object, _compilation, _context, { _env })=>{
9310
9335
  object.env = _env;
@@ -10969,7 +10994,7 @@ class TraceHookPlugin {
10969
10994
  });
10970
10995
  }
10971
10996
  }
10972
- let CORE_VERSION = "2.0.0-beta.5", VFILES_BY_COMPILER = new WeakMap();
10997
+ let CORE_VERSION = "2.0.0-beta.7", VFILES_BY_COMPILER = new WeakMap();
10973
10998
  class VirtualModulesPlugin {
10974
10999
  #staticModules;
10975
11000
  #compiler;
@@ -12550,6 +12575,9 @@ class ProvideSharedPlugin extends RspackBuiltinPlugin {
12550
12575
  return createBuiltinPlugin(this.name, rawOptions);
12551
12576
  }
12552
12577
  }
12578
+ function validateShareScope(shareScope, enhanced, pluginName) {
12579
+ 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)}`);
12580
+ }
12553
12581
  function normalizeSharedOptions(shared) {
12554
12582
  return parseOptions(shared, (item, key)=>{
12555
12583
  if ('string' != typeof item) throw Error('Unexpected array in shared');
@@ -13088,7 +13116,7 @@ function getRemoteInfos(options) {
13088
13116
  external: Array.isArray(item) ? item : [
13089
13117
  item
13090
13118
  ],
13091
- shareScope: options.shareScope || 'default'
13119
+ shareScope: options.shareScope ?? 'default'
13092
13120
  }), (item)=>({
13093
13121
  external: Array.isArray(item.external) ? item.external : [
13094
13122
  item.external
@@ -13162,9 +13190,11 @@ class ContainerPlugin extends RspackBuiltinPlugin {
13162
13190
  name = binding_namespaceObject.BuiltinPluginName.ContainerPlugin;
13163
13191
  _options;
13164
13192
  constructor(options){
13165
- super(), this._options = {
13193
+ super();
13194
+ let shareScope = options.shareScope || 'default', enhanced = options.enhanced ?? !1;
13195
+ validateShareScope(shareScope, enhanced, 'ContainerPlugin'), this._options = {
13166
13196
  name: options.name,
13167
- shareScope: options.shareScope || 'default',
13197
+ shareScope,
13168
13198
  library: options.library || {
13169
13199
  type: 'global',
13170
13200
  name: options.name
@@ -13182,7 +13212,7 @@ class ContainerPlugin extends RspackBuiltinPlugin {
13182
13212
  ],
13183
13213
  name: item.name || void 0
13184
13214
  })),
13185
- enhanced: options.enhanced ?? !1
13215
+ enhanced
13186
13216
  };
13187
13217
  }
13188
13218
  raw(compiler) {
@@ -13207,20 +13237,25 @@ class ContainerReferencePlugin extends RspackBuiltinPlugin {
13207
13237
  name = binding_namespaceObject.BuiltinPluginName.ContainerReferencePlugin;
13208
13238
  _options;
13209
13239
  constructor(options){
13210
- super(), this._options = {
13240
+ super();
13241
+ let enhanced = options.enhanced ?? !1;
13242
+ options.shareScope && validateShareScope(options.shareScope, enhanced, 'ContainerReferencePlugin');
13243
+ let remotes = parseOptions(options.remotes, (item)=>({
13244
+ external: Array.isArray(item) ? item : [
13245
+ item
13246
+ ],
13247
+ shareScope: options.shareScope || 'default'
13248
+ }), (item)=>({
13249
+ external: Array.isArray(item.external) ? item.external : [
13250
+ item.external
13251
+ ],
13252
+ shareScope: item.shareScope || options.shareScope || 'default'
13253
+ }));
13254
+ for (let [, config] of remotes)validateShareScope(config.shareScope, enhanced, 'ContainerReferencePlugin');
13255
+ this._options = {
13211
13256
  remoteType: options.remoteType,
13212
- remotes: parseOptions(options.remotes, (item)=>({
13213
- external: Array.isArray(item) ? item : [
13214
- item
13215
- ],
13216
- shareScope: options.shareScope || 'default'
13217
- }), (item)=>({
13218
- external: Array.isArray(item.external) ? item.external : [
13219
- item.external
13220
- ],
13221
- shareScope: item.shareScope || options.shareScope || 'default'
13222
- })),
13223
- enhanced: options.enhanced ?? !1
13257
+ remotes,
13258
+ enhanced
13224
13259
  };
13225
13260
  }
13226
13261
  raw(compiler) {
@@ -13253,7 +13288,7 @@ async function transform(source, options) {
13253
13288
  let _options = JSON.stringify(options || {});
13254
13289
  return binding_default().transform(source, _options);
13255
13290
  }
13256
- let exports_rspackVersion = "2.0.0-beta.5", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
13291
+ let exports_rspackVersion = "2.0.0-beta.7", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
13257
13292
  getNormalizedRspackOptions: getNormalizedRspackOptions,
13258
13293
  applyRspackOptionsDefaults: applyRspackOptionsDefaults,
13259
13294
  getNormalizedWebpackOptions: getNormalizedRspackOptions,
@@ -7,9 +7,7 @@ function __webpack_require__(moduleId) {
7
7
  };
8
8
  return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.exports;
9
9
  }
10
- __webpack_require__.m = __webpack_modules__, __webpack_require__.add = function(modules) {
11
- Object.assign(__webpack_require__.m, modules);
12
- }, __webpack_require__.n = (module)=>{
10
+ __webpack_require__.m = __webpack_modules__, __webpack_require__.n = (module)=>{
13
11
  var getter = module && module.__esModule ? ()=>module.default : ()=>module;
14
12
  return __webpack_require__.d(getter, {
15
13
  a: getter
@@ -19,6 +17,8 @@ __webpack_require__.m = __webpack_modules__, __webpack_require__.add = function(
19
17
  enumerable: !0,
20
18
  get: definition[key]
21
19
  });
20
+ }, __webpack_require__.add = function(modules) {
21
+ Object.assign(__webpack_require__.m, modules);
22
22
  }, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports)=>{
23
23
  "u" > typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports, Symbol.toStringTag, {
24
24
  value: 'Module'
@@ -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;
package/hot/dev-server.js CHANGED
@@ -28,7 +28,7 @@ if (import.meta.webpackHot) {
28
28
  );
29
29
  log(
30
30
  'warning',
31
- '[HMR] (Probably because of restarting the webpack-dev-server)',
31
+ '[HMR] (Probably because of restarting the rspack-dev-server)',
32
32
  );
33
33
  if (typeof window !== 'undefined') {
34
34
  window.location.reload();
package/hot/emitter.js CHANGED
@@ -20,6 +20,4 @@ EventEmitter.prototype.emit = function (eventName) {
20
20
 
21
21
  var emitter = new EventEmitter();
22
22
 
23
- // TODO: remove default export when rspack-dev-server refactored
24
- export default emitter;
25
23
  export { emitter };
package/hot/log.js CHANGED
@@ -84,6 +84,4 @@ log.groupEnd = groupEnd;
84
84
  log.setLogLevel = setLogLevel;
85
85
  log.formatError = formatError;
86
86
 
87
- // TODO: remove default export when rspack-dev-server refactored
88
- export default log;
89
87
  export { log };
@@ -22,7 +22,7 @@ if (import.meta.webpackHot) {
22
22
  log('warning', '[HMR] Cannot find update. Need to do a full reload!');
23
23
  log(
24
24
  'warning',
25
- '[HMR] (Probably because of restarting the webpack-dev-server)',
25
+ '[HMR] (Probably because of restarting the rspack-dev-server)',
26
26
  );
27
27
  return;
28
28
  }