@rspack/core 2.1.0-beta.0 → 2.1.0-rc.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.
@@ -1 +1 @@
1
- {"name":"webpack-sources","author":"Tobias Koppers @sokra","version":"3.3.4","license":"MIT","types":"types.d.ts","type":"commonjs"}
1
+ {"name":"webpack-sources","author":"Tobias Koppers @sokra","version":"3.5.0","license":"MIT","types":"types.d.ts","type":"commonjs"}
@@ -96,6 +96,22 @@ declare class CachedSource extends Source {
96
96
  onName: (nameIndex: number, name: string) => void,
97
97
  ): GeneratedSourceInfo;
98
98
  }
99
+ declare interface ClearCacheOptions {
100
+ /**
101
+ * drop cached source maps (default `true`)
102
+ */
103
+ maps?: boolean;
104
+
105
+ /**
106
+ * drop cached source/buffer copies (default `true`)
107
+ */
108
+ source?: boolean;
109
+
110
+ /**
111
+ * drop the parsed object form of cached source maps on `SourceMapSource` instances (default `false` — re-parsing JSON is significantly more expensive than `toString`). Only takes effect when a serialized form (buffer or string) is also retained, so the data remains recoverable.
112
+ */
113
+ parsedMap?: boolean;
114
+ }
99
115
  declare class CompatSource extends Source {
100
116
  constructor(sourceLike: SourceLike);
101
117
  static from(sourceLike: SourceLike): Source;
@@ -318,10 +334,24 @@ declare class Source {
318
334
  constructor();
319
335
  source(): SourceValue;
320
336
  buffer(): Buffer;
337
+ buffers(): Buffer[];
321
338
  size(): number;
322
339
  map(options?: MapOptions): null | RawSourceMap;
323
340
  sourceAndMap(options?: MapOptions): SourceAndMap;
324
341
  updateHash(hash: HashLike): void;
342
+
343
+ /**
344
+ * Release cached data held by this source. clearCache is a memory
345
+ * hint: it never affects correctness or output, only how expensive
346
+ * the next read is. Subclasses override; the base is a no-op so
347
+ * every Source supports the call. Composite sources always recurse
348
+ * into wrapped sources. When the same child is reachable via several
349
+ * parents (e.g. modules shared across webpack chunks), pass a shared
350
+ * `visited` WeakSet so each subtree is walked at most once.
351
+ * Not safe to call concurrently with source/map/sourceAndMap/
352
+ * streamChunks/updateHash on the same instance.
353
+ */
354
+ clearCache(options?: ClearCacheOptions, visited?: WeakSet<Source>): void;
325
355
  }
326
356
  declare interface SourceAndMap {
327
357
  /**
@@ -345,6 +375,11 @@ declare interface SourceLike {
345
375
  */
346
376
  buffer?: () => Buffer;
347
377
 
378
+ /**
379
+ * buffers
380
+ */
381
+ buffers?: () => Buffer[];
382
+
348
383
  /**
349
384
  * size
350
385
  */
@@ -364,6 +399,11 @@ declare interface SourceLike {
364
399
  * hash updater
365
400
  */
366
401
  updateHash?: (hash: HashLike) => void;
402
+
403
+ /**
404
+ * clear cache
405
+ */
406
+ clearCache?: (options?: ClearCacheOptions, visited?: WeakSet<Source>) => void;
367
407
  }
368
408
  declare class SourceMapSource extends Source {
369
409
  constructor(
@@ -458,4 +498,3 @@ declare interface StreamChunksOptions {
458
498
  };
459
499
 
460
500
 
461
-
@@ -39,7 +39,7 @@ export type ChunkLoading = false | ChunkLoadingType;
39
39
  /** Whether to create a load-on-demand asynchronous chunk for entry. */
40
40
  export type AsyncChunks = boolean;
41
41
  /** Option to set the method of loading WebAssembly Modules. */
42
- export type WasmLoadingType = LiteralUnion<'fetch-streaming' | 'fetch' | 'async-node', string>;
42
+ export type WasmLoadingType = 'fetch' | 'async-node' | 'universal';
43
43
  /** Option to set the method of loading WebAssembly Modules. */
44
44
  export type WasmLoading = false | WasmLoadingType;
45
45
  export type ScriptType = false | 'text/javascript' | 'module';
@@ -194,7 +194,7 @@ export type StrictModuleErrorHandling = boolean;
194
194
  /** Indicates what global object will be used to mount the library. */
195
195
  export type GlobalObject = string;
196
196
  /** List of wasm loading types enabled for use by entry points. */
197
- export type EnabledWasmLoadingTypes = string[];
197
+ export type EnabledWasmLoadingTypes = ('...' | WasmLoadingType)[];
198
198
  /** The name of the native import() function. */
199
199
  export type ImportFunctionName = string;
200
200
  /** The name of the native import.meta object. */
@@ -1380,14 +1380,15 @@ export type CacheStorageOptions = {
1380
1380
  directory?: string;
1381
1381
  /**
1382
1382
  * Maximum age of unused filesystem cache in seconds. Must be an integer
1383
- * between 0 and 4294967295.
1383
+ * between 1 and 4294967295, or Infinity to disable age-based cleanup.
1384
1384
  * @default 7 * 24 * 60 * 60
1385
1385
  */
1386
1386
  maxAge?: number;
1387
1387
  /**
1388
1388
  * Maximum number of filesystem cache generations to retain in the cache
1389
- * directory. Must be an integer between 0 and 4294967295.
1390
- * @default No generation count limit; maxAge cleanup still applies
1389
+ * directory. Must be an integer between 1 and 4294967295, or Infinity to
1390
+ * disable generation-based cleanup.
1391
+ * @default 3
1391
1392
  */
1392
1393
  maxGenerations?: number;
1393
1394
  };
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import { __webpack_require__ } from "./612.js";
8
8
  let __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
9
9
  import * as __rspack_external_node_util_1b29d436 from "node:util";
10
10
  __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__) {
11
+ "../../node_modules/.pnpm/enhanced-resolve@5.24.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;){
@@ -2037,10 +2037,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2037
2037
  return this.#createCachedAssets();
2038
2038
  }
2039
2039
  get entrypoints() {
2040
- return new Map(this.#inner.entrypoints.map((entrypoint)=>[
2041
- entrypoint.name,
2042
- entrypoint
2043
- ]));
2040
+ let entrypoints = new Map(), rawEntryPoints = this.#inner.entrypoints;
2041
+ for(let i = 0; i < rawEntryPoints.length; i++){
2042
+ let entrypoint = rawEntryPoints[i];
2043
+ entrypoints.set(entrypoint.name, entrypoint);
2044
+ }
2045
+ return entrypoints;
2044
2046
  }
2045
2047
  get chunkGroups() {
2046
2048
  return this.#inner.chunkGroups;
@@ -2130,25 +2132,16 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
2130
2132
  this.#inner.renameAsset(filename, newFilename);
2131
2133
  }
2132
2134
  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
- }));
2135
+ return this.#inner.getAssets().map((asset)=>this.#createAsset(asset));
2141
2136
  }
