@rspack/core 0.7.6-canary-1a0d77d-20240627143904 → 1.0.0-alpha.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 (87) hide show
  1. package/README.md +2 -2
  2. package/compiled/enhanced-resolve/index.js +11 -11
  3. package/compiled/webpack-sources/index.d.ts +130 -0
  4. package/compiled/webpack-sources/index.js +3520 -0
  5. package/compiled/webpack-sources/license +21 -0
  6. package/compiled/webpack-sources/package.json +1 -0
  7. package/dist/Chunk.d.ts +19 -14
  8. package/dist/Chunk.js +22 -17
  9. package/dist/ChunkGraph.d.ts +1 -1
  10. package/dist/ChunkGraph.js +5 -5
  11. package/dist/ChunkGroup.d.ts +17 -7
  12. package/dist/ChunkGroup.js +12 -2
  13. package/dist/Compilation.d.ts +31 -33
  14. package/dist/Compilation.js +33 -53
  15. package/dist/Compiler.d.ts +26 -28
  16. package/dist/Compiler.js +74 -26
  17. package/dist/ContextModuleFactory.d.ts +1 -1
  18. package/dist/ContextModuleFactory.js +1 -1
  19. package/dist/Entrypoint.d.ts +1 -1
  20. package/dist/Entrypoint.js +2 -2
  21. package/dist/Module.d.ts +12 -7
  22. package/dist/Module.js +1 -0
  23. package/dist/MultiCompiler.d.ts +11 -11
  24. package/dist/MultiCompiler.js +30 -13
  25. package/dist/NormalModule.d.ts +7 -4
  26. package/dist/NormalModule.js +27 -11
  27. package/dist/NormalModuleFactory.d.ts +3 -1
  28. package/dist/NormalModuleFactory.js +3 -23
  29. package/dist/ResolverFactory.d.ts +3 -3
  30. package/dist/ResolverFactory.js +1 -1
  31. package/dist/RspackError.d.ts +8 -0
  32. package/dist/RspackError.js +21 -0
  33. package/dist/Stats.d.ts +4 -2
  34. package/dist/Stats.js +6 -0
  35. package/dist/Template.d.ts +1 -1
  36. package/dist/Template.js +2 -2
  37. package/dist/Watching.d.ts +1 -1
  38. package/dist/builtin-loader/swc/index.d.ts +0 -4
  39. package/dist/builtin-loader/swc/index.js +1 -5
  40. package/dist/builtin-loader/swc/preact.d.ts +3 -4
  41. package/dist/builtin-loader/swc/types.d.ts +2 -17
  42. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -0
  43. package/dist/builtin-plugin/BundlerInfoRspackPlugin.js +1 -0
  44. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
  45. package/dist/builtin-plugin/JavascriptModulesPlugin.js +1 -1
  46. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +1 -1
  47. package/dist/builtin-plugin/SplitChunksPlugin.js +11 -2
  48. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +0 -28
  49. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +20 -69
  50. package/dist/builtin-plugin/css-extract/index.d.ts +2 -2
  51. package/dist/config/adapter.js +30 -16
  52. package/dist/config/adapterRuleUse.js +0 -11
  53. package/dist/config/defaults.js +22 -30
  54. package/dist/config/normalization.js +13 -5
  55. package/dist/config/zod.d.ts +753 -205
  56. package/dist/config/zod.js +27 -13
  57. package/dist/container/ModuleFederationPlugin.js +1 -1
  58. package/dist/container/default.runtime.js +1 -170
  59. package/dist/exports.d.ts +9 -2
  60. package/dist/exports.js +11 -6
  61. package/dist/lib/Cache.d.ts +3 -3
  62. package/dist/lib/Cache.js +1 -1
  63. package/dist/loader-runner/index.js +37 -12
  64. package/dist/rspack.d.ts +1 -1
  65. package/dist/rspackOptionsApply.js +3 -0
  66. package/dist/stats/DefaultStatsFactoryPlugin.js +35 -11
  67. package/dist/stats/DefaultStatsPrinterPlugin.js +2 -2
  68. package/dist/stats/StatsFactory.d.ts +2 -2
  69. package/dist/stats/StatsFactory.js +12 -12
  70. package/dist/stats/StatsPrinter.d.ts +1 -1
  71. package/dist/stats/StatsPrinter.js +8 -8
  72. package/dist/stats/statsFactoryUtils.d.ts +13 -4
  73. package/dist/util/SplitChunkSize.d.ts +5 -0
  74. package/dist/util/SplitChunkSize.js +18 -0
  75. package/dist/util/index.d.ts +2 -2
  76. package/dist/util/index.js +4 -3
  77. package/dist/util/memoize.js +5 -1
  78. package/dist/util/source.d.ts +1 -1
  79. package/dist/util/source.js +1 -1
  80. package/package.json +14 -9
  81. package/dist/builtin-loader/swc/emotion.d.ts +0 -17
  82. package/dist/builtin-loader/swc/emotion.js +0 -22
  83. package/dist/builtin-loader/swc/relay.d.ts +0 -5
  84. package/dist/builtin-loader/swc/relay.js +0 -48
  85. package/dist/container/default.runtime.d.ts +0 -2
  86. package/dist/lite-tapable/index.d.ts +0 -146
  87. package/dist/lite-tapable/index.js +0 -752
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 JS Foundation and other contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ {"name":"webpack-sources","author":"Tobias Koppers @sokra","version":"3.2.3","license":"MIT","types":"index.d.ts","type":"commonjs"}
package/dist/Chunk.d.ts CHANGED
@@ -3,19 +3,19 @@ import { Compilation } from ".";
3
3
  import { ChunkGroup } from "./ChunkGroup";
