@rspack/core 1.6.0-beta.0 → 1.6.0-beta.1

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.
@@ -153,7 +153,7 @@ export declare class Compilation {
153
153
  log: liteTapable.SyncBailHook<[string, LogEntry], true>;
154
154
  additionalAssets: any;
155
155
  optimizeModules: liteTapable.SyncBailHook<Iterable<Module>, void>;
156
- afterOptimizeModules: liteTapable.SyncHook<Iterable<Module>, void>;
156
+ afterOptimizeModules: liteTapable.SyncHook<Iterable<Module>>;
157
157
  optimizeTree: liteTapable.AsyncSeriesHook<[
158
158
  Iterable<Chunk>,
159
159
  Iterable<Module>
@@ -163,21 +163,18 @@ export declare class Compilation {
163
163
  Iterable<Module>
164
164
  ], void>;
165
165
  finishModules: liteTapable.AsyncSeriesHook<[Iterable<Module>], void>;
166
- chunkHash: liteTapable.SyncHook<[Chunk, Hash], void>;
167
- chunkAsset: liteTapable.SyncHook<[Chunk, string], void>;
166
+ chunkHash: liteTapable.SyncHook<[Chunk, Hash]>;
167
+ chunkAsset: liteTapable.SyncHook<[Chunk, string]>;
168
168
  processWarnings: liteTapable.SyncWaterfallHook<[WebpackError[]]>;
169
- succeedModule: liteTapable.SyncHook<[Module], void>;
170
- stillValidModule: liteTapable.SyncHook<[Module], void>;
171
- statsPreset: liteTapable.HookMap<liteTapable.SyncHook<[
172
- Partial<StatsOptions>,
173
- CreateStatsOptionsContext
174
- ], void>>;
169
+ succeedModule: liteTapable.SyncHook<[Module]>;
170
+ stillValidModule: liteTapable.SyncHook<[Module]>;
171
+ statsPreset: liteTapable.HookMap<liteTapable.SyncHook<[Partial<StatsOptions>, CreateStatsOptionsContext]>>;
175
172
  statsNormalize: liteTapable.SyncHook<[
176
173
  Partial<StatsOptions>,
177
174
  CreateStatsOptionsContext
178
- ], void>;
179
- statsFactory: liteTapable.SyncHook<[StatsFactory, StatsOptions], void>;
180
- statsPrinter: liteTapable.SyncHook<[StatsPrinter, StatsOptions], void>;
175
+ ]>;
176
+ statsFactory: liteTapable.SyncHook<[StatsFactory, StatsOptions]>;
177
+ statsPrinter: liteTapable.SyncHook<[StatsPrinter, StatsOptions]>;
181
178
  buildModule: liteTapable.SyncHook<[Module]>;
182
179
  executeModule: liteTapable.SyncHook<[
183
180
  ExecuteModuleArgument,
@@ -186,10 +183,10 @@ export declare class Compilation {
186
183
  additionalTreeRuntimeRequirements: liteTapable.SyncHook<[
187
184
  Chunk,
188
185
  Set<string>
189
- ], void>;
186
+ ]>;
190
187
  runtimeRequirementInTree: liteTapable.HookMap<liteTapable.SyncBailHook<[Chunk, Set<string>], void>>;
191
- runtimeModule: liteTapable.SyncHook<[JsRuntimeModule, Chunk], void>;
192
- seal: liteTapable.SyncHook<[], void>;
188
+ runtimeModule: liteTapable.SyncHook<[JsRuntimeModule, Chunk]>;
189
+ seal: liteTapable.SyncHook<[]>;
193
190
  afterSeal: liteTapable.AsyncSeriesHook<[], void>;
194
191
  needAdditionalPass: liteTapable.SyncBailHook<[], boolean>;
195
192
  }>;
@@ -411,7 +408,7 @@ export declare class Entries implements Map<string, EntryData> {
411
408
  entries(): ReturnType<Map<string, EntryData>["entries"]>;
412
409
  values(): ReturnType<Map<string, EntryData>["values"]>;
413
410
  [Symbol.iterator](): ReturnType<Map<string, EntryData>["entries"]>;
414
- get [Symbol.toStringTag](): string;
411
+ readonly [Symbol.toStringTag] = "Map";
415
412
  has(key: string): boolean;
416
413
  set(key: string, value: EntryData): this;
417
414
  delete(key: string): boolean;
@@ -107,6 +107,14 @@ declare class Compiler {
107
107
  cache: Cache;
108
108
  compilerPath: string;
109
109
  options: RspackOptionsNormalized;
110
+ /**
111
+ * Whether to skip dropping Rust compiler instance to improve performance.
112
+ * This is an internal option api and could be removed or changed at any time.
113
+ * @internal
114
+ * true: Skip dropping Rust compiler instance.
115
+ * false: Drop Rust compiler instance when Compiler is garbage collected.
116
+ */
117
+ unsafeFastDrop: boolean;
110
118
  /**
111
119
  * Note: This is not a webpack public API, maybe removed in future.
112
120
  * @internal
@@ -41,6 +41,7 @@ export declare class MultiCompiler {
41
41
  running: boolean;
42
42
  watching?: MultiWatching;
43
43
  constructor(compilers: Compiler[] | Record<string, Compiler>, options?: MultiCompilerOptions);
44
+ set unsafeFastDrop(value: boolean);
44
45
  get options(): import(".").RspackOptionsNormalized[] & MultiCompilerOptions;
45
46
  get outputPath(): string;
46
47
  get inputFileSystem(): InputFileSystem;
@@ -7,3 +7,6 @@ export declare class NonErrorEmittedError extends Error {
7
7
  export declare class DeadlockRiskError extends Error {
8
8
  constructor(message: string);
9
9
  }
10
+ export declare class ValidationError extends Error {
11
+ constructor(message: string);
12
+ }
@@ -321,5 +321,8 @@ export declare const RuntimeGlobals: {
321
321
  * ) =\> void
322
322
  */
323
323
  readonly asyncModule: "__webpack_require__.a";
324
+ readonly asyncModuleExportSymbol: "__webpack_require__.aE";
325
+ readonly makeDeferredNamespaceObject: "__webpack_require__.z";
326
+ readonly makeDeferredNamespaceObjectSymbol: "__webpack_require__.zS";
324
327
  };
325
328
  export declare const isReservedRuntimeGlobal: (r: string) => boolean;
@@ -1,3 +1,12 @@
1
+ /**
2
+ * The following code is modified based on
3
+ * https://github.com/webpack/webpack/blob/4b4ca3b/lib/Watching.js
4
+ *
5
+ * MIT Licensed
6
+ * Author Tobias Koppers @sokra
7
+ * Copyright (c) JS Foundation and other contributors
8
+ * https://github.com/webpack/webpack/blob/main/LICENSE
9
+ */
1
10
  import type { Callback } from "@rspack/lite-tapable";
2
11
  import type { Compiler } from ".";
3
12
  import { Stats } from ".";
@@ -1,5 +1,11 @@
1
1
  import type { Compiler } from "../Compiler";
2
2
  export declare class EsmLibraryPlugin {
3
3
  static PLUGIN_NAME: string;
4
+ options?: {
5
+ preserveModules?: string;
6
+ };
7
+ constructor(options?: {
8
+ preserveModules?: string;
9
+ });
4
10
  apply(compiler: Compiler): void;
5
11
  }
@@ -28,7 +28,6 @@ declare const NativeSubresourceIntegrityPlugin: {
28
28
  export declare class SubresourceIntegrityPlugin extends NativeSubresourceIntegrityPlugin {
29
29
  private integrities;
30
30
  private options;
31
- private validateError;
32
31
  constructor(options?: SubresourceIntegrityPluginOptions);
33
32
  private isEnabled;
34
33
  private getIntegrityChecksumForAsset;
@@ -77,7 +77,6 @@ export type HtmlRspackPluginOptions = {
77
77
  */
78
78
  [key: string]: any;
79
79
  };
80
- export declare function validateHtmlPluginOptions(options: HtmlRspackPluginOptions): string | null;
81
80
  export declare const getPluginOptions: (compilation: Compilation, uid: number) => any;
82
81
  export declare const setPluginOptions: (compilation: Compilation, uid: number, options: HtmlRspackPluginOptions) => void;
83
82
  export declare const cleanPluginOptions: (compilation: Compilation, uid: number) => void;
@@ -1,12 +1,3 @@
1
- /**
2
- * The following code is modified based on
3
- * https://github.com/webpack/webpack/blob/4b4ca3b/lib/config/defaults.js
4
- *
5
- * MIT Licensed
6
- * Author Tobias Koppers @sokra
7
- * Copyright (c) JS Foundation and other contributors
8
- * https://github.com/webpack/webpack/blob/main/LICENSE
9
- */
10
1
  import type { RspackOptionsNormalized } from "./normalization";
11
2
  export declare const applyRspackOptionsDefaults: (options: RspackOptionsNormalized) => void;
12
3
  export declare const applyRspackOptionsBaseDefaults: (options: RspackOptionsNormalized) => void;
@@ -200,7 +200,7 @@ export type DevServerOptions<A extends BasicApplication = BasicApplication, S ex
200
200
  open?: string | boolean | Open | (string | Open)[] | undefined;
201
201
  setupExitSignals?: boolean | undefined;
202
202
  client?: boolean | ClientConfiguration | undefined;
203
- headers?: Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response> | undefined) => Headers) | undefined;
203
+ headers?: Headers | ((req: Request, res: Response, context: DevMiddlewareContext | undefined) => Headers) | undefined;
204
204
  onListening?: ((devServer: Server) => void) | undefined;
205
205
  setupMiddlewares?: ((middlewares: Middleware[], devServer: Server) => Middleware[]) | undefined;
206
206
  };
@@ -76,6 +76,7 @@ export interface ModuleOptionsNormalized {
76
76
  parser: ParserOptionsByModuleType;
77
77
  generator: GeneratorOptionsByModuleType;
78
78
  noParse?: NoParseOption;
79
+ unsafeCache?: boolean | RegExp;
79
80
  }
80
81
  export type ExperimentCacheNormalized = boolean | {
81
82
  type: "memory";
@@ -121,6 +122,7 @@ export interface ExperimentsNormalized {
121
122
  typeReexportsPresence?: boolean;
122
123
  lazyBarrel?: boolean;
123
124
  nativeWatcher?: boolean;
125
+ deferImport?: boolean;
124
126
  }
125
127
  export type IgnoreWarningsNormalized = ((warning: WebpackError, compilation: Compilation) => boolean)[];
126
128
  export type OptimizationRuntimeChunkNormalized = false | {
@@ -818,6 +818,8 @@ export type JavascriptParserOptions = {
818
818
  typeReexportsPresence?: "no-tolerant" | "tolerant" | "tolerant-no-check";
819
819
  /** Whether to enable JSX parsing */
820
820
  jsx?: boolean;
821
+ /** Whether to enable defer import */
822
+ deferImport?: boolean;
821
823
  };
822
824
  export type JsonParserOptions = {
823
825
  /**
@@ -990,6 +992,10 @@ export type ModuleOptions = {
990
992
  generator?: GeneratorOptionsByModuleType;
991
993
  /** Keep module mechanism of the matched modules as-is, such as module.exports, require, import. */
992
994
  noParse?: NoParseOption;
995
+ /**
996
+ * Cache the resolving of module requests.
997
+ */
998
+ unsafeCache?: boolean | RegExp;
993
999
  };
994
1000
  type AllowTarget = "web" | "webworker" | "es3" | "es5" | "es2015" | "es2016" | "es2017" | "es2018" | "es2019" | "es2020" | "es2021" | "es2022" | "es2023" | "es2024" | "es2025" | "node" | "async-node" | `node${number}` | `async-node${number}` | `node${number}.${number}` | `async-node${number}.${number}` | "electron-main" | `electron${number}-main` | `electron${number}.${number}-main` | "electron-renderer" | `electron${number}-renderer` | `electron${number}.${number}-renderer` | "electron-preload" | `electron${number}-preload` | `electron${number}.${number}-preload` | "nwjs" | `nwjs${number}` | `nwjs${number}.${number}` | "node-webkit" | `node-webkit${number}` | `node-webkit${number}.${number}` | "browserslist" | `browserslist:${string}`;
995
1001
  /** Used to configure the target environment of Rspack output and the ECMAScript version of Rspack runtime code. */
@@ -2116,6 +2122,11 @@ export type Experiments = {
2116
2122
  * @default false
2117
2123
  */
2118
2124
  lazyBarrel?: boolean;
2125
+ /**
2126
+ * Enable defer import feature
2127
+ * @default false
2128
+ */
2129
+ deferImport?: boolean;
2119
2130
  };
2120
2131
  export type Watch = boolean;
2121
2132
  /** Options for watch mode. */
@@ -2148,8 +2159,7 @@ export type WatchOptions = {
2148
2159
  /**
2149
2160
  * Options for devServer, it based on `webpack-dev-server@5`
2150
2161
  * */
2151
- export interface DevServer extends DevServerOptions {
2152
- }
2162
+ export type DevServer = DevServerOptions;
2153
2163
  export type { Middleware as DevServerMiddleware } from "./devServer";
2154
2164
  /**
2155
2165
  * Ignore specific warnings.
package/dist/exports.d.ts CHANGED
@@ -20,7 +20,7 @@ export type { default as ModuleGraph } from "./ModuleGraph";
20
20
  export { MultiStats } from "./MultiStats";
21
21
  export { NormalModule } from "./NormalModule";
22
22
  export type { NormalModuleFactory } from "./NormalModuleFactory";
23
- export type { RspackError, RspackSeverity } from "./RspackError";
23
+ export { type RspackError, type RspackSeverity, ValidationError } from "./RspackError";
24
24
  export { RuntimeGlobals } from "./RuntimeGlobals";
25
25
  export { RuntimeModule } from "./RuntimeModule";
26
26
  export type { StatsAsset, StatsChunk, StatsCompilation, StatsError, StatsModule } from "./Stats";
@@ -42,8 +42,6 @@ type Config = {
42
42
  };
43
43
  export declare const config: Config;
44
44
  export type * from "./config";
45
- import { ValidationError } from "./schema/validate";
46
- export { ValidationError };
47
45
  export declare const util: {
48
46
  createHash: (algorithm: "debug" | "xxhash64" | "md4" | "native-md4" | (string & {}) | (new () => import("./util/hash").default)) => import("./util/hash").default;
49
47
  cleverMerge: <First, Second>(first: First, second: Second) => First | Second | (First & Second);