@rspack/core 1.6.0-beta.0 → 1.6.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 (42) hide show
  1. package/compiled/watchpack/index.js +1000 -3
  2. package/dist/Compilation.d.ts +13 -16
  3. package/dist/Compiler.d.ts +8 -0
  4. package/dist/MultiCompiler.d.ts +1 -0
  5. package/dist/MultiStats.d.ts +3 -2
  6. package/dist/RspackError.d.ts +3 -0
  7. package/dist/RuntimeGlobals.d.ts +3 -0
  8. package/dist/Watching.d.ts +9 -0
  9. package/dist/builtin-plugin/EsmLibraryPlugin.d.ts +6 -0
  10. package/dist/builtin-plugin/InlineExportsPlugin.d.ts +9 -0
  11. package/dist/builtin-plugin/SubresourceIntegrityPlugin.d.ts +0 -1
  12. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +2 -1
  13. package/dist/builtin-plugin/css-extract/index.d.ts +2 -2
  14. package/dist/builtin-plugin/html-plugin/options.d.ts +0 -1
  15. package/dist/builtin-plugin/index.d.ts +1 -0
  16. package/dist/config/defaults.d.ts +0 -9
  17. package/dist/config/devServer.d.ts +8 -8
  18. package/dist/config/normalization.d.ts +2 -0
  19. package/dist/config/types.d.ts +47 -8
  20. package/dist/cssExtractHmr.js +1 -2
  21. package/dist/exports.d.ts +1 -3
  22. package/dist/index.js +739 -4826
  23. package/dist/lib/Cache.d.ts +1 -1
  24. package/dist/loader-runner/ModuleError.d.ts +7 -1
  25. package/dist/loader-runner/service.d.ts +1 -1
  26. package/dist/stats/DefaultStatsFactoryPlugin.d.ts +16 -0
  27. package/dist/util/fs.d.ts +25 -2
  28. package/dist/util/index.d.ts +0 -3
  29. package/dist/util/source.d.ts +5 -6
  30. package/dist/util/validateConfig.d.ts +5 -0
  31. package/dist/worker.js +21 -8
  32. package/package.json +8 -10
  33. package/compiled/graceful-fs/index.d.ts +0 -13
  34. package/compiled/graceful-fs/index.js +0 -1063
  35. package/compiled/graceful-fs/license +0 -15
  36. package/compiled/graceful-fs/package.json +0 -1
  37. package/dist/loader-runner/ModuleWarning.d.ts +0 -7
  38. package/dist/schema/config.d.ts +0 -1030
  39. package/dist/schema/loaders.d.ts +0 -402
  40. package/dist/schema/plugins.d.ts +0 -167
  41. package/dist/schema/utils.d.ts +0 -5
  42. package/dist/schema/validate.d.ts +0 -10
@@ -13,7 +13,7 @@ export interface Etag {
13
13
  toString(): string;
14
14
  }
15
15
  export type CallbackCache<T> = (err?: WebpackError | null, result?: T) => void;
