@rspack/core 0.6.5 → 0.7.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/Chunk.d.ts +1 -1
  2. package/dist/Chunk.js +1 -1
  3. package/dist/ChunkGroup.d.ts +2 -0
  4. package/dist/ChunkGroup.js +4 -0
  5. package/dist/Compilation.d.ts +46 -65
  6. package/dist/Compilation.js +128 -222
  7. package/dist/Compiler.d.ts +75 -44
  8. package/dist/Compiler.js +325 -278
  9. package/dist/ContextModuleFactory.d.ts +7 -3
  10. package/dist/ContextModuleFactory.js +2 -2
  11. package/dist/Entrypoint.d.ts +1 -1
  12. package/dist/Entrypoint.js +1 -1
  13. package/dist/ExecuteModulePlugin.js +1 -1
  14. package/dist/Module.d.ts +11 -0
  15. package/dist/Module.js +2 -2
  16. package/dist/MultiCompiler.d.ts +10 -25
  17. package/dist/MultiCompiler.js +3 -3
  18. package/dist/MultiStats.d.ts +1 -1
  19. package/dist/NormalModuleFactory.d.ts +1 -1
  20. package/dist/Stats.d.ts +2 -2
  21. package/dist/Watching.d.ts +0 -9
  22. package/dist/Watching.js +12 -2
  23. package/dist/builtin-loader/swc/index.d.ts +6 -6
  24. package/dist/builtin-loader/swc/index.js +3 -3
  25. package/dist/builtin-loader/swc/types.d.ts +2 -2
  26. package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
  27. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
  28. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
  29. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
  30. package/dist/builtin-plugin/BannerPlugin.d.ts +2 -2
  31. package/dist/builtin-plugin/BannerPlugin.js +1 -1
  32. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
  33. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
  34. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
  35. package/dist/builtin-plugin/CopyRspackPlugin.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 +1 -1
  39. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.d.ts +1 -1
  40. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.d.ts +1 -1
  41. package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +1 -1
  42. package/dist/builtin-plugin/DynamicEntryPlugin.js +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/EnableLibraryPlugin.d.ts +1 -1
  46. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
  47. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
  48. package/dist/builtin-plugin/EntryPlugin.d.ts +1 -1
  49. package/dist/builtin-plugin/EntryPlugin.js +1 -1
  50. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
  51. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
  52. package/dist/builtin-plugin/ExternalsPlugin.d.ts +3 -3
  53. package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
  54. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
  55. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +1 -1
  56. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +2 -2
  57. package/dist/builtin-plugin/HtmlRspackPlugin.js +2 -2
  58. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
  59. package/dist/builtin-plugin/IgnorePlugin.d.ts +1 -1
  60. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
  61. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
  62. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
  63. package/dist/builtin-plugin/JsLoaderRspackPlugin.js +1 -1
  64. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
  65. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
  66. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +1 -1
  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 -1
  70. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
  71. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
  72. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
  73. package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
  74. package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
  75. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
  76. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
  77. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +1 -1
  78. package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
  79. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
  80. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +15 -0
  81. package/dist/builtin-plugin/SizeLimitsPlugin.js +9 -0
  82. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
  83. package/dist/builtin-plugin/SplitChunksPlugin.d.ts +2 -2
  84. package/dist/builtin-plugin/SplitChunksPlugin.js +4 -4
  85. package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +1 -1
  86. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
  87. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
  88. package/dist/builtin-plugin/WebWorkerTemplatePlugin.d.ts +1 -1
  89. package/dist/builtin-plugin/WorkerPlugin.d.ts +2 -2
  90. package/dist/builtin-plugin/base.d.ts +1 -1
  91. package/dist/builtin-plugin/css-extract/index.d.ts +5 -4
  92. package/dist/builtin-plugin/css-extract/loader.d.ts +1 -1
  93. package/dist/builtin-plugin/css-extract/loader.js +2 -2
  94. package/dist/builtin-plugin/index.d.ts +44 -43
  95. package/dist/builtin-plugin/index.js +44 -43
  96. package/dist/config/adapter.d.ts +2 -2
  97. package/dist/config/adapter.js +6 -5
  98. package/dist/config/adapterRuleUse.d.ts +2 -1
  99. package/dist/config/adapterRuleUse.js +2 -2
  100. package/dist/config/defaults.js +21 -4
  101. package/dist/config/index.d.ts +2 -2
  102. package/dist/config/index.js +2 -2
  103. package/dist/config/normalization.d.ts +2 -2
  104. package/dist/config/normalization.js +1 -0
  105. package/dist/config/zod.d.ts +317 -189
  106. package/dist/config/zod.js +23 -29
  107. package/dist/container/ContainerPlugin.d.ts +1 -1
  108. package/dist/container/ContainerReferencePlugin.d.ts +1 -1
  109. package/dist/container/ContainerReferencePlugin.js +1 -1
  110. package/dist/container/ModuleFederationPlugin.js +1 -1
  111. package/dist/container/ModuleFederationPluginV1.d.ts +1 -1
  112. package/dist/container/ModuleFederationPluginV1.js +1 -1
  113. package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
  114. package/dist/exports.d.ts +36 -30
  115. package/dist/exports.js +36 -28
  116. package/dist/fileSystem.d.ts +12 -8
  117. package/dist/fileSystem.js +25 -48
  118. package/dist/index.d.ts +1 -1
  119. package/dist/index.js +1 -1
  120. package/dist/lite-tapable/index.d.ts +6 -0
  121. package/dist/lite-tapable/index.js +107 -1
  122. package/dist/loader-runner/index.js +13 -13
  123. package/dist/logging/Logger.d.ts +1 -1
  124. package/dist/logging/createConsoleLogger.js +0 -14
  125. package/dist/node/NodeEnvironmentPlugin.d.ts +1 -1
  126. package/dist/node/NodeEnvironmentPlugin.js +1 -1
  127. package/dist/node/nodeConsole.js +0 -4
  128. package/dist/rspack.d.ts +4 -13
  129. package/dist/rspack.js +8 -8
  130. package/dist/rspackOptionsApply.d.ts +1 -10
  131. package/dist/rspackOptionsApply.js +17 -5
  132. package/dist/sharing/ConsumeSharedPlugin.d.ts +1 -1
  133. package/dist/sharing/ConsumeSharedPlugin.js +1 -1
  134. package/dist/stats/DefaultStatsFactoryPlugin.js +2 -2
  135. package/dist/stats/StatsFactory.d.ts +2 -2
  136. package/dist/stats/StatsFactory.js +0 -9
  137. package/dist/stats/StatsPrinter.d.ts +1 -1
  138. package/dist/stats/statsFactoryUtils.d.ts +1 -1
  139. package/dist/util/comparators.d.ts +1 -1
  140. package/dist/util/fs.d.ts +64 -0
  141. package/dist/util/fs.js +122 -0
  142. package/dist/util/index.d.ts +2 -1
  143. package/dist/util/index.js +16 -11
  144. package/dist/util/source.d.ts +18 -0
  145. package/dist/util/source.js +66 -0
  146. package/package.json +6 -5
  147. package/dist/util/createSource.d.ts +0 -5
  148. package/dist/util/createSource.js +0 -65
