@rspack/core 1.0.0-alpha.2 → 1.0.0-alpha.4

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 (166) hide show
  1. package/compiled/browserslist/index.js +17 -17
  2. package/compiled/enhanced-resolve/index.js +107 -107
  3. package/compiled/graceful-fs/index.js +8 -8
  4. package/compiled/json-parse-even-better-errors/index.js +2 -2
  5. package/compiled/neo-async/index.js +2 -2
  6. package/compiled/watchpack/index.js +15 -15
  7. package/compiled/webpack-sources/index.js +76 -76
  8. package/compiled/zod/index.js +30 -30
  9. package/compiled/zod-validation-error/index.js +6 -6
  10. package/dist/ChunkGraph.d.ts +1 -1
  11. package/dist/Compilation.d.ts +9 -9
  12. package/dist/Compilation.js +27 -24
  13. package/dist/Compiler.d.ts +6 -6
  14. package/dist/Compiler.js +5 -6
  15. package/dist/ContextModuleFactory.d.ts +1 -1
  16. package/dist/ErrorHelpers.d.ts +16 -7
  17. package/dist/ErrorHelpers.js +34 -33
  18. package/dist/ExecuteModulePlugin.js +1 -1
  19. package/dist/FileSystem.d.ts +2 -2
  20. package/dist/Module.d.ts +5 -5
  21. package/dist/Module.js +3 -6
  22. package/dist/MultiCompiler.d.ts +3 -3
  23. package/dist/MultiCompiler.js +1 -1
  24. package/dist/MultiStats.d.ts +2 -2
  25. package/dist/MultiWatching.d.ts +2 -2
  26. package/dist/NormalModule.d.ts +1 -1
  27. package/dist/NormalModuleFactory.d.ts +1 -1
  28. package/dist/Resolver.d.ts +19 -0
  29. package/dist/Resolver.js +39 -0
  30. package/dist/ResolverFactory.d.ts +12 -46
  31. package/dist/ResolverFactory.js +55 -120
  32. package/dist/RspackError.d.ts +1 -1
  33. package/dist/RuntimeGlobals.d.ts +1 -1
  34. package/dist/RuntimeGlobals.js +3 -3
  35. package/dist/Stats.d.ts +2 -2
  36. package/dist/Stats.js +4 -4
  37. package/dist/Template.js +2 -2
  38. package/dist/Watching.d.ts +3 -3
  39. package/dist/builtin-loader/swc/index.d.ts +0 -2
  40. package/dist/builtin-loader/swc/index.js +1 -3
  41. package/dist/builtin-loader/swc/pluginImport.d.ts +17 -1
  42. package/dist/builtin-loader/swc/react.d.ts +11 -1
  43. package/dist/builtin-plugin/APIPlugin.d.ts +3 -3
  44. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +3 -3
  45. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +3 -3
  46. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +3 -3
  47. package/dist/builtin-plugin/BannerPlugin.d.ts +25 -4
  48. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +4 -4
  49. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +3 -3
  50. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +3 -3
  51. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +4 -4
  52. package/dist/builtin-plugin/CssModulesPlugin.d.ts +3 -3
  53. package/dist/builtin-plugin/DataUriPlugin.d.ts +3 -3
  54. package/dist/builtin-plugin/DefinePlugin.d.ts +10 -4
  55. package/dist/builtin-plugin/DefinePlugin.js +42 -8
  56. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +3 -3
  57. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +3 -3
  58. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +5 -5
  59. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +3 -3
  60. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +3 -3
  61. package/dist/builtin-plugin/EnableLibraryPlugin.d.ts +2 -2
  62. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +3 -3
  63. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +3 -3
  64. package/dist/builtin-plugin/EntryPlugin.d.ts +5 -5
  65. package/dist/builtin-plugin/EntryPlugin.js +1 -1
  66. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +4 -4
  67. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +5 -5
  68. package/dist/builtin-plugin/ExternalsPlugin.d.ts +22 -6
  69. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +3 -3
  70. package/dist/builtin-plugin/FileUriPlugin.d.ts +3 -3
  71. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +3 -3
  72. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +3 -3
  73. package/dist/builtin-plugin/HotModuleReplacementPlugin.d.ts +2 -2
  74. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +19 -4
  75. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +4 -4
  76. package/dist/builtin-plugin/IgnorePlugin.d.ts +4 -4
  77. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +3 -3
  78. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +2 -2
  79. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +4 -4
  80. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +3 -3
  81. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +4 -4
  82. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +4 -4
  83. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +3 -3
  84. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +3 -3
  85. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +3 -3
  86. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +3 -3
  87. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +3 -3
  88. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +3 -3
  89. package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +3 -3
  90. package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +3 -3
  91. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +3 -3
  92. package/dist/builtin-plugin/ProgressPlugin.d.ts +4 -4
  93. package/dist/builtin-plugin/ProvidePlugin.d.ts +3 -3
  94. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +3 -3
  95. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +3 -3
  96. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +4 -4
  97. package/dist/builtin-plugin/RuntimePlugin.d.ts +3 -3
  98. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +3 -3
  99. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +9 -4
  100. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +4 -4
  101. package/dist/builtin-plugin/SplitChunksPlugin.d.ts +3 -3
  102. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +12 -4
  103. package/dist/builtin-plugin/SwcCssMinimizerPlugin.js +7 -1
  104. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +4 -4
  105. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +2 -2
  106. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +3 -3
  107. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +3 -3
  108. package/dist/builtin-plugin/WorkerPlugin.d.ts +3 -3
  109. package/dist/builtin-plugin/WorkerPlugin.js +5 -1
  110. package/dist/builtin-plugin/base.d.ts +6 -6
  111. package/dist/builtin-plugin/base.js +4 -4
  112. package/dist/builtin-plugin/css-extract/index.d.ts +1 -1
  113. package/dist/builtin-plugin/css-extract/loader.js +15 -5
  114. package/dist/builtin-plugin/css-extract/utils.d.ts +1 -1
  115. package/dist/builtin-plugin/index.d.ts +1 -7
  116. package/dist/builtin-plugin/index.js +3 -17
  117. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +11 -17
  118. package/dist/builtin-plugin/lazy-compilation/plugin.d.ts +2 -2
  119. package/dist/config/adapter.d.ts +5 -4
  120. package/dist/config/adapter.js +23 -11
  121. package/dist/config/adapterRuleUse.d.ts +7 -7
  122. package/dist/config/adapterRuleUse.js +1 -1
  123. package/dist/config/browserslistTargetHandler.js +1 -1
  124. package/dist/config/defaults.d.ts +1 -1
  125. package/dist/config/defaults.js +4 -3
  126. package/dist/config/zod.d.ts +491 -384
  127. package/dist/config/zod.js +44 -42
  128. package/dist/container/ContainerPlugin.d.ts +3 -3
  129. package/dist/container/ContainerReferencePlugin.d.ts +4 -4
  130. package/dist/container/ModuleFederationPlugin.d.ts +2 -2
  131. package/dist/container/ModuleFederationPlugin.js +2 -2
  132. package/dist/container/ModuleFederationPluginV1.d.ts +5 -5
  133. package/dist/container/ModuleFederationRuntimePlugin.d.ts +3 -3
  134. package/dist/container/default.runtime.js +1 -1
  135. package/dist/lib/EntryOptionPlugin.d.ts +2 -2
  136. package/dist/lib/NormalModuleReplacementPlugin.d.ts +2 -2
  137. package/dist/loader-runner/index.d.ts +2 -2
  138. package/dist/loader-runner/index.js +38 -51
  139. package/dist/loader-runner/loadLoader.js +1 -1
  140. package/dist/logging/runtime.js +1 -1
  141. package/dist/node/NodeTemplatePlugin.d.ts +1 -1
  142. package/dist/node/NodeWatchFileSystem.d.ts +1 -1
  143. package/dist/rspack.d.ts +3 -3
  144. package/dist/rspack.js +1 -1
  145. package/dist/rspackOptionsApply.d.ts +1 -1
  146. package/dist/rspackOptionsApply.js +1 -19
  147. package/dist/sharing/ConsumeSharedPlugin.d.ts +2 -2
  148. package/dist/sharing/ConsumeSharedPlugin.js +1 -1
  149. package/dist/sharing/ProvideSharedPlugin.d.ts +2 -2
  150. package/dist/sharing/SharePlugin.d.ts +1 -1
  151. package/dist/sharing/ShareRuntimePlugin.d.ts +2 -2
  152. package/dist/stats/DefaultStatsFactoryPlugin.js +246 -46
  153. package/dist/stats/DefaultStatsPresetPlugin.js +17 -17
  154. package/dist/stats/DefaultStatsPrinterPlugin.js +1 -1
  155. package/dist/stats/StatsFactory.d.ts +2 -2
  156. package/dist/stats/statsFactoryUtils.d.ts +16 -1
  157. package/dist/util/SplitChunkSize.d.ts +1 -1
  158. package/dist/util/bindingVersionCheck.js +1 -1
  159. package/dist/util/comparators.d.ts +1 -1
  160. package/dist/util/fs.d.ts +1 -1
  161. package/dist/util/identifier.d.ts +65 -62
  162. package/dist/util/identifier.js +30 -55
  163. package/dist/util/index.d.ts +1 -1
  164. package/dist/util/index.js +4 -2
  165. package/dist/util/validate.d.ts +1 -1
  166. package/package.json +7 -34