2142
2137
  getAsset(name) {
2143
2138
  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
- });
2139
+ if (asset) return this.#createAsset(asset);
2140
+ }
2141
+ #createAsset(asset) {
2142
+ return Object.defineProperty(asset, 'source', {
2143
+ get: ()=>this.__internal__getAssetSource(asset.name)
2144
+ }), asset;
2152
2145
  }
2153
2146
  __internal__pushRspackDiagnostic(diagnostic) {
2154
2147
  this.#inner.pushDiagnostic(diagnostic);
@@ -6721,7 +6714,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
6721
6714
  case 'persistent':
6722
6715
  D(cache, 'version', ''), F(cache, 'buildDependencies', ()=>[]), F(cache.snapshot, 'immutablePaths', ()=>[]), F(cache.snapshot, 'unmanagedPaths', ()=>[]), F(cache.snapshot, 'managedPaths', ()=>[
6723
6716
  /[\\/]node_modules[\\/][^.]/
6724
- ]), D(cache.storage, 'type', 'filesystem'), F(cache.storage, 'directory', ()=>{
6717
+ ]), D(cache.storage, 'type', 'filesystem'), D(cache.storage, 'maxAge', 604800), D(cache.storage, 'maxGenerations', 3), F(cache.storage, 'directory', ()=>{
6725
6718
  let modeName = mode || 'production', compilerName = name ? `${name}-${modeName}` : modeName, cacheName = compilerIndex ? `${compilerName}-${compilerIndex}` : compilerName;
6726
6719
  return node_path.resolve(context, 'node_modules/.cache/rspack', cacheName);
6727
6720
  }), D(cache, 'portable', !1), D(cache, 'readonly', !1);
@@ -7038,7 +7031,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
7038
7031
  return output.wasmLoading && enabledWasmLoadingTypes.add(output.wasmLoading), output.workerWasmLoading && enabledWasmLoadingTypes.add(output.workerWasmLoading), forEachEntry((desc)=>{
7039
7032
  desc.wasmLoading && enabledWasmLoadingTypes.add(desc.wasmLoading);
7040
7033
  }), 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));
