@rspack/core 1.0.10 → 1.0.12

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 (219) hide show
  1. package/compiled/browserslist/index.js +94 -49
  2. package/compiled/browserslist/package.json +1 -1
  3. package/dist/builtin-plugin/css-extract/utils.d.ts +1 -0
  4. package/dist/config/types.d.ts +309 -0
  5. package/dist/config/zod.d.ts +22 -534
  6. package/dist/cssExtractHmr.js +224 -0
  7. package/dist/cssExtractLoader.js +277 -0
  8. package/dist/index.js +23255 -31
  9. package/dist/{builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts → runtime/cssExtractHmr.d.ts} +1 -0
  10. package/dist/runtime/moduleFederationDefaultRuntime.d.ts +2 -0
  11. package/dist/stats/statsFactoryUtils.d.ts +1 -0
  12. package/package.json +8 -5
  13. package/compiled/json-parse-even-better-errors/index.d.ts +0 -1
  14. package/compiled/json-parse-even-better-errors/index.js +0 -193
  15. package/compiled/json-parse-even-better-errors/package.json +0 -1
  16. package/compiled/neo-async/index.d.ts +0 -685
  17. package/compiled/neo-async/index.js +0 -9207
  18. package/compiled/neo-async/license +0 -22
  19. package/compiled/neo-async/package.json +0 -1
  20. package/compiled/zod-validation-error/index.d.ts +0 -41
  21. package/compiled/zod-validation-error/index.js +0 -335
  22. package/compiled/zod-validation-error/license +0 -9
  23. package/compiled/zod-validation-error/package.json +0 -1
  24. package/dist/Chunk.js +0 -118
  25. package/dist/ChunkGraph.js +0 -27
  26. package/dist/ChunkGroup.js +0 -76
  27. package/dist/Compilation.js +0 -854
  28. package/dist/Compiler.js +0 -925
  29. package/dist/ContextModuleFactory.js +0 -36
  30. package/dist/DependenciesBlock.js +0 -30
  31. package/dist/Dependency.js +0 -43
  32. package/dist/Entrypoint.js +0 -21
  33. package/dist/ErrorHelpers.js +0 -62
  34. package/dist/ExecuteModulePlugin.js +0 -46
  35. package/dist/FileSystem.js +0 -34
  36. package/dist/FileSystemInfo.js +0 -2
  37. package/dist/Module.js +0 -226
  38. package/dist/ModuleTypeConstants.js +0 -92
  39. package/dist/MultiCompiler.js +0 -440
  40. package/dist/MultiStats.js +0 -161
  41. package/dist/MultiWatching.js +0 -62
  42. package/dist/NormalModule.js +0 -97
  43. package/dist/NormalModuleFactory.js +0 -43
  44. package/dist/Resolver.js +0 -39
  45. package/dist/ResolverFactory.js +0 -61
  46. package/dist/RspackError.js +0 -21
  47. package/dist/RuleSetCompiler.js +0 -10
  48. package/dist/RuntimeGlobals.js +0 -357
  49. package/dist/RuntimeModule.js +0 -58
  50. package/dist/Stats.js +0 -161
  51. package/dist/Template.js +0 -206
  52. package/dist/Watching.js +0 -290
  53. package/dist/builtin-loader/index.js +0 -17
  54. package/dist/builtin-loader/lightningcss/index.js +0 -175
  55. package/dist/builtin-loader/swc/index.js +0 -5
  56. package/dist/builtin-loader/swc/pluginImport.js +0 -35
  57. package/dist/builtin-loader/swc/react.js +0 -7
  58. package/dist/builtin-loader/swc/types.js +0 -2
  59. package/dist/builtin-plugin/APIPlugin.js +0 -6
  60. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.js +0 -6
  61. package/dist/builtin-plugin/AssetModulesPlugin.js +0 -6
  62. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.js +0 -6
  63. package/dist/builtin-plugin/BannerPlugin.js +0 -22
  64. package/dist/builtin-plugin/BundlerInfoRspackPlugin.js +0 -12
  65. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.js +0 -6
  66. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.js +0 -6
  67. package/dist/builtin-plugin/ContextReplacementPlugin.js +0 -43
  68. package/dist/builtin-plugin/CopyRspackPlugin.js +0 -21
  69. package/dist/builtin-plugin/CssModulesPlugin.js +0 -6
  70. package/dist/builtin-plugin/DataUriPlugin.js +0 -6
  71. package/dist/builtin-plugin/DefinePlugin.js +0 -44
  72. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.js +0 -6
  73. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.js +0 -6
  74. package/dist/builtin-plugin/DynamicEntryPlugin.js +0 -36
  75. package/dist/builtin-plugin/ElectronTargetPlugin.js +0 -6
  76. package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +0 -6
  77. package/dist/builtin-plugin/EnableLibraryPlugin.js +0 -39
  78. package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +0 -6
  79. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.js +0 -6
  80. package/dist/builtin-plugin/EntryPlugin.js +0 -34
  81. package/dist/builtin-plugin/EvalDevToolModulePlugin.js +0 -6
  82. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.js +0 -16
  83. package/dist/builtin-plugin/ExternalsPlugin.js +0 -51
  84. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.js +0 -6
  85. package/dist/builtin-plugin/FileUriPlugin.js +0 -6
  86. package/dist/builtin-plugin/FlagDependencyExportsPlugin.js +0 -6
  87. package/dist/builtin-plugin/FlagDependencyUsagePlugin.js +0 -6
  88. package/dist/builtin-plugin/HotModuleReplacementPlugin.js +0 -18
  89. package/dist/builtin-plugin/HtmlRspackPlugin.js +0 -285
  90. package/dist/builtin-plugin/HttpExternalsRspackPlugin.js +0 -11
  91. package/dist/builtin-plugin/IgnorePlugin.js +0 -20
  92. package/dist/builtin-plugin/InferAsyncModulesPlugin.js +0 -6
  93. package/dist/builtin-plugin/JavascriptModulesPlugin.js +0 -55
  94. package/dist/builtin-plugin/JsLoaderRspackPlugin.js +0 -9
  95. package/dist/builtin-plugin/JsonModulesPlugin.js +0 -6
  96. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +0 -30
  97. package/dist/builtin-plugin/LimitChunkCountPlugin.js +0 -8
  98. package/dist/builtin-plugin/MangleExportsPlugin.js +0 -6
  99. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.js +0 -6
  100. package/dist/builtin-plugin/ModuleChunkFormatPlugin.js +0 -6
  101. package/dist/builtin-plugin/ModuleConcatenationPlugin.js +0 -6
  102. package/dist/builtin-plugin/NamedChunkIdsPlugin.js +0 -6
  103. package/dist/builtin-plugin/NamedModuleIdsPlugin.js +0 -6
  104. package/dist/builtin-plugin/NaturalChunkIdsPlugin.js +0 -6
  105. package/dist/builtin-plugin/NaturalModuleIdsPlugin.js +0 -6
  106. package/dist/builtin-plugin/NoEmitOnErrorsPlugin.js +0 -6
  107. package/dist/builtin-plugin/NodeTargetPlugin.js +0 -6
  108. package/dist/builtin-plugin/ProgressPlugin.js +0 -15
  109. package/dist/builtin-plugin/ProvidePlugin.js +0 -14
  110. package/dist/builtin-plugin/RealContentHashPlugin.js +0 -6
  111. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.js +0 -6
  112. package/dist/builtin-plugin/RuntimeChunkPlugin.js +0 -6
  113. package/dist/builtin-plugin/RuntimePlugin.js +0 -6
  114. package/dist/builtin-plugin/SideEffectsFlagPlugin.js +0 -6
  115. package/dist/builtin-plugin/SizeLimitsPlugin.js +0 -9
  116. package/dist/builtin-plugin/SourceMapDevToolPlugin.js +0 -14
  117. package/dist/builtin-plugin/SplitChunksPlugin.js +0 -92
  118. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +0 -80
  119. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.js +0 -6
  120. package/dist/builtin-plugin/WebWorkerTemplatePlugin.js +0 -6
  121. package/dist/builtin-plugin/WorkerPlugin.js +0 -31
  122. package/dist/builtin-plugin/base.js +0 -58
  123. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +0 -182
  124. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +0 -2
  125. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +0 -31
  126. package/dist/builtin-plugin/css-extract/index.js +0 -105
  127. package/dist/builtin-plugin/css-extract/loader.js +0 -204
  128. package/dist/builtin-plugin/css-extract/utils.js +0 -51
  129. package/dist/builtin-plugin/index.js +0 -84
  130. package/dist/builtin-plugin/lazy-compilation/backend.js +0 -139
  131. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.js +0 -6
  132. package/dist/builtin-plugin/lazy-compilation/plugin.js +0 -60
  133. package/dist/config/adapter.js +0 -691
  134. package/dist/config/adapterRuleUse.js +0 -107
  135. package/dist/config/browserslistTargetHandler.js +0 -345
  136. package/dist/config/defaults.js +0 -876
  137. package/dist/config/index.js +0 -20
  138. package/dist/config/normalization.js +0 -299
  139. package/dist/config/target.js +0 -318
  140. package/dist/config/types.js +0 -3
  141. package/dist/config/zod.js +0 -1030
  142. package/dist/container/ContainerPlugin.js +0 -50
  143. package/dist/container/ContainerReferencePlugin.js +0 -49
  144. package/dist/container/ModuleFederationPlugin.js +0 -137
  145. package/dist/container/ModuleFederationPluginV1.js +0 -63
  146. package/dist/container/ModuleFederationRuntimePlugin.js +0 -6
  147. package/dist/container/options.js +0 -48
  148. package/dist/error/ConcurrentCompilationError.js +0 -20
  149. package/dist/exports.js +0 -183
  150. package/dist/lib/AbstractMethodError.js +0 -51
  151. package/dist/lib/Cache.js +0 -111
  152. package/dist/lib/CacheFacade.js +0 -321
  153. package/dist/lib/Dependency.js +0 -11
  154. package/dist/lib/EntryOptionPlugin.js +0 -89
  155. package/dist/lib/EnvironmentPlugin.js +0 -57
  156. package/dist/lib/HookWebpackError.js +0 -83
  157. package/dist/lib/IgnoreWarningsPlugin.js +0 -35
  158. package/dist/lib/LoaderOptionsPlugin.js +0 -74
  159. package/dist/lib/LoaderTargetPlugin.js +0 -37
  160. package/dist/lib/ModuleFilenameHelpers.js +0 -83
  161. package/dist/lib/NormalModuleReplacementPlugin.js +0 -85
  162. package/dist/lib/WebpackError.js +0 -20
  163. package/dist/lib/cache/MemoryCachePlugin.js +0 -40
  164. package/dist/lib/cache/getLazyHashedEtag.js +0 -73
  165. package/dist/lib/cache/mergeEtags.js +0 -74
  166. package/dist/lib/formatLocation.js +0 -64
  167. package/dist/loader-runner/LoaderLoadingError.js +0 -19
  168. package/dist/loader-runner/index.js +0 -735
  169. package/dist/loader-runner/loadLoader.js +0 -64
  170. package/dist/logging/Logger.js +0 -143
  171. package/dist/logging/createConsoleLogger.js +0 -176
  172. package/dist/logging/runtime.js +0 -37
  173. package/dist/logging/truncateArgs.js +0 -81
  174. package/dist/node/NodeEnvironmentPlugin.js +0 -50
  175. package/dist/node/NodeTemplatePlugin.js +0 -26
  176. package/dist/node/NodeWatchFileSystem.js +0 -144
  177. package/dist/node/nodeConsole.js +0 -146
  178. package/dist/rspack.js +0 -123
  179. package/dist/rspackOptionsApply.js +0 -274
  180. package/dist/sharing/ConsumeSharedPlugin.js +0 -69
  181. package/dist/sharing/ProvideSharedPlugin.js +0 -50
  182. package/dist/sharing/SharePlugin.js +0 -66
  183. package/dist/sharing/ShareRuntimePlugin.js +0 -26
  184. package/dist/sharing/utils.js +0 -8
  185. package/dist/stats/DefaultStatsFactoryPlugin.js +0 -1173
  186. package/dist/stats/DefaultStatsPresetPlugin.js +0 -305
  187. package/dist/stats/DefaultStatsPrinterPlugin.js +0 -1069
  188. package/dist/stats/StatsFactory.js +0 -167
  189. package/dist/stats/StatsPrinter.js +0 -142
  190. package/dist/stats/statsFactoryUtils.js +0 -341
  191. package/dist/util/ArrayQueue.js +0 -108
  192. package/dist/util/AssetInfo.js +0 -39
  193. package/dist/util/IterableHelpers.js +0 -35
  194. package/dist/util/MergeCaller.js +0 -24
  195. package/dist/util/SizeFormatHelpers.js +0 -24
  196. package/dist/util/SplitChunkSize.js +0 -18
  197. package/dist/util/assertNotNil.js +0 -9
  198. package/dist/util/assetCondition.js +0 -2
  199. package/dist/util/bindingVersionCheck.js +0 -124
  200. package/dist/util/cleverMerge.js +0 -504
  201. package/dist/util/comparators.js +0 -108
  202. package/dist/util/createHash.js +0 -161
  203. package/dist/util/createReadonlyMap.js +0 -29
  204. package/dist/util/fake.js +0 -28
  205. package/dist/util/fs.js +0 -120
  206. package/dist/util/hash/BatchedHash.js +0 -69
  207. package/dist/util/hash/index.js +0 -39
  208. package/dist/util/hash/md4.js +0 -27
  209. package/dist/util/hash/wasm-hash.js +0 -167
  210. package/dist/util/hash/xxhash64.js +0 -27
  211. package/dist/util/identifier.js +0 -330
  212. package/dist/util/index.js +0 -123
  213. package/dist/util/memoize.js +0 -61
  214. package/dist/util/scheme.js +0 -57
  215. package/dist/util/smartGrouping.js +0 -148
  216. package/dist/util/source.js +0 -42
  217. package/dist/util/validate.js +0 -77
  218. package/dist/util/webpack.js +0 -27
  219. /package/dist/{container/default.runtime.js → moduleFederationDefaultRuntime.js} +0 -0