@@ -36,40 +36,31 @@ 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_inner;
39
+ var _Compilation_instances, _Compilation_inner, _Compilation_cachedAssets, _Compilation_createCachedAssets;
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.Compilation = void 0;
42
- /**
43
- * The following code is modified based on
44
- * https://github.com/webpack/webpack/blob/4b4ca3bb53f36a5b8fc6bc1bd976ed7af161bd80/lib/Compilation.js
45
- *
46
- * MIT Licensed
47
- * Author Tobias Koppers @sokra
48
- * Copyright (c) JS Foundation and other contributors
49
- * https://github.com/webpack/webpack/blob/main/LICENSE
50
- */
51
42
  const tapable = __importStar(require("tapable"));
52
43
  const liteTapable = __importStar(require("./lite-tapable"));
44
+ const Chunk_1 = require("./Chunk");
45
+ const ChunkGraph_1 = require("./ChunkGraph");
46
+ const Entrypoint_1 = require("./Entrypoint");
53
47
  const ErrorHelpers_1 = __importDefault(require("./ErrorHelpers"));
54
48
  const Logger_1 = require("./logging/Logger");
49
+ const Module_1 = require("./Module");
55
50
  const NormalModule_1 = require("./NormalModule");
56
51
  const Stats_1 = require("./Stats");
57
52
  const StatsFactory_1 = require("./stats/StatsFactory");
