@rspack/core 1.0.0-alpha.5 → 1.0.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.
Files changed (181) hide show
  1. package/compiled/zod/index.d.ts +138 -52
  2. package/compiled/zod/index.js +300 -103
  3. package/compiled/zod/package.json +1 -1
  4. package/compiled/zod-validation-error/index.js +6 -6
  5. package/dist/Compilation.d.ts +22 -4
  6. package/dist/Compilation.js +64 -49
  7. package/dist/Compiler.d.ts +11 -10
  8. package/dist/Compiler.js +42 -42
  9. package/dist/ErrorHelpers.js +2 -4
  10. package/dist/Module.d.ts +1 -0
  11. package/dist/Module.js +3 -6
  12. package/dist/ModuleTypeConstants.d.ts +45 -69
  13. package/dist/ModuleTypeConstants.js +24 -77
  14. package/dist/NormalModule.d.ts +1 -0
  15. package/dist/NormalModule.js +1 -0
  16. package/dist/Stats.js +4 -6
  17. package/dist/Template.d.ts +31 -147
  18. package/dist/Template.js +40 -236
  19. package/dist/builtin-loader/lightningcss/index.d.ts +89 -0
  20. package/dist/builtin-loader/lightningcss/index.js +175 -0
  21. package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
  22. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
  23. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
  24. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
  25. package/dist/builtin-plugin/BannerPlugin.d.ts +25 -49
  26. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
  27. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
  28. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
  29. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
  30. package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
  31. package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
  32. package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
  33. package/dist/builtin-plugin/DefinePlugin.js +9 -13
  34. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
  35. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
  36. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +1 -1
  37. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
  38. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
  39. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
  40. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
  41. package/dist/builtin-plugin/EntryPlugin.d.ts +4 -3
  42. package/dist/builtin-plugin/EntryPlugin.js +1 -0
  43. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
  44. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
  45. package/dist/builtin-plugin/ExternalsPlugin.d.ts +29 -5
  46. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +1 -1
  47. package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
  48. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
  49. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
  50. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +9 -9
  51. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
  52. package/dist/builtin-plugin/IgnorePlugin.d.ts +1 -1
  53. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
  54. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +2 -2
  55. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
  56. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
  57. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +1 -1
  58. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +4 -1
  59. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
  60. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
  61. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
  62. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
  63. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +1 -1
  64. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
  65. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
  66. package/dist/builtin-plugin/NaturalChunkIdsPlugin.d.ts +1 -1
  67. package/dist/builtin-plugin/NaturalModuleIdsPlugin.d.ts +1 -1
  68. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
  69. package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
  70. package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
  71. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
  72. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
  73. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +1 -1
  74. package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
  75. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
  76. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +1 -1
  77. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
  78. package/dist/builtin-plugin/SplitChunksPlugin.js +5 -15
  79. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
  80. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
  81. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +15 -23
  82. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
  83. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
  84. package/dist/builtin-plugin/base.d.ts +1 -1
  85. package/dist/builtin-plugin/base.js +1 -3
  86. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts +3 -3
  87. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +17 -66
  88. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +2 -0
  89. package/dist/builtin-plugin/css-extract/hmr/{normalize-url.js → normalizeUrl.js} +15 -24
  90. package/dist/builtin-plugin/css-extract/loader.d.ts +8 -3
  91. package/dist/builtin-plugin/css-extract/loader.js +28 -17
  92. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +1 -1
  93. package/dist/config/adapter.d.ts +1 -1
  94. package/dist/config/adapter.js +39 -25
  95. package/dist/config/adapterRuleUse.d.ts +5 -5
  96. package/dist/config/adapterRuleUse.js +23 -1
  97. package/dist/config/browserslistTargetHandler.d.ts +17 -15
  98. package/dist/config/browserslistTargetHandler.js +27 -33
  99. package/dist/config/defaults.js +27 -31
  100. package/dist/config/normalization.d.ts +8 -3
  101. package/dist/config/normalization.js +7 -5
  102. package/dist/config/target.d.ts +48 -109
  103. package/dist/config/target.js +50 -86
  104. package/dist/config/zod.d.ts +2660 -2305
  105. package/dist/config/zod.js +38 -19
  106. package/dist/container/ContainerPlugin.d.ts +7 -7
  107. package/dist/container/ContainerReferencePlugin.d.ts +1 -1
  108. package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
  109. package/dist/container/options.js +1 -1
  110. package/dist/exports.d.ts +4 -4
  111. package/dist/exports.js +2 -2
  112. package/dist/lib/AbstractMethodError.d.ts +12 -3
  113. package/dist/lib/AbstractMethodError.js +29 -21
  114. package/dist/lib/Cache.d.ts +40 -46
  115. package/dist/lib/Cache.js +43 -78
  116. package/dist/lib/CacheFacade.d.ts +119 -143
  117. package/dist/lib/CacheFacade.js +123 -123
  118. package/dist/lib/EntryOptionPlugin.d.ts +19 -2
  119. package/dist/lib/EntryOptionPlugin.js +22 -6
  120. package/dist/lib/EnvironmentPlugin.d.ts +17 -10
  121. package/dist/lib/EnvironmentPlugin.js +16 -15
  122. package/dist/lib/HookWebpackError.d.ts +27 -33
  123. package/dist/lib/HookWebpackError.js +33 -34
  124. package/dist/lib/IgnoreWarningsPlugin.d.ts +25 -0
  125. package/dist/lib/{ignoreWarningsPlugin.js → IgnoreWarningsPlugin.js} +17 -0
  126. package/dist/lib/LoaderOptionsPlugin.d.ts +18 -9
  127. package/dist/lib/LoaderOptionsPlugin.js +38 -14
  128. package/dist/lib/LoaderTargetPlugin.d.ts +17 -8
  129. package/dist/lib/LoaderTargetPlugin.js +17 -15
  130. package/dist/lib/ModuleFilenameHelpers.d.ts +10 -1
  131. package/dist/lib/ModuleFilenameHelpers.js +10 -3
  132. package/dist/lib/NormalModuleReplacementPlugin.d.ts +15 -5
  133. package/dist/lib/NormalModuleReplacementPlugin.js +15 -5
  134. package/dist/lib/WebpackError.d.ts +29 -22
  135. package/dist/lib/WebpackError.js +17 -29
  136. package/dist/lib/cache/getLazyHashedEtag.d.ts +24 -24
  137. package/dist/lib/cache/getLazyHashedEtag.js +20 -23
  138. package/dist/lib/cache/mergeEtags.d.ts +15 -9
  139. package/dist/lib/cache/mergeEtags.js +23 -22
  140. package/dist/lib/formatLocation.d.ts +13 -8
  141. package/dist/lib/formatLocation.js +20 -20
  142. package/dist/loader-runner/LoaderLoadingError.d.ts +11 -1
  143. package/dist/loader-runner/LoaderLoadingError.js +3 -5
  144. package/dist/loader-runner/index.js +7 -9
  145. package/dist/loader-runner/loadLoader.d.ts +11 -2
  146. package/dist/loader-runner/loadLoader.js +17 -19
  147. package/dist/logging/createConsoleLogger.js +2 -6
  148. package/dist/logging/truncateArgs.js +5 -9
  149. package/dist/node/nodeConsole.js +1 -3
  150. package/dist/rspackOptionsApply.js +2 -2
  151. package/dist/stats/DefaultStatsFactoryPlugin.js +18 -8
  152. package/dist/stats/DefaultStatsPresetPlugin.js +4 -4
  153. package/dist/stats/DefaultStatsPrinterPlugin.js +11 -16
  154. package/dist/stats/StatsFactory.js +13 -17
  155. package/dist/stats/StatsPrinter.js +7 -9
  156. package/dist/util/AssetInfo.js +11 -7
  157. package/dist/util/SplitChunkSize.js +1 -1
  158. package/dist/util/cleverMerge.d.ts +33 -57
  159. package/dist/util/cleverMerge.js +89 -145
  160. package/dist/util/comparators.d.ts +1 -1
  161. package/dist/util/comparators.js +3 -5
  162. package/dist/util/createHash.d.ts +4 -3
  163. package/dist/util/createHash.js +31 -45
  164. package/dist/util/fs.js +9 -13
  165. package/dist/util/hash/BatchedHash.d.ts +24 -9
  166. package/dist/util/hash/BatchedHash.js +16 -13
  167. package/dist/util/hash/index.d.ts +9 -9
  168. package/dist/util/hash/index.js +14 -11
  169. package/dist/util/hash/md4.d.ts +29 -2
  170. package/dist/util/hash/md4.js +7 -3
  171. package/dist/util/hash/wasm-hash.d.ts +52 -5
  172. package/dist/util/hash/wasm-hash.js +19 -22
  173. package/dist/util/hash/xxhash64.d.ts +29 -2
  174. package/dist/util/hash/xxhash64.js +7 -3
  175. package/dist/util/identifier.js +9 -15
  176. package/dist/util/index.js +1 -1
  177. package/dist/util/memoize.js +7 -9
  178. package/package.json +9 -8
  179. package/compiled/enhanced-resolve/index.js +0 -5566
  180. package/dist/builtin-plugin/css-extract/hmr/normalize-url.d.ts +0 -2
  181. package/dist/lib/ignoreWarningsPlugin.d.ts +0 -7