7034
+ }), D(output, 'bundlerInfo', {}), 'object' == typeof output.bundlerInfo && (D(output.bundlerInfo, 'version', "2.1.0-rc.0"), D(output.bundlerInfo, 'bundler', 'rspack'), D(output.bundlerInfo, 'force', !1));
7042
7035
  }, applyExternalsPresetsDefaults = (externalsPresets, { targetProperties, buildHttp, outputModule })=>{
7043
7036
  let isUniversal = (key)=>!!(outputModule && targetProperties && null === targetProperties[key]);
7044
7037
  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')));
@@ -8336,7 +8329,7 @@ class MultiStats {
8336
8329
  obj.children = this.stats.map((stat, idx)=>{
8337
8330
  let obj = stat.toJson(childOptions.children[idx]), compilationName = stat.compilation.name;
8338
8331
  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(''));
8332
+ }), childOptions.version && (obj.rspackVersion = "2.1.0-rc.0", obj.version = "5.75.0"), childOptions.hash && (obj.hash = obj.children.map((j)=>j.hash).join(''));
8340
8333
  let mapError = (j, obj)=>({
8341
8334
  ...obj,
8342
8335
  compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
@@ -8845,7 +8838,7 @@ let arraySum = (array)=>{
8845
8838
  let str = `${a}`, length = lengths[i];
8846
8839
  return str.length === length ? str : length > 5 ? `...${str.slice(-length + 3)}` : length > 0 ? str.slice(-length) : '';
8847
8840
  });
8848
- }, CachedInputFileSystem = __webpack_require__("../../node_modules/.pnpm/enhanced-resolve@5.22.1/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js");
8841
+ }, CachedInputFileSystem = __webpack_require__("../../node_modules/.pnpm/enhanced-resolve@5.24.0/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js");
8849
8842
  var CachedInputFileSystem_default = __webpack_require__.n(CachedInputFileSystem);
8850
8843
  class NodeEnvironmentPlugin {
8851
8844
  options;
@@ -9610,7 +9603,7 @@ let iterateConfig = (config, options, fn)=>{
9610
9603
  object.hash = context.getStatsCompilation(compilation).hash;
9611
9604
  },
9612
9605
  version: (object)=>{
9613
- object.version = "5.75.0", object.rspackVersion = "2.1.0-beta.0";
9606
+ object.version = "5.75.0", object.rspackVersion = "2.1.0-rc.0";
9614
9607
  },
9615
9608
  env: (object, _compilation, _context, { _env })=>{
9616
9609
  object.env = _env;
@@ -10941,12 +10934,6 @@ function validateRspackConfig(config) {
10941
10934
  let { minChunks } = optimization.splitChunks;
10942
10935
  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
10936
  }
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
10937
  })(config), (({ output, externals, externalsType })=>{
10951
10938
  let library = output?.library;
10952
10939
  if (!('object' == typeof library && 'type' in library && 'umd' === library.type) || void 0 !== externalsType && 'umd' !== externalsType) return;
@@ -11277,7 +11264,7 @@ class TraceHookPlugin {
11277
11264
  });
11278
11265
  }