@@ -1,440 +0,0 @@
1
- "use strict";
2
- /**
3
- * The following code is modified based on
4
- * https://github.com/webpack/webpack/blob/4b4ca3b/lib/MultiCompiler.js
5
- *
6
- * MIT Licensed
7
- * Author Tobias Koppers @sokra
8
- * Copyright (c) JS Foundation and other contributors
9
- * https://github.com/webpack/webpack/blob/main/LICENSE
10
- */
11
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
- if (k2 === undefined) k2 = k;
13
- var desc = Object.getOwnPropertyDescriptor(m, k);
14
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
- desc = { enumerable: true, get: function() { return m[k]; } };
16
- }
17
- Object.defineProperty(o, k2, desc);
18
- }) : (function(o, m, k, k2) {
19
- if (k2 === undefined) k2 = k;
20
- o[k2] = m[k];
21
- }));
22
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
- Object.defineProperty(o, "default", { enumerable: true, value: v });
24
- }) : function(o, v) {
25
- o["default"] = v;
26
- });
27
- var __importStar = (this && this.__importStar) || function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
35
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
36
- 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");
37
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
38
- };
39
- var __importDefault = (this && this.__importDefault) || function (mod) {
40
- return (mod && mod.__esModule) ? mod : { "default": mod };
41
- };
42
- var _MultiCompiler_instances, _MultiCompiler_runGraph;
43
- Object.defineProperty(exports, "__esModule", { value: true });
44
- exports.MultiCompiler = void 0;
45
- const liteTapable = __importStar(require("@rspack/lite-tapable"));
46
- const neo_async_1 = __importDefault(require("../compiled/neo-async"));
47
- const MultiStats_1 = __importDefault(require("./MultiStats"));
48
- const MultiWatching_1 = __importDefault(require("./MultiWatching"));
49
- const ConcurrentCompilationError_1 = __importDefault(require("./error/ConcurrentCompilationError"));
50
- const ArrayQueue_1 = __importDefault(require("./util/ArrayQueue"));
51
- class MultiCompiler {
52
- constructor(compilers, options) {
53
- _MultiCompiler_instances.add(this);
54
- let normalizedCompilers;
55
- if (!Array.isArray(compilers)) {
56
- normalizedCompilers = Object.entries(compilers).map(([name, compiler]) => {
57
- compiler.name = name;
58
- return compiler;
59
- });
60
- }
61
- else {
62
- normalizedCompilers = compilers;
63
- }
64
- this.hooks = {
65
- done: new liteTapable.SyncHook(["stats"]),
66
- invalid: new liteTapable.MultiHook(normalizedCompilers.map(c => c.hooks.invalid)),
67
- run: new liteTapable.MultiHook(normalizedCompilers.map(c => c.hooks.run)),
68
- watchClose: new liteTapable.SyncHook([]),
69
- watchRun: new liteTapable.MultiHook(normalizedCompilers.map(c => c.hooks.watchRun)),
70
- infrastructureLog: new liteTapable.MultiHook(normalizedCompilers.map(c => c.hooks.infrastructureLog))
71
- };
72
- this.compilers = normalizedCompilers;
73
- this._options = {
74
- parallelism: options?.parallelism || Number.POSITIVE_INFINITY
75
- };
76
- this.dependencies = new WeakMap();
77
- this.running = false;
78
- const compilerStats = this.compilers.map(() => null);
79
- let doneCompilers = 0;
80
- for (let index = 0; index < this.compilers.length; index++) {
81
- const compiler = this.compilers[index];
82
- const compilerIndex = index;
83
- let compilerDone = false;
84
- compiler.hooks.done.tap("MultiCompiler", stats => {
85
- if (!compilerDone) {
86
- compilerDone = true;
87
- doneCompilers++;
88
- }
89
- compilerStats[compilerIndex] = stats;
90
- if (doneCompilers === this.compilers.length) {
91
- this.hooks.done.call(new MultiStats_1.default(compilerStats));
92
- }
93
- });
94
- compiler.hooks.invalid.tap("MultiCompiler", () => {
95
- if (compilerDone) {
96
- compilerDone = false;
97
- doneCompilers--;
98
- }
99
- });
100
- }
101
- }
102
- get options() {
103
- return Object.assign(this.compilers.map(c => c.options), this._options);
104
- }
105
- get outputPath() {
106
- let commonPath = this.compilers[0].outputPath;
107
- for (const compiler of this.compilers) {
108
- while (compiler.outputPath.indexOf(commonPath) !== 0 &&
109
- /[/\\]/.test(commonPath)) {
110
- commonPath = commonPath.replace(/[/\\][^/\\]*$/, "");
111
- }
112
- }
113
- if (!commonPath && this.compilers[0].outputPath[0] === "/")
114
- return "/";
115
- return commonPath;
116
- }
117
- get inputFileSystem() {
118
- throw new Error("Cannot read inputFileSystem of a MultiCompiler");
119
- }
120
- get outputFileSystem() {
121
- throw new Error("Cannot read outputFileSystem of a MultiCompiler");
122
- }
123
- get watchFileSystem() {
124
- throw new Error("Cannot read watchFileSystem of a MultiCompiler");
125
- }
126
- get intermediateFileSystem() {
127
- throw new Error("Cannot read outputFileSystem of a MultiCompiler");
128
- }
129
- set inputFileSystem(value) {
130
- for (const compiler of this.compilers) {
131
- compiler.inputFileSystem = value;
132
- }
133
- }
134
- set outputFileSystem(value) {
135
- for (const compiler of this.compilers) {
136
- compiler.outputFileSystem = value;
137
- }
138
- }
139
- set watchFileSystem(value) {
140
- for (const compiler of this.compilers) {
141
- compiler.watchFileSystem = value;
142
- }
143
- }
144
- set intermediateFileSystem(value) {
145
- for (const compiler of this.compilers) {
146
- compiler.intermediateFileSystem = value;
147
- }
148
- }
149
- getInfrastructureLogger(name) {
150
- return this.compilers[0].getInfrastructureLogger(name);
151
- }
152
- /**
153
- * @param compiler - the child compiler
154
- * @param dependencies - its dependencies
155
- */
156
- setDependencies(compiler, dependencies) {
157
- this.dependencies.set(compiler, dependencies);
158
- }
159
- /**
160
- * @param callback - signals when the validation is complete
161
- * @returns true if the dependencies are valid
162
- */
163
- validateDependencies(callback) {
164
- const edges = new Set();
165
- const missing = [];
166
- const targetFound = (compiler) => {
167
- for (const edge of edges) {
168
- if (edge.target === compiler) {
169
- return true;
170
- }
171
- }
172
- return false;
173
- };
174
- const sortEdges = (e1, e2) => {
175
- return (e1.source.name.localeCompare(e2.source.name) ||
176
- e1.target.name.localeCompare(e2.target.name));
177
- };
178
- for (const source of this.compilers) {
179
- const dependencies = this.dependencies.get(source);
180
- if (dependencies) {
181
- for (const dep of dependencies) {
182
- const target = this.compilers.find(c => c.name === dep);
183
- if (!target) {
184
- missing.push(dep);
185
- }
186
- else {
187
- edges.add({
188
- source,
189
- target
190
- });
191
- }
192
- }
193
- }
194
- }
195
- const errors = missing.map(m => `Compiler dependency \`${m}\` not found.`);
196
- const stack = this.compilers.filter(c => !targetFound(c));
197
- while (stack.length > 0) {
198
- const current = stack.pop();
199
- for (const edge of edges) {
200
- if (edge.source === current) {
201
- edges.delete(edge);
202
- const target = edge.target;
203
- if (!targetFound(target)) {
204
- stack.push(target);
205
- }
206
- }
207
- }
208
- }
209
- if (edges.size > 0) {
210
- const lines = Array.from(edges)
211
- .sort(sortEdges)
212
- .map(edge => `${edge.source.name} -> ${edge.target.name}`);
213
- lines.unshift("Circular dependency found in compiler dependencies.");
214
- errors.unshift(lines.join("\n"));
215
- }
216
- if (errors.length > 0) {
217
- const message = errors.join("\n");
218
- callback(new Error(message));
219
- return false;
220
- }
221
- return true;
222
- }
223
- /**
224
- * @param watchOptions - the watcher's options
225
- * @param handler - signals when the call finishes
226
- * @returns a compiler watcher
227
- */
228
- watch(watchOptions, handler) {
229
- if (this.running) {
230
- return handler(new ConcurrentCompilationError_1.default());
231
- }
232
- this.running = true;
233
- if (this.validateDependencies(handler)) {
234
- const watchings = __classPrivateFieldGet(this, _MultiCompiler_instances, "m", _MultiCompiler_runGraph).call(this, (compiler, idx, done, isBlocked, setChanged, setInvalid) => {
235
- const watching = compiler.watch(Array.isArray(watchOptions) ? watchOptions[idx] : watchOptions, done);
236
- if (watching) {
237
- watching.onInvalid = setInvalid;
238
- watching.onChange = setChanged;
239
- watching.isBlocked = isBlocked;
240
- }
241
- return watching;
242
- }, (compiler, watching, _done) => {
243
- if (compiler.watching !== watching)
244
- return;
245
- if (!watching.running)
246
- watching.invalidate();
247
- }, handler);
248
- return new MultiWatching_1.default(watchings, this);
249
- }
250
- return new MultiWatching_1.default([], this);
251
- }
252
- run(callback) {
253
- if (this.running) {
254
- return callback(new ConcurrentCompilationError_1.default());
255
- }
256
- this.running = true;
257
- if (this.validateDependencies(callback)) {
258
- __classPrivateFieldGet(this, _MultiCompiler_instances, "m", _MultiCompiler_runGraph).call(this, () => { }, (compiler, _, callback) => compiler.run(callback), (err, stats) => {
259
- this.running = false;
260
- if (callback !== undefined) {
261
- return callback(err, stats);
262
- }
263
- });
264
- }
265
- }
266
- purgeInputFileSystem() {
267
- for (const compiler of this.compilers) {
268
- compiler.inputFileSystem?.purge?.();
269
- }
270
- }
271
- close(callback) {
272
- neo_async_1.default.each(this.compilers, (compiler, cb) => {
273
- compiler.close(cb);
274
- },
275
- // cannot be resolved without assertion
276
- // Type 'Error | null | undefined' is not assignable to type 'Error | null'
277
- callback);
278
- }
279
- }
280
- exports.MultiCompiler = MultiCompiler;
281
- _MultiCompiler_instances = new WeakSet(), _MultiCompiler_runGraph = function _MultiCompiler_runGraph(setup, run, callback) {
282
- // State transitions for nodes:
283
- // -> blocked (initial)
284
- // blocked -> starting [running++] (when all parents done)
285
- // queued -> starting [running++] (when processing the queue)
286
- // starting -> running (when run has been called)
287
- // running -> done [running--] (when compilation is done)
288
- // done -> pending (when invalidated from file change)
289
- // pending -> blocked [add to queue] (when invalidated from aggregated changes)
290
- // done -> blocked [add to queue] (when invalidated, from parent invalidation)
291
- // running -> running-outdated (when invalidated, either from change or parent invalidation)
292
- // running-outdated -> blocked [running--] (when compilation is done)
293
- const nodes = this.compilers.map(compiler => ({
294
- compiler,
295
- setupResult: undefined,
296
- result: undefined,
297
- state: "blocked",
298
- children: [],
299
- parents: []
300
- }));
301
- // only useful for MultiCompiler options.name and options.dependencies
302
- const compilerToNode = new Map();
303
- for (const node of nodes)
304
- compilerToNode.set(node.compiler.name, node);
305
- for (const node of nodes) {
306
- const dependencies = this.dependencies.get(node.compiler);
307
- if (!dependencies)
308
- continue;
309
- for (const dep of dependencies) {
310
- const parent = compilerToNode.get(dep);
311
- node.parents.push(parent);
312
- parent.children.push(node);
313
- }
314
- }
315
- const queue = new ArrayQueue_1.default();
316
- for (const node of nodes) {
317
- if (node.parents.length === 0) {
318
- node.state = "queued";
319
- queue.enqueue(node);
320
- }
321
- }
322
- let errored = false;
323
- let running = 0;
324
- const parallelism = this._options.parallelism;
325
- const nodeDone = (node, err, stats) => {
326
- if (errored)
327
- return;
328
- if (err) {
329
- errored = true;
330
- return neo_async_1.default.each(nodes, (node, callback) => {
331
- if (node.compiler.watching) {
332
- node.compiler.watching.close(callback);
333
- }
334
- else {
335
- callback();
336
- }
337
- }, () => callback(err));
338
- }
339
- node.result = stats;
340
- running--;
341
- if (node.state === "running") {
342
- node.state = "done";
343
- for (const child of node.children) {
344
- if (child.state === "blocked")
345
- queue.enqueue(child);
346
- }
347
- }
348
- else if (node.state === "running-outdated") {
349
- node.state = "blocked";
350
- queue.enqueue(node);
351
- }
352
- processQueue();
353
- };
354
- /**
355
- * @param {Node} node node
356
- * @returns {void}
357
- */
358
- const nodeInvalidFromParent = (node) => {
359
- if (node.state === "done") {
360
- node.state = "blocked";
361
- }
362
- else if (node.state === "running") {
363
- node.state = "running-outdated";
364
- }
365
- for (const child of node.children) {
366
- nodeInvalidFromParent(child);
367
- }
368
- };
369
- /**
370
- * @param {Node} node node
371
- * @returns {void}
372
- */
373
- const nodeInvalid = (node) => {
374
- if (node.state === "done") {
375
- node.state = "pending";
376
- }
377
- else if (node.state === "running") {
378
- node.state = "running-outdated";
379
- }
380
- for (const child of node.children) {
381
- nodeInvalidFromParent(child);
382
- }
383
- };
384
- /**
385
- * @param {Node} node node
386
- * @returns {void}
387
- */
388
- const nodeChange = (node) => {
389
- nodeInvalid(node);
390
- if (node.state === "pending") {
391
- node.state = "blocked";
392
- }
393
- if (node.state === "blocked") {
394
- queue.enqueue(node);
395
- processQueue();
396
- }
397
- };
398
- const setupResults = [];
399
- nodes.forEach((node, i) => {
400
- setupResults.push((node.setupResult = setup(node.compiler, i, nodeDone.bind(null, node), () => node.state !== "starting" && node.state !== "running", () => nodeChange(node), () => nodeInvalid(node))));
401
- });
402
- let processing = true;
403
- const processQueue = () => {
404
- if (processing)
405
- return;
406
- processing = true;
407
- process.nextTick(processQueueWorker);
408
- };
409
- const processQueueWorker = () => {
410
- while (running < parallelism && queue.length > 0 && !errored) {
411
- const node = queue.dequeue();
412
- if (node.state === "queued" ||
413
- (node.state === "blocked" &&
414
- node.parents.every(p => p.state === "done"))) {
415
- running++;
416
- node.state = "starting";
417
- run(node.compiler, node.setupResult, nodeDone.bind(null, node));
418
- node.state = "running";
419
- }
420
- }
421
- processing = false;
422
- if (!errored &&
423
- running === 0 &&
424
- nodes.every(node => node.state === "done")) {
425
- const stats = [];
426
- for (const node of nodes) {
427
- const result = node.result;
428
- if (result) {
429
- node.result = undefined;
430
- stats.push(result);
431
- }
432
- }
433
- if (stats.length > 0) {
434
- callback(null, new MultiStats_1.default(stats));
435
- }
436
- }
437
- };
438
- processQueueWorker();
439
- return setupResults;
440
- };
@@ -1,161 +0,0 @@
1
- "use strict";
2
- /**
3
- * The following code is modified based on
4
- * https://github.com/webpack/webpack/blob/4b4ca3b/lib/MultiStats.js
5
- *
6
- * MIT Licensed
7
- * Author Tobias Koppers @sokra
8
- * Copyright (c) JS Foundation and other contributors
9
- * https://github.com/webpack/webpack/blob/main/LICENSE
10
- */
11
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
- if (k2 === undefined) k2 = k;
13
- var desc = Object.getOwnPropertyDescriptor(m, k);
14
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
- desc = { enumerable: true, get: function() { return m[k]; } };
16
- }
17
- Object.defineProperty(o, k2, desc);
18
- }) : (function(o, m, k, k2) {
19
- if (k2 === undefined) k2 = k;
20
- o[k2] = m[k];
21
- }));
22
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
- Object.defineProperty(o, "default", { enumerable: true, value: v });
24
- }) : function(o, v) {
25
- o["default"] = v;
26
- });
27
- var __importStar = (this && this.__importStar) || function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
35
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
36
- 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");
37
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
38
- };
39
- var _MultiStats_instances, _MultiStats_createChildOptions;
40
- Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.MultiStats = void 0;
42
- const util_1 = require("./util");
43
- const identifierUtils = __importStar(require("./util/identifier"));
44
- class MultiStats {
45
- constructor(stats) {
46
- _MultiStats_instances.add(this);
47
- this.stats = stats;
48
- }
49
- get hash() {
50
- return this.stats.map(stat => stat.hash).join("");
51
- }
52
- hasErrors() {
53
- return this.stats.some(stat => stat.hasErrors());
54
- }
55
- hasWarnings() {
56
- return this.stats.some(stat => stat.hasWarnings());
57
- }
58
- toJson(options) {
59
- const childOptions = __classPrivateFieldGet(this, _MultiStats_instances, "m", _MultiStats_createChildOptions).call(this, options || {}, {
60
- forToString: false
61
- });
62
- const obj = {};
63
- obj.children = this.stats.map((stat, idx) => {
64
- const obj = stat.toJson(childOptions.children[idx]);
65
- const compilationName = stat.compilation.name;
66
- const name = compilationName &&
67
- identifierUtils.makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root);
68
- obj.name = name;
69
- return obj;
70
- });
71
- if (childOptions.version) {
72
- obj.rspackVersion = require("../package.json").version;
73
- obj.version = require("../package.json").webpackVersion;
74
- }
75
- if (childOptions.hash) {
76
- obj.hash = obj.children.map(j => j.hash).join("");
77
- }
78
- const mapError = (j, obj) => {
79
- return {
80
- ...obj,
81
- compilerPath: obj.compilerPath
82
- ? `${j.name}.${obj.compilerPath}`
83
- : j.name
84
- };
85
- };
86
- if (childOptions.errors) {
87
- obj.errors = [];
88
- for (const j of obj.children) {
89
- for (const i of j.errors || []) {
90
- obj.errors.push(mapError(j, i));
91
- }
92
- }
93
- }
94
- if (childOptions.warnings) {
95
- obj.warnings = [];
96
- for (const j of obj.children) {
97
- for (const i of j.warnings || []) {
98
- obj.warnings.push(mapError(j, i));
99
- }
100
- }
101
- }
102
- if (childOptions.errorsCount) {
103
- obj.errorsCount = 0;
104
- for (const j of obj.children) {
105
- obj.errorsCount += j.errorsCount || 0;
106
- }
107
- }
108
- if (childOptions.warningsCount) {
109
- obj.warningsCount = 0;
110
- for (const j of obj.children) {
111
- obj.warningsCount += j.warningsCount || 0;
112
- }
113
- }
114
- return obj;
115
- }
116
- toString(options) {
117
- const childOptions = __classPrivateFieldGet(this, _MultiStats_instances, "m", _MultiStats_createChildOptions).call(this, options || {}, {
118
- forToString: true
119
- });
120
- const results = this.stats.map((stat, idx) => {
121
- const str = stat.toString(childOptions.children[idx]);
122
- const compilationName = stat.compilation.name;
123
- const name = compilationName &&
124
- identifierUtils
125
- .makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root)
126
- .replace(/\|/g, " ");
127
- if (!str)
128
- return str;
129
- return name ? `${name}:\n${(0, util_1.indent)(str, " ")}` : str;
130
- });
131
- return results.filter(Boolean).join("\n\n");
132
- }
133
- }
134
- exports.default = MultiStats;
135
- exports.MultiStats = MultiStats;
136
- _MultiStats_instances = new WeakSet(), _MultiStats_createChildOptions = function _MultiStats_createChildOptions(options, context) {
137
- const { children: childrenOptions = undefined, ...baseOptions } = typeof options === "string" ? { preset: options } : options;
138
- const children = this.stats.map((stat, idx) => {
139
- const childOptions = Array.isArray(childrenOptions)
140
- ? childrenOptions[idx]
141
- : childrenOptions;
142
- return stat.compilation.createStatsOptions({
143
- ...baseOptions,
144
- ...(typeof childOptions === "string"
145
- ? { preset: childOptions }
146
- : childOptions && typeof childOptions === "object"
147
- ? childOptions
148
- : undefined)
149
- }, context);
150
- });
151
- return {
152
- hash: children.every(o => o.hash),
153
- errorsCount: children.every(o => o.errorsCount),
154
- warningsCount: children.every(o => o.warningsCount),
155
- errors: children.every(o => o.errors),
156
- warnings: children.every(o => o.warnings),
157
- children,
158
- context: "",
159
- version: ""
160
- };
161
- };
@@ -1,62 +0,0 @@
1
- "use strict";
2
- /**
3
- * The following code is modified based on
4
- * https://github.com/webpack/webpack/blob/4b4ca3b/lib/MultiWatching.js
5
- *
6
- * MIT Licensed
7
- * Author Tobias Koppers @sokra
8
- * Copyright (c) JS Foundation and other contributors
9
- * https://github.com/webpack/webpack/blob/main/LICENSE
10
- */
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const neo_async_1 = __importDefault(require("../compiled/neo-async"));
16
- class MultiWatching {
17
- /**
18
- * @param watchings - child compilers' watchers
19
- * @param compiler - the compiler
20
- */
21
- constructor(watchings, compiler) {
22
- this.watchings = watchings;
23
- this.compiler = compiler;
24
- }
25
- invalidate(callback) {
26
- if (callback) {
27
- neo_async_1.default.each(this.watchings, (watching, callback) => watching.invalidate(callback),
28
- // cannot be resolved without assertion
29
- // Type 'Error | null | undefined' is not assignable to type 'Error | null'
30
- callback);
31
- }
32
- else {
33
- for (const watching of this.watchings) {
34
- watching.invalidate();
35
- }
36
- }
37
- }
38
- close(callback) {
39
- neo_async_1.default.forEach(this.watchings, (watching, finishedCallback) => {
40
- watching.close(finishedCallback);
41
- }, err => {
42
- this.compiler.hooks.watchClose.call();
43
- if (typeof callback === "function") {
44
- this.compiler.running = false;
45
- // cannot be resolved without assertion
46
- // Type 'Error | null | undefined' is not assignable to type 'Error | null'
47
- callback(err);
48
- }
49
- });
50
- }
51
- suspend() {
52
- for (const watching of this.watchings) {
53
- watching.suspend();
54
- }
55
- }
56
- resume() {
57
- for (const watching of this.watchings) {
58
- watching.resume();
59
- }
60
- }
61
- }
62
- exports.default = MultiWatching;