@@ -1 +1 @@
1
- {"name":"zod","author":"Colin McDonnell <colin@colinhacks.com>","version":"3.22.4","funding":"https://github.com/sponsors/colinhacks","license":"MIT","types":"index.d.ts","type":"commonjs"}
1
+ {"name":"zod","author":"Colin McDonnell <colin@colinhacks.com>","version":"3.23.8","funding":"https://github.com/sponsors/colinhacks","license":"MIT","types":"index.d.ts","type":"commonjs"}
@@ -2,7 +2,7 @@
2
2
  /******/ "use strict";
3
3
  /******/ var __webpack_modules__ = ({
4
4
 
5
- /***/ 479:
5
+ /***/ 381:
6
6
  /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
7
7
 
8
8
 
@@ -32,8 +32,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
32
32
  Object.defineProperty(exports, "__esModule", ({ value: true }));
33
33
  exports.isValidationErrorLike = exports.isValidationError = exports.toValidationError = exports.fromZodError = exports.ValidationError = void 0;
34
34
  const zod = __importStar(__nccwpck_require__(934));
35
- const joinPath_1 = __nccwpck_require__(14);
36
- const NonEmptyArray_1 = __nccwpck_require__(80);
35
+ const joinPath_1 = __nccwpck_require__(954);
36
+ const NonEmptyArray_1 = __nccwpck_require__(978);
37
37
  class ValidationError extends Error {
38
38
  details;
39
39
  name;
@@ -104,7 +104,7 @@ exports.isValidationErrorLike = isValidationErrorLike;
104
104
 
105
105
  /***/ }),
106
106
 
107
- /***/ 80:
107
+ /***/ 978:
108
108
  /***/ ((__unused_webpack_module, exports) => {
109
109
 
110
110
 
@@ -118,7 +118,7 @@ exports.isNonEmptyArray = isNonEmptyArray;
118
118
 
119
119
  /***/ }),
120
120
 
121
- /***/ 14:
121
+ /***/ 954:
122
122
  /***/ ((__unused_webpack_module, exports) => {
123
123
 
124
124
 
@@ -203,7 +203,7 @@ var exports = __webpack_exports__;
203
203
 
204
204
  Object.defineProperty(exports, "__esModule", ({ value: true }));
205
205
  exports.fromZodError = exports.isValidationErrorLike = exports.isValidationError = exports.toValidationError = exports.ValidationError = void 0;
206
- var ValidationError_1 = __nccwpck_require__(479);
206
+ var ValidationError_1 = __nccwpck_require__(381);
207
207
  Object.defineProperty(exports, "ValidationError", ({ enumerable: true, get: function () { return ValidationError_1.ValidationError; } }));
208
208
  Object.defineProperty(exports, "toValidationError", ({ enumerable: true, get: function () { return ValidationError_1.toValidationError; } }));
209
209
  Object.defineProperty(exports, "isValidationError", ({ enumerable: true, get: function () { return ValidationError_1.isValidationError; } }));
@@ -13,20 +13,21 @@ import * as liteTapable from "@rspack/lite-tapable";
13
13
  import type { Source } from "../compiled/webpack-sources";
14
14
  import { Chunk } from "./Chunk";
15
15
  import { ChunkGraph } from "./ChunkGraph";
16
+ import { ChunkGroup } from "./ChunkGroup";
16
17
  import type { Compiler } from "./Compiler";
17
18
  import type { ContextModuleFactory } from "./ContextModuleFactory";
18
19
  import { Entrypoint } from "./Entrypoint";
19
20
  import { type CodeGenerationResult, Module } from "./Module";
20
21
  import type { NormalModuleFactory } from "./NormalModuleFactory";
21
22
  import type { ResolverFactory } from "./ResolverFactory";
23
+ import { type RspackError } from "./RspackError";
22
24
  import { Stats, type StatsAsset, type StatsError, type StatsModule } from "./Stats";
23
25
  import type { Filename, OutputNormalized, RspackOptionsNormalized, RspackPluginInstance, StatsOptions, StatsValue } from "./config";
24
26
  import { Logger } from "./logging/Logger";
25
27
  import { StatsFactory } from "./stats/StatsFactory";
26
28
  import { StatsPrinter } from "./stats/StatsPrinter";
27
29
  import { type AssetInfo } from "./util/AssetInfo";
28
- import Hash = require("./util/hash");
29
- import { type RspackError } from "./RspackError";
30
+ import type Hash from "./util/hash";
30
31
  export { type AssetInfo } from "./util/AssetInfo";
31
32
  export type Assets = Record<string, Source>;
32
33
  export interface Asset {
@@ -41,6 +42,10 @@ export interface LogEntry {
41
42
  time?: number;
42
43
  trace?: string[];
43
44
  }
45
+ export type RuntimeModule = liteTapable.SyncHook<[
46
+ JsRuntimeModule,
47
+ Chunk
48
+ ], void>;
44
49
  export interface CompilationParams {
45
50
  normalModuleFactory: NormalModuleFactory;
46
51
  contextModuleFactory: ContextModuleFactory;
@@ -143,7 +148,7 @@ export declare class Compilation {
143
148
  Chunk,
144
149
  Set<string>
145
150
  ], void>;
146
- runtimeModule: liteTapable.SyncHook<[JsRuntimeModule, Chunk], void>;
151
+ runtimeModule: RuntimeModule;
147
152
  afterSeal: liteTapable.AsyncSeriesHook<[], void>;
148
153
  }>;
149
154
  name?: string;
@@ -172,6 +177,13 @@ export declare class Compilation {
172
177
  * Get a map of all entrypoints.
173
178
  */
174
179
  get entrypoints(): ReadonlyMap<string, Entrypoint>;
180
+ get chunkGroups(): ReadonlyArray<ChunkGroup>;
181
+ /**
182
+ * Get the named chunk groups.
183
+ *
184
+ * Note: This is a proxy for webpack internal API, only method `get` and `keys` are supported now.
185
+ */
186
+ get namedChunkGroups(): ReadonlyMap<string, Readonly<ChunkGroup>>;
175
187
  get modules(): ReadonlySet<Module>;
176
188
  get chunks(): ReadonlySet<Chunk>;
177
189
  /**
@@ -189,7 +201,7 @@ export declare class Compilation {
189
201
  buildInfo: Record<string, unknown>;
190
202
  buildMeta: Record<string, unknown>;
191
203
  };
192
- getCache(name: string): import("./lib/CacheFacade");
204
+ getCache(name: string): import("./lib/CacheFacade").CacheFacade;
193
205
  createStatsOptions(optionsOrPreset: StatsValue | undefined, context?: CreateStatsOptionsContext): NormalizedStatsOptions;
194
206
  createStatsFactory(options: StatsOptions): StatsFactory;
195
207
  createStatsPrinter(options: StatsOptions): StatsPrinter;
@@ -207,6 +219,12 @@ export declare class Compilation {
207
219
  * @param assetInfo - extra asset information
208
220
  */
209
221
  emitAsset(filename: string, source: Source, assetInfo?: AssetInfo): void;
222
+ /**
223
+ * Note: This is not a webpack public API, maybe removed in future.
224
+ *
225
+ * @internal
226
+ */
227
+ __internal__emit_asset_from_loader(filename: string, source: Source, assetInfo: AssetInfo, module: string): void;
210
228
  deleteAsset(filename: string): void;
211
229
  renameAsset(filename: string, newFilename: string): void;
212
230
  /**
@@ -36,16 +36,18 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
36
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
38
  };
39
- var _Compilation_instances, _Compilation_inner, _Compilation_cachedAssets, _Compilation_cachedEntrypoints, _Compilation_customModules, _Compilation_createCachedAssets, _Compilation_rebuildModuleCaller;
39
+ var _Compilation_instances, _Compilation_inner, _Compilation_customModules, _Compilation_createCachedAssets, _Compilation_rebuildModuleCaller;
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.Compilation = void 0;
42
42
  const binding_1 = require("@rspack/binding");
43
43
  const liteTapable = __importStar(require("@rspack/lite-tapable"));
44
44
  const Chunk_1 = require("./Chunk");
45
45
  const ChunkGraph_1 = require("./ChunkGraph");
46
+ const ChunkGroup_1 = require("./ChunkGroup");
46
47
  const Entrypoint_1 = require("./Entrypoint");
47
48
  const ErrorHelpers_1 = require("./ErrorHelpers");
48
49
  const Module_1 = require("./Module");
50
+ const RspackError_1 = require("./RspackError");
49
51
  const Stats_1 = require("./Stats");
50
52
  const Logger_1 = require("./logging/Logger");
51
53
  const StatsFactory_1 = require("./stats/StatsFactory");
@@ -55,13 +57,10 @@ const MergeCaller_1 = __importDefault(require("./util/MergeCaller"));
55
57
  const fake_1 = require("./util/fake");
56
58
  const memoize_1 = require("./util/memoize");
57
59
  const source_1 = require("./util/source");
58
- const RspackError_1 = require("./RspackError");
59
60
  class Compilation {
60
61
  constructor(compiler, inner) {
61
62
  _Compilation_instances.add(this);
62
63
  _Compilation_inner.set(this, void 0);
63
- _Compilation_cachedAssets.set(this, void 0);
64
- _Compilation_cachedEntrypoints.set(this, void 0);
65
64
  this.fileSystemInfo = {
66
65
  createSnapshot() {
67
66
  // fake implement to support html-webpack-plugin
@@ -180,22 +179,38 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
180
179
  * Get a map of all assets.
181
180
  */
182
181
  get assets() {
183
- if (!__classPrivateFieldGet(this, _Compilation_cachedAssets, "f")) {
184
- __classPrivateFieldSet(this, _Compilation_cachedAssets, __classPrivateFieldGet(this, _Compilation_instances, "m", _Compilation_createCachedAssets).call(this), "f");
185
- }
186
- return __classPrivateFieldGet(this, _Compilation_cachedAssets, "f");
182
+ return (0, memoize_1.memoizeValue)(() => __classPrivateFieldGet(this, _Compilation_instances, "m", _Compilation_createCachedAssets).call(this));
187
183
  }
188
184
  /**
189
185
  * Get a map of all entrypoints.
190
186
  */
191
187
  get entrypoints() {
192
- if (!__classPrivateFieldGet(this, _Compilation_cachedEntrypoints, "f")) {
193
- __classPrivateFieldSet(this, _Compilation_cachedEntrypoints, new Map(Object.entries(__classPrivateFieldGet(this, _Compilation_inner, "f").entrypoints).map(([n, e]) => [
194
- n,
195
- Entrypoint_1.Entrypoint.__from_binding(e, __classPrivateFieldGet(this, _Compilation_inner, "f"))
196
- ])), "f");
197
- }
198
- return __classPrivateFieldGet(this, _Compilation_cachedEntrypoints, "f");
188
+ return (0, memoize_1.memoizeValue)(() => new Map(Object.entries(__classPrivateFieldGet(this, _Compilation_inner, "f").entrypoints).map(([n, e]) => [
189
+ n,
190
+ Entrypoint_1.Entrypoint.__from_binding(e, __classPrivateFieldGet(this, _Compilation_inner, "f"))
191
+ ])));
192
+ }
193
+ get chunkGroups() {
194
+ return (0, memoize_1.memoizeValue)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").chunkGroups.map(cg => ChunkGroup_1.ChunkGroup.__from_binding(cg, __classPrivateFieldGet(this, _Compilation_inner, "f"))));
195
+ }
196
+ /**
197
+ * Get the named chunk groups.
198
+ *
199
+ * Note: This is a proxy for webpack internal API, only method `get` and `keys` are supported now.
200
+ */
201
+ get namedChunkGroups() {
202
+ return {
203
+ keys: () => {
204
+ const names = __classPrivateFieldGet(this, _Compilation_inner, "f").getNamedChunkGroupKeys();
205
+ return names[Symbol.iterator]();
206
+ },
207
+ get: (property) => {
208
+ if (typeof property === "string") {
209
+ const chunk = __classPrivateFieldGet(this, _Compilation_inner, "f").getNamedChunkGroup(property) || undefined;
210
+ return chunk && ChunkGroup_1.ChunkGroup.__from_binding(chunk, __classPrivateFieldGet(this, _Compilation_inner, "f"));
211
+ }
212
+ }
213
+ };
199
214
  }
200
215
  get modules() {
201
216
  return (0, memoize_1.memoizeValue)(() => new Set(this.__internal__getModules().map(item => Module_1.Module.__from_binding(item, this))));
@@ -259,11 +274,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
259
274
  this.hooks.statsNormalize.call(options, context);
260
275
  return options;
261
276
  }
262
- else {
263
- const options = {};
264
- this.hooks.statsNormalize.call(options, context);
265
- return options;
266
- }
277
+ const options = {};
278
+ this.hooks.statsNormalize.call(options, context);
279
+ return options;
267
280
  }
268
281
  createStatsFactory(options) {
269
282
  const statsFactory = new StatsFactory_1.StatsFactory();
@@ -306,6 +319,14 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
306
319
  emitAsset(filename, source, assetInfo) {
307
320
  __classPrivateFieldGet(this, _Compilation_inner, "f").emitAsset(filename, source_1.JsSource.__to_binding(source), AssetInfo_1.JsAssetInfo.__to_binding(assetInfo));
308
321
  }
322
+ /**
323
+ * Note: This is not a webpack public API, maybe removed in future.
324
+ *
325
+ * @internal
326
+ */
327
+ __internal__emit_asset_from_loader(filename, source, assetInfo, module) {
328
+ __classPrivateFieldGet(this, _Compilation_inner, "f").emitAssetFromLoader(filename, source_1.JsSource.__to_binding(source), AssetInfo_1.JsAssetInfo.__to_binding(assetInfo), module);
329
+ }
309
330
  deleteAsset(filename) {
310
331
  __classPrivateFieldGet(this, _Compilation_inner, "f").deleteAsset(filename);
311
332
  }
@@ -411,12 +432,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
411
432
  }
412
433
  }
413
434
  ];
414
- proxyMethod.forEach(item => {
435
+ for (const item of proxyMethod) {
415
436
  const proxyedMethod = new Proxy(errors[item.method], {
416
437
  apply: item.handler
417
438
  });
418
439
  errors[item.method] = proxyedMethod;
419
- });
440
+ }
420
441
  return errors;
421
442
  }
422
443
  get warnings() {
@@ -476,12 +497,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
476
497
  }
477
498
  }
