@rspack/core 2.1.0-beta.0 → 2.1.0

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/compiled/http-proxy-middleware/package.json +1 -1
  2. package/compiled/watchpack/index.js +474 -235
  3. package/compiled/watchpack/package.json +1 -1
  4. package/compiled/watchpack/types/DirectoryWatcher.d.ts +2 -0
  5. package/compiled/watchpack/types/index.d.ts +121 -113
  6. package/compiled/watchpack/types/util/globToRegExp.d.ts +2 -0
  7. package/compiled/watchpack/types/watchpack.d.ts +1 -1
  8. package/compiled/webpack-sources/index.js +953 -351
  9. package/compiled/webpack-sources/package.json +1 -1
  10. package/compiled/webpack-sources/types.d.ts +40 -1
  11. package/dist/Module.d.ts +0 -1
  12. package/dist/NativeWatchFileSystem.d.ts +29 -0
  13. package/dist/RuntimeGlobals.d.ts +0 -1
  14. package/dist/builtin-loader/swc/types.d.ts +1 -59
  15. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
  16. package/dist/builtin-plugin/html-plugin/options.d.ts +1 -1
  17. package/dist/config/normalization.d.ts +2 -2
  18. package/dist/config/types.d.ts +15 -14
  19. package/dist/index.js +116 -67
  20. package/dist/lib/HookWebpackError.d.ts +0 -1
  21. package/dist/lib/cache/getLazyHashedEtag.d.ts +1 -1
  22. package/dist/lib/cache/mergeEtags.d.ts +0 -1
  23. package/dist/node/NodeWatchFileSystem.d.ts +13 -1
  24. package/dist/rslib-runtime-worker.js +22 -0
  25. package/dist/rspack.d.ts +0 -1
  26. package/dist/sharing/IndependentSharedPlugin.d.ts +0 -1
  27. package/dist/stats/statsFactoryUtils.d.ts +0 -6
  28. package/dist/util/comparators.d.ts +1 -1
  29. package/dist/util/fake.d.ts +0 -3
  30. package/dist/util/fs.d.ts +9 -8
  31. package/dist/worker.js +1 -1
  32. package/package.json +7 -7
  33. /package/dist/{612.js → rslib-runtime-index.js} +0 -0
package/dist/index.js CHANGED
@@ -4,11 +4,12 @@ import { createRequire, createRequire as __rspack_createRequire } from "node:mod
4
4
  import node_path, { isAbsolute, join, relative, resolve as external_node_path_resolve, sep } from "node:path";
5
5
  import node_fs, { readFileSync } from "node:fs";
6
6
  import node_querystring from "node:querystring";
7
- import { __webpack_require__ } from "./612.js";
7
+ import { EventEmitter } from "node:events";
8
+ import { __webpack_require__ } from "./rslib-runtime-index.js";
8
9
  let __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
9
10
  import * as __rspack_external_node_util_1b29d436 from "node:util";
10
11
  __webpack_require__.add({
11
- "../../node_modules/.pnpm/enhanced-resolve@5.22.1/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js" (module, __unused_rspack_exports, __webpack_require__) {
12
+ "../../node_modules/.pnpm/enhanced-resolve@5.24.0/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js" (module, __unused_rspack_exports, __webpack_require__) {
12
13
  let { nextTick } = __webpack_require__("process"), dirname = (path)=>{
13
14
  let idx = path.length - 1;
14
15
  for(; idx >= 0;){
@@ -1218,7 +1219,7 @@ let concatComparatorsCache = new TwoKeyWeakMap(), concatComparators = (...comps)
1218
1219
  return null != aValue ? null != bValue ? comparator(aValue, bValue) : -1 : +(null != bValue);
1219
1220
  };
1220
1221
  return compareSelectCache.set(getter, comparator, result), result;
1221
- }, compareNumbers = (a, b)=>typeof a != typeof b ? typeof a < typeof b ? -1 : 1 : a < b ? -1 : +(a > b);
1222
+ };
1222
1223
  class StatsFactory {
1223
1224
  hooks;
1224
1225
  _caches;
@@ -2037,10 +2038,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2037
2038
  return this.#createCachedAssets();
2038
2039
  }
2039
2040
  get entrypoints() {
2040
- return new Map(this.#inner.entrypoints.map((entrypoint)=>[
2041
- entrypoint.name,
2042
- entrypoint
2043
- ]));
2041
+ let entrypoints = new Map(), rawEntryPoints = this.#inner.entrypoints;
2042
+ for(let i = 0; i < rawEntryPoints.length; i++){
2043
+ let entrypoint = rawEntryPoints[i];
2044
+ entrypoints.set(entrypoint.name, entrypoint);
2045
+ }
2046
+ return entrypoints;
2044
2047
  }
2045
2048
  get chunkGroups() {
2046
2049
  return this.#inner.chunkGroups;
@@ -2130,25 +2133,16 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2130
2133
  this.#inner.renameAsset(filename, newFilename);
2131
2134
  }
2132
2135
  getAssets() {
2133
- return this.#inner.getAssets().map((asset)=>Object.defineProperties(asset, {
2134
- info: {
2135
- value: asset.info
2136
- },
2137
- source: {
2138
- get: ()=>this.__internal__getAssetSource(asset.name)
2139
- }
2140
- }));
2136
+ return this.#inner.getAssets().map((asset)=>this.#createAsset(asset));
2141
2137
  }
2142
2138
  getAsset(name) {
2143
2139
  let asset = this.#inner.getAsset(name);
2144
- if (asset) return Object.defineProperties(asset, {
2145
- info: {
2146
- value: asset.info
2147
- },
2148
- source: {
2149
- get: ()=>this.__internal__getAssetSource(asset.name)
2150
- }
2151
- });
2140
+ if (asset) return this.#createAsset(asset);
2141
+ }
2142
+ #createAsset(asset) {
2143
+ return Object.defineProperty(asset, 'source', {
2144
+ get: ()=>this.__internal__getAssetSource(asset.name)
2145
+ }), asset;
2152
2146
  }