@@ -56,8 +56,8 @@ function getRawExtractCommentsOptions(extractComments) {
56
56
  }
57
57
  exports.SwcJsMinimizerRspackPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.SwcJsMinimizerRspackPlugin, (options) => {
58
58
  let compress = options?.compress ?? true;
59
- let mangle = options?.mangle ?? true;
60
- let format = {
59
+ const mangle = options?.mangle ?? true;
60
+ const format = {
61
61
  comments: false,
62
62
  ...options?.format
63
63
  };
@@ -2,9 +2,9 @@ import { BuiltinPluginName } from "@rspack/binding";
2
2
  export declare const WarnCaseSensitiveModulesPlugin: {
3
3
  new (): {
4
4
  name: BuiltinPluginName;
5
- _options: void;
6
- affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
7
- raw(): import("@rspack/binding").BuiltinPlugin;
5
+ _args: [];
6
+ affectedHooks: "done" | "compilation" | "failed" | "environment" | "emit" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
7
+ raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
8
8
  apply(compiler: import("../Compiler").Compiler): void;
9
9
  };
10
10
  };
@@ -2,9 +2,9 @@ import { BuiltinPluginName } from "@rspack/binding";
2
2
  export declare const WebWorkerTemplatePlugin: {
3
3
  new (): {
4
4
  name: BuiltinPluginName;
5
- _options: undefined;
6
- affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
7
- raw(): import("@rspack/binding").BuiltinPlugin;
5
+ _args: [];
6
+ affectedHooks: "done" | "compilation" | "failed" | "environment" | "emit" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
7
+ raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
8
8
  apply(compiler: import("../Compiler").Compiler): void;
9
9
  };
10
10
  };
@@ -1,6 +1,6 @@
1
- import { BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
2
- import { Compiler } from "../Compiler";
3
- import { ChunkLoading, OutputModule, WasmLoading, WorkerPublicPath } from "../config";
1
+ import { type BuiltinPlugin, BuiltinPluginName } from "@rspack/binding";
2
+ import type { Compiler } from "../Compiler";
3
+ import type { ChunkLoading, OutputModule, WasmLoading, WorkerPublicPath } from "../config";
4
4
  import { RspackBuiltinPlugin } from "./base";
5
5
  export declare class WorkerPlugin extends RspackBuiltinPlugin {
6
6
  private chunkLoading;
@@ -6,7 +6,11 @@ const EnableChunkLoadingPlugin_1 = require("./EnableChunkLoadingPlugin");
6
6
  const EnableWasmLoadingPlugin_1 = require("./EnableWasmLoadingPlugin");
7
7
  const base_1 = require("./base");
8
8
  class WorkerPlugin extends base_1.RspackBuiltinPlugin {
9
- constructor(chunkLoading, wasmLoading, module, workerPublicPath) {
9
+ constructor(chunkLoading, wasmLoading,
10
+ // @ts-expect-error not implemented
11
+ module,
12
+ // @ts-expect-error not implemented
13
+ workerPublicPath) {
10
14
  super();
11
15
  this.chunkLoading = chunkLoading;
12
16
  this.wasmLoading = wasmLoading;
@@ -1,5 +1,5 @@
1
- import * as binding from "@rspack/binding";
2
- import { Compiler, RspackPluginInstance } from "..";
1
+ import type * as binding from "@rspack/binding";
2
+ import type { Compiler, RspackPluginInstance } from "..";
3
3
  type AffectedHooks = keyof Compiler["hooks"];
4
4
  export declare const HOOKS_CAN_NOT_INHERENT_FROM_PARENT: string[];
5
5
  export declare function canInherentFromParent(affectedHooks?: AffectedHooks): boolean;
@@ -10,12 +10,12 @@ export declare abstract class RspackBuiltinPlugin implements RspackPluginInstanc
10
10
  apply(compiler: Compiler): void;
11
11
  }
12
12
  export declare function createBuiltinPlugin<R>(name: binding.BuiltinPluginName, options: R): binding.BuiltinPlugin;
13
- export declare function create<T extends any[], R>(name: binding.BuiltinPluginName, resolve: (...args: T) => R, affectedHooks?: AffectedHooks): {
13
+ export declare function create<T extends any[], R>(name: binding.BuiltinPluginName, resolve: (this: Compiler, ...args: T) => R, affectedHooks?: AffectedHooks): {
14
14
  new (...args: T): {
15
15
  name: binding.BuiltinPluginName;
16
- _options: R;
17
- affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
18
- raw(): binding.BuiltinPlugin;
16
+ _args: T;
17
+ affectedHooks: "done" | "compilation" | "failed" | "environment" | "emit" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
18
+ raw(compiler: Compiler): binding.BuiltinPlugin;
19
19
  apply(compiler: Compiler): void;
20
20
  };
21
21
  };
@@ -22,7 +22,7 @@ function canInherentFromParent(affectedHooks) {
22
22
  exports.canInherentFromParent = canInherentFromParent;
23
23
  class RspackBuiltinPlugin {
24
24
  apply(compiler) {
25
- let raw = this.raw(compiler);
25
+ const raw = this.raw(compiler);
26
26
  if (raw) {
27
27
  raw.canInherentFromParent = canInherentFromParent(this.affectedHooks);
28
28
  compiler.__internal__registerBuiltinPlugin(raw);
@@ -46,10 +46,10 @@ affectedHooks) {
46
46
  super();
47
47
  this.name = name;
48
48
  this.affectedHooks = affectedHooks;
49
- this._options = resolve(...args);
49
+ this._args = args;
50
50
  }
51
- raw() {
52
- return createBuiltinPlugin(name, this._options);
51
+ raw(compiler) {
52
+ return createBuiltinPlugin(name, resolve.apply(compiler, this._args));
53
53
  }
54
54
  }
55
55
  // Make the plugin class name consistent with webpack
@@ -1,5 +1,5 @@
1
1
  import type { RawCssExtractPluginOption } from "@rspack/binding";
2
- import { Compiler } from "../..";
2
+ import type { Compiler } from "../..";
3
3
  export * from "./loader";
4
4
  export type { CssExtractRspackLoaderOptions } from "./loader";
5
5
  export interface CssExtractRspackPluginOptions {
@@ -34,7 +34,12 @@ const loader = function loader(content) {
34
34
  if (this._compiler &&
35
35
  this._compiler.options &&
36
36
  this._compiler.options.experiments &&
37
- this._compiler.options.experiments.css) {
37
+ this._compiler.options.experiments.css &&
38
+ this._module &&
39
+ (this._module.type === "css" ||
40
+ this._module.type === "css/auto" ||
41
+ this._module.type === "css/global" ||
42
+ this._module.type === "css/module")) {
38
43
  return content;
39
44
  }
40
45
  };
@@ -42,8 +47,13 @@ const pitch = function (request, _, data) {
42
47
  if (this._compiler &&
43
48
  this._compiler.options &&
44
49
  this._compiler.options.experiments &&
45
- this._compiler.options.experiments.css) {
46
- let e = new Error("You can't use `experiments.css` and `css-extract-rspack-plugin` together, please set `experiments.css` to `false`");
50
+ this._compiler.options.experiments.css &&
51
+ this._module &&
52
+ (this._module.type === "css" ||
53
+ this._module.type === "css/auto" ||
54
+ this._module.type === "css/global" ||
55
+ this._module.type === "css/module")) {
56
+ const e = new Error(`use type 'css' and \`CssExtractRspackPlugin\` together, please set \`experiments.css\` to \`false\` or set \`{ type: "javascript/auto" }\` for rules with \`CssExtractRspackPlugin\` in your rspack config (now \`CssExtractRspackPlugin\` does nothing).`);
47
57
  e.stack = undefined;
48
58
  this.emitWarning(e);
49
59
  return;
@@ -107,8 +117,8 @@ const pitch = function (request, _, data) {
107
117
  const identifierCountMap = new Map();
108
118
  dependencies = exports
109
119
  .map(([id, content, media, sourceMap, supports, layer]) => {
110
- let identifier = id;
111
- let context = this.rootContext;
120
+ const identifier = id;
121
+ const context = this.rootContext;
112
122
  const count = identifierCountMap.get(identifier) || 0;
113
123
  identifierCountMap.set(identifier, count + 1);
114
124
  return {
@@ -1,4 +1,4 @@
1
- import { LoaderContext } from "../..";
1
+ import type { LoaderContext } from "../..";
2
2
  export declare function isAbsolutePath(str: string): boolean;
3
3
  export declare function isRelativePath(str: string): boolean;
4
4
  export declare function stringifyRequest(loaderContext: LoaderContext, request: string): string;
@@ -1,9 +1,9 @@
1
+ export { RspackBuiltinPlugin } from "./base";
1
2
  export * from "./APIPlugin";
2
3
  export * from "./ArrayPushCallbackChunkFormatPlugin";
3
4
  export * from "./AssetModulesPlugin";
4
5
  export * from "./AsyncWebAssemblyModulesPlugin";
5
6
  export * from "./BannerPlugin";
6
- export { RspackBuiltinPlugin } from "./base";
7
7
  export * from "./BundlerInfoRspackPlugin";
8
8
  export * from "./ChunkPrefetchPreloadPlugin";
9
9
  export * from "./CommonJsChunkFormatPlugin";
@@ -63,9 +63,3 @@ export * from "./WarnCaseSensitiveModulesPlugin";
63
63
  export * from "./WebWorkerTemplatePlugin";
64
64
  export * from "./WorkerPlugin";
65
65
  export * from "./FetchCompileAsyncWasmPlugin";
66
- import { RawBuiltins } from "@rspack/binding";
67
- import { RspackOptionsNormalized } from "..";
68
- export interface Builtins {
69
- treeShaking?: boolean | "module";
70
- }
71
- export declare function deprecated_resolveBuiltins(builtins: Builtins, options: RspackOptionsNormalized): RawBuiltins;
@@ -14,14 +14,14 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.deprecated_resolveBuiltins = exports.RspackBuiltinPlugin = void 0;
17
+ exports.RspackBuiltinPlugin = void 0;
18
+ var base_1 = require("./base");
19
+ Object.defineProperty(exports, "RspackBuiltinPlugin", { enumerable: true, get: function () { return base_1.RspackBuiltinPlugin; } });
18
20
  __exportStar(require("./APIPlugin"), exports);
19
21
  __exportStar(require("./ArrayPushCallbackChunkFormatPlugin"), exports);
20
22
  __exportStar(require("./AssetModulesPlugin"), exports);
21
23
  __exportStar(require("./AsyncWebAssemblyModulesPlugin"), exports);
22
24
  __exportStar(require("./BannerPlugin"), exports);
23
- var base_1 = require("./base");
24
- Object.defineProperty(exports, "RspackBuiltinPlugin", { enumerable: true, get: function () { return base_1.RspackBuiltinPlugin; } });
25
25
  __exportStar(require("./BundlerInfoRspackPlugin"), exports);
26
26
  __exportStar(require("./ChunkPrefetchPreloadPlugin"), exports);
27
27
  __exportStar(require("./CommonJsChunkFormatPlugin"), exports);
@@ -81,17 +81,3 @@ __exportStar(require("./WarnCaseSensitiveModulesPlugin"), exports);
81
81
  __exportStar(require("./WebWorkerTemplatePlugin"), exports);
82
82
  __exportStar(require("./WorkerPlugin"), exports);
83
83
  __exportStar(require("./FetchCompileAsyncWasmPlugin"), exports);
84
- function resolveTreeShaking(treeShaking, production) {
85
- return treeShaking !== undefined
86
- ? treeShaking.toString()
87
- : production
88
- ? "true"
89
- : "false";
90
- }
91
- function deprecated_resolveBuiltins(builtins, options) {
92
- const production = options.mode === "production" || !options.mode;
93
- return {
94
- treeShaking: resolveTreeShaking(builtins.treeShaking, production)
95
- };
96
- }
97
- exports.deprecated_resolveBuiltins = deprecated_resolveBuiltins;
@@ -1,4 +1,4 @@
1
- import { BuiltinPluginName, JsModule, RawRegex } from "@rspack/binding";
1
+ import { BuiltinPluginName, type JsModule, type RawRegex } from "@rspack/binding";
2
2
  export declare const BuiltinLazyCompilationPlugin: {
3
3
  new (module: (args: {
4
4
  module: string;
@@ -9,22 +9,16 @@ export declare const BuiltinLazyCompilationPlugin: {
9
9
  client: string;
10
10
  }, cacheable: boolean, entries: boolean, imports: boolean, test?: RawRegex | ((m: JsModule) => boolean) | undefined): {
11
11
  name: BuiltinPluginName;
12
- _options: {
13
- module: (args: {
14
- module: string;
15
- path: string;
16
- }) => {
17
- active: boolean;
18
- data: string;
19
- client: string;
20
- };
21
- cacheable: boolean;
22
- imports: boolean;
23
- entries: boolean;
24
- test: RawRegex | ((m: JsModule) => boolean) | undefined;
25
- };
26
- affectedHooks: "make" | "compile" | "emit" | "afterEmit" | "invalid" | "done" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
27
- raw(): import("@rspack/binding").BuiltinPlugin;
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?: RawRegex | ((m: JsModule) => boolean) | undefined];
20
+ affectedHooks: "done" | "compilation" | "failed" | "environment" | "emit" | "make" | "compile" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "shutdown" | "watchRun" | "watchClose" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
21
+ raw(compiler: import("../../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
28
22
  apply(compiler: import("../../Compiler").Compiler): void;
29
23
  };
30
24
  };
@@ -1,6 +1,6 @@
1
- import { JsModule, RawRegex } from "@rspack/binding";
1
+ import type { JsModule, RawRegex } from "@rspack/binding";
2
2
  import type { Compiler } from "../..";
3
- import { LazyCompilationDefaultBackendOptions } from "./backend";
3
+ import { type LazyCompilationDefaultBackendOptions } from "./backend";
4
4
  export default class LazyCompilationPlugin {
5
5
  cacheable: boolean;
6
6
  entries: boolean;
@@ -1,9 +1,10 @@
1
1
  import type { RawLibraryOptions, RawOptions } from "@rspack/binding";
2
- import { Compiler } from "../Compiler";
3
- import { LoaderContext, LoaderDefinition, LoaderDefinitionFunction } from "./adapterRuleUse";
4
- import { RspackOptionsNormalized } from "./normalization";
5
- import { ChunkLoading, LibraryOptions } from "./zod";
2
+ import type { Compiler } from "../Compiler";
3
+ import { type LoaderContext, type LoaderDefinition, type LoaderDefinitionFunction } from "./adapterRuleUse";
4
+ import type { RspackOptionsNormalized } from "./normalization";
5
+ import type { ChunkLoading, LibraryOptions, Resolve } from "./zod";
6
6
  export type { LoaderContext, LoaderDefinition, LoaderDefinitionFunction };
7
7
  export declare const getRawOptions: (options: RspackOptionsNormalized, compiler: Compiler) => RawOptions;
8
+ export declare function getRawResolve(resolve: Resolve): RawOptions["resolve"];
8
9
  export declare function getRawLibrary(library: LibraryOptions): RawLibraryOptions;
9
10
  export declare function getRawChunkLoading(chunkLoading: ChunkLoading): string;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getRawChunkLoading = exports.getRawLibrary = exports.getRawOptions = void 0;
6
+ exports.getRawChunkLoading = exports.getRawLibrary = exports.getRawResolve = exports.getRawOptions = void 0;
7
7
  const assert_1 = __importDefault(require("assert"));
8
8
  const Stats_1 = require("../Stats");
9
9
  const util_1 = require("../util");
@@ -106,6 +106,7 @@ function getRawResolve(resolve) {
106
106
  byDependency: getRawResolveByDependency(resolve.byDependency)
107
107
  };
108
108
  }
109
+ exports.getRawResolve = getRawResolve;
109
110
  function getRawCrossOriginLoading(crossOriginLoading) {
110
111
  if (typeof crossOriginLoading === "boolean") {
111
112
  return { type: "bool", boolPayload: crossOriginLoading };
@@ -261,7 +262,7 @@ const getRawModuleRule = (rule, path, options, upperType) => {
261
262
  }
262
263
  let funcUse;
263
264
  if (typeof rule.use === "function") {
264
- let use = rule.use;
265
+ const use = rule.use;
265
266
  funcUse = (rawContext) => {
266
267
  const context = {
267
268
  ...rawContext,
@@ -271,7 +272,7 @@ const getRawModuleRule = (rule, path, options, upperType) => {
271
272
  return (0, adapterRuleUse_1.createRawModuleRuleUses)(uses ?? [], `${path}.use`, options);
272
273
  };
273
274
  }
274
- let rawModuleRule = {
275
+ const rawModuleRule = {
275
276
  test: rule.test ? getRawRuleSetCondition(rule.test) : undefined,
276
277
  include: rule.include ? getRawRuleSetCondition(rule.include) : undefined,
277
278
  exclude: rule.exclude ? getRawRuleSetCondition(rule.exclude) : undefined,
@@ -325,7 +326,7 @@ const getRawModuleRule = (rule, path, options, upperType) => {
325
326
  delete rawModuleRule.resource;
326
327
  delete rawModuleRule.resourceQuery;
327
328
  delete rawModuleRule.resourceFragment;
328
- rawModuleRule.rspackResource = getRawRuleSetCondition(function (resourceQueryFragment) {
329
+ rawModuleRule.rspackResource = getRawRuleSetCondition(resourceQueryFragment => {
329
330
  const { path, query, fragment } = (0, identifier_1.parseResource)(resourceQueryFragment);
330
331
  if (rule.test && !tryMatch(path, rule.test)) {
331
332
  return false;
@@ -391,10 +392,14 @@ function getRawRuleSetLogicalConditions(logical) {
391
392
  };
392
393
  }
393
394
  function getRawParserOptionsByModuleType(parser) {
394
- return Object.fromEntries(Object.entries(parser).map(([k, v]) => [k, getRawParserOptions(v, k)]));
395
+ return Object.fromEntries(Object.entries(parser)
396
+ .map(([k, v]) => [k, getRawParserOptions(v, k)])
397
+ .filter(([k, v]) => v !== undefined));
395
398
  }
396
399
  function getRawGeneratorOptionsByModuleType(parser) {
397
- return Object.fromEntries(Object.entries(parser).map(([k, v]) => [k, getRawGeneratorOptions(v, k)]));
400
+ return Object.fromEntries(Object.entries(parser)
401
+ .map(([k, v]) => [k, getRawGeneratorOptions(v, k)])
402
+ .filter(([k, v]) => v !== undefined));
398
403
  }
399
404
  function getRawParserOptions(parser, type) {
400
405
  if (type === "asset") {
@@ -404,10 +409,8 @@ function getRawParserOptions(parser, type) {
404
409
  };
405
410
  }
406
411
  else if (type === "javascript") {
407
- return {
408
- type: "javascript",
409
- javascript: getRawJavascriptParserOptions(parser)
410
- };
412
+ // Filter this out, since `parser["javascript"]` already merge into `parser["javascript/*"]` in default.ts
413
+ return;
411
414
  }
412
415
  else if (type === "javascript/auto") {
413
416
  return {
@@ -469,7 +472,8 @@ function getRawJavascriptParserOptions(parser) {
469
472
  ? "false"
470
473
  : parser.reexportExportsPresence,
471
474
  strictExportPresence: parser.strictExportPresence ?? false,
472
- worker: getRawJavascriptParserOptionsWorker(parser.worker)
475
+ worker: getRawJavascriptParserOptionsWorker(parser.worker),
476
+ overrideStrict: parser.overrideStrict
473
477
  };
474
478
  }
475
479
  function getRawJavascriptParserOptionsWorker(worker) {
@@ -545,6 +549,14 @@ function getRawGeneratorOptions(generator, type) {
545
549
  cssModule: getRawCssAutoOrModuleGeneratorOptions(generator)
546
550
  };
547
551
  }
552
+ if ([
553
+ "javascript",
554
+ "javascript/auto",
555
+ "javascript/dynamic",
556
+ "javascript/esm"
557
+ ].includes(type)) {
558
+ return undefined;
559
+ }
548
560
  throw new Error(`unreachable: unknow module type: ${type}`);
549
561
  }
550
562
  function getRawAssetGeneratorOptions(options) {
@@ -1,13 +1,13 @@
1
1
  /// <reference types="node" />
2
2
  import type { JsAssetInfo, RawModuleRuleUse, RawOptions } from "@rspack/binding";
3
- import { ResolveRequest } from "../../compiled/enhanced-resolve";
4
- import { Compiler } from "../Compiler";
5
- import { Logger } from "../logging/Logger";
3
+ import type { ResolveRequest } from "../../compiled/enhanced-resolve";
4
+ import type { Compiler } from "../Compiler";
5
+ import type { Logger } from "../logging/Logger";
6
6
  import Hash = require("../util/hash");
7
- import { Compilation } from "../Compilation";
8
- import { Module } from "../Module";
9
- import { LoaderObject } from "../loader-runner";
10
- import { Mode, Resolve, RuleSetUseItem, Target } from "./zod";
7
+ import type { Compilation } from "../Compilation";
8
+ import type { Module } from "../Module";
9
+ import { type LoaderObject } from "../loader-runner";
10
+ import type { Mode, Resolve, RuleSetUseItem, Target } from "./zod";
11
11
  export declare const BUILTIN_LOADER_PREFIX = "builtin:";
12
12
  export interface ComposeJsUseOptions {
13
13
  devtool: RawOptions["devtool"];
@@ -15,7 +15,7 @@ function createRawModuleRuleUses(uses, path, options) {
15
15
  exports.createRawModuleRuleUses = createRawModuleRuleUses;
16
16
  const getSwcLoaderOptions = (o, options) => {
17
17
  if (o && typeof o === "object" && o.rspackExperiments) {
18
- let expr = o.rspackExperiments;
18
+ const expr = o.rspackExperiments;
19
19
  if (expr.import || expr.pluginImport) {
20
20
  expr.import = (0, builtin_loader_1.resolvePluginImport)(expr.import || expr.pluginImport);
21
21
  }
@@ -83,7 +83,7 @@ const resolve = browsers => {
83
83
  const [parsedMajor, parserMinor] =
84
84
  // safari TP supports all features for normal safari
85
85
  parsedVersion === "TP"
86
- ? [Infinity, Infinity]
86
+ ? [Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY]
87
87
  : parsedVersion.includes("-")
88
88
  ? parsedVersion.split("-")[0].split(".")
89
89
  : parsedVersion.split(".");
@@ -7,6 +7,6 @@
7
7
  * Copyright (c) JS Foundation and other contributors
8
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
9
9
  */
10
- import { RspackOptionsNormalized } from "./normalization";
10
+ import type { RspackOptionsNormalized } from "./normalization";
11
11
  export declare const applyRspackOptionsDefaults: (options: RspackOptionsNormalized) => void;
12
12
  export declare const applyRspackOptionsBaseDefaults: (options: RspackOptionsNormalized) => void;
@@ -30,7 +30,7 @@ const applyRspackOptionsDefaults = (options) => {
30
30
  });
31
31
  const { mode, target } = options;
32
32
  (0, assert_1.default)(!(0, util_1.isNil)(target));
33
- let targetProperties = target === false
33
+ const targetProperties = target === false
34
34
  ? false
35
35
  : typeof target === "string"
36
36
  ? (0, target_1.getTargetProperties)(target, options.context)
@@ -151,6 +151,7 @@ const applyJavascriptParserOptionsDefaults = (parserOptions, fallback) => {
151
151
  D(parserOptions, "reexportExportsPresence", fallback?.reexportExportsPresence);
152
152
  D(parserOptions, "strictExportPresence", fallback?.strictExportPresence ?? false);
153
153
  D(parserOptions, "worker", fallback?.worker ?? ["..."]);
154
+ D(parserOptions, "overrideStrict", fallback?.overrideStrict ?? undefined);
154
155
  };
155
156
  const applyModuleDefaults = (module, { asyncWebAssembly, css, targetProperties }) => {
156
157
  (0, assertNotNil_1.assertNotNill)(module.parser);
@@ -726,8 +727,8 @@ const applyOptimizationDefaults = (optimization, { production, development, css
726
727
  F(splitChunks, "minSize", () => (production ? 20000 : 10000));
727
728
  // F(splitChunks, "minRemainingSize", () => (development ? 0 : undefined));
728
729
  // F(splitChunks, "enforceSizeThreshold", () => (production ? 50000 : 30000));
729
- F(splitChunks, "maxAsyncRequests", () => (production ? 30 : Infinity));
730
- F(splitChunks, "maxInitialRequests", () => (production ? 30 : Infinity));
730
+ F(splitChunks, "maxAsyncRequests", () => production ? 30 : Number.POSITIVE_INFINITY);
731
+ F(splitChunks, "maxInitialRequests", () => production ? 30 : Number.POSITIVE_INFINITY);
731
732
  D(splitChunks, "automaticNameDelimiter", "-");
732
733
  const { cacheGroups } = splitChunks;
733
734
  if (cacheGroups) {