478
499
  ];
479
- proxyMethod.forEach(item => {
500
+ for (const item of proxyMethod) {
480
501
  const proxyedMethod = new Proxy(warnings[item.method], {
481
502
  apply: item.handler
482
503
  });
483
504
  warnings[item.method] = proxyedMethod;
484
- });
505
+ }
485
506
  return warnings;
486
507
  }
487
508
  getPath(filename, data = {}) {
@@ -563,34 +584,28 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
563
584
  return `${name}/${childName}`;
564
585
  });
565
586
  }
566
- else {
567
- return this.getLogger(() => {
568
- if (typeof name === "function") {
569
- name = name();
570
- if (!name) {
571
- throw new TypeError("Compilation.getLogger(name) called with a function not returning a name");
572
- }
587
+ return this.getLogger(() => {
588
+ if (typeof name === "function") {
589
+ name = name();
590
+ if (!name) {
591
+ throw new TypeError("Compilation.getLogger(name) called with a function not returning a name");
573
592
  }
574
- return `${name}/${childName}`;
575
- });
576
- }
593
+ }
594
+ return `${name}/${childName}`;
595
+ });
577
596
  }
578
- else {
579
- if (typeof childName === "function") {
580
- return this.getLogger(() => {
581
- if (typeof childName === "function") {
582
- childName = childName();
583
- if (!childName) {
584
- throw new TypeError("Logger.getChildLogger(name) called with a function not returning a name");
585
- }
597
+ if (typeof childName === "function") {
598
+ return this.getLogger(() => {
599
+ if (typeof childName === "function") {
600
+ childName = childName();
601
+ if (!childName) {
602
+ throw new TypeError("Logger.getChildLogger(name) called with a function not returning a name");
586
603
  }
587
- return `${name}/${childName}`;
588
- });
589
- }
590
- else {
591
- return this.getLogger(`${name}/${childName}`);
592
- }
604
+ }
605
+ return `${name}/${childName}`;
606
+ });
593
607
  }
608
+ return this.getLogger(`${name}/${childName}`);
594
609
  });