4
4
  export declare class Chunk {
5
5
  #private;
6
- name?: string;
7
- id?: string;
8
- ids: Array<string>;
9
- idNameHints: Array<string>;
10
- filenameTemplate?: string;
11
- cssFilenameTemplate?: string;
12
- files: Array<string>;
13
- runtime: Array<string>;
14
- hash?: string;
15
- contentHash: Record<string, string>;
16
- renderedHash?: string;
17
- chunkReasons: Array<string>;
18
- auxiliaryFiles: Array<string>;
6
+ name?: Readonly<string>;
7
+ id?: Readonly<string>;
8
+ ids: ReadonlyArray<string>;
9
+ idNameHints: ReadonlyArray<string>;
10
+ filenameTemplate?: Readonly<string>;
11
+ cssFilenameTemplate?: Readonly<string>;
12
+ files: ReadonlySet<string>;
13
+ runtime: ReadonlySet<string>;
14
+ hash?: Readonly<string>;
15
+ contentHash: Readonly<Record<string, string>>;
16
+ renderedHash?: Readonly<string>;
17
+ chunkReason?: Readonly<string>;
18
+ auxiliaryFiles: ReadonlySet<string>;
19
19
  static __from_binding(chunk: JsChunk, compilation: Compilation): Chunk;
20
20
  static __from_binding(chunk: JsChunk, compilation: JsCompilation): Chunk;
21
21
  constructor(chunk: JsChunk, compilation: JsCompilation);
@@ -26,5 +26,10 @@ export declare class Chunk {
26
26
  getAllAsyncChunks(): Iterable<Chunk>;
27
27
  getAllInitialChunks(): Iterable<Chunk>;
28
28
  getAllReferencedChunks(): Iterable<Chunk>;
29
- __internal_innerUkey(): number;
29
+ /**
30
+ * Note: This is not a webpack public API, maybe removed in future.
31
+ *
32
+ * @internal
33
+ */
34
+ __internal__innerUkey(): number;
30
35
  }
package/dist/Chunk.js CHANGED
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _Chunk_inner, _Chunk_inner_compilation;
13
+ var _Chunk_inner, _Chunk_innerCompilation;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.Chunk = void 0;
16
16
  const binding_1 = require("@rspack/binding");
@@ -26,52 +26,57 @@ class Chunk {
26
26
  }
27
27
  constructor(chunk, compilation) {
28
28
  _Chunk_inner.set(this, void 0);
29
- _Chunk_inner_compilation.set(this, void 0);
29
+ _Chunk_innerCompilation.set(this, void 0);
30
30
  __classPrivateFieldSet(this, _Chunk_inner, chunk, "f");
31
- __classPrivateFieldSet(this, _Chunk_inner_compilation, compilation, "f");
31
+ __classPrivateFieldSet(this, _Chunk_innerCompilation, compilation, "f");
32
32
  this.name = chunk.name;
33
33
  this.id = chunk.id;
34
34
  this.ids = chunk.ids;
35
35
  this.idNameHints = chunk.idNameHints;
36
36
  this.filenameTemplate = chunk.filenameTemplate;
37
37
  this.cssFilenameTemplate = chunk.cssFilenameTemplate;
38
- this.files = chunk.files;
39
- this.runtime = chunk.runtime;
38
+ this.files = new Set(chunk.files);
39
+ this.runtime = new Set(chunk.runtime);
40
40
  this.hash = chunk.hash;
41
41
  this.contentHash = chunk.contentHash;
42
42
  this.renderedHash = chunk.renderedHash;
43
- this.chunkReasons = chunk.chunkReasons;
44
- this.auxiliaryFiles = chunk.auxiliaryFiles;
43
+ this.chunkReason = chunk.chunkReason;
44
+ this.auxiliaryFiles = new Set(chunk.auxiliaryFiles);
45
45
  }
46
46
  isOnlyInitial() {
47
- return (0, binding_1.__chunk_inner_is_only_initial)(__classPrivateFieldGet(this, _Chunk_inner, "f").__inner_ukey, __classPrivateFieldGet(this, _Chunk_inner_compilation, "f"));
47
+ return (0, binding_1.__chunk_inner_is_only_initial)(__classPrivateFieldGet(this, _Chunk_inner, "f").__inner_ukey, __classPrivateFieldGet(this, _Chunk_innerCompilation, "f"));
48
48
  }
49
49
  canBeInitial() {
50
- return (0, binding_1.__chunk_inner_can_be_initial)(__classPrivateFieldGet(this, _Chunk_inner, "f").__inner_ukey, __classPrivateFieldGet(this, _Chunk_inner_compilation, "f"));
50
+ return (0, binding_1.__chunk_inner_can_be_initial)(__classPrivateFieldGet(this, _Chunk_inner, "f").__inner_ukey, __classPrivateFieldGet(this, _Chunk_innerCompilation, "f"));
51
51
  }
52
52
  hasRuntime() {
53
- return (0, binding_1.__chunk_inner_has_runtime)(__classPrivateFieldGet(this, _Chunk_inner, "f").__inner_ukey, __classPrivateFieldGet(this, _Chunk_inner_compilation, "f"));
53
+ return (0, binding_1.__chunk_inner_has_runtime)(__classPrivateFieldGet(this, _Chunk_inner, "f").__inner_ukey, __classPrivateFieldGet(this, _Chunk_innerCompilation, "f"));
54
54
  }
55
55
  get groupsIterable() {
56
56
  const chunk_groups = __classPrivateFieldGet(this, _Chunk_inner, "f").__inner_groups.map(ukey => {
57
- const cg = (0, binding_1.__chunk_group_inner_get_chunk_group)(ukey, __classPrivateFieldGet(this, _Chunk_inner_compilation, "f"));
58
- return ChunkGroup_1.ChunkGroup.__from_binding(cg, __classPrivateFieldGet(this, _Chunk_inner_compilation, "f"));
57
+ const cg = (0, binding_1.__chunk_group_inner_get_chunk_group)(ukey, __classPrivateFieldGet(this, _Chunk_innerCompilation, "f"));
58
+ return ChunkGroup_1.ChunkGroup.__from_binding(cg, __classPrivateFieldGet(this, _Chunk_innerCompilation, "f"));
59
59
  });
60
60
  chunk_groups.sort(comparators_1.compareChunkGroupsByIndex);
61
61
  return new Set(chunk_groups);
62
62
  }
63
63
  getAllAsyncChunks() {
64
- return new Set((0, binding_1.__chunk_inner_get_all_async_chunks)(__classPrivateFieldGet(this, _Chunk_inner, "f").__inner_ukey, __classPrivateFieldGet(this, _Chunk_inner_compilation, "f")).map(c => Chunk.__from_binding(c, __classPrivateFieldGet(this, _Chunk_inner_compilation, "f"))));
64
+ return new Set((0, binding_1.__chunk_inner_get_all_async_chunks)(__classPrivateFieldGet(this, _Chunk_inner, "f").__inner_ukey, __classPrivateFieldGet(this, _Chunk_innerCompilation, "f")).map(c => Chunk.__from_binding(c, __classPrivateFieldGet(this, _Chunk_innerCompilation, "f"))));
65
65
  }
66
66
  getAllInitialChunks() {
67
- return new Set((0, binding_1.__chunk_inner_get_all_initial_chunks)(__classPrivateFieldGet(this, _Chunk_inner, "f").__inner_ukey, __classPrivateFieldGet(this, _Chunk_inner_compilation, "f")).map(c => Chunk.__from_binding(c, __classPrivateFieldGet(this, _Chunk_inner_compilation, "f"))));
67
+ return new Set((0, binding_1.__chunk_inner_get_all_initial_chunks)(__classPrivateFieldGet(this, _Chunk_inner, "f").__inner_ukey, __classPrivateFieldGet(this, _Chunk_innerCompilation, "f")).map(c => Chunk.__from_binding(c, __classPrivateFieldGet(this, _Chunk_innerCompilation, "f"))));
68
68
  }
69
69
  getAllReferencedChunks() {
70
- return new Set((0, binding_1.__chunk_inner_get_all_referenced_chunks)(__classPrivateFieldGet(this, _Chunk_inner, "f").__inner_ukey, __classPrivateFieldGet(this, _Chunk_inner_compilation, "f")).map(c => Chunk.__from_binding(c, __classPrivateFieldGet(this, _Chunk_inner_compilation, "f"))));
70
+ return new Set((0, binding_1.__chunk_inner_get_all_referenced_chunks)(__classPrivateFieldGet(this, _Chunk_inner, "f").__inner_ukey, __classPrivateFieldGet(this, _Chunk_innerCompilation, "f")).map(c => Chunk.__from_binding(c, __classPrivateFieldGet(this, _Chunk_innerCompilation, "f"))));
71
71
  }
72
- __internal_innerUkey() {
72
+ /**
73
+ * Note: This is not a webpack public API, maybe removed in future.
74
+ *
75
+ * @internal
76
+ */
77
+ __internal__innerUkey() {
73
78
  return __classPrivateFieldGet(this, _Chunk_inner, "f").__inner_ukey;
74
79
  }
75
80
  }
76
81
  exports.Chunk = Chunk;
77
- _Chunk_inner = new WeakMap(), _Chunk_inner_compilation = new WeakMap();
82
+ _Chunk_inner = new WeakMap(), _Chunk_innerCompilation = new WeakMap();
@@ -4,7 +4,7 @@ import { Module } from "./Module";
4
4
  export declare class ChunkGraph {
5
5
  private compilation;
6
6
  constructor(compilation: Compilation);
7
- getChunkModules(chunk: Chunk): Module[];
7
+ getChunkModules(chunk: Chunk): Readonly<Module[]>;
8
8
  getChunkModulesIterable(chunk: Chunk): Iterable<Module>;
9
9
  getChunkEntryModulesIterable(chunk: Chunk): Iterable<Module>;
10
10
  getChunkEntryDependentChunksIterable(chunk: Chunk): Iterable<Chunk>;
@@ -9,19 +9,19 @@ class ChunkGraph {
9
9
  this.compilation = compilation;
10
10
  }
11
11
  getChunkModules(chunk) {
12
- return (0, binding_1.__chunk_graph_inner_get_chunk_modules)(chunk.__internal_innerUkey(), this.compilation.__internal_getInner()).map(m => Module_1.Module.__from_binding(m, this.compilation));
12
+ return (0, binding_1.__chunk_graph_inner_get_chunk_modules)(chunk.__internal__innerUkey(), this.compilation.__internal_getInner()).map(m => Module_1.Module.__from_binding(m, this.compilation));
13
13
  }
14
14
  getChunkModulesIterable(chunk) {
15
- return new Set((0, binding_1.__chunk_graph_inner_get_chunk_modules)(chunk.__internal_innerUkey(), this.compilation.__internal_getInner()).map(m => Module_1.Module.__from_binding(m, this.compilation)));
15
+ return new Set((0, binding_1.__chunk_graph_inner_get_chunk_modules)(chunk.__internal__innerUkey(), this.compilation.__internal_getInner()).map(m => Module_1.Module.__from_binding(m, this.compilation)));
16
16
  }
17
17
  getChunkEntryModulesIterable(chunk) {
18
- return new Set((0, binding_1.__chunk_graph_inner_get_chunk_entry_modules)(chunk.__internal_innerUkey(), this.compilation.__internal_getInner()).map(m => Module_1.Module.__from_binding(m, this.compilation)));
18
+ return new Set((0, binding_1.__chunk_graph_inner_get_chunk_entry_modules)(chunk.__internal__innerUkey(), this.compilation.__internal_getInner()).map(m => Module_1.Module.__from_binding(m, this.compilation)));
19
19
  }
20
20
  getChunkEntryDependentChunksIterable(chunk) {
21
- return new Set((0, binding_1.__chunk_graph_inner_get_chunk_entry_dependent_chunks_iterable)(chunk.__internal_innerUkey(), this.compilation.__internal_getInner()).map(c => Chunk_1.Chunk.__from_binding(c, this.compilation.__internal_getInner())));
21
+ return new Set((0, binding_1.__chunk_graph_inner_get_chunk_entry_dependent_chunks_iterable)(chunk.__internal__innerUkey(), this.compilation.__internal_getInner()).map(c => Chunk_1.Chunk.__from_binding(c, this.compilation.__internal_getInner())));
22
22
  }
23
23
  getChunkModulesIterableBySourceType(chunk, sourceType) {
24
- return new Set((0, binding_1.__chunk_graph_inner_get_chunk_modules_iterable_by_source_type)(chunk.__internal_innerUkey(), sourceType, this.compilation.__internal_getInner()).map(m => Module_1.Module.__from_binding(m, this.compilation)));
24
+ return new Set((0, binding_1.__chunk_graph_inner_get_chunk_modules_iterable_by_source_type)(chunk.__internal__innerUkey(), sourceType, this.compilation.__internal_getInner()).map(m => Module_1.Module.__from_binding(m, this.compilation)));
25
25
  }
26
26
  }
27
27
  exports.ChunkGraph = ChunkGraph;
@@ -4,11 +4,21 @@ export declare class ChunkGroup {
4
4
  #private;
5
5
  static __from_binding(chunk: JsChunkGroup, compilation: JsCompilation): ChunkGroup;
6
6
  protected constructor(inner: JsChunkGroup, compilation: JsCompilation);
7
- getFiles(): string[];
8
- getParents(): ChunkGroup[];
9
- get chunks(): Chunk[];
10
- get index(): number | undefined;
11
- get name(): string | undefined;
12
- __internal_innerUkey(): number;
13
- __internal_innerCompilation(): JsCompilation;
7
+ getFiles(): ReadonlyArray<string>;
8
+ getParents(): ReadonlyArray<ChunkGroup>;
9
+ get chunks(): ReadonlyArray<Chunk>;
10
+ get index(): Readonly<number | undefined>;
11
+ get name(): Readonly<string | undefined>;
12
+ /**
13
+ * Note: This is not a webpack public API, maybe removed in future.
14
+ *
15
+ * @internal
16
+ */
17
+ __internal__innerUkey(): number;
18
+ /**
19
+ * Note: This is not a webpack public API, maybe removed in future.
20
+ *
21
+ * @internal
22
+ */
23
+ __internal__innerCompilation(): JsCompilation;
14
24
  }
@@ -49,10 +49,20 @@ class ChunkGroup {
49
49
  get name() {
50
50
  return __classPrivateFieldGet(this, _ChunkGroup_inner, "f").name;
51
51
  }
52
- __internal_innerUkey() {
52
+ /**
53
+ * Note: This is not a webpack public API, maybe removed in future.
54
+ *
55
+ * @internal
56
+ */
57
+ __internal__innerUkey() {
53
58
  return __classPrivateFieldGet(this, _ChunkGroup_inner, "f").__inner_ukey;
54
59
  }
55
- __internal_innerCompilation() {
60
+ /**
61
+ * Note: This is not a webpack public API, maybe removed in future.
62
+ *
63
+ * @internal
64
+ */
65
+ __internal__innerCompilation() {
56
66
  return __classPrivateFieldGet(this, _ChunkGroup_innerCompilation, "f");
57
67
  }
58
68
  }
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  /**
3
2
  * The following code is modified based on
4
3
  * https://github.com/webpack/webpack/blob/4b4ca3bb53f36a5b8fc6bc1bd976ed7af161bd80/lib/Compilation.js
@@ -8,12 +7,12 @@
8
7
  * Copyright (c) JS Foundation and other contributors
9
8
  * https://github.com/webpack/webpack/blob/main/LICENSE
10
9
  */
11
- import type { ExternalObject, JsCompilation, JsModule, JsPathData, JsRuntimeModule, JsStatsError, JsStatsWarning } from "@rspack/binding";
12
- import * as tapable from "tapable";
13
- import { Source } from "webpack-sources";
10
+ import type * as binding from "@rspack/binding";
11
+ import { type ExternalObject, type JsCompilation, type JsModule, type JsPathData, type JsRuntimeModule } from "@rspack/binding";
12
+ import * as liteTapable from "@rspack/lite-tapable";
13
+ import { Source } from "../compiled/webpack-sources";
14
14
  import { ContextModuleFactory } from "./ContextModuleFactory";
15
15
  import { Filename, OutputNormalized, RspackOptionsNormalized, RspackPluginInstance, StatsOptions, StatsValue } from "./config";
16
- import * as liteTapable from "./lite-tapable";
17
16
  import ResolverFactory = require("./ResolverFactory");
18
17
  import { Chunk } from "./Chunk";
19
18
  import { ChunkGraph } from "./ChunkGraph";
@@ -26,7 +25,8 @@ import { Logger } from "./logging/Logger";
26
25
  import { StatsFactory } from "./stats/StatsFactory";
27
26
  import { StatsPrinter } from "./stats/StatsPrinter";
28
27
  import { type AssetInfo } from "./util/AssetInfo";
29
- import MergeCaller from "./util/MergeCaller";
28
+ import Hash = require("./util/hash");
29
+ import { RspackError } from "./RspackError";
30
30
  export { type AssetInfo } from "./util/AssetInfo";
31
31
  export type Assets = Record<string, Source>;
32
32
  export interface Asset {
@@ -102,11 +102,11 @@ export type CreateStatsOptionsContext = KnownCreateStatsOptionsContext & Record<
102
102
  export type NormalizedStatsOptions = KnownNormalizedStatsOptions & Omit<StatsOptions, keyof KnownNormalizedStatsOptions> & Record<string, any>;
103
103
  export declare class Compilation {
104
104
  #private;
105
- hooks: {
105
+ hooks: Readonly<{
106
106
  processAssets: liteTapable.AsyncSeriesHook<Assets>;
107
107
  afterProcessAssets: liteTapable.SyncHook<Assets>;
108
- childCompiler: tapable.SyncHook<[Compiler, string, number]>;
109
- log: tapable.SyncBailHook<[string, LogEntry], true>;
108
+ childCompiler: liteTapable.SyncHook<[Compiler, string, number]>;
109
+ log: liteTapable.SyncBailHook<[string, LogEntry], true>;
110
110
  additionalAssets: any;
111
111
  optimizeModules: liteTapable.SyncBailHook<Iterable<Module>, void>;
112
112
  afterOptimizeModules: liteTapable.SyncHook<Iterable<Module>, void>;
@@ -119,17 +119,21 @@ export declare class Compilation {
119
119
  Iterable<Module>
120
120
  ], void>;
121
121
  finishModules: liteTapable.AsyncSeriesHook<[Iterable<Module>], void>;
122
+ chunkHash: liteTapable.SyncHook<[Chunk, Hash], void>;
122
123
  chunkAsset: liteTapable.SyncHook<[Chunk, string], void>;
123
- processWarnings: tapable.SyncWaterfallHook<[Error[]]>;
124
+ processWarnings: liteTapable.SyncWaterfallHook<[Error[]]>;
124
125
  succeedModule: liteTapable.SyncHook<[Module], void>;
125
126
  stillValidModule: liteTapable.SyncHook<[Module], void>;
126
- statsPreset: tapable.HookMap<tapable.SyncHook<[Partial<StatsOptions>, CreateStatsOptionsContext], void>>;
127
- statsNormalize: tapable.SyncHook<[
127
+ statsPreset: liteTapable.HookMap<liteTapable.SyncHook<[
128
+ Partial<StatsOptions>,
129
+ CreateStatsOptionsContext
130
+ ], void>>;
131
+ statsNormalize: liteTapable.SyncHook<[
128
132
  Partial<StatsOptions>,
129
133
  CreateStatsOptionsContext
130
134
  ], void>;
131
- statsFactory: tapable.SyncHook<[StatsFactory, StatsOptions], void>;
132
- statsPrinter: tapable.SyncHook<[StatsPrinter, StatsOptions], void>;
135
+ statsFactory: liteTapable.SyncHook<[StatsFactory, StatsOptions], void>;
136
+ statsPrinter: liteTapable.SyncHook<[StatsPrinter, StatsOptions], void>;
133
137
  buildModule: liteTapable.SyncHook<[Module]>;
134
138
  executeModule: liteTapable.SyncHook<[
135
139
  ExecuteModuleArgument,
@@ -141,7 +145,7 @@ export declare class Compilation {
141
145
  ], void>;
142
146
  runtimeModule: liteTapable.SyncHook<[JsRuntimeModule, Chunk], void>;
143
147
  afterSeal: liteTapable.AsyncSeriesHook<[], void>;
144
- };
148
+ }>;
145
149
  name?: string;
146
150
  startTime?: number;
147
151
  endTime?: number;
@@ -158,13 +162,8 @@ export declare class Compilation {
158
162
  createSnapshot(): null;
159
163
  };
160
164
  constructor(compiler: Compiler, inner: JsCompilation);
161
- get currentNormalModuleHooks(): {
162
- loader: tapable.SyncHook<[import("./config").LoaderContext<{}>], void, tapable.UnsetAdditionalOptions>;
163
- readResourceForScheme: any;
164
- readResource: tapable.HookMap<tapable.AsyncSeriesBailHook<[import("./config").LoaderContext<{}>], string | Buffer, tapable.UnsetAdditionalOptions>>;
165
- };
166
- get hash(): string | null;
167
- get fullHash(): string | null;
165
+ get hash(): Readonly<string | null>;
166
+ get fullHash(): Readonly<string | null>;
168
167
  /**
169
168
  * Get a map of all assets.
170
169
  */
@@ -173,14 +172,14 @@ export declare class Compilation {
173
172
  * Get a map of all entrypoints.
174
173
  */
175
174
  get entrypoints(): ReadonlyMap<string, Entrypoint>;
176
- get modules(): Module[];
177
- get chunks(): Chunk[];
175
+ get modules(): ReadonlySet<Module>;
176
+ get chunks(): ReadonlySet<Chunk>;
178
177
  /**
179
178
  * Get the named chunks.
180
179
  *
181
- * Note: This is a proxy for webpack internal API, only method `get` is supported now.
180
+ * Note: This is a proxy for webpack internal API, only method `get` and `keys` is supported now.
182
181
  */
183
- get namedChunks(): Map<string, Readonly<Chunk>>;
182
+ get namedChunks(): ReadonlyMap<string, Readonly<Chunk>>;
184
183
  /**
185
184
  * Note: This is not a webpack public API, maybe removed in future.
186
185
  *
@@ -220,19 +219,19 @@ export declare class Compilation {
220
219
  *
221
220
  * @internal
222
221
  */
223
- __internal__pushDiagnostic(severity: "error" | "warning", title: string, message: string): void;
222
+ __internal__pushDiagnostic(diagnostic: binding.JsDiagnostic): void;
224
223
  /**
225
224
  * Note: This is not a webpack public API, maybe removed in future.
226
225
  *
227
226
  * @internal
228
227
  */
229
228
  __internal__pushNativeDiagnostics(diagnostics: ExternalObject<"Diagnostic[]">): void;
230
- get errors(): JsStatsError[];
231
- get warnings(): JsStatsWarning[];
229
+ get errors(): RspackError[];
230
+ get warnings(): RspackError[];
232
231
  getPath(filename: Filename, data?: PathData): string;
233
- getPathWithInfo(filename: Filename, data?: PathData): import("@rspack/binding").PathWithInfo;
232
+ getPathWithInfo(filename: Filename, data?: PathData): binding.PathWithInfo;
234
233
  getAssetPath(filename: Filename, data?: PathData): string;
235
- getAssetPathWithInfo(filename: Filename, data?: PathData): import("@rspack/binding").PathWithInfo;
234
+ getAssetPathWithInfo(filename: Filename, data?: PathData): binding.PathWithInfo;
236
235
  getLogger(name: string | (() => string)): Logger;
237
236
  fileDependencies: {
238
237
  [Symbol.iterator](): Generator<string, void, unknown>;
@@ -260,7 +259,6 @@ export declare class Compilation {
260
259
  };
261
260
  getStats(): Stats;
262
261
  createChildCompiler(name: string, outputOptions: OutputNormalized, plugins: RspackPluginInstance[]): Compiler;
263
- _rebuildModuleCaller: MergeCaller<[string, (err: Error, m: Module) => void]>;
264
262
  rebuildModule(m: Module, f: (err: Error, m: Module) => void): void;
265
263
  /**
266
264
  * Get the `Source` of a given asset filename.
@@ -319,7 +317,7 @@ export declare class Compilation {
319
317
  *
320
318
  * @internal
321
319
  */
322
- __internal_getInner(): JsCompilation;
320
+ __internal_getInner(): binding.JsCompilation;
323
321
  seal(): void;
324
322
  unseal(): void;
325
323
  static PROCESS_ASSETS_STAGE_ADDITIONAL: number;
@@ -36,27 +36,26 @@ 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_customModules, _Compilation_createCachedAssets;
39
+ var _Compilation_instances, _Compilation_inner, _Compilation_cachedAssets, _Compilation_customModules, _Compilation_createCachedAssets, _Compilation_rebuildModuleCaller;
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.Compilation = void 0;
42
- const tapable = __importStar(require("tapable"));
43
- const liteTapable = __importStar(require("./lite-tapable"));
42
+ const binding_1 = require("@rspack/binding");
43
+ const liteTapable = __importStar(require("@rspack/lite-tapable"));
44
44
  const Chunk_1 = require("./Chunk");
45
45
  const ChunkGraph_1 = require("./ChunkGraph");
46
46
  const Entrypoint_1 = require("./Entrypoint");
47
47
  const ErrorHelpers_1 = __importDefault(require("./ErrorHelpers"));
48
48
  const Module_1 = require("./Module");
49
- const NormalModule_1 = require("./NormalModule");
50
49
  const Stats_1 = require("./Stats");
51
50
  const Logger_1 = require("./logging/Logger");
52
51
  const StatsFactory_1 = require("./stats/StatsFactory");
53
52
  const StatsPrinter_1 = require("./stats/StatsPrinter");
54
- const util_1 = require("./util");
55
53
  const AssetInfo_1 = require("./util/AssetInfo");
56
54
  const MergeCaller_1 = __importDefault(require("./util/MergeCaller"));
57
55
  const fake_1 = require("./util/fake");
58
56
  const memoize_1 = require("./util/memoize");
59
57
  const source_1 = require("./util/source");
58
+ const RspackError_1 = require("./RspackError");
60
59
  class Compilation {
61
60
  constructor(compiler, inner) {
62
61
  _Compilation_instances.add(this);
@@ -77,7 +76,7 @@ class Compilation {
77
76
  this.contextDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").getContextDependencies(), d => __classPrivateFieldGet(this, _Compilation_inner, "f").addContextDependencies(d));
78
77
  this.missingDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").getMissingDependencies(), d => __classPrivateFieldGet(this, _Compilation_inner, "f").addMissingDependencies(d));
79
78
  this.buildDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").getBuildDependencies(), d => __classPrivateFieldGet(this, _Compilation_inner, "f").addBuildDependencies(d));
80
- this._rebuildModuleCaller = (function (compilation) {
79
+ _Compilation_rebuildModuleCaller.set(this, (function (compilation) {
81
80
  return new MergeCaller_1.default((args) => {
82
81
  __classPrivateFieldGet(compilation, _Compilation_inner, "f").rebuildModule(args.map(item => item[0]), function (err, modules) {
83
82
  for (const [id, callback] of args) {
@@ -91,7 +90,7 @@ class Compilation {
91
90
  }
92
91
  });
93
92
  }, 10);
94
- })(this);
93
+ })(this));
95
94
  __classPrivateFieldSet(this, _Compilation_inner, inner, "f");
96
95
  __classPrivateFieldSet(this, _Compilation_cachedAssets, __classPrivateFieldGet(this, _Compilation_instances, "m", _Compilation_createCachedAssets).call(this), "f");
97
96
  __classPrivateFieldSet(this, _Compilation_customModules, {}, "f");
@@ -131,12 +130,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
131
130
  afterProcessAssets: new liteTapable.SyncHook(["assets"]),
132
131
  /** @deprecated */
133
132
  additionalAssets: createProcessAssetsHook("additionalAssets", Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL, () => []),
134
- childCompiler: new tapable.SyncHook([
133
+ childCompiler: new liteTapable.SyncHook([
135
134
  "childCompiler",
136
135
  "compilerName",
137
136
  "compilerIndex"
138
137
  ]),
139
- log: new tapable.SyncBailHook(["origin", "logEntry"]),
138
+ log: new liteTapable.SyncBailHook(["origin", "logEntry"]),
140
139
  optimizeModules: new liteTapable.SyncBailHook(["modules"]),
141
140
  afterOptimizeModules: new liteTapable.SyncBailHook(["modules"]),
142
141
  optimizeTree: new liteTapable.AsyncSeriesHook(["chunks", "modules"]),
@@ -145,14 +144,15 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
145
144
  "modules"
146
145
  ]),
147
146
  finishModules: new liteTapable.AsyncSeriesHook(["modules"]),
147
+ chunkHash: new liteTapable.SyncHook(["chunk", "hash"]),
148
148
  chunkAsset: new liteTapable.SyncHook(["chunk", "filename"]),
149
- processWarnings: new tapable.SyncWaterfallHook(["warnings"]),
149
+ processWarnings: new liteTapable.SyncWaterfallHook(["warnings"]),
150
150
  succeedModule: new liteTapable.SyncHook(["module"]),
151
151
  stillValidModule: new liteTapable.SyncHook(["module"]),
152
- statsPreset: new tapable.HookMap(() => new tapable.SyncHook(["options", "context"])),
153
- statsNormalize: new tapable.SyncHook(["options", "context"]),
154
- statsFactory: new tapable.SyncHook(["statsFactory", "options"]),
155
- statsPrinter: new tapable.SyncHook(["statsPrinter", "options"]),
152
+ statsPreset: new liteTapable.HookMap(() => new liteTapable.SyncHook(["options", "context"])),
153
+ statsNormalize: new liteTapable.SyncHook(["options", "context"]),
154
+ statsFactory: new liteTapable.SyncHook(["statsFactory", "options"]),
155
+ statsPrinter: new liteTapable.SyncHook(["statsPrinter", "options"]),
156
156
  buildModule: new liteTapable.SyncHook(["module"]),
157
157
  executeModule: new liteTapable.SyncHook(["options", "context"]),
158
158
  additionalTreeRuntimeRequirements: new liteTapable.SyncHook([
@@ -172,9 +172,6 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
172
172
  this.children = [];
173
173
  this.chunkGraph = new ChunkGraph_1.ChunkGraph(this);
174
174
  }
175
- get currentNormalModuleHooks() {
176
- return NormalModule_1.NormalModule.getCompilationHooks(this);
177
- }
178
175
  get hash() {
179
176
  return __classPrivateFieldGet(this, _Compilation_inner, "f").hash;
180
177
  }
@@ -197,23 +194,22 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
197
194
  ]));
198
195
  }
199
196
  get modules() {
200
- return (0, memoize_1.memoizeValue)(() => {
201
- return this.__internal__getModules().map(item => Module_1.Module.__from_binding(item, this));
202
- });
197
+ return (0, memoize_1.memoizeValue)(() => new Set(this.__internal__getModules().map(item => Module_1.Module.__from_binding(item, this))));
203
198
  }
204
- // FIXME: Webpack returns a `Set`
205
199
  get chunks() {
206
- return (0, memoize_1.memoizeValue)(() => {
207
- return this.__internal__getChunks();
208
- });
200
+ return (0, memoize_1.memoizeValue)(() => new Set(this.__internal__getChunks()));
209
201
  }
210
202
  /**
211
203
  * Get the named chunks.
212
204
  *
213
- * Note: This is a proxy for webpack internal API, only method `get` is supported now.
205
+ * Note: This is a proxy for webpack internal API, only method `get` and `keys` is supported now.
214
206
  */
215
207
  get namedChunks() {
216
208
  return {
209
+ keys: () => {
210
+ const names = __classPrivateFieldGet(this, _Compilation_inner, "f").getNamedChunkKeys();
211
+ return names[Symbol.iterator]();
212
+ },
217
213
  get: (property) => {
218
214
  if (typeof property === "string") {
219
215
  const chunk = __classPrivateFieldGet(this, _Compilation_inner, "f").getNamedChunk(property) || undefined;
@@ -347,8 +343,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
347
343
  *
348
344
  * @internal
349
345
  */
350
- __internal__pushDiagnostic(severity, title, message) {
351
- __classPrivateFieldGet(this, _Compilation_inner, "f").pushDiagnostic(severity, title, message);
346
+ __internal__pushDiagnostic(diagnostic) {
347
+ __classPrivateFieldGet(this, _Compilation_inner, "f").pushDiagnostic(diagnostic);
352
348
  }
353
349
  /**
354
350
  * Note: This is not a webpack public API, maybe removed in future.
@@ -360,14 +356,14 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
360
356
  }
361
357
  get errors() {
362
358
  const inner = __classPrivateFieldGet(this, _Compilation_inner, "f");
363
- const errors = inner.getStats().getErrors();
359
+ const errors = inner.getErrors();
364
360
  const proxyMethod = [
365
361
  {
366
362
  method: "push",
367
363
  handler(target, thisArg, errs) {
368
364
  for (let i = 0; i < errs.length; i++) {
369
365
  const error = errs[i];
370
- inner.pushDiagnostic("error", error instanceof Error ? error.name : "Error", (0, util_1.concatErrorMsgAndStack)(error));
366
+ inner.pushDiagnostic(RspackError_1.JsDiagnostic.__to_binding(error, binding_1.JsRspackSeverity.Error));
371
367
  }
372
368
  return Reflect.apply(target, thisArg, errs);
373
369
  }
@@ -390,11 +386,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
390
386
  method: "unshift",
391
387
  handler(target, thisArg, errs) {
392
388
  const errList = errs.map(error => {
393
- return {
394
- severity: "error",
395
- title: error instanceof Error ? error.name : "Error",
396
- message: (0, util_1.concatErrorMsgAndStack)(error)
397
- };
389
+ return RspackError_1.JsDiagnostic.__to_binding(error, binding_1.JsRspackSeverity.Error);
398
390
  });
399
391
  inner.spliceDiagnostic(0, 0, errList);
400
392
  return Reflect.apply(target, thisArg, errs);
@@ -404,11 +396,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
404
396
  method: "splice",
405
397
  handler(target, thisArg, [startIdx, delCount, ...errors]) {
406
398
  const errList = errors.map(error => {
407
- return {
408
- severity: "error",
409
- title: error instanceof Error ? error.name : "Error",
410
- message: (0, util_1.concatErrorMsgAndStack)(error)
411
- };
399
+ return RspackError_1.JsDiagnostic.__to_binding(error, binding_1.JsRspackSeverity.Error);
412
400
  });
413
401
  inner.spliceDiagnostic(startIdx, startIdx + delCount, errList);
414
402
  return Reflect.apply(target, thisArg, [
@@ -430,7 +418,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
430
418
  get warnings() {
431
419
  const inner = __classPrivateFieldGet(this, _Compilation_inner, "f");
432
420
  const processWarningsHook = this.hooks.processWarnings;
433
- const warnings = inner.getStats().getWarnings();
421
+ const warnings = inner.getWarnings();
434
422
  const proxyMethod = [
435
423
  {
436
424
  method: "push",
@@ -438,7 +426,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
438
426
  warns = processWarningsHook.call(warns);
439
427
  for (let i = 0; i < warns.length; i++) {
440
428
  const warn = warns[i];
441
- inner.pushDiagnostic("warning", warn instanceof Error ? warn.name : "Warning", (0, util_1.concatErrorMsgAndStack)(warn));
429
+ inner.pushDiagnostic(RspackError_1.JsDiagnostic.__to_binding(warn, binding_1.JsRspackSeverity.Warn));
442
430
  }
443
431
  return Reflect.apply(target, thisArg, warns);
444
432
  }
@@ -462,11 +450,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
462
450
  handler(target, thisArg, warns) {
463
451
  warns = processWarningsHook.call(warns);
464
452
  const warnList = warns.map(warn => {
465
- return {
466
- severity: "warning",
467
- title: warn instanceof Error ? warn.name : "Warning",
468
- message: (0, util_1.concatErrorMsgAndStack)(warn)
469
- };
453
+ return RspackError_1.JsDiagnostic.__to_binding(warn, binding_1.JsRspackSeverity.Warn);
470
454
  });
471
455
  inner.spliceDiagnostic(0, 0, warnList);
472
456
  return Reflect.apply(target, thisArg, warns);
@@ -477,11 +461,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
477
461
  handler(target, thisArg, [startIdx, delCount, ...warns]) {
478
462
  warns = processWarningsHook.call(warns);
479
463
  const warnList = warns.map(warn => {
480
- return {
481
- severity: "warning",
482
- title: warn instanceof Error ? warn.name : "Warning",
483
- message: (0, util_1.concatErrorMsgAndStack)(warn)
484
- };
464
+ return RspackError_1.JsDiagnostic.__to_binding(warn, binding_1.JsRspackSeverity.Warn);
485
465
  });
486
466
  inner.spliceDiagnostic(startIdx, startIdx + delCount, warnList);
487
467
  return Reflect.apply(target, thisArg, [
@@ -619,7 +599,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
619
599
  return this.compiler.createChildCompiler(this, name, idx, outputOptions, plugins);
620
600
  }
621
601
  rebuildModule(m, f) {
622
- this._rebuildModuleCaller.push([m.identifier(), f]);
602
+ __classPrivateFieldGet(this, _Compilation_rebuildModuleCaller, "f").push([m.identifier(), f]);
623
603
  }
624
604
  /**
625
605
  * Get the `Source` of a given asset filename.
@@ -704,7 +684,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
704
684
  seal() { }
705
685
  unseal() { }
706
686
  }
707
- _Compilation_inner = new WeakMap(), _Compilation_cachedAssets = new WeakMap(), _Compilation_customModules = new WeakMap(), _Compilation_instances = new WeakSet(), _Compilation_createCachedAssets = function _Compilation_createCachedAssets() {
687
+ _Compilation_inner = new WeakMap(), _Compilation_cachedAssets = new WeakMap(), _Compilation_customModules = new WeakMap(), _Compilation_rebuildModuleCaller = new WeakMap(), _Compilation_instances = new WeakSet(), _Compilation_createCachedAssets = function _Compilation_createCachedAssets() {
708
688
  return new Proxy({}, {
709
689
  get: (_, property) => {
710
690
  if (typeof property === "string") {