58
53
  const StatsPrinter_1 = require("./stats/StatsPrinter");
59
54
  const util_1 = require("./util");
60
- const createSource_1 = require("./util/createSource");
61
55
  const fake_1 = require("./util/fake");
62
- const MergeCaller_1 = __importDefault(require("./util/MergeCaller"));
63
56
  const memoize_1 = require("./util/memoize");
64
- const Chunk_1 = require("./Chunk");
65
- const Module_1 = require("./Module");
66
- const ChunkGraph_1 = require("./ChunkGraph");
67
- const Entrypoint_1 = require("./Entrypoint");
57
+ const MergeCaller_1 = __importDefault(require("./util/MergeCaller"));
58
+ const source_1 = require("./util/source");
68
59
  class Compilation {
69
60
  constructor(compiler, inner) {
61
+ _Compilation_instances.add(this);
70
62
  _Compilation_inner.set(this, void 0);
71
- this.childrenCounters = {};
72
- this.children = [];
63
+ _Compilation_cachedAssets.set(this, void 0);
73
64
  this.fileSystemInfo = {
74
65
  createSnapshot() {
75
66
  // fake implement to support html-webpack-plugin
@@ -93,9 +84,8 @@ class Compilation {
93
84
  }
94
85
  });
95
86
  }, 10);
96
- this.name = undefined;
97
- this.startTime = undefined;
98
- this.endTime = undefined;
87
+ __classPrivateFieldSet(this, _Compilation_inner, inner, "f");
88
+ __classPrivateFieldSet(this, _Compilation_cachedAssets, __classPrivateFieldGet(this, _Compilation_instances, "m", _Compilation_createCachedAssets).call(this), "f");
99
89
  const processAssetsHook = new liteTapable.AsyncSeriesHook([
100
90
  "assets"
101
91
  ]);
@@ -163,9 +153,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
163
153
  this.options = compiler.options;
164
154
  this.outputOptions = compiler.options.output;
165
155
  this.logging = new Map();
156
+ this.childrenCounters = {};
157
+ this.children = [];
166
158
  this.chunkGraph = new ChunkGraph_1.ChunkGraph(this);
167
- __classPrivateFieldSet(this, _Compilation_inner, inner, "f");
168
- // Cache the current NormalModuleHooks
169
159
  }
170
160
  get currentNormalModuleHooks() {
171
161
  return NormalModule_1.NormalModule.getCompilationHooks(this);
@@ -178,48 +168,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
178
168
  }
179
169
  /**
180
170
  * Get a map of all assets.
181
- *
182
- * Source: [assets](https://github.com/webpack/webpack/blob/9fcaa243573005d6fdece9a3f8d89a0e8b399613/lib/Compilation.js#L1008-L1009)
183
171
  */
184
172
  get assets() {
185
- return new Proxy({}, {
186
- get: (_, property) => {
187
- if (typeof property === "string") {
188
- return this.__internal__getAssetSource(property);
189
- }
190
- },
191
- set: (target, p, newValue, receiver) => {
192
- if (typeof p === "string") {
193
- this.__internal__setAssetSource(p, newValue);
194
- return true;
195
- }
196
- return false;
197
- },
198
- deleteProperty: (target, p) => {
199
- if (typeof p === "string") {
200
- this.__internal__deleteAssetSource(p);
201
- return true;
202
- }
203
- return false;
204
- },
205
- has: (_, property) => {
206
- if (typeof property === "string") {
207
- return this.__internal__hasAsset(property);
208
- }
209
- return false;
210
- },
211
- ownKeys: _ => {
212
- return this.__internal__getAssetFilenames();
213
- },
214
- getOwnPropertyDescriptor() {
215
- // To work with `Object.keys`, you should mark the property as enumerable.
216
- // See: https://262.ecma-international.org/7.0/#sec-enumerableownnames
217
- return {
218
- enumerable: true,
219
- configurable: true
220
- };
221
- }
222
- });
173
+ return __classPrivateFieldGet(this, _Compilation_cachedAssets, "f");
223
174
  }