11279
11266
  }
11280
- let CORE_VERSION = "2.1.0-beta.0", VFILES_BY_COMPILER = new WeakMap();
11267
+ let CORE_VERSION = "2.1.0-rc.0", VFILES_BY_COMPILER = new WeakMap();
11281
11268
  class VirtualModulesPlugin {
11282
11269
  #staticModules;
11283
11270
  #compiler;
@@ -11848,7 +11835,7 @@ class Compiler {
11848
11835
  return this.#compilationParams = params, params;
11849
11836
  }
11850
11837
  #getInstance(callback) {
11851
- var output, cache;
11838
+ var output;
11852
11839
  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
11840
 
11854
11841
  Help:
@@ -11932,18 +11919,29 @@ Help:
11932
11919
  return delete obj.preset, obj;
11933
11920
  }(options.stats)).colors ? isStatsColorSupported() : !!statsOptions.colors
11934
11921
  },
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
- }),
11922
+ cache: function(cache) {
11923
+ if (!1 === cache) return !1;
11924
+ if ('memory' === cache.type) return cache;
11925
+ let toRawStorageLimit = (name, value)=>{
11926
+ if (value === 1 / 0) return 0;
11927
+ 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}\`.`);
11928
+ return value;
11929
+ };
11930
+ return {
11931
+ ...cache,
11932
+ storage: {
11933
+ ...cache.storage,
11934
+ directory: cache.storage.directory,
11935
+ maxAge: toRawStorageLimit('cache.storage.maxAge', cache.storage.maxAge),
11936
+ maxGenerations: toRawStorageLimit('cache.storage.maxGenerations', cache.storage.maxGenerations)
11937
+ },
11938
+ snapshot: {
11939
+ immutablePaths: cache.snapshot.immutablePaths,
11940
+ unmanagedPaths: cache.snapshot.unmanagedPaths,
11941
+ managedPaths: cache.snapshot.managedPaths
11942
+ }
11943
+ };
11944
+ }(options.cache),
11947
11945
  experiments,
11948
11946
  incremental: options.incremental,
11949
11947
  node: function(node) {
@@ -13687,7 +13685,7 @@ async function transform(source, options) {
13687
13685
  let _options = JSON.stringify(options || {});
13688
13686
  return binding_default().transform(source, _options);
13689
13687
  }
13690
- let exports_rspackVersion = "2.1.0-beta.0", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
13688
+ let exports_rspackVersion = "2.1.0-rc.0", exports_version = "5.75.0", exports_WebpackError = Error, exports_config = {
13691
13689
  getNormalizedRspackOptions: getNormalizedRspackOptions,
13692
13690
  applyRspackOptionsDefaults: applyRspackOptionsDefaults,
13693
13691
  getNormalizedWebpackOptions: getNormalizedRspackOptions,
@@ -9,10 +9,12 @@
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 {
13
14
  inputFileSystem: InputFileSystem;
14
15
  watcherOptions: Watchpack.WatchOptions;
15
- watcher?: Watchpack;
16
+ watcher?: WatchpackInstance;
16
17
  constructor(inputFileSystem: InputFileSystem);
17
18
  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;
18
19
  }
20
+ export {};
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-rc.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-rc.0"
62
62
  },
63
63
  "peerDependencies": {
64
64
  "@module-federation/runtime-tools": "^0.24.1 || ^2.0.0",