@rspack/core 1.0.4 → 1.0.6
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.
- package/dist/Chunk.d.ts +5 -0
- package/dist/Chunk.js +28 -0
- package/dist/Compilation.d.ts +15 -7
- package/dist/Compilation.js +25 -8
- package/dist/Compiler.js +16 -30
- package/dist/Module.d.ts +20 -8
- package/dist/Module.js +66 -7
- package/dist/MultiCompiler.js +6 -26
- package/dist/MultiWatching.d.ts +3 -6
- package/dist/MultiWatching.js +6 -7
- package/dist/Resolver.d.ts +2 -4
- package/dist/RspackError.d.ts +2 -2
- package/dist/RspackError.js +3 -3
- package/dist/RuntimeModule.d.ts +32 -0
- package/dist/RuntimeModule.js +58 -0
- package/dist/Watching.d.ts +5 -5
- package/dist/Watching.js +3 -11
- package/dist/builtin-plugin/ContextReplacementPlugin.d.ts +10 -0
- package/dist/builtin-plugin/ContextReplacementPlugin.js +43 -0
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +1 -5
- package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ProgressPlugin.js +10 -8
- package/dist/builtin-plugin/css-extract/index.d.ts +1 -1
- package/dist/builtin-plugin/css-extract/index.js +2 -3
- package/dist/builtin-plugin/css-extract/loader.js +4 -8
- package/dist/builtin-plugin/index.d.ts +1 -0
- package/dist/builtin-plugin/index.js +1 -0
- package/dist/config/adapter.js +10 -14
- package/dist/config/adapterRuleUse.d.ts +47 -3
- package/dist/config/defaults.js +2 -7
- package/dist/config/zod.d.ts +16 -16
- package/dist/exports.d.ts +2 -0
- package/dist/exports.js +6 -2
- package/dist/loader-runner/index.js +34 -32
- package/dist/node/NodeEnvironmentPlugin.js +1 -1
- package/dist/node/NodeWatchFileSystem.d.ts +1 -1
- package/dist/node/NodeWatchFileSystem.js +1 -4
- package/dist/node/nodeConsole.js +2 -1
- package/dist/stats/DefaultStatsFactoryPlugin.js +18 -29
- package/dist/stats/DefaultStatsPrinterPlugin.js +3 -5
- package/dist/stats/StatsFactory.d.ts +1 -1
- package/dist/stats/StatsFactory.js +1 -4
- package/dist/stats/statsFactoryUtils.d.ts +7 -3
- package/dist/stats/statsFactoryUtils.js +5 -6
- package/dist/util/comparators.d.ts +2 -2
- package/dist/util/comparators.js +0 -1
- package/dist/util/index.js +12 -1
- package/dist/util/smartGrouping.d.ts +4 -4
- package/dist/util/source.d.ts +1 -12
- package/dist/util/source.js +19 -43
- package/package.json +2 -2
package/dist/Chunk.d.ts
CHANGED
|
@@ -23,6 +23,11 @@ export declare class Chunk {
|
|
|
23
23
|
canBeInitial(): boolean;
|
|
24
24
|
hasRuntime(): boolean;
|
|
25
25
|
get groupsIterable(): Iterable<ChunkGroup>;
|
|
26
|
+
getChunkMaps(realHash: boolean): {
|
|
27
|
+
hash: Record<string | number, string>;
|
|
28
|
+
contentHash: Record<string | number, Record<string, string>>;
|
|
29
|
+
name: Record<string | number, string>;
|
|
30
|
+
};
|
|
26
31
|
getAllAsyncChunks(): Iterable<Chunk>;
|
|
27
32
|
getAllInitialChunks(): Iterable<Chunk>;
|
|
28
33
|
getAllReferencedChunks(): Iterable<Chunk>;
|
package/dist/Chunk.js
CHANGED
|
@@ -60,6 +60,34 @@ class Chunk {
|
|
|
60
60
|
chunk_groups.sort(comparators_1.compareChunkGroupsByIndex);
|
|
61
61
|
return new Set(chunk_groups);
|
|
62
62
|
}
|
|
63
|
+
getChunkMaps(realHash) {
|
|
64
|
+
const chunkHashMap = {};
|
|
65
|
+
const chunkContentHashMap = {};
|
|
66
|
+
const chunkNameMap = {};
|
|
67
|
+
for (const chunk of this.getAllAsyncChunks()) {
|
|
68
|
+
const id = chunk.id;
|
|
69
|
+
if (!id)
|
|
70
|
+
continue;
|
|
71
|
+
const chunkHash = realHash ? chunk.hash : chunk.renderedHash;
|
|
72
|
+
if (chunkHash) {
|
|
73
|
+
chunkHashMap[id] = chunkHash;
|
|
74
|
+
}
|
|
75
|
+
for (const key of Object.keys(chunk.contentHash)) {
|
|
76
|
+
if (!chunkContentHashMap[key]) {
|
|
77
|
+
chunkContentHashMap[key] = {};
|
|
78
|
+
}
|
|
79
|
+
chunkContentHashMap[key][id] = chunk.contentHash[key];
|
|
80
|
+
}
|
|
81
|
+
if (chunk.name) {
|
|
82
|
+
chunkNameMap[id] = chunk.name;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
hash: chunkHashMap,
|
|
87
|
+
contentHash: chunkContentHashMap,
|
|
88
|
+
name: chunkNameMap
|
|
89
|
+
};
|
|
90
|
+
}
|
|
63
91
|
getAllAsyncChunks() {
|
|
64
92
|
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
93
|
}
|
package/dist/Compilation.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { type CodeGenerationResult, Module } from "./Module";
|
|
|
21
21
|
import type { NormalModuleFactory } from "./NormalModuleFactory";
|
|
22
22
|
import type { ResolverFactory } from "./ResolverFactory";
|
|
23
23
|
import { type RspackError } from "./RspackError";
|
|
24
|
+
import { RuntimeModule } from "./RuntimeModule";
|
|
24
25
|
import { Stats, type StatsAsset, type StatsError, type StatsModule } from "./Stats";
|
|
25
26
|
import type { Filename, OutputNormalized, RspackOptionsNormalized, RspackPluginInstance, StatsOptions, StatsValue } from "./config";
|
|
26
27
|
import { Logger } from "./logging/Logger";
|
|
@@ -43,10 +44,6 @@ export interface LogEntry {
|
|
|
43
44
|
time?: number;
|
|
44
45
|
trace?: string[];
|
|
45
46
|
}
|
|
46
|
-
export type RuntimeModule = liteTapable.SyncHook<[
|
|
47
|
-
JsRuntimeModule,
|
|
48
|
-
Chunk
|
|
49
|
-
], void>;
|
|
50
47
|
export interface CompilationParams {
|
|
51
48
|
normalModuleFactory: NormalModuleFactory;
|
|
52
49
|
contextModuleFactory: ContextModuleFactory;
|
|
@@ -167,7 +164,11 @@ export declare class Compilation {
|
|
|
167
164
|
Chunk,
|
|
168
165
|
Set<string>
|
|
169
166
|
], void>;
|
|
170
|
-
|
|
167
|
+
runtimeRequirementInTree: liteTapable.SyncBailHook<[
|
|
168
|
+
Chunk,
|
|
169
|
+
Set<string>
|
|
170
|
+
], void>;
|
|
171
|
+
runtimeModule: liteTapable.SyncHook<[JsRuntimeModule, Chunk], void>;
|
|
171
172
|
seal: liteTapable.SyncHook<[], void>;
|
|
172
173
|
afterSeal: liteTapable.AsyncSeriesHook<[], void>;
|
|
173
174
|
}>;
|
|
@@ -256,13 +257,19 @@ export declare class Compilation {
|
|
|
256
257
|
*
|
|
257
258
|
* @internal
|
|
258
259
|
*/
|
|
259
|
-
|
|
260
|
+
__internal__pushRspackDiagnostic(diagnostic: binding.JsRspackDiagnostic): void;
|
|
261
|
+
/**
|
|
262
|
+
* Note: This is not a webpack public API, maybe removed in future.
|
|
263
|
+
*
|
|
264
|
+
* @internal
|
|
265
|
+
*/
|
|
266
|
+
__internal__pushDiagnostic(diagnostic: ExternalObject<"Diagnostic">): void;
|
|
260
267
|
/**
|
|
261
268
|
* Note: This is not a webpack public API, maybe removed in future.
|
|
262
269
|
*
|
|
263
270
|
* @internal
|
|
264
271
|
*/
|
|
265
|
-
|
|
272
|
+
__internal__pushDiagnostics(diagnostics: ExternalObject<"Diagnostic[]">): void;
|
|
266
273
|
get errors(): RspackError[];
|
|
267
274
|
get warnings(): RspackError[];
|
|
268
275
|
getPath(filename: Filename, data?: PathData): string;
|
|
@@ -297,6 +304,7 @@ export declare class Compilation {
|
|
|
297
304
|
getStats(): Stats;
|
|
298
305
|
createChildCompiler(name: string, outputOptions: OutputNormalized, plugins: RspackPluginInstance[]): Compiler;
|
|
299
306
|
rebuildModule(m: Module, f: (err: Error, m: Module) => void): void;
|
|
307
|
+
addRuntimeModule(chunk: Chunk, runtimeModule: RuntimeModule): void;
|
|
300
308
|
/**
|
|
301
309
|
* Get the `Source` of a given asset filename.
|
|
302
310
|
*
|
package/dist/Compilation.js
CHANGED
|
@@ -48,6 +48,7 @@ const Entrypoint_1 = require("./Entrypoint");
|
|
|
48
48
|
const ErrorHelpers_1 = require("./ErrorHelpers");
|
|
49
49
|
const Module_1 = require("./Module");
|
|
50
50
|
const RspackError_1 = require("./RspackError");
|
|
51
|
+
const RuntimeModule_1 = require("./RuntimeModule");
|
|
51
52
|
const Stats_1 = require("./Stats");
|
|
52
53
|
const Logger_1 = require("./logging/Logger");
|
|
53
54
|
const StatsFactory_1 = require("./stats/StatsFactory");
|
|
@@ -159,6 +160,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
159
160
|
"chunk",
|
|
160
161
|
"runtimeRequirements"
|
|
161
162
|
]),
|
|
163
|
+
runtimeRequirementInTree: new liteTapable.SyncBailHook([
|
|
164
|
+
"chunk",
|
|
165
|
+
"runtimeRequirements"
|
|
166
|
+
]),
|
|
162
167
|
runtimeModule: new liteTapable.SyncHook(["module", "chunk"]),
|
|
163
168
|
seal: new liteTapable.SyncHook([]),
|
|
164
169
|
afterSeal: new liteTapable.AsyncSeriesHook([])
|
|
@@ -374,7 +379,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
374
379
|
*
|
|
375
380
|
* @internal
|
|
376
381
|
*/
|
|
377
|
-
|
|
382
|
+
__internal__pushRspackDiagnostic(diagnostic) {
|
|
378
383
|
__classPrivateFieldGet(this, _Compilation_inner, "f").pushDiagnostic(diagnostic);
|
|
379
384
|
}
|
|
380
385
|
/**
|
|
@@ -382,7 +387,15 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
382
387
|
*
|
|
383
388
|
* @internal
|
|
384
389
|
*/
|
|
385
|
-
|
|
390
|
+
__internal__pushDiagnostic(diagnostic) {
|
|
391
|
+
__classPrivateFieldGet(this, _Compilation_inner, "f").pushNativeDiagnostic(diagnostic);
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Note: This is not a webpack public API, maybe removed in future.
|
|
395
|
+
*
|
|
396
|
+
* @internal
|
|
397
|
+
*/
|
|
398
|
+
__internal__pushDiagnostics(diagnostics) {
|
|
386
399
|
__classPrivateFieldGet(this, _Compilation_inner, "f").pushNativeDiagnostics(diagnostics);
|
|
387
400
|
}
|
|
388
401
|
get errors() {
|
|
@@ -394,7 +407,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
394
407
|
handler(target, thisArg, errs) {
|
|
395
408
|
for (let i = 0; i < errs.length; i++) {
|
|
396
409
|
const error = errs[i];
|
|
397
|
-
inner.pushDiagnostic(RspackError_1.
|
|
410
|
+
inner.pushDiagnostic(RspackError_1.JsRspackDiagnostic.__to_binding(error, binding_1.JsRspackSeverity.Error));
|
|
398
411
|
}
|
|
399
412
|
return Reflect.apply(target, thisArg, errs);
|
|
400
413
|
}
|
|
@@ -417,7 +430,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
417
430
|
method: "unshift",
|
|
418
431
|
handler(target, thisArg, errs) {
|
|
419
432
|
const errList = errs.map(error => {
|
|
420
|
-
return RspackError_1.
|
|
433
|
+
return RspackError_1.JsRspackDiagnostic.__to_binding(error, binding_1.JsRspackSeverity.Error);
|
|
421
434
|
});
|
|
422
435
|
inner.spliceDiagnostic(0, 0, errList);
|
|
423
436
|
return Reflect.apply(target, thisArg, errs);
|
|
@@ -427,7 +440,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
427
440
|
method: "splice",
|
|
428
441
|
handler(target, thisArg, [startIdx, delCount, ...errors]) {
|
|
429
442
|
const errList = errors.map(error => {
|
|
430
|
-
return RspackError_1.
|
|
443
|
+
return RspackError_1.JsRspackDiagnostic.__to_binding(error, binding_1.JsRspackSeverity.Error);
|
|
431
444
|
});
|
|
432
445
|
inner.spliceDiagnostic(startIdx, startIdx + delCount, errList);
|
|
433
446
|
return Reflect.apply(target, thisArg, [
|
|
@@ -455,7 +468,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
455
468
|
method: "push",
|
|
456
469
|
handler(target, thisArg, warns) {
|
|
457
470
|
return Reflect.apply(target, thisArg, processWarningsHook.call(warns).map(warn => {
|
|
458
|
-
inner.pushDiagnostic(RspackError_1.
|
|
471
|
+
inner.pushDiagnostic(RspackError_1.JsRspackDiagnostic.__to_binding(warn, binding_1.JsRspackSeverity.Warn));
|
|
459
472
|
return warn;
|
|
460
473
|
}));
|
|
461
474
|
}
|
|
@@ -479,7 +492,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
479
492
|
handler(target, thisArg, warns) {
|
|
480
493
|
const warnings = processWarningsHook.call(warns);
|
|
481
494
|
inner.spliceDiagnostic(0, 0, warnings.map(warn => {
|
|
482
|
-
return RspackError_1.
|
|
495
|
+
return RspackError_1.JsRspackDiagnostic.__to_binding(warn, binding_1.JsRspackSeverity.Warn);
|
|
483
496
|
}));
|
|
484
497
|
return Reflect.apply(target, thisArg, warnings);
|
|
485
498
|
}
|
|
@@ -489,7 +502,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
489
502
|
handler(target, thisArg, [startIdx, delCount, ...warns]) {
|
|
490
503
|
warns = processWarningsHook.call(warns);
|
|
491
504
|
const warnList = warns.map(warn => {
|
|
492
|
-
return RspackError_1.
|
|
505
|
+
return RspackError_1.JsRspackDiagnostic.__to_binding(warn, binding_1.JsRspackSeverity.Warn);
|
|
493
506
|
});
|
|
494
507
|
inner.spliceDiagnostic(startIdx, startIdx + delCount, warnList);
|
|
495
508
|
return Reflect.apply(target, thisArg, [
|
|
@@ -624,6 +637,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
624
637
|
rebuildModule(m, f) {
|
|
625
638
|
__classPrivateFieldGet(this, _Compilation_rebuildModuleCaller, "f").push([m.identifier(), f]);
|
|
626
639
|
}
|
|
640
|
+
addRuntimeModule(chunk, runtimeModule) {
|
|
641
|
+
runtimeModule.attach(this, chunk, this.chunkGraph);
|
|
642
|
+
__classPrivateFieldGet(this, _Compilation_inner, "f").addRuntimeModule(chunk.__internal__innerUkey(), RuntimeModule_1.RuntimeModule.__to_binding(this, runtimeModule));
|
|
643
|
+
}
|
|
627
644
|
/**
|
|
628
645
|
* Get the `Source` of a given asset filename.
|
|
629
646
|
*
|
package/dist/Compiler.js
CHANGED
|
@@ -220,8 +220,7 @@ class Compiler {
|
|
|
220
220
|
let normalizedChildName = childName;
|
|
221
221
|
if (typeof normalizedName === "function") {
|
|
222
222
|
if (typeof normalizedChildName === "function") {
|
|
223
|
-
|
|
224
|
-
return this.getInfrastructureLogger(_ => {
|
|
223
|
+
return this.getInfrastructureLogger(() => {
|
|
225
224
|
if (typeof normalizedName === "function") {
|
|
226
225
|
normalizedName = normalizedName();
|
|
227
226
|
if (!normalizedName) {
|
|
@@ -268,12 +267,13 @@ class Compiler {
|
|
|
268
267
|
*/
|
|
269
268
|
watch(watchOptions, handler) {
|
|
270
269
|
if (this.running) {
|
|
271
|
-
//
|
|
270
|
+
// cannot be resolved without assertion
|
|
271
|
+
// copy from webpack
|
|
272
|
+
// Type 'void' is not assignable to type 'Watching'.
|
|
272
273
|
return handler(new ConcurrentCompilationError_1.default());
|
|
273
274
|
}
|
|
274
275
|
this.running = true;
|
|
275
276
|
this.watchMode = true;
|
|
276
|
-
// @ts-expect-error
|
|
277
277
|
this.watching = new Watching_1.Watching(this, watchOptions, handler);
|
|
278
278
|
return this.watching;
|
|
279
279
|
}
|
|
@@ -287,7 +287,6 @@ class Compiler {
|
|
|
287
287
|
const startTime = Date.now();
|
|
288
288
|
this.running = true;
|
|
289
289
|
const doRun = () => {
|
|
290
|
-
// @ts-expect-error
|
|
291
290
|
const finalCallback = (err, stats) => {
|
|
292
291
|
this.idle = true;
|
|
293
292
|
this.cache.beginIdle();
|
|
@@ -426,11 +425,10 @@ class Compiler {
|
|
|
426
425
|
...__classPrivateFieldGet(childCompiler, _Compiler_builtinPlugins, "f"),
|
|
427
426
|
...__classPrivateFieldGet(this, _Compiler_builtinPlugins, "f").filter(plugin => plugin.canInherentFromParent === true)
|
|
428
427
|
], "f");
|
|
429
|
-
for (const
|
|
428
|
+
for (const hookName in this.hooks) {
|
|
429
|
+
const name = hookName;
|
|
430
430
|
if ((0, base_1.canInherentFromParent)(name)) {
|
|
431
|
-
//@ts-ignore
|
|
432
431
|
if (childCompiler.hooks[name]) {
|
|
433
|
-
//@ts-ignore
|
|
434
432
|
childCompiler.hooks[name].taps = this.hooks[name].taps.slice();
|
|
435
433
|
}
|
|
436
434
|
}
|
|
@@ -596,6 +594,13 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
596
594
|
runtimeRequirements: (0, RuntimeGlobals_1.__to_binding_runtime_globals)(set)
|
|
597
595
|
};
|
|
598
596
|
}),
|
|
597
|
+
registerCompilationRuntimeRequirementInTree: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationRuntimeRequirementInTree, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.runtimeRequirementInTree, queried => ({ chunk, runtimeRequirements }) => {
|
|
598
|
+
const set = (0, RuntimeGlobals_1.__from_binding_runtime_globals)(runtimeRequirements);
|
|
599
|
+
queried.call(Chunk_1.Chunk.__from_binding(chunk, __classPrivateFieldGet(this, _Compiler_compilation, "f")), set);
|
|
600
|
+
return {
|
|
601
|
+
runtimeRequirements: (0, RuntimeGlobals_1.__to_binding_runtime_globals)(set)
|
|
602
|
+
};
|
|
603
|
+
}),
|
|
599
604
|
registerCompilationRuntimeModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationRuntimeModule, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.runtimeModule, queried => ({ module, chunk }) => {
|
|
600
605
|
const originSource = module.source?.source;
|
|
601
606
|
queried.call(module, Chunk_1.Chunk.__from_binding(chunk, __classPrivateFieldGet(this, _Compiler_compilation, "f")));
|
|
@@ -750,30 +755,11 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
750
755
|
}),
|
|
751
756
|
registerContextModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryAfterResolve, () => __classPrivateFieldGet(this, _Compiler_compilationParams, "f").contextModuleFactory.hooks.afterResolve, queried => async (bindingData) => {
|
|
752
757
|
const data = bindingData
|
|
753
|
-
? (
|
|
754
|
-
resource: bindingData.resource,
|
|
755
|
-
regExp: bindingData.regExp
|
|
756
|
-
? new RegExp(bindingData.regExp.source, bindingData.regExp.flags)
|
|
757
|
-
: undefined,
|
|
758
|
-
request: bindingData.request,
|
|
759
|
-
context: bindingData.context,
|
|
760
|
-
// TODO: Dependencies are not fully supported yet; this is a placeholder to prevent errors in moment-locales-webpack-plugin.
|
|
761
|
-
dependencies: []
|
|
762
|
-
})
|
|
758
|
+
? Module_1.ContextModuleFactoryAfterResolveData.__from_binding(bindingData)
|
|
763
759
|
: false;
|
|
764
760
|
const ret = await queried.promise(data);
|
|
765
761
|
const result = ret
|
|
766
|
-
? (
|
|
767
|
-
resource: ret.resource,
|
|
768
|
-
context: ret.context,
|
|
769
|
-
request: ret.request,
|
|
770
|
-
regExp: ret.regExp
|
|
771
|
-
? {
|
|
772
|
-
source: ret.regExp.source,
|
|
773
|
-
flags: ret.regExp.flags
|
|
774
|
-
}
|
|
775
|
-
: undefined
|
|
776
|
-
})
|
|
762
|
+
? Module_1.ContextModuleFactoryAfterResolveData.__to_binding(ret)
|
|
777
763
|
: false;
|
|
778
764
|
return result;
|
|
779
765
|
}),
|
|
@@ -849,7 +835,7 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
849
835
|
}
|
|
850
836
|
}
|
|
851
837
|
if (__classPrivateFieldGet(this, _Compiler_nonSkippableRegisters, "f").join() !== kinds.join()) {
|
|
852
|
-
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (
|
|
838
|
+
__classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_getInstance).call(this, (_error, instance) => {
|
|
853
839
|
instance.setNonSkippableRegisters(kinds);
|
|
854
840
|
__classPrivateFieldSet(this, _Compiler_nonSkippableRegisters, kinds, "f");
|
|
855
841
|
});
|
package/dist/Module.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { JsCodegenerationResult, JsCreateData, JsFactoryMeta, JsModule, ModuleDTO } from "@rspack/binding";
|
|
1
|
+
import type { JsCodegenerationResult, JsContextModuleFactoryAfterResolveData, JsCreateData, JsFactoryMeta, JsModule, ModuleDTO } from "@rspack/binding";
|
|
2
2
|
import type { Source } from "../compiled/webpack-sources";
|
|
3
3
|
import type { Compilation } from "./Compilation";
|
|
4
4
|
import { DependenciesBlock } from "./DependenciesBlock";
|
|
5
|
+
import type { Dependency } from "./Dependency";
|
|
5
6
|
export type ResourceData = {
|
|
6
7
|
resource: string;
|
|
7
8
|
path: string;
|
|
@@ -28,13 +29,24 @@ export type ContextModuleFactoryBeforeResolveResult = false | {
|
|
|
28
29
|
context: string;
|
|
29
30
|
request?: string;
|
|
30
31
|
};
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
export declare class ContextModuleFactoryAfterResolveData {
|
|
33
|
+
#private;
|
|
34
|
+
static __from_binding(binding: JsContextModuleFactoryAfterResolveData): ContextModuleFactoryAfterResolveData;
|
|
35
|
+
static __to_binding(data: ContextModuleFactoryAfterResolveData): JsContextModuleFactoryAfterResolveData;
|
|
36
|
+
constructor(data: JsContextModuleFactoryAfterResolveData);
|
|
37
|
+
get resource(): string;
|
|
38
|
+
set resource(val: string);
|
|
39
|
+
get context(): string;
|
|
40
|
+
set context(val: string);
|
|
41
|
+
get request(): string;
|
|
42
|
+
set request(val: string);
|
|
43
|
+
get regExp(): RegExp | undefined;
|
|
44
|
+
set regExp(val: RegExp | undefined);
|
|
45
|
+
get recursive(): boolean;
|
|
46
|
+
set recursive(val: boolean);
|
|
47
|
+
get dependencies(): Dependency[];
|
|
48
|
+
}
|
|
49
|
+
export type ContextModuleFactoryAfterResolveResult = false | ContextModuleFactoryAfterResolveData;
|
|
38
50
|
export declare class Module {
|
|
39
51
|
#private;
|
|
40
52
|
context?: Readonly<string>;
|
package/dist/Module.js
CHANGED
|
@@ -1,20 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
|
+
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");
|
|
5
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
|
+
};
|
|
2
7
|
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
8
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
9
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
11
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
12
|
};
|
|
8
|
-
var
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
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
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _Module_inner, _Module_originalSource, _CodeGenerationResult_inner;
|
|
13
|
+
var _ContextModuleFactoryAfterResolveData_inner, _Module_inner, _Module_originalSource, _CodeGenerationResult_inner;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.CodeGenerationResults = exports.CodeGenerationResult = exports.Module = void 0;
|
|
15
|
+
exports.CodeGenerationResults = exports.CodeGenerationResult = exports.Module = exports.ContextModuleFactoryAfterResolveData = void 0;
|
|
16
16
|
const DependenciesBlock_1 = require("./DependenciesBlock");
|
|
17
17
|
const source_1 = require("./util/source");
|
|
18
|
+
class ContextModuleFactoryAfterResolveData {
|
|
19
|
+
static __from_binding(binding) {
|
|
20
|
+
return new ContextModuleFactoryAfterResolveData(binding);
|
|
21
|
+
}
|
|
22
|
+
static __to_binding(data) {
|
|
23
|
+
return __classPrivateFieldGet(data, _ContextModuleFactoryAfterResolveData_inner, "f");
|
|
24
|
+
}
|
|
25
|
+
constructor(data) {
|
|
26
|
+
_ContextModuleFactoryAfterResolveData_inner.set(this, void 0);
|
|
27
|
+
__classPrivateFieldSet(this, _ContextModuleFactoryAfterResolveData_inner, data, "f");
|
|
28
|
+
}
|
|
29
|
+
get resource() {
|
|
30
|
+
return __classPrivateFieldGet(this, _ContextModuleFactoryAfterResolveData_inner, "f").resource;
|
|
31
|
+
}
|
|
32
|
+
set resource(val) {
|
|
33
|
+
__classPrivateFieldGet(this, _ContextModuleFactoryAfterResolveData_inner, "f").resource = val;
|
|
34
|
+
}
|
|
35
|
+
get context() {
|
|
36
|
+
return __classPrivateFieldGet(this, _ContextModuleFactoryAfterResolveData_inner, "f").context;
|
|
37
|
+
}
|
|
38
|
+
set context(val) {
|
|
39
|
+
__classPrivateFieldGet(this, _ContextModuleFactoryAfterResolveData_inner, "f").context = val;
|
|
40
|
+
}
|
|
41
|
+
get request() {
|
|
42
|
+
return __classPrivateFieldGet(this, _ContextModuleFactoryAfterResolveData_inner, "f").request;
|
|
43
|
+
}
|
|
44
|
+
set request(val) {
|
|
45
|
+
__classPrivateFieldGet(this, _ContextModuleFactoryAfterResolveData_inner, "f").request = val;
|
|
46
|
+
}
|
|
47
|
+
get regExp() {
|
|
48
|
+
if (!__classPrivateFieldGet(this, _ContextModuleFactoryAfterResolveData_inner, "f").regExp) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
const { source, flags } = __classPrivateFieldGet(this, _ContextModuleFactoryAfterResolveData_inner, "f").regExp;
|
|
52
|
+
return new RegExp(source, flags);
|
|
53
|
+
}
|
|
54
|
+
set regExp(val) {
|
|
55
|
+
if (!val) {
|
|
56
|
+
__classPrivateFieldGet(this, _ContextModuleFactoryAfterResolveData_inner, "f").regExp = undefined;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
__classPrivateFieldGet(this, _ContextModuleFactoryAfterResolveData_inner, "f").regExp = {
|
|
60
|
+
source: val.source,
|
|
61
|
+
flags: val.flags
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
get recursive() {
|
|
65
|
+
return __classPrivateFieldGet(this, _ContextModuleFactoryAfterResolveData_inner, "f").recursive;
|
|
66
|
+
}
|
|
67
|
+
set recursive(val) {
|
|
68
|
+
__classPrivateFieldGet(this, _ContextModuleFactoryAfterResolveData_inner, "f").recursive = val;
|
|
69
|
+
}
|
|
70
|
+
get dependencies() {
|
|
71
|
+
// TODO: Dependencies are not fully supported yet; this is a placeholder to prevent errors in moment-locales-webpack-plugin.
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.ContextModuleFactoryAfterResolveData = ContextModuleFactoryAfterResolveData;
|
|
76
|
+
_ContextModuleFactoryAfterResolveData_inner = new WeakMap();
|
|
18
77
|
class Module {
|
|
19
78
|
static __from_binding(module, compilation) {
|
|
20
79
|
return new Module(module, compilation);
|
package/dist/MultiCompiler.js
CHANGED
|
@@ -171,7 +171,6 @@ class MultiCompiler {
|
|
|
171
171
|
}
|
|
172
172
|
return false;
|
|
173
173
|
};
|
|
174
|
-
// @ts-expect-error
|
|
175
174
|
const sortEdges = (e1, e2) => {
|
|
176
175
|
return (e1.source.name.localeCompare(e2.source.name) ||
|
|
177
176
|
e1.target.name.localeCompare(e2.target.name));
|
|
@@ -193,7 +192,6 @@ class MultiCompiler {
|
|
|
193
192
|
}
|
|
194
193
|
}
|
|
195
194
|
}
|
|
196
|
-
/** @type {string[]} */
|
|
197
195
|
const errors = missing.map(m => `Compiler dependency \`${m}\` not found.`);
|
|
198
196
|
const stack = this.compilers.filter(c => !targetFound(c));
|
|
199
197
|
while (stack.length > 0) {
|
|
@@ -209,7 +207,6 @@ class MultiCompiler {
|
|
|
209
207
|
}
|
|
210
208
|
}
|
|
211
209
|
if (edges.size > 0) {
|
|
212
|
-
/** @type {string[]} */
|
|
213
210
|
const lines = Array.from(edges)
|
|
214
211
|
.sort(sortEdges)
|
|
215
212
|
.map(edge => `${edge.source.name} -> ${edge.target.name}`);
|
|
@@ -234,14 +231,8 @@ class MultiCompiler {
|
|
|
234
231
|
}
|
|
235
232
|
this.running = true;
|
|
236
233
|
if (this.validateDependencies(handler)) {
|
|
237
|
-
const watchings = __classPrivateFieldGet(this, _MultiCompiler_instances, "m", _MultiCompiler_runGraph).call(this,
|
|
238
|
-
|
|
239
|
-
(compiler, idx, done, isBlocked, setChanged, setInvalid) => {
|
|
240
|
-
const watching = compiler.watch(
|
|
241
|
-
// @ts-expect-error
|
|
242
|
-
Array.isArray(watchOptions) ? watchOptions[idx] : watchOptions,
|
|
243
|
-
// @ts-expect-error
|
|
244
|
-
done);
|
|
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);
|
|
245
236
|
if (watching) {
|
|
246
237
|
watching.onInvalid = setInvalid;
|
|
247
238
|
watching.onChange = setChanged;
|
|
@@ -254,7 +245,6 @@ class MultiCompiler {
|
|
|
254
245
|
if (!watching.running)
|
|
255
246
|
watching.invalidate();
|
|
256
247
|
}, handler);
|
|
257
|
-
// @ts-expect-error
|
|
258
248
|
return new MultiWatching_1.default(watchings, this);
|
|
259
249
|
}
|
|
260
250
|
return new MultiWatching_1.default([], this);
|
|
@@ -282,13 +272,13 @@ class MultiCompiler {
|
|
|
282
272
|
neo_async_1.default.each(this.compilers, (compiler, cb) => {
|
|
283
273
|
compiler.close(cb);
|
|
284
274
|
},
|
|
285
|
-
//
|
|
275
|
+
// cannot be resolved without assertion
|
|
276
|
+
// Type 'Error | null | undefined' is not assignable to type 'Error | null'
|
|
286
277
|
callback);
|
|
287
278
|
}
|
|
288
279
|
}
|
|
289
280
|
exports.MultiCompiler = MultiCompiler;
|
|
290
281
|
_MultiCompiler_instances = new WeakSet(), _MultiCompiler_runGraph = function _MultiCompiler_runGraph(setup, run, callback) {
|
|
291
|
-
/** @typedef {{ compiler: Compiler, setupResult: SetupResult, result: Stats, state: "pending" | "blocked" | "queued" | "starting" | "running" | "running-outdated" | "done", children: Node[], parents: Node[] }} Node */
|
|
292
282
|
// State transitions for nodes:
|
|
293
283
|
// -> blocked (initial)
|
|
294
284
|
// blocked -> starting [running++] (when all parents done)
|
|
@@ -332,12 +322,6 @@ _MultiCompiler_instances = new WeakSet(), _MultiCompiler_runGraph = function _Mu
|
|
|
332
322
|
let errored = false;
|
|
333
323
|
let running = 0;
|
|
334
324
|
const parallelism = this._options.parallelism;
|
|
335
|
-
/**
|
|
336
|
-
* @param {Node} node node
|
|
337
|
-
* @param {Error=} err error
|
|
338
|
-
* @param {Stats=} stats result
|
|
339
|
-
* @returns {void}
|
|
340
|
-
*/
|
|
341
325
|
const nodeDone = (node, err, stats) => {
|
|
342
326
|
if (errored)
|
|
343
327
|
return;
|
|
@@ -401,8 +385,7 @@ _MultiCompiler_instances = new WeakSet(), _MultiCompiler_runGraph = function _Mu
|
|
|
401
385
|
* @param {Node} node node
|
|
402
386
|
* @returns {void}
|
|
403
387
|
*/
|
|
404
|
-
|
|
405
|
-
const nodeChange = node => {
|
|
388
|
+
const nodeChange = (node) => {
|
|
406
389
|
nodeInvalid(node);
|
|
407
390
|
if (node.state === "pending") {
|
|
408
391
|
node.state = "blocked";
|
|
@@ -414,9 +397,7 @@ _MultiCompiler_instances = new WeakSet(), _MultiCompiler_runGraph = function _Mu
|
|
|
414
397
|
};
|
|
415
398
|
const setupResults = [];
|
|
416
399
|
nodes.forEach((node, i) => {
|
|
417
|
-
setupResults.push((node.setupResult = setup(node.compiler, i,
|
|
418
|
-
// @ts-expect-error
|
|
419
|
-
nodeDone.bind(null, node), () => node.state !== "starting" && node.state !== "running", () => nodeChange(node), () => nodeInvalid(node))));
|
|
400
|
+
setupResults.push((node.setupResult = setup(node.compiler, i, nodeDone.bind(null, node), () => node.state !== "starting" && node.state !== "running", () => nodeChange(node), () => nodeInvalid(node))));
|
|
420
401
|
});
|
|
421
402
|
let processing = true;
|
|
422
403
|
const processQueue = () => {
|
|
@@ -433,7 +414,6 @@ _MultiCompiler_instances = new WeakSet(), _MultiCompiler_runGraph = function _Mu
|
|
|
433
414
|
node.parents.every(p => p.state === "done"))) {
|
|
434
415
|
running++;
|
|
435
416
|
node.state = "starting";
|
|
436
|
-
// @ts-expect-error
|
|
437
417
|
run(node.compiler, node.setupResult, nodeDone.bind(null, node));
|
|
438
418
|
node.state = "running";
|
|
439
419
|
}
|
package/dist/MultiWatching.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* Copyright (c) JS Foundation and other contributors
|
|
8
8
|
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
9
|
*/
|
|
10
|
+
import type { Callback } from "@rspack/lite-tapable";
|
|
10
11
|
import type { MultiCompiler } from "./MultiCompiler";
|
|
11
12
|
import type { Watching } from "./Watching";
|
|
12
13
|
declare class MultiWatching {
|
|
@@ -17,12 +18,8 @@ declare class MultiWatching {
|
|
|
17
18
|
* @param compiler - the compiler
|
|
18
19
|
*/
|
|
19
20
|
constructor(watchings: Watching[], compiler: MultiCompiler);
|
|
20
|
-
invalidate(callback:
|
|
21
|
-
|
|
22
|
-
* @param {Callback<void>} callback signals when the watcher is closed
|
|
23
|
-
* @returns {void}
|
|
24
|
-
*/
|
|
25
|
-
close(callback: any): void;
|
|
21
|
+
invalidate(callback: Callback<Error, void>): void;
|
|
22
|
+
close(callback: Callback<Error, void>): void;
|
|
26
23
|
suspend(): void;
|
|
27
24
|
resume(): void;
|
|
28
25
|
}
|
package/dist/MultiWatching.js
CHANGED
|
@@ -22,10 +22,12 @@ class MultiWatching {
|
|
|
22
22
|
this.watchings = watchings;
|
|
23
23
|
this.compiler = compiler;
|
|
24
24
|
}
|
|
25
|
-
// @ts-expect-error
|
|
26
25
|
invalidate(callback) {
|
|
27
26
|
if (callback) {
|
|
28
|
-
neo_async_1.default.each(this.watchings, (watching, callback) => watching.invalidate(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);
|
|
29
31
|
}
|
|
30
32
|
else {
|
|
31
33
|
for (const watching of this.watchings) {
|
|
@@ -33,11 +35,6 @@ class MultiWatching {
|
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
|
-
/**
|
|
37
|
-
* @param {Callback<void>} callback signals when the watcher is closed
|
|
38
|
-
* @returns {void}
|
|
39
|
-
*/
|
|
40
|
-
// @ts-expect-error
|
|
41
38
|
close(callback) {
|
|
42
39
|
neo_async_1.default.forEach(this.watchings, (watching, finishedCallback) => {
|
|
43
40
|
watching.close(finishedCallback);
|
|
@@ -45,6 +42,8 @@ class MultiWatching {
|
|
|
45
42
|
this.compiler.hooks.watchClose.call();
|
|
46
43
|
if (typeof callback === "function") {
|
|
47
44
|
this.compiler.running = false;
|
|
45
|
+
// cannot be resolved without assertion
|
|
46
|
+
// Type 'Error | null | undefined' is not assignable to type 'Error | null'
|
|
48
47
|
callback(err);
|
|
49
48
|
}
|
|
50
49
|
});
|
package/dist/Resolver.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type * as binding from "@rspack/binding";
|
|
2
2
|
import { type Resolve } from "./config";
|
|
3
|
+
import type { ResolveCallback } from "./config/adapterRuleUse";
|
|
3
4
|
type ResolveContext = {};
|
|
4
|
-
type ErrorWithDetail = Error & {
|
|
5
|
-
details?: string;
|
|
6
|
-
};
|
|
7
5
|
type ResolveOptionsWithDependencyType = Resolve & {
|
|
8
6
|
dependencyCategory?: string;
|
|
9
7
|
resolveToContext?: boolean;
|
|
@@ -12,7 +10,7 @@ export declare class Resolver {
|
|
|
12
10
|
binding: binding.JsResolver;
|
|
13
11
|
constructor(binding: binding.JsResolver);
|
|
14
12
|
resolveSync(context: object, path: string, request: string): string | false;
|
|
15
|
-
resolve(context: object, path: string, request: string, resolveContext: ResolveContext, callback:
|
|
13
|
+
resolve(context: object, path: string, request: string, resolveContext: ResolveContext, callback: ResolveCallback): void;
|
|
16
14
|
withOptions({ dependencyCategory, resolveToContext, ...resolve }: ResolveOptionsWithDependencyType): Resolver;
|
|
17
15
|
}
|
|
18
16
|
export {};
|
package/dist/RspackError.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as binding from "@rspack/binding";
|
|
2
2
|
export type RspackError = binding.JsRspackError;
|
|
3
|
-
export declare class
|
|
4
|
-
static __to_binding(error: Error | RspackError, severity: binding.JsRspackSeverity): binding.
|
|
3
|
+
export declare class JsRspackDiagnostic {
|
|
4
|
+
static __to_binding(error: Error | RspackError, severity: binding.JsRspackSeverity): binding.JsRspackDiagnostic;
|
|
5
5
|
}
|
|
6
6
|
export declare class NonErrorEmittedError extends Error {
|
|
7
7
|
constructor(error: Error);
|