224
175
  /**
225
176
  * Get a map of all entrypoints.
@@ -230,6 +181,32 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
230
181
  Entrypoint_1.Entrypoint.__from_binding(e, __classPrivateFieldGet(this, _Compilation_inner, "f"))
231
182
  ]));
232
183
  }
184
+ get modules() {
185
+ return (0, memoize_1.memoizeValue)(() => {
186
+ return this.__internal__getModules().map(item => Module_1.Module.__from_binding(item));
187
+ });
188
+ }
189
+ // FIXME: Webpack returns a `Set`
190
+ get chunks() {
191
+ return (0, memoize_1.memoizeValue)(() => {
192
+ return this.__internal__getChunks();
193
+ });
194
+ }
195
+ /**
196
+ * Get the named chunks.
197
+ *
198
+ * Note: This is a proxy for webpack internal API, only method `get` is supported now.
199
+ */
200
+ get namedChunks() {
201
+ return {
202
+ get: (property) => {
203
+ if (typeof property === "string") {
204
+ const chunk = __classPrivateFieldGet(this, _Compilation_inner, "f").getNamedChunk(property) || undefined;
205
+ return chunk && Chunk_1.Chunk.__from_binding(chunk, __classPrivateFieldGet(this, _Compilation_inner, "f"));
206
+ }
207
+ }
208
+ };
209
+ }
233
210
  getCache(name) {
234
211
  return this.compiler.getCache(name);
235
212
  }
@@ -291,20 +268,17 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
291
268
  /**
292
269
  * Update an existing asset. Trying to update an asset that doesn't exist will throw an error.
293
270
  *
294
- * See: [Compilation.updateAsset](https://webpack.js.org/api/compilation-object/#updateasset)
295
- * Source: [updateAsset](https://github.com/webpack/webpack/blob/9fcaa243573005d6fdece9a3f8d89a0e8b399613/lib/Compilation.js#L4320)
296
- *
297
271
  * FIXME: *AssetInfo* may be undefined in update fn for webpack impl, but still not implemented in rspack
298
272
  */
299
273
  updateAsset(filename, newSourceOrFunction, assetInfoUpdateOrFunction) {
300
274
  let compatNewSourceOrFunction;
301
275
  if (typeof newSourceOrFunction === "function") {
302
276
  compatNewSourceOrFunction = function newSourceFunction(source) {
303
- return (0, createSource_1.createRawFromSource)(newSourceOrFunction((0, createSource_1.createSourceFromRaw)(source)));
277
+ return source_1.JsSource.__to_binding(newSourceOrFunction(source_1.JsSource.__from_binding(source)));
304
278
  };
305
279
  }
306
280
  else {
307
- compatNewSourceOrFunction = (0, createSource_1.createRawFromSource)(newSourceOrFunction);
281
+ compatNewSourceOrFunction = source_1.JsSource.__to_binding(newSourceOrFunction);
308
282
  }
309
283
  __classPrivateFieldGet(this, _Compilation_inner, "f").updateAsset(filename, compatNewSourceOrFunction, assetInfoUpdateOrFunction === undefined
310
284
  ? assetInfoUpdateOrFunction
@@ -315,15 +289,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
315
289
  /**
316
290
  * Emit an not existing asset. Trying to emit an asset that already exists will throw an error.
317
291
  *
318
- * See: [Compilation.emitAsset](https://webpack.js.org/api/compilation-object/#emitasset)
319
- * Source: [emitAsset](https://github.com/webpack/webpack/blob/9fcaa243573005d6fdece9a3f8d89a0e8b399613/lib/Compilation.js#L4239)
320
- *
321
292
  * @param file - file name
322
293
  * @param source - asset source
323
294
  * @param assetInfo - extra asset information
324
295
  */
325
296
  emitAsset(filename, source, assetInfo) {
326
- __classPrivateFieldGet(this, _Compilation_inner, "f").emitAsset(filename, (0, createSource_1.createRawFromSource)(source), (0, util_1.toJsAssetInfo)(assetInfo));
297
+ __classPrivateFieldGet(this, _Compilation_inner, "f").emitAsset(filename, source_1.JsSource.__to_binding(source), (0, util_1.toJsAssetInfo)(assetInfo));
327
298
  }
328
299
  deleteAsset(filename) {
329
300
  __classPrivateFieldGet(this, _Compilation_inner, "f").deleteAsset(filename);
@@ -333,9 +304,6 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
333
304
  }
334
305
  /**
335
306
  * Get an array of Asset
336
- *
337
- * See: [Compilation.getAssets](https://webpack.js.org/api/compilation-object/#getassets)
338
- * Source: [getAssets](https://github.com/webpack/webpack/blob/9fcaa243573005d6fdece9a3f8d89a0e8b399613/lib/Compilation.js#L4448)
339
307
  */
340
308
  getAssets() {
341
309
  const assets = __classPrivateFieldGet(this, _Compilation_inner, "f").getAssets();
@@ -354,9 +322,19 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
354
322
  get: () => this.__internal__getAssetSource(asset.name)
355
323
  });
356
324
  }