16
- type GotHandler = (result: any | null, callback: (error: Error | null) => void) => void;
16
+ type GotHandler<T = any> = (result: T | null, callback: (error: Error | null) => void) => void;
17
17
  export declare class Cache {
18
18
  static STAGE_DISK: number;
19
19
  static STAGE_MEMORY: number;
@@ -1,5 +1,11 @@
1
1
  import WebpackError from "../lib/WebpackError";
2
- export default class ModuleError extends WebpackError {
2
+ export declare class ModuleError extends WebpackError {
3
+ error?: Error;
4
+ constructor(err: Error, { from }?: {
5
+ from?: string;
6
+ });
7
+ }
8
+ export declare class ModuleWarning extends WebpackError {
3
9
  error?: Error;
4
10
  constructor(err: Error, { from }?: {
5
11
  from?: string;
@@ -61,7 +61,7 @@ export declare enum RequestType {
61
61
  export declare enum RequestSyncType {
62
62
  WaitForPendingRequest = "WaitForPendingRequest"
63
63
  }
64
- export type HandleIncomingRequest = (requestType: RequestType, ...args: any[]) => Promise<any> | any;
64
+ export type HandleIncomingRequest = (requestType: RequestType, ...args: any[]) => any;
65
65
  type WorkerArgs = any[];
66
66
  export type WorkerError = Error;
67
67
  export declare function serializeError(error: unknown): WorkerError;
@@ -1,4 +1,20 @@
1
1
  import type { Compiler } from "../Compiler";
2
+ export declare const SHARED_ITEM_NAMES: {
3
+ "compilation.children[]": string;
4
+ "compilation.modules[]": string;
5
+ "compilation.entrypoints[]": string;
6
+ "compilation.namedChunkGroups[]": string;
7
+ "compilation.errors[]": string;
8
+ "chunk.modules[]": string;
9
+ "chunk.origins[]": string;
10
+ "compilation.chunks[]": string;
11
+ "compilation.assets[]": string;
12
+ "asset.related[]": string;
13
+ "module.issuerPath[]": string;
14
+ "module.reasons[]": string;
15
+ "module.modules[]": string;
16
+ "module.children[]": string;
17
+ };
2
18
  export declare class DefaultStatsFactoryPlugin {
3
19
  apply(compiler: Compiler): void;
4
20
  }
package/dist/util/fs.d.ts CHANGED
@@ -68,6 +68,28 @@ interface IDirent {
68
68
  isSocket: () => boolean;
69
69
  name: string | Buffer;
70
70
  }
71
+ export interface StreamOptions {
72
+ flags?: string;
73
+ encoding?: NodeJS.BufferEncoding;
74
+ fd?: any;
75
+ mode?: number;
76
+ autoClose?: boolean;
77
+ emitClose?: boolean;
78
+ start?: number;
79
+ signal?: null | AbortSignal;
80
+ }
81
+ export interface FSImplementation {
82
+ open?: (...args: any[]) => any;
83
+ close?: (...args: any[]) => any;
84
+ }
85
+ export type CreateReadStreamFSImplementation = FSImplementation & {
86
+ read: (...args: any[]) => any;
87
+ };
88
+ export type ReadStreamOptions = StreamOptions & {
89
+ fs?: null | CreateReadStreamFSImplementation;
90
+ end?: number;
91
+ };
92
+ export type CreateReadStream = (path: PathLike, options?: NodeJS.BufferEncoding | ReadStreamOptions) => NodeJS.ReadableStream;
71
93
  export interface OutputFileSystem {
72
94
  writeFile: (arg0: string | number, arg1: string | Buffer, arg2: (arg0?: null | NodeJS.ErrnoException) => void) => void;
73
95
  mkdir: (arg0: string, arg1: (arg0?: null | NodeJS.ErrnoException) => void) => void;
@@ -81,6 +103,7 @@ export interface OutputFileSystem {
81
103
  join?: (arg0: string, arg1: string) => string;
82
104
  relative?: (arg0: string, arg1: string) => string;
83
105
  dirname?: (arg0: string) => string;
106
+ createReadStream?: CreateReadStream;
84
107
  }
85
108
  export type JsonPrimitive = string | number | boolean | null;
86
109
  export type JsonArray = JsonValue[];
@@ -326,9 +349,9 @@ export type Open = (file: PathLike, flags: undefined | string | number, callback
326
349
  export type IntermediateFileSystemExtras = {
327
350
  rename: (arg0: PathLike, arg1: PathLike, arg2: (arg0: null | NodeJS.ErrnoException) => void) => void;
328
351
  mkdirSync: MkdirSync;
329
- write: Write<Buffer>;
352
+ write: Write;
330
353
  open: Open;
331
- read: Read<Buffer>;
354
+ read: Read;
332
355
  close: (arg0: number, arg1: (arg0: null | NodeJS.ErrnoException) => void) => void;
333
356
  };
334
357
  export declare function rmrf(fs: OutputFileSystem, p: string, callback: (err?: Error | null) => void): void;
@@ -5,7 +5,4 @@ export declare const toObject: (input: string | Buffer | object) => object;
5
5
  export declare function serializeObject(map: string | object | undefined | null): Buffer | undefined;
6
6
  export declare function indent(str: string, prefix: string): string;
7
7
  export declare function stringifyLoaderObject(o: LoaderObject): string;
8
- export declare function asArray<T>(item: T[]): T[];
9
- export declare function asArray<T>(item: readonly T[]): readonly T[];
10
- export declare function asArray<T>(item: T): T[];
11
8
  export declare const unsupported: (name: string, issue?: string) => never;
@@ -1,7 +1,6 @@
1
- import type { JsCompatSourceOwned } from "@rspack/binding";
2
- import { Source } from "../../compiled/webpack-sources";
3
- declare class JsSource extends Source {
4
- static __from_binding(source: JsCompatSourceOwned): Source;
5
- static __to_binding(source: Source): JsCompatSourceOwned;
1
+ import type { JsSource } from "@rspack/binding";
2
+ import { type Source } from "../../compiled/webpack-sources";
3
+ export declare class SourceAdapter {
4
+ static fromBinding(source: JsSource): Source;
5
+ static toBinding(source: Source): JsSource;
6
6
  }
7
- export { JsSource };
@@ -0,0 +1,5 @@
1
+ import type { Configuration } from "../config";
2
+ /**
3
+ * Performs configuration validation that cannot be covered by TypeScript types.
4
+ */
5
+ export declare function validateRspackConfig(config: Configuration): void;
package/dist/worker.js CHANGED
@@ -206,10 +206,9 @@ var __webpack_modules__ = {
206
206
  "./src/util/createHash.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
207
207
  let createMd4, createXxhash64;
208
208
  __webpack_require__.d(__webpack_exports__, {
209
- n: ()=>createHash
209
+ n: ()=>createHash_createHash
210
210
  });
211
- let external_node_crypto_namespaceObject = require("node:crypto");
212
- var external_node_crypto_default = __webpack_require__.n(external_node_crypto_namespaceObject), external_node_util_ = __webpack_require__("node:util");
211
+ var external_node_util_ = __webpack_require__("node:util");
213
212
  class WebpackError_WebpackError extends Error {
214
213
  loc;
215
214
  file;
@@ -383,7 +382,7 @@ var __webpack_modules__ = {
383
382
  return encoding ? this.wasmHash.digest(encoding) : this.wasmHash.digest();
384
383
  }
385
384
  }
386
- let createHash = (algorithm)=>{
385
+ let createHash_createHash = (algorithm)=>{
387
386
  if ("function" == typeof algorithm) return new BulkUpdateDecorator(()=>new algorithm());
388
387
  switch(algorithm){
389
388
  case "debug":
@@ -405,15 +404,24 @@ var __webpack_modules__ = {
405
404
  return createMd4();
406
405
  })());
407
406
  case "native-md4":
408
- return new BulkUpdateDecorator(()=>external_node_crypto_default().createHash("md4"), "md4");
407
+ return new BulkUpdateDecorator(()=>{
408
+ let { createHash } = __webpack_require__("node:crypto");
409
+ return createHash("md4");
410
+ }, "md4");
409
411
  default:
410
- return new BulkUpdateDecorator(()=>external_node_crypto_default().createHash(algorithm), algorithm);
412
+ return new BulkUpdateDecorator(()=>{
413
+ let { createHash } = __webpack_require__("node:crypto");
414
+ return createHash(algorithm);
415
+ }, algorithm);
411
416
  }
412
417
  };
413
418
  },
414
419
  "@rspack/binding": function(module) {
415
420
  module.exports = require("@rspack/binding");
416
421
  },
422
+ "node:crypto": function(module) {
423
+ module.exports = require("node:crypto");
424
+ },
417
425
  "node:fs": function(module) {
418
426
  module.exports = require("node:fs");
419
427
  },
@@ -430,6 +438,11 @@ var __webpack_modules__ = {
430
438
  module.exports = import("../compiled/tinypool/dist/index.js").then(function(module) {
431
439
  return module;
432
440
  });
441
+ },
442
+ "node:worker_threads": function(module) {
443
+ module.exports = import("node:worker_threads").then(function(module) {
444
+ return module;
445
+ });
433
446
  }
434
447
  }, __webpack_module_cache__ = {};
435
448
  function __webpack_require__(moduleId) {
@@ -892,8 +905,8 @@ for(var __webpack_i__ in (()=>{
892
905
  currentLoaderObject.normalExecuted = !0, fn && (!function(args, raw) {
893
906
  if (!raw && args[0] instanceof Uint8Array) {
894
907
  var buf;
895
- let str;
896
- args[0] = (buf = args[0], 0xfeff === (str = decoder.decode(buf.buffer instanceof SharedArrayBuffer ? Buffer.from(buf) : buf)).charCodeAt(0) ? str.slice(1) : str);
908
+ let isShared, str;
909
+ args[0] = (isShared = (buf = args[0]).buffer instanceof SharedArrayBuffer || buf.buffer.constructor?.name === "SharedArrayBuffer", 0xfeff === (str = decoder.decode(isShared ? Buffer.from(buf) : buf)).charCodeAt(0) ? str.slice(1) : str);
897
910
  } else raw && "string" == typeof args[0] && (args[0] = Buffer.from(args[0], "utf-8"));
898
911
  raw && args[0] instanceof Uint8Array && !Buffer.isBuffer(args[0]) && (args[0] = Buffer.from(args[0].buffer));
899
912
  }(args, !!currentLoaderObject.raw), args = await utils_runSyncOrAsync(fn, loaderContext, args) || []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "1.6.0-beta.0",
3
+ "version": "1.6.0",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "The fast Rust-based web bundler with webpack-compatible API",
@@ -37,30 +37,28 @@
37
37
  "directory": "packages/rspack"
38
38
  },
39
39
  "devDependencies": {
40
- "@ast-grep/napi": "^0.39.6",
40
+ "@ast-grep/napi": "^0.39.7",
41
+ "@napi-rs/wasm-runtime": "1.0.7",
41
42
  "@rsbuild/plugin-node-polyfill": "^1.4.2",
42
- "@rslib/core": "0.15.0",
43
+ "@rslib/core": "0.16.1",
43
44
  "@swc/types": "0.1.25",
44
- "@types/graceful-fs": "4.1.9",
45
+ "@types/node": "^20.19.24",
45
46
  "@types/watchpack": "^2.4.4",
46
47
  "browserslist-load-config": "^1.0.1",
47
48
  "enhanced-resolve": "5.18.3",
48
49
  "glob-to-regexp": "^0.4.1",
49
- "graceful-fs": "^4.2.11",
50
50
  "memfs": "4.48.1",
51
51
  "prebundle": "^1.4.2",
52
52
  "tinypool": "^1.1.1",
53
53
  "tsx": "^4.20.6",
54
54
  "typescript": "^5.9.3",
55
55
  "watchpack": "^2.4.4",
56
- "webpack-sources": "3.3.3",
57
- "zod": "^3.25.76",
58
- "zod-validation-error": "3.5.3"
56
+ "webpack-sources": "3.3.3"
59
57
  },
60
58
  "dependencies": {
61
- "@module-federation/runtime-tools": "0.20.0",
59
+ "@module-federation/runtime-tools": "0.21.2",
62
60
  "@rspack/lite-tapable": "1.0.1",
63
- "@rspack/binding": "1.6.0-beta.0"
61
+ "@rspack/binding": "1.6.0"
64
62
  },
65
63
  "peerDependencies": {
66
64
  "@swc/helpers": ">=0.5.1"
@@ -1,13 +0,0 @@
1
- /// <reference types="node" />
2
- export * from 'fs';
3
-
4
- /**
5
- * Use this method to patch the global fs module (or any other fs-like module).
6
- * NOTE: This should only ever be done at the top-level application layer, in order to delay on
7
- * EMFILE errors from any fs-using dependencies. You should **not** do this in a library, because
8
- * it can cause unexpected delays in other parts of the program.
9
- * @param fsModule The reference to the fs module or an fs-like module.
10
- */
11
- declare function gracefulify<T>(fsModule: T): T;
12
-
13
- export { gracefulify };