2153
2147
  __internal__pushRspackDiagnostic(diagnostic) {
2154
2148
  this.#inner.pushDiagnostic(diagnostic);
@@ -2852,7 +2846,7 @@ let toBuffer = (bufLike)=>{
2852
2846
  throw Error('Buffer, Uint8Array or string expected');
2853
2847
  };
2854
2848
  function serializeObject(map) {
2855
- if (!isNil(map)) return 'string' == typeof map ? map ? toBuffer(map) : void 0 : toBuffer(JSON.stringify(map));
2849
+ if (!isNil(map)) return 'string' == typeof map ? map ? Buffer.from(map) : void 0 : Buffer.from(JSON.stringify(map));
2856
2850
  }
2857
2851
  function stringifyLoaderObject(o) {
2858
2852
  return o.path + o.query + o.fragment;
@@ -3690,7 +3684,7 @@ let compilationOptionsMap = new WeakMap(), hooks_compilationHooksMap = new WeakM
3690
3684
  ...value
3691
3685
  };
3692
3686
  }
3693
- let scriptLoading = c.scriptLoading ?? 'defer', configInject = c.inject ?? !0, base = 'string' == typeof c.base ? {
3687
+ let scriptLoading = c.scriptLoading ?? (this.options.output.module ? 'module' : 'defer'), configInject = c.inject ?? !0, base = 'string' == typeof c.base ? {
3694
3688
  href: c.base
3695
3689
  } : c.base, chunksSortMode = c.chunksSortMode ?? 'auto', compilation = null;
3696
3690
  function generateRenderData(data) {
@@ -4927,7 +4921,7 @@ async function runLoaders(compiler, context) {
4927
4921
  break;
4928
4922
  case binding_namespaceObject.JsLoaderState.Normal:
4929
4923
  {
4930
- let content = context.content, sourceMap = JsSourceMap.__from_binding(context.sourceMap), additionalData = context.additionalData;
4924
+ let sourceMap, content = context.content, rawSourceMap = context.sourceMap, sourceMapParsed = !1, additionalData = context.additionalData;
4931
4925
  for(; loaderContext.loaderIndex >= 0;){
4932
4926
  let currentLoaderObject = loaderContext.loaders[loaderContext.loaderIndex], parallelism = enableParallelism(currentLoaderObject);
4933
4927
  if (currentLoaderObject.shouldYield()) break;
@@ -4937,13 +4931,13 @@ async function runLoaders(compiler, context) {
4937
4931
  }
4938
4932
  await utils_loadLoader(currentLoaderObject, compiler);
4939
4933
  let fn = currentLoaderObject.normal;
4940
- parallelism && fn || (currentLoaderObject.normalExecuted = !0), fn && ([content, sourceMap, additionalData] = await isomorphoicRun(fn, [
4934
+ parallelism && fn || (currentLoaderObject.normalExecuted = !0), fn && (sourceMapParsed || (sourceMap = JsSourceMap.__from_binding(rawSourceMap), sourceMapParsed = !0), [content, sourceMap, additionalData] = await isomorphoicRun(fn, [
4941
4935
  content,
4942
4936
  sourceMap,
4943
4937
  additionalData
4944
4938
  ]));
4945
4939
  }
4946
- context.content = isNil(content) ? null : toBuffer(content), context.sourceMap = JsSourceMap.__to_binding(sourceMap), context.additionalData = additionalData || void 0, context.__internal__utf8Hint = 'string' == typeof content;
4940
+ context.content = isNil(content) ? null : toBuffer(content), context.sourceMap = sourceMapParsed ? JsSourceMap.__to_binding(sourceMap) : rawSourceMap, context.additionalData = additionalData || void 0, context.__internal__utf8Hint = 'string' == typeof content;
4947
4941
  break;
4948
4942
  }
4949
4943
  default:
@@ -6719,7 +6713,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6719
6713
  case 'memory':
6720
6714
  break;
6721
6715
  case 'persistent':
6722
- D(cache, 'version', ''), F(cache, 'buildDependencies', ()=>[]), F(cache.snapshot, 'immutablePaths', ()=>[]), F(cache.snapshot, 'unmanagedPaths', ()=>[]), F(cache.snapshot, 'managedPaths', ()=>[
6716
+ D(cache, 'version', ''), D(cache, 'maxAge', 604800), D(cache, 'maxVersions', 3), F(cache, 'buildDependencies', ()=>[]), F(cache.snapshot, 'immutablePaths', ()=>[]), F(cache.snapshot, 'unmanagedPaths', ()=>[]), F(cache.snapshot, 'managedPaths', ()=>[
6723
6717
  /[\\/]node_modules[\\/][^.]/
6724
6718
  ]), D(cache.storage, 'type', 'filesystem'), F(cache.storage, 'directory', ()=>{
6725
6719
  let modeName = mode || 'production', compilerName = name ? `${name}-${modeName}` : modeName, cacheName = compilerIndex ? `${compilerName}-${compilerIndex}` : compilerName;
@@ -7038,7 +7032,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
7038
7032
  return output.wasmLoading && enabledWasmLoadingTypes.add(output.wasmLoading), output.workerWasmLoading && enabledWasmLoadingTypes.add(output.workerWasmLoading), forEachEntry((desc)=>{
7039
7033
  desc.wasmLoading && enabledWasmLoadingTypes.add(desc.wasmLoading);
7040
7034
  }), Array.from(enabledWasmLoadingTypes);
7041
- }), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.1.0-beta.0"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !1));
7035
+ }), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.1.0"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !1));
7042
7036
  }, applyExternalsPresetsDefaults = (externalsPresets, { targetProperties, buildHttp, outputModule })=>{
7043
7037
  let isUniversal = (key)=>!!(outputModule && targetProperties && null === targetProperties[key]);
7044
7038
  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')));
@@ -7357,6 +7351,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
7357
7351
  return {
7358
7352
  type: 'persistent',
7359
7353
  version: cache.version,
7354
+ maxAge: cache.maxAge,
7355
+ maxVersions: cache.maxVersions,
7360
7356
  portable: cache.portable,
7361
7357
  readonly: cache.readonly,
7362
7358
  buildDependencies: nestedArray(cache.buildDependencies, (deps)=>deps.map((d)=>node_path.resolve(context, d))),
@@ -7373,9 +7369,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
7373
7369
  })),
7374
7370
  storage: nestedConfig(cache.storage, (storage)=>({
7375
7371
  type: storage.type,
7376
- directory: optionalNestedConfig(storage.directory, (d)=>node_path.resolve(context, d)),
7377
- maxAge: storage.maxAge,
7378
- maxGenerations: storage.maxGenerations
7372
+ directory: optionalNestedConfig(storage.directory, (d)=>node_path.resolve(context, d))
7379
7373
  }))
7380
7374
  };
7381
7375
  }
@@ -8336,7 +8330,7 @@ class MultiStats {
8336
8330
  obj.children = this.stats.map((stat, idx)=>{
8337
8331
  let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
8338
8332
  return obj.name = compilationName && makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root), obj;
8339
- }), childOptions.version && (obj.rspackVersion = "2.1.0-beta.0", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
8333
+ }), childOptions.version && (obj.rspackVersion = "2.1.0", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
8340
8334
  let mapError = (j, obj)=>({
8341
8335
  ...obj,
8342
8336
  compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
@@ -8666,21 +8660,38 @@ let filterToFunction = (item)=>{
8666
8660
  true: 2,
8667
8661
  verbose: 1
8668
8662
  };
8663
+ class NativeWatcherShim extends EventEmitter {
8664
+ #trigger;
8665
+ constructor(trigger){
8666
+ super(), this.#trigger = trigger;
8667
+ }
8668
+ _onChange(item, _mtime, file, _type) {
8669
+ this.#trigger('change', file ?? item);
8670
+ }
8671
+ _onRemove(item, file, _type) {
8672
+ this.#trigger('remove', file ?? item);
8673
+ }
8674
+ }
8669
8675
  class NativeWatchFileSystem {
8670
8676
  #inner;
8671
8677
  #isFirstWatch = !0;
8672
8678
  #inputFileSystem;
8679
+ #events = new EventEmitter();
8680
+ #watcher;
8673
8681
  constructor(inputFileSystem){
8674
8682
  this.#inputFileSystem = inputFileSystem;
8675
8683
  }
8684
+ get watcher() {
8685
+ return this.#watcher;
8686
+ }
8676
8687
  watch(files, directories, missing, startTime, options, callback, callbackUndelayed) {
8677
8688
  if ((!files.added || 'function' != typeof files.added[Symbol.iterator]) && (!files.removed || 'function' != typeof files.removed[Symbol.iterator])) throw Error("Invalid arguments: 'files'");
8678
8689
  if ((!directories.added || 'function' != typeof directories.added[Symbol.iterator]) && (!directories.removed || 'function' != typeof directories.removed[Symbol.iterator])) throw Error("Invalid arguments: 'directories'");
8679
8690
  if ('function' != typeof callback) throw Error("Invalid arguments: 'callback'");
8680
8691
  if ('object' != typeof options) throw Error("Invalid arguments: 'options'");
8681
8692
  if ('function' != typeof callbackUndelayed && callbackUndelayed) throw Error("Invalid arguments: 'callbackUndelayed'");
8682
- let nativeWatcher = this.getNativeWatcher(options);
8683
- return nativeWatcher.watch(this.formatWatchDependencies(files), this.formatWatchDependencies(directories), this.formatWatchDependencies(missing), BigInt(startTime), (err, result)=>{
8693
+ let nativeWatcher = this.getNativeWatcher(options), watcher = new NativeWatcherShim((kind, path)=>this.#inner?.triggerEvent(kind, path));
8694
+ return this.#watcher = watcher, nativeWatcher.watch(this.formatWatchDependencies(files), this.formatWatchDependencies(directories), this.formatWatchDependencies(missing), BigInt(startTime), (err, result)=>{
8684
8695
  if (err) return void callback(err, new Map(), new Map(), new Set(), new Set());
8685
8696
  nativeWatcher.pause();
8686
8697
  let changedFiles = result.changedFiles, removedFiles = result.removedFiles;
@@ -8689,9 +8700,13 @@ class NativeWatchFileSystem {
8689
8700
  for (let item of changedFiles)fs.purge?.(item);
8690
8701
  for (let item of removedFiles)fs.purge?.(item);
8691
8702
  }
8692
- callback(err, new Map(), new Map(), new Set(changedFiles), new Set(removedFiles));
8693
- }, (fileName)=>{
8694
- callbackUndelayed(fileName, Date.now());
8703
+ let changes = new Set(changedFiles), removals = new Set(removedFiles);
8704
+ this.#events.emit('aggregated', changes, removals), watcher.emit('aggregated', changes, removals), callback(err, new Map(), new Map(), changes, removals);
8705
+ }, (event)=>{
8706
+ if ('change' === event.kind) {
8707
+ let mtime = Date.now();
8708
+ callbackUndelayed(event.path, mtime), this.#events.emit('change', event.path, mtime), watcher.emit('change', event.path, mtime);
8709
+ } else this.#events.emit('remove', event.path), watcher.emit('remove', event.path);
8695
8710
  }), this.#isFirstWatch = !1, {
8696
8711
  close: ()=>{
8697
8712
  nativeWatcher.close().then(()=>{
@@ -8727,6 +8742,19 @@ class NativeWatchFileSystem {
8727
8742
  triggerEvent(kind, path) {
8728
8743
  this.#inner?.triggerEvent(kind, path);
8729
8744
  }
8745
+ on(event, listener) {
8746
+ return this.#events.on(event, listener), this;
8747
+ }
8748
+ once(event, listener) {
8749
+ return this.#events.once(event, listener), this;
8750
+ }
8751
+ emit(event, arg1, arg2) {
8752
+ if ('aggregated' === event) {
8753
+ let notified = this.#events.emit('aggregated', arg1, arg2), shimNotified = this.#watcher?.emit('aggregated', arg1, arg2) ?? !1;
8754
+ return notified || shimNotified;
8755
+ }
8756
+ return !!this.#inner && (this.#inner.triggerEvent(event, arg1), !0);
8757
+ }
8730
8758
  formatWatchDependencies(dependencies) {
8731
8759
  return this.#isFirstWatch ? [
8732
8760
  Array.from(dependencies),
@@ -8742,6 +8770,7 @@ class NodeWatchFileSystem {
8742
8770
  inputFileSystem;
8743
8771
  watcherOptions;
8744
8772
  watcher;
8773
+ #events = new EventEmitter();
8745
8774
  constructor(inputFileSystem){
8746
8775
  this.inputFileSystem = inputFileSystem, this.watcherOptions = {
8747
8776
  aggregateTimeout: 0
@@ -8756,7 +8785,13 @@ class NodeWatchFileSystem {
8756
8785
  if ('object' != typeof options) throw Error("Invalid arguments: 'options'");
8757
8786
  if ('function' != typeof callbackUndelayed && callbackUndelayed) throw Error("Invalid arguments: 'callbackUndelayed'");
8758
8787
  let oldWatcher = this.watcher, Watchpack = NodeWatchFileSystem_require('../compiled/watchpack/index.js');
8759
- this.watcher = new Watchpack(options), callbackUndelayed && this.watcher?.once('change', callbackUndelayed);
8788
+ this.watcher = new Watchpack(options), callbackUndelayed && this.watcher?.once('change', callbackUndelayed), this.watcher?.on('change', (filename, mtime)=>{
8789
+ this.#events.emit('change', filename, mtime);
8790
+ }), this.watcher?.on('remove', (filename)=>{
8791
+ this.#events.emit('remove', filename);
8792
+ }), this.watcher?.on('aggregated', (changes, removals)=>{
8793
+ this.#events.emit('aggregated', changes, removals);
8794
+ });
8760
8795
  let fetchTimeInfo = ()=>{
8761
8796
  let fileTimeInfoEntries = new Map(), contextTimeInfoEntries = new Map();
8762
8797
  return this.watcher?.collectTimeInfoEntries(fileTimeInfoEntries, contextTimeInfoEntries), {
@@ -8819,6 +8854,15 @@ class NodeWatchFileSystem {
8819
8854
  }
8820
8855
  };
8821
8856
  }
8857
+ on(event, listener) {
8858
+ return this.#events.on(event, listener), this;
8859
+ }
8860
+ once(event, listener) {
8861
+ return this.#events.once(event, listener), this;
8862
+ }
8863
+ emit(event, arg1, arg2) {
8864
+ return 'aggregated' === event ? this.#events.emit('aggregated', arg1, arg2) : !!this.watcher && ('change' === event ? this.watcher._onChange(arg1, arg2 ?? Date.now(), arg1, 'change') : this.watcher._onRemove(arg1, arg1, 'rename'), !0);
8865
+ }
8822
8866
  }
8823
8867
  let arraySum = (array)=>{
8824
8868
  let sum = 0;
@@ -8845,7 +8889,7 @@ let arraySum = (array)=>{
8845
8889
  let str = `${a}`, length = lengths[i];
8846
8890
  return str.length === length ? str : length > 5 ? `...${str.slice(-length + 3)}` : length > 0 ? str.slice(-length) : '';
8847
8891
  });
8848
- }, CachedInputFileSystem = __webpack_require__("../../node_modules/.pnpm/enhanced-resolve@5.22.1/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js");
8892
+ }, CachedInputFileSystem = __webpack_require__("../../node_modules/.pnpm/enhanced-resolve@5.24.0/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js");
8849
8893
  var CachedInputFileSystem_default = __webpack_require__.n(CachedInputFileSystem);
8850
8894
  class NodeEnvironmentPlugin {
8851
8895
  options;
@@ -9458,7 +9502,7 @@ let iterateConfig = (config, options, fn)=>{
9458
9502
  'asset.related': ASSET_SORTERS
9459
9503
  }, MODULES_SORTER = {
9460
9504
  _: (comparators)=>{
9461
- comparators.push(compareSelect((m)=>m.commonAttributes.depth, compareNumbers), compareSelect((m)=>m.commonAttributes.preOrderIndex, compareNumbers), compareSelect((m)=>m.commonAttributes.moduleDescriptor?.identifier, compareIds));
9505
+ comparators.push(compareSelect((m)=>m.commonAttributes.depth, compareIds), compareSelect((m)=>m.commonAttributes.preOrderIndex, compareIds), compareSelect((m)=>m.commonAttributes.moduleDescriptor?.identifier, compareIds));
9462
9506
  }
9463
9507
  }, SORTERS = {
9464
9508
  'compilation.chunks': {
@@ -9610,7 +9654,7 @@ let iterateConfig = (config, options, fn)=>{
9610
9654
  object.hash = context.getStatsCompilation(compilation).hash;
9611
9655
  },
9612
9656
  version: (object)=>{
9613
- object.version = "5.75.0", object.rspackVersion = "2.1.0-beta.0";
9657
+ object.version = "5.75.0", object.rspackVersion = "2.1.0";
9614
9658
  },
9615
9659
  env: (object, _compilation, _context, { _env })=>{
9616
9660
  object.env = _env;
@@ -10941,12 +10985,6 @@ function validateRspackConfig(config) {
10941
10985
  let { minChunks } = optimization.splitChunks;
10942
10986
  if (void 0 !== minChunks && minChunks < 1) throw Error(`${validateConfig_ERROR_PREFIX} "optimization.splitChunks.minChunks" must be greater than or equal to 1, get \`${minChunks}\`.`);
10943
10987
  }
10944
- })(config), (({ cache })=>{
10945
- if ('object' != typeof cache || 'persistent' !== cache.type) return;
10946
- let maxAge = cache.storage?.maxAge;
10947
- if (void 0 !== maxAge && (!Number.isSafeInteger(maxAge) || maxAge < 0 || maxAge > 0xffffffff)) throw Error(`${validateConfig_ERROR_PREFIX} "cache.storage.maxAge" must be an integer between 0 and 4294967295, get \`${maxAge}\`.`);
10948
- let maxGenerations = cache.storage?.maxGenerations;
10949
- if (void 0 !== maxGenerations && (!Number.isSafeInteger(maxGenerations) || maxGenerations < 0 || maxGenerations > 0xffffffff)) throw Error(`${validateConfig_ERROR_PREFIX} "cache.storage.maxGenerations" must be an integer between 0 and 4294967295, get \`${maxGenerations}\`.`);
10950
10988
  })(config), (({ output, externals, externalsType })=>{
10951
10989
  let library = output?.library;
10952
10990
  if (!('object' == typeof library && 'type' in library && 'umd' === library.type) || void 0 !== externalsType && 'umd' !== externalsType) return;
@@ -11277,7 +11315,7 @@ class TraceHookPlugin {
11277
11315
  });
11278
11316
  }
11279
11317
  }
11280
- let CORE_VERSION = "2.1.0-beta.0", VFILES_BY_COMPILER = new WeakMap();
11318
+ let CORE_VERSION = "2.1.0", VFILES_BY_COMPILER = new WeakMap();
11281
11319
  class VirtualModulesPlugin {
11282
11320
  #staticModules;
11283
11321
  #compiler;
@@ -11848,7 +11886,7 @@ class Compiler {
11848
11886
  return this.#compilationParams = params, params;
11849
11887
  }
11850
11888
  #getInstance(callback) {
11851
- var output, cache;
11889
+ var output;
11852
11890
  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.
11853
11891
 
11854
11892
  Help:
@@ -11932,18 +11970,29 @@ Help:
11932
11970
  return delete obj.preset, obj;
11933
11971
  }(options.stats)).colors ? isStatsColorSupported() : !!statsOptions.colors
11934
11972
  },
11935
- cache: !1 !== (cache = options.cache) && ('memory' === cache.type ? cache : {
11936
- ...cache,
11937
- storage: {
11938
- ...cache.storage,
11939
- directory: cache.storage.directory
11940
- },
11941
- snapshot: {
11942
- immutablePaths: cache.snapshot.immutablePaths,
11943
- unmanagedPaths: cache.snapshot.unmanagedPaths,
11944
- managedPaths: cache.snapshot.managedPaths
11945
- }
11946
- }),
11973
+ cache: function(cache) {
11974
+ if (!1 === cache) return !1;
11975
+ if ('memory' === cache.type) return cache;
11976
+ let toRawStorageLimit = (name, value)=>{
11977
+ if (value === 1 / 0) return 0;
11978
+ if (!Number.isSafeInteger(value) || value < 1 || value > 0xffffffff) throw Error(`Invalid Rspack configuration: "${name}" must be a positive integer (1..4294967295) or Infinity, get \`${value}\`.`);
11979
+ return value;
11980
+ };
11981
+ return {
11982
+ ...cache,
11983
+ maxAge: toRawStorageLimit('cache.maxAge', cache.maxAge),
11984
+ maxVersions: toRawStorageLimit('cache.maxVersions', cache.maxVersions),
11985
+ storage: {
11986
+ ...cache.storage,
11987
+ directory: cache.storage.directory
11988
+ },
11989
+ snapshot: {
11990
+ immutablePaths: cache.snapshot.immutablePaths,
11991
+ unmanagedPaths: cache.snapshot.unmanagedPaths,
11992
+ managedPaths: cache.snapshot.managedPaths
11993
+ }
11994
+ };
11995
+ }(options.cache),
11947
11996
  experiments,
11948
11997
  incremental: options.incremental,
11949
11998
  node: function(node) {
@@ -13687,7 +13736,7 @@ async function transform(source, options) {
13687
13736
  let _options = JSON.stringify(options || {});
13688
13737
  return binding_default().transform(source, _options);
13689
13738
  }
13690
- let exports_rspackVersion = "2.1.0-beta.0", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
13739
+ let exports_rspackVersion = "2.1.0", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
13691
13740
  getNormalizedRspackOptions: getNormalizedRspackOptions,
13692
13741
  applyRspackOptionsDefaults: applyRspackOptionsDefaults,
13693
13742
  getNormalizedWebpackOptions: getNormalizedRspackOptions,
@@ -13933,7 +13982,7 @@ let exports_rspackVersion = "2.1.0-beta.0", exports_version = "5.75.0", exports_
13933
13982
  }
13934
13983
  }, src_fn = Object.assign(rspack_rspack, exports_namespaceObject);
13935
13984
  src_fn.rspack = src_fn, src_fn.webpack = src_fn;
13936
- let src_rspack_0 = src_fn;
13985
+ let src_rspack = src_fn;
13937
13986
  var AsyncDependenciesBlock = binding_namespaceObject.AsyncDependenciesBlock, ConcatenatedModule = binding_namespaceObject.ConcatenatedModule, ContextModule = binding_namespaceObject.ContextModule, Dependency = binding_namespaceObject.Dependency, EntryDependency = binding_namespaceObject.EntryDependency, ExternalModule = binding_namespaceObject.ExternalModule, Module = binding_namespaceObject.Module, NormalModule = binding_namespaceObject.NormalModule;
13938
- export default src_rspack_0;
13939
- export { AsyncDependenciesBlock, BannerPlugin, CaseSensitivePlugin, CircularCheckRspackPlugin, CircularDependencyRspackPlugin, Compilation, Compiler, ConcatenatedModule, ContextModule, ContextReplacementPlugin, CopyRspackPlugin, CssExtractRspackPlugin, DefaultRuntimeGlobals as RuntimeGlobals, DefinePlugin, Dependency, DllPlugin, DllReferencePlugin, DynamicEntryPlugin, EntryDependency, EntryPlugin, EnvironmentPlugin, EvalDevToolModulePlugin, EvalSourceMapDevToolPlugin, ExternalModule, ExternalsPlugin, HotModuleReplacementPlugin, HtmlRspackPlugin, IgnorePlugin, LightningCssMinimizerRspackPlugin, LoaderOptionsPlugin, LoaderTargetPlugin, Module, ModuleFilenameHelpers_namespaceObject as ModuleFilenameHelpers, ModuleGraphConnection, MultiCompiler, MultiStats, NoEmitOnErrorsPlugin, NormalModule, NormalModuleReplacementPlugin, ProgressPlugin, ProvidePlugin, RspackOptionsApply, RspackOptionsApply as WebpackOptionsApply, RuntimeModule, RuntimePlugin, SourceMapDevToolPlugin, Stats, SubresourceIntegrityPlugin, SwcJsMinimizerRspackPlugin, Template, ValidationError, container, electron, exports_WebpackError as WebpackError, exports_config as config, exports_experiments as experiments, exports_ids as ids, exports_library as library, exports_node as node, exports_rspackVersion as rspackVersion, exports_version as version, exports_wasm as wasm, index_js_namespaceObject as sources, javascript, lazyCompilationMiddleware, lib_EntryOptionPlugin as EntryOptionPlugin, optimize, sharing, src_rspack_0 as "module.exports", src_rspack_0 as rspack, statsFactoryUtils_StatsErrorCode as StatsErrorCode, util, web, webworker };
13987
+ export default src_rspack;
13988
+ export { AsyncDependenciesBlock, BannerPlugin, CaseSensitivePlugin, CircularCheckRspackPlugin, CircularDependencyRspackPlugin, Compilation, Compiler, ConcatenatedModule, ContextModule, ContextReplacementPlugin, CopyRspackPlugin, CssExtractRspackPlugin, DefaultRuntimeGlobals as RuntimeGlobals, DefinePlugin, Dependency, DllPlugin, DllReferencePlugin, DynamicEntryPlugin, EntryDependency, EntryPlugin, EnvironmentPlugin, EvalDevToolModulePlugin, EvalSourceMapDevToolPlugin, ExternalModule, ExternalsPlugin, HotModuleReplacementPlugin, HtmlRspackPlugin, IgnorePlugin, LightningCssMinimizerRspackPlugin, LoaderOptionsPlugin, LoaderTargetPlugin, Module, ModuleFilenameHelpers_namespaceObject as ModuleFilenameHelpers, ModuleGraphConnection, MultiCompiler, MultiStats, NoEmitOnErrorsPlugin, NormalModule, NormalModuleReplacementPlugin, ProgressPlugin, ProvidePlugin, RspackOptionsApply, RspackOptionsApply as WebpackOptionsApply, RuntimeModule, RuntimePlugin, SourceMapDevToolPlugin, Stats, SubresourceIntegrityPlugin, SwcJsMinimizerRspackPlugin, Template, ValidationError, container, electron, exports_WebpackError as WebpackError, exports_config as config, exports_experiments as experiments, exports_ids as ids, exports_library as library, exports_node as node, exports_rspackVersion as rspackVersion, exports_version as version, exports_wasm as wasm, index_js_namespaceObject as sources, javascript, lazyCompilationMiddleware, lib_EntryOptionPlugin as EntryOptionPlugin, optimize, sharing, src_rspack as "module.exports", src_rspack as rspack, statsFactoryUtils_StatsErrorCode as StatsErrorCode, util, web, webworker };
@@ -19,7 +19,6 @@ export declare class HookWebpackError extends WebpackError {
19
19
  */
20
20
  constructor(error: Error, hook: string);
21
21
  }
22
- export default HookWebpackError;
23
22
  /**
24
23
  * @param error an error
25
24
  * @param hook name of the hook
@@ -32,4 +32,4 @@ declare class LazyHashedEtag {
32
32
  * @returns etag
33
33
  */
34
34
  export declare const getter: (obj: HashableObject, hashFunction?: string | HashConstructor) => LazyHashedEtag;
35
- export default getter;
35
+ export {};
@@ -14,4 +14,3 @@ import type { Etag } from '../Cache.js';
14
14
  * @returns result
15
15
  */
16
16
  export declare const mergeEtags: (first: Etag, second: Etag) => Etag;
17
- export default mergeEtags;
@@ -9,10 +9,22 @@
9
9
  */
10
10
  import type Watchpack from '../../compiled/watchpack/index.js';
11
11
  import type { FileSystemInfoEntry, InputFileSystem, Watcher, WatchFileSystem } from '../util/fs.js';
12
+ type WatchpackInstance = InstanceType<typeof Watchpack>;
12
13
  export default class NodeWatchFileSystem implements WatchFileSystem {
14
+ #private;
13
15
  inputFileSystem: InputFileSystem;
14
16
  watcherOptions: Watchpack.WatchOptions;
15
- watcher?: Watchpack;
17
+ watcher?: WatchpackInstance;
16
18
  constructor(inputFileSystem: InputFileSystem);
17
19
  watch(files: Iterable<string>, directories: Iterable<string>, missing: Iterable<string>, startTime: number, options: Watchpack.WatchOptions, callback: (error: Error | null, fileTimeInfoEntries: Map<string, FileSystemInfoEntry | 'ignore'>, contextTimeInfoEntries: Map<string, FileSystemInfoEntry | 'ignore'>, changedFiles: Set<string>, removedFiles: Set<string>) => void, callbackUndelayed: (fileName: string, changeTime: number) => void): Watcher;
20
+ on(event: 'change', listener: (filename: string, mtime: number) => void): this;
21
+ on(event: 'remove', listener: (filename: string) => void): this;
22
+ on(event: 'aggregated', listener: (changes: Set<string>, removals: Set<string>) => void): this;
23
+ once(event: 'change', listener: (filename: string, mtime: number) => void): this;
24
+ once(event: 'remove', listener: (filename: string) => void): this;
25
+ once(event: 'aggregated', listener: (changes: Set<string>, removals: Set<string>) => void): this;
26
+ emit(event: 'change', filename: string, mtime: number): boolean;
27
+ emit(event: 'remove', filename: string): boolean;
28
+ emit(event: 'aggregated', changes: Set<string>, removals: Set<string>): boolean;
18
29
  }
30
+ export {};
@@ -0,0 +1,22 @@
1
+ var __webpack_require__ = {};
2
+ __webpack_require__.n = (module)=>{
3
+ var getter = module && module.__esModule ? ()=>module.default : ()=>module;
4
+ return __webpack_require__.d(getter, {
5
+ a: getter
6
+ }), getter;
7
+ }, __webpack_require__.d = (exports, getters, values)=>{
8
+ var define = (defs, kind)=>{
9
+ for(var key in defs)__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key) && Object.defineProperty(exports, key, {
10
+ enumerable: !0,
11
+ [kind]: defs[key]
12
+ });
13
+ };
14
+ define(getters, "get"), define(values, "value");
15
+ }, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports)=>{
16
+ "u" > typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ }), Object.defineProperty(exports, '__esModule', {
19
+ value: !0
20
+ });
21
+ };
22
+ export { __webpack_require__ };
package/dist/rspack.d.ts CHANGED
@@ -22,4 +22,3 @@ declare function rspack(options: MultiRspackOptions, callback?: Callback<Error,
22
22
  declare function rspack(options: RspackOptions, callback?: Callback<Error, Stats>): null | Compiler;
23
23
  declare function rspack(options: MultiRspackOptions | RspackOptions, callback?: Callback<Error, MultiStats | Stats>): null | MultiCompiler | Compiler;
24
24
  export { createCompiler, createMultiCompiler, MultiStats, rspack, Stats };
25
- export default rspack;
@@ -2,7 +2,6 @@ import type { Compiler } from '../Compiler.js';
2
2
  import type { LibraryOptions, Plugins } from '../config/index.js';
3
3
  import { type ModuleFederationManifestPluginOptions } from '../container/ModuleFederationManifestPlugin.js';
4
4
  import type { Shared, SharedConfig } from './SharePlugin.js';
5
- export type MakeRequired<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
6
5
  export interface IndependentSharePluginOptions {
7
6
  name: string;
8
7
  shared: Shared;
@@ -126,11 +126,6 @@ export type KnownStatsModule = {
126
126
  filteredModules?: number;
127
127
  source?: string | Buffer;
128
128
  };
129
- export type KnownStatsProfile = {
130
- total: number;
131
- resolving: number;
132
- building: number;
133
- };
134
129
  export type StatsModule = KnownStatsModule & Record<string, any>;
135
130
  export type KnownStatsModuleIssuer = {
136
131
  identifier?: string;
@@ -334,5 +329,4 @@ export declare const errorsSpaceLimit: (errors: StatsError[], max: number) => {
334
329
  errors: StatsError[];
335
330
  filtered: number;
336
331
  };
337
- export declare const warningFromStatsWarning: (warning: binding.JsStatsError) => Error;
338
332
  export {};
@@ -11,6 +11,6 @@ export type Comparator = <T>(arg0: T, arg1: T) => -1 | 0 | 1;
11
11
  type Selector<A, B> = (input: A) => B;
12
12
  export declare const concatComparators: (...comps: Comparator[]) => Comparator;
13
13
  export declare const compareIds: <T = string | number>(a: T, b: T) => -1 | 0 | 1;
14
- export declare const compareSelect: <T, R>(getter: Selector<T, R>, comparator: Comparator) => Comparator;
15
14
  export declare const compareNumbers: (a: number, b: number) => -1 | 0 | 1;
15
+ export declare const compareSelect: <T, R>(getter: Selector<T, R>, comparator: Comparator) => Comparator;
16
16
  export {};
@@ -1,6 +1,3 @@
1
- export type FakeHook<T> = T & {
2
- _fakeHook: true;
3
- };
4
1
  export declare function createFakeCompilationDependencies(getDeps: () => string[], addDeps: (deps: string[]) => void): {
5
2
  [Symbol.iterator](): Generator<string, void, unknown>;
6
3
  has: (dep: string) => boolean;
package/dist/util/fs.d.ts CHANGED
@@ -113,7 +113,6 @@ export type JsonObject = {
113
113
  } & {
114
114
  [Key in string]?: JsonValue | undefined;
115
115
  };
116
- export type NoParamCallback = (err: NodeJS.ErrnoException | null) => void;
117
116
  export type StringCallback = (err: NodeJS.ErrnoException | null, data?: string) => void;
118
117
  export type BufferCallback = (err: NodeJS.ErrnoException | null, data?: Buffer) => void;
119
118
  export type StringOrBufferCallback = (err: NodeJS.ErrnoException | null, data?: string | Buffer) => void;
@@ -124,7 +123,6 @@ export type ReaddirDirentCallback = (err: NodeJS.ErrnoException | null, files?:
124
123
  export type StatsCallback = (err: NodeJS.ErrnoException | null, stats?: IStats) => void;
125
124
  export type BigIntStatsCallback = (err: NodeJS.ErrnoException | null, stats?: IBigIntStats) => void;
126
125
  export type StatsOrBigIntStatsCallback = (err: NodeJS.ErrnoException | null, stats?: IStats | IBigIntStats) => void;
127
- export type NumberCallback = (err: NodeJS.ErrnoException | null, data?: number) => void;
128
126
  export type ReadJsonCallback = (err: NodeJS.ErrnoException | Error | null, data?: JsonObject) => void;
129
127
  export type PathLike = string | Buffer | URL;
130
128
  export type PathOrFileDescriptor = PathLike | number;
@@ -320,12 +318,6 @@ export type InputFileSystem = {
320
318
  dirname?: (path: string) => string;
321
319
  };
322
320
  export type IntermediateFileSystem = InputFileSystem & OutputFileSystem & IntermediateFileSystemExtras;
323
- export type WriteStreamOptions = {
324
- flags?: string;
325
- encoding?: 'ascii' | 'utf8' | 'utf-8' | 'utf16le' | 'utf-16le' | 'ucs2' | 'ucs-2' | 'latin1' | 'binary' | 'base64' | 'base64url' | 'hex';
326
- fd?: any;
327
- mode?: number;
328
- };
329
321
  export type MakeDirectoryOptions = {
330
322
  recursive?: boolean;
331
323
  mode?: string | number;
@@ -371,5 +363,14 @@ export interface WatchFileSystem {
371
363
  added?: Iterable<String>;
372
364
  removed?: Iterable<String>;
373
365
  }, startTime: number, options: WatchOptions, callback: (error: Error | null, fileTimeInfoEntries: Map<string, FileSystemInfoEntry | 'ignore'>, contextTimeInfoEntries: Map<string, FileSystemInfoEntry | 'ignore'>, changedFiles: Set<string>, removedFiles: Set<string>) => void, callbackUndelayed: (fileName: string, changeTime: number) => void): Watcher;
366
+ on?(event: 'change', listener: (filename: string, mtime: number) => void): this;
367
+ on?(event: 'remove', listener: (filename: string) => void): this;
368
+ on?(event: 'aggregated', listener: (changes: Set<string>, removals: Set<string>) => void): this;
369
+ once?(event: 'change', listener: (filename: string, mtime: number) => void): this;
370
+ once?(event: 'remove', listener: (filename: string) => void): this;
371
+ once?(event: 'aggregated', listener: (changes: Set<string>, removals: Set<string>) => void): this;
372
+ emit?(event: 'change', filename: string, mtime: number): boolean;
373
+ emit?(event: 'remove', filename: string): boolean;
374
+ emit?(event: 'aggregated', changes: Set<string>, removals: Set<string>): boolean;
374
375
  }
375
376
  export {};
package/dist/worker.js CHANGED
@@ -1,5 +1,5 @@
1
1
  let createMd4, createXxhash64, url;
2
- import { __webpack_require__ } from "./612.js";
2
+ import { __webpack_require__ } from "./rslib-runtime-worker.js";
3
3
  import node_fs from "node:fs";
4
4
  import node_querystring from "node:querystring";
5
5
  import { inspect, promisify } from "node:util";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "2.1.0-beta.0",
3
+ "version": "2.1.0",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "Fast Rust-based bundler for the web with a modernized webpack API",
@@ -40,25 +40,25 @@
40
40
  "@ast-grep/napi": "^0.43.0",
41
41
  "@napi-rs/wasm-runtime": "1.1.5",
42
42
  "@rsbuild/plugin-node-polyfill": "^1.4.6",
43
- "@rslib/core": "^0.22.1",
43
+ "@rslib/core": "^0.23.0",
44
44
  "@rspack/lite-tapable": "1.1.2",
45
45
  "@swc/types": "0.1.27",
46
46
  "@types/node": "^20.19.43",
47
47
  "browserslist-load-config": "^1.0.3",
48
48
  "browserslist-to-es-version": "^1.4.2",
49
49
  "connect-next": "^4.0.3",
50
- "enhanced-resolve": "5.22.1",
51
- "http-proxy-middleware": "^4.1.0",
50
+ "enhanced-resolve": "5.24.0",
51
+ "http-proxy-middleware": "^4.1.1",
52
52
  "memfs": "4.57.7",
53
53
  "open": "^11.0.0",
54
54
  "prebundle": "^1.6.5",
55
55
  "tinypool": "^2.1.0",
56
56
  "typescript": "^6.0.3",
57
- "watchpack": "2.5.1",
58
- "webpack-sources": "3.3.4"
57
+ "watchpack": "2.5.2",
58
+ "webpack-sources": "3.5.0"
59
59
  },
60
60
  "dependencies": {
61
- "@rspack/binding": "2.1.0-beta.0"
61
+ "@rspack/binding": "2.1.0"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@module-federation/runtime-tools": "^0.24.1 || ^2.0.0",
File without changes