357
- pushDiagnostic(severity, title, message) {
325
+ /**
326
+ * Note: This is not a webpack public API, maybe removed in future.
327
+ *
328
+ * @internal
329
+ */
330
+ __internal__pushDiagnostic(severity, title, message) {
358
331
  __classPrivateFieldGet(this, _Compilation_inner, "f").pushDiagnostic(severity, title, message);
359
332
  }
333
+ /**
334
+ * Note: This is not a webpack public API, maybe removed in future.
335
+ *
336
+ * @internal
337
+ */
360
338
  __internal__pushNativeDiagnostics(diagnostics) {
361
339
  __classPrivateFieldGet(this, _Compilation_inner, "f").pushNativeDiagnostics(diagnostics);
362
340
  }
@@ -369,15 +347,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
369
347
  handler(target, thisArg, errs) {
370
348
  for (let i = 0; i < errs.length; i++) {
371
349
  const error = errs[i];
372
- if ((0, util_1.isJsStatsError)(error)) {
373
- inner.pushDiagnostic("error", "Error", (0, util_1.concatErrorMsgAndStack)(error));
374
- }
375
- else if (typeof error === "string") {
376
- inner.pushDiagnostic("error", "Error", error);
377
- }
378
- else {
379
- inner.pushDiagnostic("error", error.name, (0, util_1.concatErrorMsgAndStack)(error));
380
- }
350
+ inner.pushDiagnostic("error", error instanceof Error ? error.name : "Error", (0, util_1.concatErrorMsgAndStack)(error));
381
351
  }
382
352
  return Reflect.apply(target, thisArg, errs);
383
353
  }
@@ -400,27 +370,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
400
370
  method: "unshift",
401
371
  handler(target, thisArg, errs) {
402
372
  const errList = errs.map(error => {
403
- if ((0, util_1.isJsStatsError)(error)) {
404
- return {
405
- severity: "error",
406
- title: "Error",
407
- message: (0, util_1.concatErrorMsgAndStack)(error)
408
- };
409
- }
410
- else if (typeof error === "string") {
411
- return {
412
- severity: "error",
413
- title: "Error",
414
- message: error
415
- };
416
- }
417
- else {
418
- return {
419
- severity: "error",
420
- title: error.name,
421
- message: (0, util_1.concatErrorMsgAndStack)(error)
422
- };
423
- }
373
+ return {
374
+ severity: "error",
375
+ title: error instanceof Error ? error.name : "Error",
376
+ message: (0, util_1.concatErrorMsgAndStack)(error)
377
+ };
424
378
  });
425
379
  inner.spliceDiagnostic(0, 0, errList);
426
380
  return Reflect.apply(target, thisArg, errs);
@@ -430,27 +384,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
430
384
  method: "splice",
431
385
  handler(target, thisArg, [startIdx, delCount, ...errors]) {
432
386
  const errList = errors.map(error => {
433
- if ((0, util_1.isJsStatsError)(error)) {
434
- return {
435
- severity: "error",
436
- title: "Error",
437
- message: (0, util_1.concatErrorMsgAndStack)(error)
438
- };
439
- }
440
- else if (typeof error === "string") {
441
- return {
442
- severity: "error",
443
- title: "Error",
444
- message: error
445
- };
446
- }
447
- else {
448
- return {
449
- severity: "error",
450
- title: error.name,
451
- message: (0, util_1.concatErrorMsgAndStack)(error)
452
- };
453
- }
387
+ return {
388
+ severity: "error",
389
+ title: error instanceof Error ? error.name : "Error",
390
+ message: (0, util_1.concatErrorMsgAndStack)(error)
391
+ };
454
392
  });
455
393
  inner.spliceDiagnostic(startIdx, startIdx + delCount, errList);
456
394
  return Reflect.apply(target, thisArg, [
@@ -480,7 +418,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
480
418
  warns = processWarningsHook.call(warns);
481
419
  for (let i = 0; i < warns.length; i++) {
482
420
  const warn = warns[i];
483
- inner.pushDiagnostic("warning", (0, util_1.isJsStatsError)(warn) ? "Warning" : warn.name, (0, util_1.concatErrorMsgAndStack)(warn));
421
+ inner.pushDiagnostic("warning", warn instanceof Error ? warn.name : "Warning", (0, util_1.concatErrorMsgAndStack)(warn));
484
422
  }
485
423
  return Reflect.apply(target, thisArg, warns);
486
424
  }
@@ -506,7 +444,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
506
444
  const warnList = warns.map(warn => {
507
445
  return {
508
446
  severity: "warning",
509
- title: (0, util_1.isJsStatsError)(warn) ? "Warning" : warn.name,
447
+ title: warn instanceof Error ? warn.name : "Warning",
510
448
  message: (0, util_1.concatErrorMsgAndStack)(warn)
511
449
  };
512
450
  });
@@ -521,7 +459,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
521
459
  const warnList = warns.map(warn => {
522
460
  return {
523
461
  severity: "warning",
524
- title: (0, util_1.isJsStatsError)(warn) ? "Warning" : warn.name,
462
+ title: warn instanceof Error ? warn.name : "Warning",
525
463
  message: (0, util_1.concatErrorMsgAndStack)(warn)
526
464
  };
527
465
  });
@@ -579,7 +517,6 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
579
517
  const logEntry = {
580
518
  time: Date.now(),
581
519
  type,
582
- // @ts-expect-error
583
520
  args,
584
521
  // @ts-expect-error
585
522
  trace
@@ -653,94 +590,6 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
653
590
  }
654
591
  });
655
592
  }
656
- get modules() {
657
- return (0, memoize_1.memoizeValue)(() => {
658
- return this.__internal__getModules().map(item => Module_1.Module.__from_binding(item));
659
- });
660
- }
661
- // FIXME: This is not aligned with Webpack.
662
- get chunks() {
663
- return (0, memoize_1.memoizeValue)(() => {
664
- return this.__internal__getChunks();
665
- });
666
- }
667
- /**
668
- * Get the named chunks.
669
- *
670
- * Note: This is a proxy for webpack internal API, only method `get` is supported now.
671
- */
672
- get namedChunks() {
673
- return {
674
- get: (property) => {
675
- if (typeof property === "string") {
676
- const chunk = __classPrivateFieldGet(this, _Compilation_inner, "f").getNamedChunk(property);
677
- return chunk && Chunk_1.Chunk.__from_binding(chunk, __classPrivateFieldGet(this, _Compilation_inner, "f"));
678
- }
679
- }
680
- };
681
- }
682
- /**
683
- * Get the associated `modules` of an given chunk.
684
- *
685
- * Note: This is not a webpack public API, maybe removed in future.
686
- *
687
- * @internal
688
- */
689
- __internal__getAssociatedModules(chunk) {
690
- var _a;
691
- const modules = this.__internal__getModules();
692
- const moduleMap = new Map();
693
- for (const module of modules) {
694
- moduleMap.set(module.moduleIdentifier, module);
695
- }
696
- return (_a = chunk.modules) === null || _a === void 0 ? void 0 : _a.flatMap(chunkModule => {
697
- var _a;
698
- const jsModule = this.__internal__findJsModule((_a = chunkModule.issuer) !== null && _a !== void 0 ? _a : chunkModule.identifier, moduleMap);
699
- return {
700
- ...jsModule
701
- // dependencies: chunkModule.reasons?.flatMap(jsReason => {
702
- // let jsOriginModule = this.__internal__findJsModule(
703
- // jsReason.moduleIdentifier ?? "",
704
- // moduleMap
705
- // );
706
- // return {
707
- // ...jsReason,
708
- // originModule: jsOriginModule
709
- // };
710
- // })
711
- };
712
- });
713
- }
714
- /**
715
- * Find a modules in an array.
716
- *
717
- * Note: This is not a webpack public API, maybe removed in future.
718
- *
719
- * @internal
720
- */
721
- __internal__findJsModule(identifier, modules) {
722
- return modules.get(identifier);
723
- }
724
- /**
725
- *
726
- * Note: This is not a webpack public API, maybe removed in future.
727
- *
728
- * @internal
729
- */
730
- __internal__getModules() {
731
- return __classPrivateFieldGet(this, _Compilation_inner, "f").getModules();
732
- }
733
- /**
734
- *
735
- * Note: This is not a webpack public API, maybe removed in future.
736
- *
737
- * @internal
738
- */
739
- __internal__getChunks() {
740
- return __classPrivateFieldGet(this, _Compilation_inner, "f")
741
- .getChunks()
742
- .map(c => Chunk_1.Chunk.__from_binding(c, __classPrivateFieldGet(this, _Compilation_inner, "f")));
743
- }
744
593
  getStats() {
745
594
  return new Stats_1.Stats(this);
746
595
  }
@@ -764,7 +613,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
764
613
  if (!rawSource) {
765
614
  return;
766
615
  }
767
- return (0, createSource_1.createSourceFromRaw)(rawSource);
616
+ return source_1.JsSource.__from_binding(rawSource);
768
617
  }
