@rspack/core 1.0.10 → 1.0.11

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 (217) hide show
  1. package/dist/builtin-plugin/css-extract/utils.d.ts +1 -0
  2. package/dist/config/types.d.ts +309 -0
  3. package/dist/config/zod.d.ts +22 -534
  4. package/dist/cssExtractHmr.js +224 -0
  5. package/dist/cssExtractLoader.js +277 -0
  6. package/dist/index.js +23347 -31
  7. package/dist/{builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts → runtime/cssExtractHmr.d.ts} +1 -0
  8. package/dist/runtime/moduleFederationDefaultRuntime.d.ts +2 -0
  9. package/dist/stats/statsFactoryUtils.d.ts +1 -0
  10. package/package.json +8 -5
  11. package/compiled/json-parse-even-better-errors/index.d.ts +0 -1
  12. package/compiled/json-parse-even-better-errors/index.js +0 -193
  13. package/compiled/json-parse-even-better-errors/package.json +0 -1
  14. package/compiled/neo-async/index.d.ts +0 -685
  15. package/compiled/neo-async/index.js +0 -9207
  16. package/compiled/neo-async/license +0 -22
  17. package/compiled/neo-async/package.json +0 -1
  18. package/compiled/zod-validation-error/index.d.ts +0 -41
  19. package/compiled/zod-validation-error/index.js +0 -335
  20. package/compiled/zod-validation-error/license +0 -9
  21. package/compiled/zod-validation-error/package.json +0 -1
  22. package/dist/Chunk.js +0 -118
  23. package/dist/ChunkGraph.js +0 -27
  24. package/dist/ChunkGroup.js +0 -76
  25. package/dist/Compilation.js +0 -854
  26. package/dist/Compiler.js +0 -925
  27. package/dist/ContextModuleFactory.js +0 -36
  28. package/dist/DependenciesBlock.js +0 -30
  29. package/dist/Dependency.js +0 -43
  30. package/dist/Entrypoint.js +0 -21
  31. package/dist/ErrorHelpers.js +0 -62
  32. package/dist/ExecuteModulePlugin.js +0 -46
  33. package/dist/FileSystem.js +0 -34
  34. package/dist/FileSystemInfo.js +0 -2
  35. package/dist/Module.js +0 -226
  36. package/dist/ModuleTypeConstants.js +0 -92
  37. package/dist/MultiCompiler.js +0 -440
  38. package/dist/MultiStats.js +0 -161
  39. package/dist/MultiWatching.js +0 -62
  40. package/dist/NormalModule.js +0 -97
  41. package/dist/NormalModuleFactory.js +0 -43
  42. package/dist/Resolver.js +0 -39
  43. package/dist/ResolverFactory.js +0 -61
  44. package/dist/RspackError.js +0 -21
  45. package/dist/RuleSetCompiler.js +0 -10
  46. package/dist/RuntimeGlobals.js +0 -357
  47. package/dist/RuntimeModule.js +0 -58
  48. package/dist/Stats.js +0 -161
  49. package/dist/Template.js +0 -206
  50. package/dist/Watching.js +0 -290
  51. package/dist/builtin-loader/index.js +0 -17
  52. package/dist/builtin-loader/lightningcss/index.js +0 -175
  53. package/dist/builtin-loader/swc/index.js +0 -5
  54. package/dist/builtin-loader/swc/pluginImport.js +0 -35
  55. package/dist/builtin-loader/swc/react.js +0 -7
  56. package/dist/builtin-loader/swc/types.js +0 -2
  57. package/dist/builtin-plugin/APIPlugin.js +0 -6
  58. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.js +0 -6
  59. package/dist/builtin-plugin/AssetModulesPlugin.js +0 -6
  60. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.js +0 -6
  61. package/dist/builtin-plugin/BannerPlugin.js +0 -22
  62. package/dist/builtin-plugin/BundlerInfoRspackPlugin.js +0 -12
  63. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.js +0 -6
  64. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.js +0 -6
  65. package/dist/builtin-plugin/ContextReplacementPlugin.js +0 -43
  66. package/dist/builtin-plugin/CopyRspackPlugin.js +0 -21
  67. package/dist/builtin-plugin/CssModulesPlugin.js +0 -6
  68. package/dist/builtin-plugin/DataUriPlugin.js +0 -6
  69. package/dist/builtin-plugin/DefinePlugin.js +0 -44
  70. package/dist/builtin-plugin/DeterministicChunkIdsPlugin.js +0 -6
  71. package/dist/builtin-plugin/DeterministicModuleIdsPlugin.js +0 -6
  72. package/dist/builtin-plugin/DynamicEntryPlugin.js +0 -36
  73. package/dist/builtin-plugin/ElectronTargetPlugin.js +0 -6
  74. package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +0 -6
  75. package/dist/builtin-plugin/EnableLibraryPlugin.js +0 -39
  76. package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +0 -6
  77. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.js +0 -6
  78. package/dist/builtin-plugin/EntryPlugin.js +0 -34
  79. package/dist/builtin-plugin/EvalDevToolModulePlugin.js +0 -6
  80. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.js +0 -16
  81. package/dist/builtin-plugin/ExternalsPlugin.js +0 -51
  82. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.js +0 -6
  83. package/dist/builtin-plugin/FileUriPlugin.js +0 -6
  84. package/dist/builtin-plugin/FlagDependencyExportsPlugin.js +0 -6
  85. package/dist/builtin-plugin/FlagDependencyUsagePlugin.js +0 -6
  86. package/dist/builtin-plugin/HotModuleReplacementPlugin.js +0 -18
  87. package/dist/builtin-plugin/HtmlRspackPlugin.js +0 -285
  88. package/dist/builtin-plugin/HttpExternalsRspackPlugin.js +0 -11
  89. package/dist/builtin-plugin/IgnorePlugin.js +0 -20
  90. package/dist/builtin-plugin/InferAsyncModulesPlugin.js +0 -6
  91. package/dist/builtin-plugin/JavascriptModulesPlugin.js +0 -55
  92. package/dist/builtin-plugin/JsLoaderRspackPlugin.js +0 -9
  93. package/dist/builtin-plugin/JsonModulesPlugin.js +0 -6
  94. package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +0 -30
  95. package/dist/builtin-plugin/LimitChunkCountPlugin.js +0 -8
  96. package/dist/builtin-plugin/MangleExportsPlugin.js +0 -6
  97. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.js +0 -6
  98. package/dist/builtin-plugin/ModuleChunkFormatPlugin.js +0 -6
  99. package/dist/builtin-plugin/ModuleConcatenationPlugin.js +0 -6
  100. package/dist/builtin-plugin/NamedChunkIdsPlugin.js +0 -6
  101. package/dist/builtin-plugin/NamedModuleIdsPlugin.js +0 -6
  102. package/dist/builtin-plugin/NaturalChunkIdsPlugin.js +0 -6
  103. package/dist/builtin-plugin/NaturalModuleIdsPlugin.js +0 -6
  104. package/dist/builtin-plugin/NoEmitOnErrorsPlugin.js +0 -6
  105. package/dist/builtin-plugin/NodeTargetPlugin.js +0 -6
  106. package/dist/builtin-plugin/ProgressPlugin.js +0 -15
  107. package/dist/builtin-plugin/ProvidePlugin.js +0 -14
  108. package/dist/builtin-plugin/RealContentHashPlugin.js +0 -6
  109. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.js +0 -6
  110. package/dist/builtin-plugin/RuntimeChunkPlugin.js +0 -6
  111. package/dist/builtin-plugin/RuntimePlugin.js +0 -6
  112. package/dist/builtin-plugin/SideEffectsFlagPlugin.js +0 -6
  113. package/dist/builtin-plugin/SizeLimitsPlugin.js +0 -9
  114. package/dist/builtin-plugin/SourceMapDevToolPlugin.js +0 -14
  115. package/dist/builtin-plugin/SplitChunksPlugin.js +0 -92
  116. package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +0 -80
  117. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.js +0 -6
  118. package/dist/builtin-plugin/WebWorkerTemplatePlugin.js +0 -6
  119. package/dist/builtin-plugin/WorkerPlugin.js +0 -31
  120. package/dist/builtin-plugin/base.js +0 -58
  121. package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +0 -182
  122. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +0 -2
  123. package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +0 -31
  124. package/dist/builtin-plugin/css-extract/index.js +0 -105
  125. package/dist/builtin-plugin/css-extract/loader.js +0 -204
  126. package/dist/builtin-plugin/css-extract/utils.js +0 -51
  127. package/dist/builtin-plugin/index.js +0 -84
  128. package/dist/builtin-plugin/lazy-compilation/backend.js +0 -139
  129. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.js +0 -6
  130. package/dist/builtin-plugin/lazy-compilation/plugin.js +0 -60
  131. package/dist/config/adapter.js +0 -691
  132. package/dist/config/adapterRuleUse.js +0 -107
  133. package/dist/config/browserslistTargetHandler.js +0 -345
  134. package/dist/config/defaults.js +0 -876
  135. package/dist/config/index.js +0 -20
  136. package/dist/config/normalization.js +0 -299
  137. package/dist/config/target.js +0 -318
  138. package/dist/config/types.js +0 -3
  139. package/dist/config/zod.js +0 -1030
  140. package/dist/container/ContainerPlugin.js +0 -50
  141. package/dist/container/ContainerReferencePlugin.js +0 -49
  142. package/dist/container/ModuleFederationPlugin.js +0 -137
  143. package/dist/container/ModuleFederationPluginV1.js +0 -63
  144. package/dist/container/ModuleFederationRuntimePlugin.js +0 -6
  145. package/dist/container/options.js +0 -48
  146. package/dist/error/ConcurrentCompilationError.js +0 -20
  147. package/dist/exports.js +0 -183
  148. package/dist/lib/AbstractMethodError.js +0 -51
  149. package/dist/lib/Cache.js +0 -111
  150. package/dist/lib/CacheFacade.js +0 -321
  151. package/dist/lib/Dependency.js +0 -11
  152. package/dist/lib/EntryOptionPlugin.js +0 -89
  153. package/dist/lib/EnvironmentPlugin.js +0 -57
  154. package/dist/lib/HookWebpackError.js +0 -83
  155. package/dist/lib/IgnoreWarningsPlugin.js +0 -35
  156. package/dist/lib/LoaderOptionsPlugin.js +0 -74
  157. package/dist/lib/LoaderTargetPlugin.js +0 -37
  158. package/dist/lib/ModuleFilenameHelpers.js +0 -83
  159. package/dist/lib/NormalModuleReplacementPlugin.js +0 -85
  160. package/dist/lib/WebpackError.js +0 -20
  161. package/dist/lib/cache/MemoryCachePlugin.js +0 -40
  162. package/dist/lib/cache/getLazyHashedEtag.js +0 -73
  163. package/dist/lib/cache/mergeEtags.js +0 -74
  164. package/dist/lib/formatLocation.js +0 -64
  165. package/dist/loader-runner/LoaderLoadingError.js +0 -19
  166. package/dist/loader-runner/index.js +0 -735
  167. package/dist/loader-runner/loadLoader.js +0 -64
  168. package/dist/logging/Logger.js +0 -143
  169. package/dist/logging/createConsoleLogger.js +0 -176
  170. package/dist/logging/runtime.js +0 -37
  171. package/dist/logging/truncateArgs.js +0 -81
  172. package/dist/node/NodeEnvironmentPlugin.js +0 -50
  173. package/dist/node/NodeTemplatePlugin.js +0 -26
  174. package/dist/node/NodeWatchFileSystem.js +0 -144
  175. package/dist/node/nodeConsole.js +0 -146
  176. package/dist/rspack.js +0 -123
  177. package/dist/rspackOptionsApply.js +0 -274
  178. package/dist/sharing/ConsumeSharedPlugin.js +0 -69
  179. package/dist/sharing/ProvideSharedPlugin.js +0 -50
  180. package/dist/sharing/SharePlugin.js +0 -66
  181. package/dist/sharing/ShareRuntimePlugin.js +0 -26
  182. package/dist/sharing/utils.js +0 -8
  183. package/dist/stats/DefaultStatsFactoryPlugin.js +0 -1173
  184. package/dist/stats/DefaultStatsPresetPlugin.js +0 -305
  185. package/dist/stats/DefaultStatsPrinterPlugin.js +0 -1069
  186. package/dist/stats/StatsFactory.js +0 -167
  187. package/dist/stats/StatsPrinter.js +0 -142
  188. package/dist/stats/statsFactoryUtils.js +0 -341
  189. package/dist/util/ArrayQueue.js +0 -108
  190. package/dist/util/AssetInfo.js +0 -39
  191. package/dist/util/IterableHelpers.js +0 -35
  192. package/dist/util/MergeCaller.js +0 -24
  193. package/dist/util/SizeFormatHelpers.js +0 -24
  194. package/dist/util/SplitChunkSize.js +0 -18
  195. package/dist/util/assertNotNil.js +0 -9
  196. package/dist/util/assetCondition.js +0 -2
  197. package/dist/util/bindingVersionCheck.js +0 -124
  198. package/dist/util/cleverMerge.js +0 -504
  199. package/dist/util/comparators.js +0 -108
  200. package/dist/util/createHash.js +0 -161
  201. package/dist/util/createReadonlyMap.js +0 -29
  202. package/dist/util/fake.js +0 -28
  203. package/dist/util/fs.js +0 -120
  204. package/dist/util/hash/BatchedHash.js +0 -69
  205. package/dist/util/hash/index.js +0 -39
  206. package/dist/util/hash/md4.js +0 -27
  207. package/dist/util/hash/wasm-hash.js +0 -167
  208. package/dist/util/hash/xxhash64.js +0 -27
  209. package/dist/util/identifier.js +0 -330
  210. package/dist/util/index.js +0 -123
  211. package/dist/util/memoize.js +0 -61
  212. package/dist/util/scheme.js +0 -57
  213. package/dist/util/smartGrouping.js +0 -148
  214. package/dist/util/source.js +0 -42
  215. package/dist/util/validate.js +0 -77
  216. package/dist/util/webpack.js +0 -27
  217. /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;