@rspack-debug/core 1.4.11 → 1.6.2

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 (145) hide show
  1. package/compiled/@swc/types/index.d.ts +15 -5
  2. package/compiled/@swc/types/package.json +1 -1
  3. package/compiled/browserslist-load-config/index.d.ts +11 -0
  4. package/compiled/browserslist-load-config/index.js +26 -40
  5. package/compiled/browserslist-load-config/package.json +1 -1
  6. package/compiled/watchpack/index.js +1015 -18
  7. package/compiled/webpack-sources/index.js +82 -82
  8. package/dist/Compilation.d.ts +17 -20
  9. package/dist/Compiler.d.ts +63 -32
  10. package/dist/Module.d.ts +3 -14
  11. package/dist/MultiCompiler.d.ts +7 -3
  12. package/dist/MultiStats.d.ts +3 -2
  13. package/dist/MultiWatching.d.ts +1 -1
  14. package/dist/NativeWatchFileSystem.d.ts +8 -2
  15. package/dist/NormalModuleFactory.d.ts +2 -2
  16. package/dist/Resolver.d.ts +13 -7
  17. package/dist/ResolverFactory.d.ts +8 -5
  18. package/dist/RspackError.d.ts +3 -0
  19. package/dist/RuntimeGlobals.d.ts +3 -0
  20. package/dist/RuntimeModule.d.ts +1 -1
  21. package/dist/VirtualModulesPlugin.d.ts +12 -0
  22. package/dist/Watching.d.ts +9 -0
  23. package/dist/builtin-loader/swc/pluginImport.d.ts +2 -2
  24. package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
  25. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
  26. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
  27. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
  28. package/dist/builtin-plugin/BannerPlugin.d.ts +1 -1
  29. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
  30. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
  31. package/dist/builtin-plugin/CircularDependencyRspackPlugin.d.ts +1 -1
  32. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
  33. package/dist/builtin-plugin/ContextReplacementPlugin.d.ts +1 -1
  34. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
  35. package/dist/builtin-plugin/CssChunkingPlugin.d.ts +1 -1
  36. package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
  37. package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
  38. package/dist/builtin-plugin/DefinePlugin.d.ts +2 -2
  39. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -2
  40. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -2
  41. package/dist/builtin-plugin/DllEntryPlugin.d.ts +1 -1
  42. package/dist/builtin-plugin/DllReferenceAgencyPlugin.d.ts +1 -1
  43. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
  44. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
  45. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
  46. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
  47. package/dist/builtin-plugin/EntryPlugin.d.ts +1 -1
  48. package/dist/builtin-plugin/EsmLibraryPlugin.d.ts +11 -0
  49. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
  50. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
  51. package/dist/builtin-plugin/ExternalsPlugin.d.ts +2 -1
  52. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +1 -1
  53. package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
  54. package/dist/builtin-plugin/FlagAllModulesAsUsedPlugin.d.ts +1 -1
  55. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
  56. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -2
  57. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
  58. package/dist/builtin-plugin/IgnorePlugin.d.ts +1 -1
  59. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
  60. package/dist/builtin-plugin/InlineExportsPlugin.d.ts +9 -0
  61. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
  62. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
  63. package/dist/builtin-plugin/LibManifestPlugin.d.ts +1 -1
  64. package/dist/builtin-plugin/LightningCssMinimizerRspackPlugin.d.ts +1 -1
  65. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
  66. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -2
  67. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
  68. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
  69. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -2
  70. package/dist/builtin-plugin/ModuleInfoHeaderPlugin.d.ts +1 -1
  71. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
  72. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
  73. package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +1 -2
  74. package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +1 -2
  75. package/dist/builtin-plugin/NoEmitOnErrorsPlugin.d.ts +1 -1
  76. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
  77. package/dist/builtin-plugin/NormalModuleReplacementPlugin.d.ts +10 -0
  78. package/dist/builtin-plugin/OccurrenceChunkIdsPlugin.d.ts +1 -1
  79. package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
  80. package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
  81. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
  82. package/dist/builtin-plugin/RemoveDuplicateModulesPlugin.d.ts +1 -1
  83. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
  84. package/dist/builtin-plugin/RsdoctorPlugin.d.ts +3 -3
  85. package/dist/builtin-plugin/RslibPlugin.d.ts +1 -1
  86. package/dist/builtin-plugin/RstestPlugin.d.ts +1 -1
  87. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +1 -1
  88. package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
  89. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
  90. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +1 -1
  91. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
  92. package/dist/builtin-plugin/SubresourceIntegrityPlugin.d.ts +1 -2
  93. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +3 -2
  94. package/dist/builtin-plugin/URLPlugin.d.ts +9 -0
  95. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
  96. package/dist/builtin-plugin/base.d.ts +2 -2
  97. package/dist/builtin-plugin/css-extract/index.d.ts +2 -2
  98. package/dist/builtin-plugin/html-plugin/options.d.ts +0 -1
  99. package/dist/builtin-plugin/html-plugin/plugin.d.ts +2 -2
  100. package/dist/builtin-plugin/index.d.ts +4 -0
  101. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +3 -17
  102. package/dist/config/adapterRuleUse.d.ts +65 -7
  103. package/dist/config/defaults.d.ts +0 -9
  104. package/dist/config/devServer.d.ts +12 -13
  105. package/dist/config/index.d.ts +1 -0
  106. package/dist/config/normalization.d.ts +18 -3
  107. package/dist/config/types.d.ts +119 -18
  108. package/dist/container/ModuleFederationManifestPlugin.d.ts +37 -0
  109. package/dist/container/ModuleFederationPlugin.d.ts +3 -1
  110. package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
  111. package/dist/cssExtractHmr.js +12 -13
  112. package/dist/cssExtractLoader.js +9 -10
  113. package/dist/exports.d.ts +16 -9
  114. package/dist/index.js +1556 -5443
  115. package/dist/lib/Cache.d.ts +1 -1
  116. package/dist/loader-runner/ModuleError.d.ts +7 -1
  117. package/dist/loader-runner/loadLoader.d.ts +2 -1
  118. package/dist/loader-runner/service.d.ts +1 -1
  119. package/dist/loader-runner/utils.d.ts +2 -1
  120. package/dist/moduleFederationDefaultRuntime.js +1 -1
  121. package/dist/stats/DefaultStatsFactoryPlugin.d.ts +16 -0
  122. package/dist/stats/statsFactoryUtils.d.ts +17 -1
  123. package/dist/util/ArrayQueue.d.ts +2 -2
  124. package/dist/util/bindingVersionCheck.d.ts +1 -1
  125. package/dist/util/comparators.d.ts +1 -1
  126. package/dist/util/fs.d.ts +25 -2
  127. package/dist/util/index.d.ts +0 -3
  128. package/dist/util/source.d.ts +5 -6
  129. package/dist/util/validateConfig.d.ts +5 -0
  130. package/dist/worker.js +152 -118
  131. package/hot/lazy-compilation-node.js +1 -3
  132. package/hot/lazy-compilation-web.js +4 -3
  133. package/module.d.ts +11 -14
  134. package/package.json +20 -20
  135. package/compiled/graceful-fs/index.d.ts +0 -13
  136. package/compiled/graceful-fs/index.js +0 -1063
  137. package/compiled/graceful-fs/license +0 -15
  138. package/compiled/graceful-fs/package.json +0 -1
  139. package/dist/lib/NormalModuleReplacementPlugin.d.ts +0 -29
  140. package/dist/loader-runner/ModuleWarning.d.ts +0 -7
  141. package/dist/schema/config.d.ts +0 -996
  142. package/dist/schema/loaders.d.ts +0 -400
  143. package/dist/schema/plugins.d.ts +0 -167
  144. package/dist/schema/utils.d.ts +0 -4
  145. package/dist/schema/validate.d.ts +0 -10