769
618
  /**
770
619
  * Set the `Source` of an given asset filename.
@@ -774,7 +623,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
774
623
  * @internal
775
624
  */
776
625
  __internal__setAssetSource(filename, source) {
777
- __classPrivateFieldGet(this, _Compilation_inner, "f").setAssetSource(filename, (0, createSource_1.createRawFromSource)(source));
626
+ __classPrivateFieldGet(this, _Compilation_inner, "f").setAssetSource(filename, source_1.JsSource.__to_binding(source));
778
627
  }
779
628
  /**
780
629
  * Delete the `Source` of an given asset filename.
@@ -806,13 +655,70 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
806
655
  __internal__hasAsset(name) {
807
656
  return __classPrivateFieldGet(this, _Compilation_inner, "f").hasAsset(name);
808
657
  }
658
+ /**
659
+ * Note: This is not a webpack public API, maybe removed in future.
660
+ *
661
+ * @internal
662
+ */
663
+ __internal__getModules() {
664
+ return __classPrivateFieldGet(this, _Compilation_inner, "f").getModules();
665
+ }
666
+ /**
667
+ * Note: This is not a webpack public API, maybe removed in future.
668
+ *
669
+ * @internal
670
+ */
671
+ __internal__getChunks() {
672
+ return __classPrivateFieldGet(this, _Compilation_inner, "f")
673
+ .getChunks()
674
+ .map(c => Chunk_1.Chunk.__from_binding(c, __classPrivateFieldGet(this, _Compilation_inner, "f")));
675
+ }
809
676
  __internal_getInner() {
810
677
  return __classPrivateFieldGet(this, _Compilation_inner, "f");
811
678
  }