595
610
  }
596
611
  getStats() {
@@ -687,7 +702,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
687
702
  seal() { }
688
703
  unseal() { }
689
704
  }
690
- _Compilation_inner = new WeakMap(), _Compilation_cachedAssets = new WeakMap(), _Compilation_cachedEntrypoints = new WeakMap(), _Compilation_customModules = new WeakMap(), _Compilation_rebuildModuleCaller = new WeakMap(), _Compilation_instances = new WeakSet(), _Compilation_createCachedAssets = function _Compilation_createCachedAssets() {
705
+ _Compilation_inner = new WeakMap(), _Compilation_customModules = new WeakMap(), _Compilation_rebuildModuleCaller = new WeakMap(), _Compilation_instances = new WeakSet(), _Compilation_createCachedAssets = function _Compilation_createCachedAssets() {
691
706
  return new Proxy({}, {
692
707
  get: (_, property) => {
693
708
  if (typeof property === "string") {
@@ -10,22 +10,23 @@
10
10
  */
11
11
  import * as binding from "@rspack/binding";
12
12
  import * as liteTapable from "@rspack/lite-tapable";
13
- import type Watchpack from "../compiled/watchpack";
14
- import { Compilation, type CompilationParams } from "./Compilation";
13
+ import Cache from "./lib/Cache";
14
+ import CacheFacade from "./lib/CacheFacade";
15
+ import { Chunk } from "./Chunk";
16
+ import { Compilation } from "./Compilation";
15
17
  import { ContextModuleFactory } from "./ContextModuleFactory";
18
+ import { NormalModuleFactory } from "./NormalModuleFactory";
19
+ import { ResolverFactory } from "./ResolverFactory";
16
20
  import { RuleSetCompiler } from "./RuleSetCompiler";
17
21
  import { Stats } from "./Stats";
18
- import { type EntryNormalized, type OutputNormalized, type RspackOptionsNormalized, type RspackPluginInstance } from "./config";
22
+ import { Watching } from "./Watching";
19
23
  import { rspack } from "./index";
20
- import Cache = require("./lib/Cache");
21
- import CacheFacade = require("./lib/CacheFacade");
24
+ import { Logger } from "./logging/Logger";
25
+ import type Watchpack from "../compiled/watchpack";
22
26
  import type { Source } from "../compiled/webpack-sources";
23
- import { Chunk } from "./Chunk";
27
+ import type { CompilationParams } from "./Compilation";
24
28
  import type { FileSystemInfoEntry } from "./FileSystemInfo";
25
- import { NormalModuleFactory } from "./NormalModuleFactory";
26
- import { ResolverFactory } from "./ResolverFactory";
27
- import { Watching } from "./Watching";
28
- import { Logger } from "./logging/Logger";
29
+ import type { EntryNormalized, OutputNormalized, RspackOptionsNormalized, RspackPluginInstance } from "./config";
29
30
  import type { OutputFileSystem, WatchFileSystem } from "./util/fs";
30
31
  export interface AssetEmittedInfo {
31
32
  content: Buffer;
package/dist/Compiler.js CHANGED
@@ -50,29 +50,29 @@ exports.Compiler = void 0;
50
50
  */
51
51
  const binding = __importStar(require("@rspack/binding"));
52
52
  const liteTapable = __importStar(require("@rspack/lite-tapable"));
53
+ const ExecuteModulePlugin_1 = __importDefault(require("./ExecuteModulePlugin"));
54
+ const ConcurrentCompilationError_1 = __importDefault(require("./error/ConcurrentCompilationError"));
55
+ const Cache_1 = __importDefault(require("./lib/Cache"));
56
+ const CacheFacade_1 = __importDefault(require("./lib/CacheFacade"));
57
+ const RuntimeGlobals_1 = require("./RuntimeGlobals");
58
+ const builtin_plugin_1 = require("./builtin-plugin");
59
+ const Chunk_1 = require("./Chunk");
53
60
  const Compilation_1 = require("./Compilation");
54
61
  const ContextModuleFactory_1 = require("./ContextModuleFactory");
55
62
  const FileSystem_1 = require("./FileSystem");
56
- const RuleSetCompiler_1 = require("./RuleSetCompiler");
57
- const Stats_1 = require("./Stats");
58
- const config_1 = require("./config");
59
- const ConcurrentCompilationError_1 = __importDefault(require("./error/ConcurrentCompilationError"));
60
- const index_1 = require("./index");
61
- const Cache = require("./lib/Cache");
62
- const CacheFacade = require("./lib/CacheFacade");
63
- const Chunk_1 = require("./Chunk");
64
- const ExecuteModulePlugin_1 = __importDefault(require("./ExecuteModulePlugin"));
65
63
  const Module_1 = require("./Module");
66
64
  const NormalModuleFactory_1 = require("./NormalModuleFactory");
67
65
  const ResolverFactory_1 = require("./ResolverFactory");
68
- const RuntimeGlobals_1 = require("./RuntimeGlobals");
66
+ const RuleSetCompiler_1 = require("./RuleSetCompiler");
67
+ const Stats_1 = require("./Stats");
69
68
  const Watching_1 = require("./Watching");
70
- const builtin_plugin_1 = require("./builtin-plugin");
69
+ const config_1 = require("./config");
70
+ const index_1 = require("./index");
71
+ const util_1 = require("./util");
71
72
  const base_1 = require("./builtin-plugin/base");
72
73
  const defaults_1 = require("./config/defaults");
73
74
  const HookWebpackError_1 = require("./lib/HookWebpackError");
74
75
  const Logger_1 = require("./logging/Logger");
75
- const util_1 = require("./util");
76
76
  const assertNotNil_1 = require("./util/assertNotNil");
77
77
  const bindingVersionCheck_1 = require("./util/bindingVersionCheck");
78
78
  const createHash_1 = require("./util/createHash");
@@ -147,7 +147,7 @@ class Compiler {
147
147
  this.options = options;
148
148
  this.resolverFactory = new ResolverFactory_1.ResolverFactory();
149
149
  this.context = context;
150
- this.cache = new Cache();
150
+ this.cache = new Cache_1.default();
151
151
  this.compilerPath = "";
152
152
  this.running = false;
153
153
  this.idle = false;
@@ -189,7 +189,7 @@ class Compiler {
189
189
  * @returns the cache facade instance
190
190
  */
191
191
  getCache(name) {
192
- return new CacheFacade(this.cache, `${this.compilerPath}${name}`, this.options.output.hashFunction);
192
+ return new CacheFacade_1.default(this.cache, `${this.compilerPath}${name}`, this.options.output.hashFunction);
193
193
  }
194
194
  /**
195
195
  * @param name - name of the logger, or function called once to get the logger name
@@ -233,34 +233,28 @@ class Compiler {
233
233
  return `${name}/${childName}`;
234
234
  });
235
235
  }
236
- else {
237
- return this.getInfrastructureLogger(() => {
238
- if (typeof name === "function") {
239
- name = name();
240
- if (!name) {
241
- throw new TypeError("Compiler.getInfrastructureLogger(name) called with a function not returning a name");
242
- }
236
+ return this.getInfrastructureLogger(() => {
237
+ if (typeof name === "function") {
238
+ name = name();
239
+ if (!name) {
240
+ throw new TypeError("Compiler.getInfrastructureLogger(name) called with a function not returning a name");
243
241
  }
244
- return `${name}/${childName}`;
245
- });
246
- }
242
+ }
243
+ return `${name}/${childName}`;
244
+ });
247
245
  }
248
- else {
249
- if (typeof childName === "function") {
250
- return this.getInfrastructureLogger(() => {
251
- if (typeof childName === "function") {
252
- childName = childName();
253
- if (!childName) {
254
- throw new TypeError("Logger.getChildLogger(name) called with a function not returning a name");
255
- }
246
+ if (typeof childName === "function") {
247
+ return this.getInfrastructureLogger(() => {
248
+ if (typeof childName === "function") {
249
+ childName = childName();
250
+ if (!childName) {
251
+ throw new TypeError("Logger.getChildLogger(name) called with a function not returning a name");
256
252
  }
257
- return `${name}/${childName}`;
258
- });
259
- }
260
- else {
261
- return this.getInfrastructureLogger(`${name}/${childName}`);
262
- }
253
+ }
254
+ return `${name}/${childName}`;
255
+ });
263
256
  }
257
+ return this.getInfrastructureLogger(`${name}/${childName}`);
264
258
  });
265
259
  }
266
260
  /**
@@ -322,9 +316,7 @@ class Compiler {
322
316
  if (err) {
323
317
  return finalCallback(err);
324
318
  }
325
- else {
326
- return finalCallback(null, stats);
327
- }
319
+ return finalCallback(null, stats);
328
320
  });
329
321
  });
330
322
  });
@@ -632,7 +624,9 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
632
624
  },
633
625
  require: __webpack_require__
634
626
  };
635
- interceptModuleExecution.forEach((handler) => handler(execOptions));
627
+ for (const handler of interceptModuleExecution) {
628
+ handler(execOptions);
629
+ }
636
630
  const result = codegenResults.map[id]["build time"];
637
631
  const moduleObject = execOptions.module;
638
632
  if (id)
@@ -660,6 +654,9 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
660
654
  registerCompilationOptimizeTreeTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeTree, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.optimizeTree, queried => async () => await queried.promise(__classPrivateFieldGet(this, _Compiler_compilation, "f").chunks, __classPrivateFieldGet(this, _Compiler_compilation, "f").modules)),
661
655
  registerCompilationOptimizeChunkModulesTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationOptimizeChunkModules, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.optimizeChunkModules, queried => async () => await queried.promise(__classPrivateFieldGet(this, _Compiler_compilation, "f").chunks, __classPrivateFieldGet(this, _Compiler_compilation, "f").modules)),
662
656
  registerCompilationChunkHashTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationChunkHash, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.chunkHash, queried => (chunk) => {
657
+ if (!this.options.output.hashFunction) {
658
+ throw new Error("'output.hashFunction' cannot be undefined");
659
+ }
663
660
  const hash = (0, createHash_1.createHash)(this.options.output.hashFunction);
664
661
  queried.call(Chunk_1.Chunk.__from_binding(chunk, __classPrivateFieldGet(this, _Compiler_compilation, "f")), hash);
665
662
  const digestResult = hash.digest(this.options.output.hashDigest);
@@ -779,6 +776,9 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
779
776
  }),
780
777
  registerJavascriptModulesChunkHashTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.JavascriptModulesChunkHash, () => builtin_plugin_1.JavascriptModulesPlugin.getCompilationHooks(__classPrivateFieldGet(this, _Compiler_compilation, "f"))
781
778
  .chunkHash, queried => (chunk) => {
779
+ if (!this.options.output.hashFunction) {
780
+ throw new Error("'output.hashFunction' cannot be undefined");
781
+ }
782
782
  const hash = (0, createHash_1.createHash)(this.options.output.hashFunction);
783
783
  queried.call(Chunk_1.Chunk.__from_binding(chunk, __classPrivateFieldGet(this, _Compiler_compilation, "f")), hash);
784
784
  const digestResult = hash.digest(this.options.output.hashDigest);
@@ -42,10 +42,8 @@ const cutOffMessage = (stack, message) => {
42
42
  if (nextLine === -1) {
43
43
  return stack === message ? "" : stack;
44
44
  }
45
- else {
46
- const firstLine = stack.slice(0, nextLine);
47
- return firstLine === message ? stack.slice(nextLine + 1) : stack;
48
- }
45
+ const firstLine = stack.slice(0, nextLine);
46
+ return firstLine === message ? stack.slice(nextLine + 1) : stack;
49
47
  };
50
48
  exports.cutOffMessage = cutOffMessage;
51
49
  const cleanUp = (stack, message) => {
package/dist/Module.d.ts CHANGED
@@ -42,6 +42,7 @@ export declare class Module {
42
42
  userRequest?: Readonly<string>;
43
43
  rawRequest?: Readonly<string>;
44
44
  type: string;
45
+ layer: null | string;
45
46
  factoryMeta?: Readonly<JsFactoryMeta>;
46
47
  /**
47
48
  * Records the dynamically added fields for Module on the JavaScript side.
package/dist/Module.js CHANGED
@@ -23,6 +23,7 @@ class Module {
23
23
  _Module_originalSource.set(this, void 0);
24
24
  __classPrivateFieldSet(this, _Module_inner, module, "f");
25
25
  this.type = module.type;
26
+ this.layer = module.layer ?? null;
26
27
  this.context = module.context;
27
28
  this.resource = module.resource;
28
29
  this.request = module.request;
@@ -40,9 +41,7 @@ class Module {
40
41
  __classPrivateFieldSet(this, _Module_originalSource, source_1.JsSource.__from_binding(__classPrivateFieldGet(this, _Module_inner, "f").originalSource), "f");
41
42
  return __classPrivateFieldGet(this, _Module_originalSource, "f");
42
43
  }
43
- else {
44
- return null;
45
- }
44
+ return null;
46
45
  }
47
46
  identifier() {
48
47
  return __classPrivateFieldGet(this, _Module_inner, "f").moduleIdentifier;
@@ -51,9 +50,7 @@ class Module {
51
50
  if (typeof __classPrivateFieldGet(this, _Module_inner, "f").nameForCondition === "string") {
52
51
  return __classPrivateFieldGet(this, _Module_inner, "f").nameForCondition;
53
52
  }
54
- else {
55
- return null;
56
- }
53
+ return null;
57
54
  }
58
55
  }
59
56
  exports.Module = Module;