@@ -26,6 +26,7 @@ export * from "./EnableLibraryPlugin";
26
26
  export * from "./EnableWasmLoadingPlugin";
27
27
  export * from "./EnsureChunkConditionsPlugin";
28
28
  export * from "./EntryPlugin";
29
+ export * from "./EsmLibraryPlugin";
29
30
  export * from "./EvalDevToolModulePlugin";
30
31
  export * from "./EvalSourceMapDevToolPlugin";
31
32
  export * from "./ExternalsPlugin";
@@ -39,6 +40,7 @@ export * from "./HttpUriPlugin";
39
40
  export * from "./html-plugin/index";
40
41
  export * from "./IgnorePlugin";
41
42
  export * from "./InferAsyncModulesPlugin";
43
+ export * from "./InlineExportsPlugin";
42
44
  export * from "./JavascriptModulesPlugin";
43
45
  export * from "./JsLoaderRspackPlugin";
44
46
  export * from "./JsonModulesPlugin";
@@ -58,6 +60,7 @@ export * from "./NaturalChunkIdsPlugin";
58
60
  export * from "./NaturalModuleIdsPlugin";
59
61
  export * from "./NodeTargetPlugin";
60
62
  export * from "./NoEmitOnErrorsPlugin";
63
+ export * from "./NormalModuleReplacementPlugin";
61
64
  export * from "./OccurrenceChunkIdsPlugin";
62
65
  export * from "./ProgressPlugin";
63
66
  export * from "./ProvidePlugin";
@@ -75,6 +78,7 @@ export * from "./SourceMapDevToolPlugin";
75
78
  export * from "./SplitChunksPlugin";
76
79
  export * from "./SubresourceIntegrityPlugin";
77
80
  export * from "./SwcJsMinimizerPlugin";
81
+ export * from "./URLPlugin";
78
82
  export * from "./WarnCaseSensitiveModulesPlugin";
79
83
  export * from "./WebWorkerTemplatePlugin";
80
84
  export * from "./WorkerPlugin";
@@ -1,23 +1,9 @@
1
1
  import type { Module } from "../../Module";