812
679
  seal() { }
813
680
  unseal() { }
814
681
  }
815
- _Compilation_inner = new WeakMap();
682
+ _Compilation_inner = new WeakMap(), _Compilation_cachedAssets = new WeakMap(), _Compilation_instances = new WeakSet(), _Compilation_createCachedAssets = function _Compilation_createCachedAssets() {
683
+ return new Proxy({}, {
684
+ get: (_, property) => {
685
+ if (typeof property === "string") {
686
+ return this.__internal__getAssetSource(property);
687
+ }
688
+ },
689
+ set: (_, p, newValue) => {
690
+ if (typeof p === "string") {
691
+ this.__internal__setAssetSource(p, newValue);
692
+ return true;
693
+ }
694
+ return false;
695
+ },
696
+ deleteProperty: (_, p) => {
697
+ if (typeof p === "string") {
698
+ this.__internal__deleteAssetSource(p);
699
+ return true;
700
+ }
701
+ return false;
702
+ },
703
+ has: (_, property) => {
704
+ if (typeof property === "string") {
705
+ return this.__internal__hasAsset(property);
706
+ }
707
+ return false;
708
+ },
709
+ ownKeys: _ => {
710
+ return this.__internal__getAssetFilenames();
711
+ },
712
+ getOwnPropertyDescriptor() {
713
+ // To work with `Object.keys`, you should mark the property as enumerable.
714
+ // See: https://262.ecma-international.org/7.0/#sec-enumerableownnames
715
+ return {
716
+ enumerable: true,
717
+ configurable: true
718
+ };
719
+ }
720
+ });
721
+ };
816
722
  Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL = -2000;
817
723
  Compilation.PROCESS_ASSETS_STAGE_PRE_PROCESS = -1000;
818
724
  Compilation.PROCESS_ASSETS_STAGE_DERIVED = -200;