2
2
  export declare const BuiltinLazyCompilationPlugin: {
3
- new (module: (args: {
4
- module: string;
5
- path: string;
6
- }) => {
7
- active: boolean;
8
- data: string;
9
- client: string;
10
- }, cacheable: boolean, entries: boolean, imports: boolean, test?: RegExp | ((module: Module) => boolean) | undefined): {
3
+ new (currentActiveModules: () => Set<string>, entries: boolean, imports: boolean, client: string, test?: RegExp | ((module: Module) => boolean) | undefined): {
11
4
  name: string;
12
- _args: [module: (args: {
13
- module: string;
14
- path: string;
15
- }) => {
16
- active: boolean;
17
- data: string;
18
- client: string;
19
- }, cacheable: boolean, entries: boolean, imports: boolean, test?: RegExp | ((module: Module) => boolean) | undefined];
20
- affectedHooks: "done" | "compilation" | "afterDone" | "thisCompilation" | "invalid" | "compile" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "emit" | "assetEmitted" | "afterEmit" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "make" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | "additionalPass" | undefined;
5
+ _args: [currentActiveModules: () => Set<string>, entries: boolean, imports: boolean, client: string, test?: RegExp | ((module: Module) => boolean) | undefined];
6
+ affectedHooks: keyof import("../..").CompilerHooks | undefined;
21
7
  raw(compiler: import("../..").Compiler): import("@rspack/binding").BuiltinPlugin;
22
8
  apply(compiler: import("../..").Compiler): void;
23
9
  };
@@ -15,19 +15,50 @@ export interface ComposeJsUseOptions {
15
15
  experiments: RawOptions["experiments"];
16
16
  compiler: Compiler;
17
17
  }
18
- export interface SourceMap {
18
+ export interface RawSourceMap {
19
+ /**
20
+ * The version of the source map format, always 3
21
+ */
19
22
  version: number;
23
+ /**
24
+ * A list of original sources used by the mappings field
25
+ */
20
26
  sources: string[];
27
+ /**
28
+ * A string with the encoded mapping data
29
+ */
21
30
  mappings: string;
22
- file?: string;
31
+ /**
32
+ * The filename of the generated code that this source map is associated with
33
+ */
34
+ file: string;
35
+ /**
36
+ * An optional source root string, used for relocating source files on a server
37
+ * or removing repeated values in the sources entry.
38
+ */
23
39
  sourceRoot?: string;
40
+ /**
41
+ * An array containing the actual content of the original source files
42
+ */
24
43
  sourcesContent?: string[];
25
- names?: string[];
44
+ /**
45
+ * A list of symbol names which may be used by the mappings field.
46
+ */
47
+ names: string[];
48
+ /**
49
+ * A unique identifier for debugging purposes
50
+ */
51
+ debugId?: string;
52
+ /**
53
+ * An array of indices into the sources array, indicating which sources
54
+ * should be ignored by debuggers
55
+ */
56
+ ignoreList?: number[];
26
57
  }
27
58
  export interface AdditionalData {
28
59
  [index: string]: any;
29
60
  }
30
- export type LoaderContextCallback = (err?: Error | null, content?: string | Buffer, sourceMap?: string | SourceMap, additionalData?: AdditionalData) => void;
61
+ export type LoaderContextCallback = (err?: Error | null, content?: string | Buffer, sourceMap?: string | RawSourceMap, additionalData?: AdditionalData) => void;
31
62
  export type ErrorWithDetails = Error & {
32
63
  details?: string;
33
64
  };
@@ -48,10 +79,13 @@ export interface Diagnostic {
48
79
  sourceCode?: string;
49
80
  /**
50
81
  * Location to the source code.
51
- *
52
82
  * If `sourceCode` is not provided, location will be omitted.
53
83
  */
54
84
  location?: DiagnosticLocation;
85
+ /**
86
+ * Optional filename to show.
87
+ * If provided, it becomes the `StatsError.file` value in stats.
88
+ */
55
89
  file?: string;
56
90
  severity: "error" | "warning";
57
91
  }
@@ -322,8 +356,32 @@ export interface LoaderContext<OptionsType = {}> {
322
356
  */
323
357
  __internal__setParseMeta: (key: string, value: string) => void;
324
358
  }
325
- export type LoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, content: string, sourceMap?: string | SourceMap, additionalData?: AdditionalData) => string | void | Buffer | Promise<string | Buffer>;
326
- export type PitchLoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, remainingRequest: string, previousRequest: string, data: object) => string | void | Buffer | Promise<string | Buffer>;
359
+ export type LoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, content: string, sourceMap?: string | RawSourceMap, additionalData?: AdditionalData) => string | void | Buffer | Promise<string | Buffer | void>;
360
+ export type PitchLoaderDefinitionFunction<OptionsType = {}, ContextAdditions = {}> = (this: LoaderContext<OptionsType> & ContextAdditions, remainingRequest: string, previousRequest: string, data: object) => string | void | Buffer | Promise<string | Buffer | void>;
361
+ /**
362
+ * Defines a loader for Rspack.
363
+ * A loader is a transformer that converts various types of modules into Rspack
364
+ * supported types. By using different kinds of loaders, you can extend Rspack to
365
+ * process additional module types, including JSX, Markdown, Sass, Less, and more.
366
+ *
367
+ * @template OptionsType - The type of options that the loader accepts
368
+ * @template ContextAdditions - Additional properties to add to the loader context
369
+ *
370
+ * @example
371
+ * ```ts
372
+ * import type { LoaderDefinition } from '@rspack/core';
373
+ *
374
+ * type MyLoaderOptions = {
375
+ * foo: string;
376
+ * };
377
+ *
378
+ * const myLoader: LoaderDefinition<MyLoaderOptions> = function(source) {
379
+ * return someOperation(source);
380
+ * };
381
+ *
382
+ * export default myLoader;
383
+ * ```
384
+ */
327
385
  export type LoaderDefinition<OptionsType = {}, ContextAdditions = {}> = LoaderDefinitionFunction<OptionsType, ContextAdditions> & {
328
386
  raw?: false;
329
387
  pitch?: PitchLoaderDefinitionFunction;
@@ -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;
@@ -7,7 +7,7 @@
7
7
  * Copyright (c) JS Foundation and other contributors
8
8
  * https://github.com/webpack/webpack-dev-server/blob/master/LICENSE
9
9
  */
10
- import type { Compiler, MultiCompiler, MultiStats, Stats, Watching } from "..";
10
+ import type { Compiler, LiteralUnion, MultiCompiler, MultiStats, Stats, Watching } from "..";
11
11
  type Logger = ReturnType<Compiler["getInfrastructureLogger"]>;
12
12
  type MultiWatching = MultiCompiler["watch"];
13
13
  type BasicServer = import("net").Server | import("tls").Server;
@@ -28,17 +28,16 @@ type ResponseData = {
28
28
  byteLength: number;
29
29
  };
30
30
  type ModifyResponseData<RequestInternal extends IncomingMessage = IncomingMessage, ResponseInternal extends ServerResponse = ServerResponse> = (req: RequestInternal, res: ResponseInternal, data: Buffer | ReadStream, byteLength: number) => ResponseData;
31
- type Headers = Array<{
31
+ type Headers = {
32
32
  key: string;
33
33
  value: string;
34
- }> | Record<string, string | string[]>;
34
+ }[] | Record<string, string | string[]>;
35
35
  type OutputFileSystem = import("..").OutputFileSystem & {
36
- createReadStream?: typeof import("fs").createReadStream;
37
36
  statSync: import("fs").StatSyncFn;
38
37
  readFileSync: typeof import("fs").readFileSync;
39
38
  };
40
39
  type RspackConfiguration = import("..").Configuration;
41
- type Port = number | string | "auto";
40
+ type Port = number | LiteralUnion<"auto", string>;
42
41
  type HistoryContext = {
43
42
  readonly match: RegExpMatchArray;
44
43
  readonly parsedUrl: import("url").Url;
@@ -80,7 +79,7 @@ type DevMiddlewareOptions<RequestInternal extends IncomingMessage = IncomingMess
80
79
  cacheImmutable?: boolean | undefined;
81
80
  };
82
81
  type BasicApplication = any;
83
- type BonjourServer = any;
82
+ type BonjourServer = Record<string, any>;
84
83
  type ChokidarWatchOptions = {
85
84
  [key: string]: any;
86
85
  };
@@ -112,7 +111,7 @@ type Static = {
112
111
  poll?: number | boolean;
113
112
  }) | undefined;
114
113
  };
115
- type ServerType<A extends BasicApplication = BasicApplication, S extends BasicServer = import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>> = "http" | "https" | "spdy" | "http2" | string | ((arg0: ServerOptions, arg1: A) => S);
114
+ type ServerType<A extends BasicApplication = BasicApplication, S extends BasicServer = import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>> = LiteralUnion<"http" | "https" | "spdy" | "http2", string> | ((arg0: ServerOptions, arg1: A) => S);
116
115
  type ServerConfiguration<A extends BasicApplication = BasicApplication, S extends BasicServer = import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>> = {
117
116
  type?: ServerType<A, S> | undefined;
118
117
  options?: ServerOptions | undefined;
@@ -123,16 +122,16 @@ type WebSocketServerConfiguration = {
123
122
  };
124
123
  type NextFunction = (err?: any) => void;
125
124
  type ProxyConfigArrayItem = {
126
- path?: HttpProxyMiddlewareOptionsFilter | undefined;
127
- context?: HttpProxyMiddlewareOptionsFilter | undefined;
125
+ path?: HttpProxyMiddlewareOptionsFilter;
126
+ context?: HttpProxyMiddlewareOptionsFilter;
128
127
  } & {
129
128
  bypass?: ByPass;
130
129
  } & {
131
130
  [key: string]: any;
132
131
  };
133
132
  type ByPass = (req: Request, res: Response, proxyConfig: ProxyConfigArrayItem) => any;
134
- type ProxyConfigArray = (ProxyConfigArrayItem | ((req?: Request | undefined, res?: Response | undefined, next?: NextFunction | undefined) => ProxyConfigArrayItem))[];
135
- type Callback = (stats?: Stats | MultiStats | undefined) => any;
133
+ type ProxyConfigArray = (ProxyConfigArrayItem | ((req?: Request, res?: Response, next?: NextFunction) => ProxyConfigArrayItem))[];
134
+ type Callback = (stats?: Stats | MultiStats) => any;
136
135
  type DevMiddlewareContext<_RequestInternal extends IncomingMessage = IncomingMessage, _ResponseInternal extends ServerResponse = ServerResponse> = {
137
136
  state: boolean;
138
137
  stats: Stats | MultiStats | undefined;
@@ -190,7 +189,7 @@ export type DevServerOptions<A extends BasicApplication = BasicApplication, S ex
190
189
  compress?: boolean | undefined;
191
190
  allowedHosts?: string | string[] | undefined;
192
191
  historyApiFallback?: boolean | HistoryApiFallbackOptions | undefined;
193
- bonjour?: boolean | Record<string, never> | BonjourServer | undefined;
192
+ bonjour?: boolean | BonjourServer | undefined;
194
193
  watchFiles?: string | string[] | WatchFiles | (string | WatchFiles)[] | undefined;
195
194
  static?: string | boolean | Static | (string | Static)[] | undefined;
196
195
  server?: ServerType<A, S> | ServerConfiguration<A, S> | undefined;
@@ -200,7 +199,7 @@ export type DevServerOptions<A extends BasicApplication = BasicApplication, S ex
200
199
  open?: string | boolean | Open | (string | Open)[] | undefined;
201
200
  setupExitSignals?: boolean | undefined;
202
201
  client?: boolean | ClientConfiguration | undefined;
203
- headers?: Headers | ((req: Request, res: Response, context: DevMiddlewareContext<Request, Response> | undefined) => Headers) | undefined;
202
+ headers?: Headers | ((req: Request, res: Response, context: DevMiddlewareContext | undefined) => Headers) | undefined;
204
203
  onListening?: ((devServer: Server) => void) | undefined;
205
204
  setupMiddlewares?: ((middlewares: Middleware[], devServer: Server) => Middleware[]) | undefined;
206
205
  };
@@ -1,4 +1,5 @@
1
1
  export * from "./adapter";
2
+ export type { RawSourceMap } from "./adapterRuleUse";
2
3
  export * from "./defaults";
3
4
  export * from "./normalization";
4
5
  export type * from "./types";
@@ -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";
@@ -84,9 +85,9 @@ export type ExperimentCacheNormalized = boolean | {
84
85
  buildDependencies: string[];
85
86
  version: string;
86
87
  snapshot: {
87
- immutablePaths: Array<string | RegExp>;
88
- unmanagedPaths: Array<string | RegExp>;
89
- managedPaths: Array<string | RegExp>;
88
+ immutablePaths: (string | RegExp)[];
89
+ unmanagedPaths: (string | RegExp)[];
90
+ managedPaths: (string | RegExp)[];
90
91
  };
91
92
  storage: {
92
93
  type: "filesystem";
@@ -95,13 +96,24 @@ export type ExperimentCacheNormalized = boolean | {
95
96
  };
96
97
  export interface ExperimentsNormalized {
97
98
  cache?: ExperimentCacheNormalized;
99
+ /**
100
+ * @deprecated This option is deprecated and will be removed in future versions.
101
+ *
102
+ * Please use the Configuration top-level `lazyCompilation` option instead.
103
+ */
98
104
  lazyCompilation?: false | LazyCompilationOptions;
99
105
  asyncWebAssembly?: boolean;
100
106
  outputModule?: boolean;
101
107
  topLevelAwait?: boolean;
102
108
  css?: boolean;
109
+ /**
110
+ * @deprecated This option is deprecated, layers is enabled since v1.6.0
111
+ */
103
112
  layers?: boolean;
104
113
  incremental?: false | Incremental;
114
+ /**
115
+ * @deprecated This option is deprecated, as it has a huge regression in some edge cases where the chunk graph has lots of cycles. We will improve performance of build_chunk_graph.
116
+ */
105
117
  parallelCodeSplitting?: boolean;
106
118
  futureDefaults?: boolean;
107
119
  rspackFuture?: RspackFutureOptions;
@@ -111,7 +123,9 @@ export interface ExperimentsNormalized {
111
123
  inlineConst?: boolean;
112
124
  inlineEnum?: boolean;
113
125
  typeReexportsPresence?: boolean;
126
+ lazyBarrel?: boolean;
114
127
  nativeWatcher?: boolean;
128
+ deferImport?: boolean;
115
129
  }
116
130
  export type IgnoreWarningsNormalized = ((warning: WebpackError, compilation: Compilation) => boolean)[];
117
131
  export type OptimizationRuntimeChunkNormalized = false | {
@@ -143,6 +157,7 @@ export interface RspackOptionsNormalized {
143
157
  optimization: Optimization;
144
158
  plugins: Plugins;
145
159
  experiments: ExperimentsNormalized;
160
+ lazyCompilation?: false | LazyCompilationOptions;
146
161
  watch?: Watch;
147
162
  watchOptions: WatchOptions;
148
163
  devServer?: DevServer;
@@ -9,6 +9,8 @@ import type { Module } from "../Module";
9
9
  import type ModuleGraph from "../ModuleGraph";
10
10
  import type { ResolveCallback } from "./adapterRuleUse";
11
11
  import type { DevServerOptions } from "./devServer";
12
+ /** https://github.com/microsoft/TypeScript/issues/29729 */
13
+ export type LiteralUnion<T extends U, U> = T | (U & Record<never, never>);
12
14
  export type FilenameTemplate = string;
13
15
  export type Filename = FilenameTemplate | ((pathData: PathData, assetInfo?: AssetInfo) => string);
14
16
  /** Name of the configuration. Used when loading multiple configurations. */
@@ -27,17 +29,17 @@ export type Context = string;
27
29
  export type Mode = "development" | "production" | "none";
28
30
  export type Falsy = false | "" | 0 | null | undefined;
29
31
  /** The publicPath of the resource referenced by this entry. */
30
- export type PublicPath = "auto" | Filename;
32
+ export type PublicPath = LiteralUnion<"auto", string> | Exclude<Filename, string>;
31
33
  /** The baseURI of the resource referenced by this entry. */
32
34
  export type BaseUri = string;
33
35
  /** How this entry load other chunks. */
34
- export type ChunkLoadingType = string | "jsonp" | "import-scripts" | "require" | "async-node" | "import";
36
+ export type ChunkLoadingType = LiteralUnion<"jsonp" | "import-scripts" | "require" | "async-node" | "import", string>;
35
37
  /** How this entry load other chunks. */
36
38
  export type ChunkLoading = false | ChunkLoadingType;
37
39
  /** Whether to create a load-on-demand asynchronous chunk for entry. */
38
40
  export type AsyncChunks = boolean;
39
41
  /** Option to set the method of loading WebAssembly Modules. */
40
- export type WasmLoadingType = string | "fetch-streaming" | "fetch" | "async-node";
42
+ export type WasmLoadingType = LiteralUnion<"fetch-streaming" | "fetch" | "async-node", string>;
41
43
  /** Option to set the method of loading WebAssembly Modules. */
42
44
  export type WasmLoading = false | WasmLoadingType;
43
45
  export type ScriptType = false | "text/javascript" | "module";
@@ -61,7 +63,7 @@ export type AuxiliaryComment = string | LibraryCustomUmdCommentObject;
61
63
  /** Specify which export should be exposed as a library. */
62
64
  export type LibraryExport = string | string[];
63
65
  /** Configure how the library will be exposed. */
64
- export type LibraryType = string | "var" | "module" | "assign" | "assign-properties" | "this" | "window" | "self" | "global" | "commonjs" | "commonjs2" | "commonjs-module" | "commonjs-static" | "amd" | "amd-require" | "umd" | "umd2" | "jsonp" | "system";
66
+ export type LibraryType = LiteralUnion<"var" | "module" | "assign" | "assign-properties" | "this" | "window" | "self" | "global" | "commonjs" | "commonjs2" | "commonjs-module" | "commonjs-static" | "amd" | "amd-require" | "umd" | "umd2" | "jsonp" | "system", string>;
65
67
  /** When using output.library.type: "umd", setting output.library.umdNamedDefine to true will name the AMD module of the UMD build. */
66
68
  export type UmdNamedDefine = boolean;
67
69
  /** Options for library. */
@@ -224,8 +226,32 @@ export type HashSalt = string;
224
226
  export type SourceMapFilename = string;
225
227
  /** This option determines the module's namespace */
226
228
  export type DevtoolNamespace = string;
229
+ export interface ModuleFilenameTemplateContext {
230
+ /** The identifier of the module */
231
+ identifier: string;
232
+ /** The shortened identifier of the module */
233
+ shortIdentifier: string;
234
+ /** The resource of the module request */
235
+ resource: string;
236
+ /** The resource path of the module request */
237
+ resourcePath: string;
238
+ /** The absolute resource path of the module request */
239
+ absoluteResourcePath: string;
240
+ /** The loaders of the module request */
241
+ loaders: string;
242
+ /** All loaders of the module request */
243
+ allLoaders: string;
244
+ /** The query of the module identifier */
245
+ query: string;
246
+ /** The module id of the module */
247
+ moduleId: string;
248
+ /** The hash of the module identifier */
249
+ hash: string;
250
+ /** The module namespace */
251
+ namespace: string;
252
+ }
227
253
  /** This option is only used when devtool uses an option that requires module names. */
228
- export type DevtoolModuleFilenameTemplate = string | ((info: any) => any);
254
+ export type DevtoolModuleFilenameTemplate = string | ((context: ModuleFilenameTemplateContext) => string);
229
255
  /** A fallback is used when the template string or function above yields duplicates. */
230
256
  export type DevtoolFallbackModuleFilenameTemplate = DevtoolModuleFilenameTemplate;
231
257
  /** Tell Rspack what kind of ES-features may be used in the generated runtime-code. */
@@ -664,6 +690,8 @@ export type RuleSetRule = {
664
690
  oneOf?: (RuleSetRule | Falsy)[];
665
691
  /** A kind of Nested Rule, an array of Rules that is also used when the parent Rule matches. */
666
692
  rules?: (RuleSetRule | Falsy)[];
693
+ /** Whether to extract source maps from the module. */
694
+ extractSourceMap?: boolean;
667
695
  };
668
696
  /** A list of rules. */
669
697
  export type RuleSetRules = ("..." | RuleSetRule | Falsy)[];
@@ -727,6 +755,11 @@ export type CssModuleParserOptions = {
727
755
  url?: CssParserUrl;
728
756
  };
729
757
  type ExportsPresence = "error" | "warn" | "auto" | false;
758
+ export type JavascriptParserCommonjsExports = boolean | "skipInEsm";
759
+ export type JavascriptParserCommonjsOption = boolean | {
760
+ /** Controls how CommonJS export mutations are handled. */
761
+ exports?: JavascriptParserCommonjsExports;
762
+ };
730
763
  export type JavascriptParserOptions = {
731
764
  /**
732
765
  * Specifies global mode for dynamic import.
@@ -757,12 +790,17 @@ export type JavascriptParserOptions = {
757
790
  * Enable parsing of new URL() syntax.
758
791
  * @default true
759
792
  * */
760
- url?: "relative" | boolean;
793
+ url?: "relative" | "new-url-relative" | boolean;
761
794
  /**
762
795
  * Enable warnings for full dynamic dependencies
763
796
  * @default true
764
797
  * */
765
798
  exprContextCritical?: boolean;
799
+ /**
800
+ * Enable warnings for unknown dynamic dependencies
801
+ * @default true
802
+ * */
803
+ unknownContextCritical?: boolean;
766
804
  /**
767
805
  * Enable warnings for partial dynamic dependencies
768
806
  * @default false
@@ -790,11 +828,24 @@ export type JavascriptParserOptions = {
790
828
  requireAsExpression?: boolean;
791
829
  requireDynamic?: boolean;
792
830
  requireResolve?: boolean;
831
+ /**
832
+ * CommonJS-specific parser options. `true` enables the default behaviour, `{ exports: 'skipInEsm' }` preserves CommonJS export mutations when executed inside ESM.
833
+ * @default true
834
+ */
835
+ commonjs?: JavascriptParserCommonjsOption;
793
836
  importDynamic?: boolean;
837
+ /**
838
+ * Enable magic comments for CommonJS require() expressions.
839
+ */
840
+ commonjsMagicComments?: boolean;
794
841
  /** Inline const values in this module */
795
842
  inlineConst?: boolean;
796
843
  /** Whether to tolerant exportsPresence for type reexport */
797
844
  typeReexportsPresence?: "no-tolerant" | "tolerant" | "tolerant-no-check";
845
+ /** Whether to enable JSX parsing */
846
+ jsx?: boolean;
847
+ /** Whether to enable defer import */
848
+ deferImport?: boolean;
798
849
  };
799
850
  export type JsonParserOptions = {
800
851
  /**
@@ -967,6 +1018,10 @@ export type ModuleOptions = {
967
1018
  generator?: GeneratorOptionsByModuleType;
968
1019
  /** Keep module mechanism of the matched modules as-is, such as module.exports, require, import. */
969
1020
  noParse?: NoParseOption;
1021
+ /**
1022
+ * Cache the resolving of module requests.
1023
+ */
1024
+ unsafeCache?: boolean | RegExp;
970
1025
  };
971
1026
  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}`;
972
1027
  /** Used to configure the target environment of Rspack output and the ECMAScript version of Rspack runtime code. */
@@ -1170,9 +1225,35 @@ export type SnapshotOptions = {};
1170
1225
  * cache: false
1171
1226
  */
1172
1227
  export type CacheOptions = boolean;
1173
- type StatsPresets = "normal" | "none" | "verbose" | "errors-only" | "errors-warnings" | "minimal" | "detailed" | "summary";
1228
+ export type StatsPresets = "normal" | "none" | "verbose" | "errors-only" | "errors-warnings" | "minimal" | "detailed" | "summary";
1174
1229
  type ModuleFilterItemTypes = RegExp | string | ((name: string, module: any, type: any) => boolean);
1175
1230
  type ModuleFilterTypes = boolean | ModuleFilterItemTypes | ModuleFilterItemTypes[];
1231
+ export type StatsColorOptions = {
1232
+ /**
1233
+ * Custom color for bold text.
1234
+ */
1235
+ bold?: string;
1236
+ /**
1237
+ * Custom color for cyan text.
1238
+ */
1239
+ cyan?: string;
1240
+ /**
1241
+ * Custom color for green text.
1242
+ */
1243
+ green?: string;
1244
+ /**
1245
+ * Custom color for magenta text.
1246
+ */
1247
+ magenta?: string;
1248
+ /**
1249
+ * Custom color for red text.
1250
+ */
1251
+ red?: string;
1252
+ /**
1253
+ * Custom color for yellow text.
1254
+ */
1255
+ yellow?: string;
1256
+ };
1176
1257
  /** Options for stats */
1177
1258
  export type StatsOptions = {
1178
1259
  /**
@@ -1232,7 +1313,7 @@ export type StatsOptions = {
1232
1313
  * Enables or disables the use of colors in the output.
1233
1314
  * @default false
1234
1315
  */
1235
- colors?: boolean;
1316
+ colors?: boolean | StatsColorOptions;
1236
1317
  /**
1237
1318
  * Enables or disables the display of the hash.
1238
1319
  * @default true
@@ -1545,6 +1626,9 @@ export type StatsOptions = {
1545
1626
  */
1546
1627
  warningsSpace?: number;
1547
1628
  };
1629
+ export type MultiStatsOptions = Omit<StatsOptions, "children"> & {
1630
+ children?: StatsValue | (StatsValue | undefined)[];
1631
+ };
1548
1632
  /**
1549
1633
  * Represents the value for stats configuration.
1550
1634
  */
@@ -1703,7 +1787,7 @@ export type Optimization = {
1703
1787
  * Customize the minimizer.
1704
1788
  * By default, `rspack.SwcJsMinimizerRspackPlugin` and `rspack.LightningCssMinimizerRspackPlugin` are used.
1705
1789
  */
1706
- minimizer?: Array<"..." | Plugin>;
1790
+ minimizer?: ("..." | Plugin)[];
1707
1791
  /**
1708
1792
  * Whether to merge chunks which contain the same modules.
1709
1793
  * Setting optimization.mergeDuplicateChunks to false will disable this optimization.
@@ -1812,9 +1896,9 @@ export type ExperimentCacheOptions = boolean | {
1812
1896
  buildDependencies?: string[];
1813
1897
  version?: string;
1814
1898
  snapshot?: {
1815
- immutablePaths?: Array<string | RegExp>;
1816
- unmanagedPaths?: Array<string | RegExp>;
1817
- managedPaths?: Array<string | RegExp>;
1899
+ immutablePaths?: (string | RegExp)[];
1900
+ unmanagedPaths?: (string | RegExp)[];
1901
+ managedPaths?: (string | RegExp)[];
1818
1902
  };
1819
1903
  storage?: {
1820
1904
  type: "filesystem";
@@ -1971,6 +2055,7 @@ export type Experiments = {
1971
2055
  cache?: ExperimentCacheOptions;
1972
2056
  /**
1973
2057
  * Enable lazy compilation.
2058
+ * @deprecated Please use the configuration top-level `lazyCompilation` option instead.
1974
2059
  * @default false
1975
2060
  */
1976
2061
  lazyCompilation?: boolean | LazyCompilationOptions;
@@ -2005,6 +2090,7 @@ export type Experiments = {
2005
2090
  css?: boolean;
2006
2091
  /**
2007
2092
  * Enable module layers feature.
2093
+ * @deprecated This option is deprecated, layers is enabled since v1.6.0
2008
2094
  * @default false
2009
2095
  */
2010
2096
  layers?: boolean;
@@ -2014,6 +2100,7 @@ export type Experiments = {
2014
2100
  incremental?: IncrementalPresets | Incremental;
2015
2101
  /**
2016
2102
  * Enable multi-threaded code splitting algorithm.
2103
+ * @deprecated This option is deprecated, it has a huge regression in some edge cases where the chunk graph has lots of cycles. We'll improve the performance of build_chunk_graph in the future instead
2017
2104
  */
2018
2105
  parallelCodeSplitting?: boolean;
2019
2106
  /**
@@ -2041,15 +2128,15 @@ export type Experiments = {
2041
2128
  */
2042
2129
  useInputFileSystem?: UseInputFileSystem;
2043
2130
  /**
2044
- * Enable inline const feature
2131
+ * Enable native watcher
2045
2132
  * @default false
2046
2133
  */
2047
- inlineConst?: boolean;
2134
+ nativeWatcher?: boolean;
2048
2135
  /**
2049
- * Enable native watcher
2136
+ * Enable inline const feature
2050
2137
  * @default false
2051
2138
  */
2052
- nativeWatcher?: boolean;
2139
+ inlineConst?: boolean;
2053
2140
  /**
2054
2141
  * Enable inline enum feature
2055
2142
  * @default false
@@ -2060,6 +2147,16 @@ export type Experiments = {
2060
2147
  * @default false
2061
2148
  */
2062
2149
  typeReexportsPresence?: boolean;
2150
+ /**
2151
+ * Enable lazy make side effects free barrel file
2152
+ * @default false
2153
+ */
2154
+ lazyBarrel?: boolean;
2155
+ /**
2156
+ * Enable defer import feature
2157
+ * @default false
2158
+ */
2159
+ deferImport?: boolean;
2063
2160
  };
2064
2161
  export type Watch = boolean;
2065
2162
  /** Options for watch mode. */
@@ -2092,8 +2189,7 @@ export type WatchOptions = {
2092
2189
  /**
2093
2190
  * Options for devServer, it based on `webpack-dev-server@5`
2094
2191
  * */
2095
- export interface DevServer extends DevServerOptions {
2096
- }
2192
+ export type DevServer = DevServerOptions;
2097
2193
  export type { Middleware as DevServerMiddleware } from "./devServer";
2098
2194
  /**
2099
2195
  * Ignore specific warnings.
@@ -2277,6 +2373,11 @@ export type RspackOptions = {
2277
2373
  * Performance optimization options.
2278
2374
  */
2279
2375
  performance?: Performance;
2376
+ /**
2377
+ * Enable lazy compilation.
2378
+ * @default false
2379
+ */
2380
+ lazyCompilation?: boolean | LazyCompilationOptions;
2280
2381
  };
2281
2382
  /** Configuration for Rspack */
2282
2383
  export type Configuration = RspackOptions;