@rspack/core 1.0.0-beta.2 → 1.0.0-beta.3
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/Compilation.d.ts +20 -1
- package/dist/Compilation.js +109 -44
- package/dist/Compiler.d.ts +1 -0
- package/dist/Compiler.js +29 -24
- package/dist/MultiCompiler.js +10 -6
- package/dist/MultiStats.d.ts +1 -1
- package/dist/MultiStats.js +19 -16
- package/dist/NormalModule.js +3 -4
- package/dist/Stats.d.ts +1 -1
- package/dist/Template.d.ts +4 -4
- package/dist/Template.js +6 -4
- package/dist/Watching.js +3 -5
- package/dist/builtin-plugin/DynamicEntryPlugin.d.ts +11 -10
- package/dist/builtin-plugin/DynamicEntryPlugin.js +26 -15
- package/dist/builtin-plugin/EntryPlugin.d.ts +2 -2
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.d.ts +21 -4
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +29 -5
- package/dist/builtin-plugin/SwcCssMinimizerPlugin.d.ts +4 -6
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +16 -10
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +11 -9
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +10 -6
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +1 -1
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +2 -2
- package/dist/builtin-plugin/css-extract/loader.js +1 -2
- package/dist/config/adapter.d.ts +2 -2
- package/dist/config/zod.d.ts +338 -62
- package/dist/config/zod.js +8 -5
- package/dist/exports.d.ts +4 -3
- package/dist/exports.js +5 -2
- package/dist/lib/Cache.js +6 -4
- package/dist/lib/CacheFacade.js +8 -9
- package/dist/lib/LoaderOptionsPlugin.d.ts +4 -2
- package/dist/lib/LoaderOptionsPlugin.js +0 -2
- package/dist/lib/cache/mergeEtags.d.ts +3 -3
- package/dist/lib/cache/mergeEtags.js +5 -3
- package/dist/loader-runner/index.js +4 -2
- package/dist/node/nodeConsole.js +5 -5
- package/dist/stats/DefaultStatsPresetPlugin.js +1 -3
- package/dist/stats/StatsFactory.js +3 -4
- package/dist/stats/StatsPrinter.js +3 -4
- package/dist/stats/statsFactoryUtils.d.ts +106 -19
- package/dist/util/assertNotNil.d.ts +1 -1
- package/dist/util/assetCondition.d.ts +2 -0
- package/dist/util/assetCondition.js +2 -0
- package/dist/util/cleverMerge.js +5 -4
- package/dist/util/createHash.js +10 -5
- package/dist/util/hash/wasm-hash.js +5 -4
- package/dist/util/identifier.d.ts +4 -4
- package/dist/util/identifier.js +10 -10
- package/dist/util/memoize.js +3 -2
- package/package.json +3 -3
- package/dist/builtin-plugin/css-extract/loader-options.json +0 -37
- package/dist/builtin-plugin/css-extract/plugin-options.json +0 -79
package/dist/Compilation.d.ts
CHANGED
|
@@ -167,6 +167,7 @@ export declare class Compilation {
|
|
|
167
167
|
Set<string>
|
|
168
168
|
], void>;
|
|
169
169
|
runtimeModule: RuntimeModule;
|
|
170
|
+
seal: liteTapable.SyncHook<[], void>;
|
|
170
171
|
afterSeal: liteTapable.AsyncSeriesHook<[], void>;
|
|
171
172
|
}>;
|
|
172
173
|
name?: string;
|
|
@@ -210,6 +211,7 @@ export declare class Compilation {
|
|
|
210
211
|
* Note: This is a proxy for webpack internal API, only method `get` and `keys` is supported now.
|
|
211
212
|
*/
|
|
212
213
|
get namedChunks(): ReadonlyMap<string, Readonly<Chunk>>;
|
|
214
|
+
get entries(): Map<string, EntryData>;
|
|
213
215
|
/**
|
|
214
216
|
* Note: This is not a webpack public API, maybe removed in future.
|
|
215
217
|
*
|
|
@@ -220,7 +222,7 @@ export declare class Compilation {
|
|
|
220
222
|
buildMeta: Record<string, unknown>;
|
|
221
223
|
};
|
|
222
224
|
getCache(name: string): import("./lib/CacheFacade").CacheFacade;
|
|
223
|
-
createStatsOptions(
|
|
225
|
+
createStatsOptions(statsValue: StatsValue | undefined, context?: CreateStatsOptionsContext): NormalizedStatsOptions;
|
|
224
226
|
createStatsFactory(options: StatsOptions): StatsFactory;
|
|
225
227
|
createStatsPrinter(options: StatsOptions): StatsPrinter;
|
|
226
228
|
/**
|
|
@@ -373,3 +375,20 @@ export declare class Compilation {
|
|
|
373
375
|
static PROCESS_ASSETS_STAGE_ANALYSE: number;
|
|
374
376
|
static PROCESS_ASSETS_STAGE_REPORT: number;
|
|
375
377
|
}
|
|
378
|
+
export type EntryData = binding.JsEntryData;
|
|
379
|
+
export declare class Entries implements Map<string, EntryData> {
|
|
380
|
+
#private;
|
|
381
|
+
constructor(data: binding.JsEntries);
|
|
382
|
+
clear(): void;
|
|
383
|
+
forEach(callback: (value: binding.JsEntryData, key: string, map: Map<string, binding.JsEntryData>) => void, thisArg?: any): void;
|
|
384
|
+
get size(): number;
|
|
385
|
+
entries(): IterableIterator<[string, binding.JsEntryData]>;
|
|
386
|
+
values(): IterableIterator<binding.JsEntryData>;
|
|
387
|
+
[Symbol.iterator](): IterableIterator<[string, binding.JsEntryData]>;
|
|
388
|
+
get [Symbol.toStringTag](): string;
|
|
389
|
+
has(key: string): boolean;
|
|
390
|
+
set(key: string, value: EntryData): this;
|
|
391
|
+
delete(key: string): boolean;
|
|
392
|
+
get(key: string): EntryData | undefined;
|
|
393
|
+
keys(): IterableIterator<string>;
|
|
394
|
+
}
|
package/dist/Compilation.js
CHANGED
|
@@ -36,9 +36,9 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
36
36
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
|
-
var _Compilation_instances, _Compilation_inner, _Compilation_customModules, _Compilation_createCachedAssets, _Compilation_rebuildModuleCaller;
|
|
39
|
+
var _Compilation_instances, _Compilation_inner, _Compilation_customModules, _Compilation_createCachedAssets, _Compilation_rebuildModuleCaller, _Entries_data;
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.Compilation = void 0;
|
|
41
|
+
exports.Entries = exports.Compilation = void 0;
|
|
42
42
|
const binding_1 = require("@rspack/binding");
|
|
43
43
|
const liteTapable = __importStar(require("@rspack/lite-tapable"));
|
|
44
44
|
const Chunk_1 = require("./Chunk");
|
|
@@ -98,12 +98,14 @@ class Compilation {
|
|
|
98
98
|
const errorMessage = (reason) => `Can't automatically convert plugin using Compilation.hooks.${name} to Compilation.hooks.processAssets because ${reason}.
|
|
99
99
|
BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a single Compilation.hooks.processAssets hook.`;
|
|
100
100
|
const getOptions = (options) => {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (options.stage) {
|
|
101
|
+
const isString = typeof options === "string";
|
|
102
|
+
if (!isString && options.stage) {
|
|
104
103
|
throw new Error(errorMessage("it's using the 'stage' option"));
|
|
105
104
|
}
|
|
106
|
-
return {
|
|
105
|
+
return {
|
|
106
|
+
...(isString ? { name: options } : options),
|
|
107
|
+
stage: stage
|
|
108
|
+
};
|
|
107
109
|
};
|
|
108
110
|
return Object.freeze({
|
|
109
111
|
name,
|
|
@@ -157,6 +159,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
157
159
|
"runtimeRequirements"
|
|
158
160
|
]),
|
|
159
161
|
runtimeModule: new liteTapable.SyncHook(["module", "chunk"]),
|
|
162
|
+
seal: new liteTapable.SyncHook([]),
|
|
160
163
|
afterSeal: new liteTapable.AsyncSeriesHook([])
|
|
161
164
|
};
|
|
162
165
|
this.compiler = compiler;
|
|
@@ -237,6 +240,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
237
240
|
}
|
|
238
241
|
};
|
|
239
242
|
}
|
|
243
|
+
get entries() {
|
|
244
|
+
return new Entries(__classPrivateFieldGet(this, _Compilation_inner, "f").entries);
|
|
245
|
+
}
|
|
240
246
|
/**
|
|
241
247
|
* Note: This is not a webpack public API, maybe removed in future.
|
|
242
248
|
*
|
|
@@ -255,7 +261,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
255
261
|
getCache(name) {
|
|
256
262
|
return this.compiler.getCache(name);
|
|
257
263
|
}
|
|
258
|
-
createStatsOptions(
|
|
264
|
+
createStatsOptions(statsValue, context = {}) {
|
|
265
|
+
let optionsOrPreset = statsValue;
|
|
259
266
|
if (typeof optionsOrPreset === "boolean" ||
|
|
260
267
|
typeof optionsOrPreset === "string") {
|
|
261
268
|
optionsOrPreset = { preset: optionsOrPreset };
|
|
@@ -448,12 +455,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
448
455
|
{
|
|
449
456
|
method: "push",
|
|
450
457
|
handler(target, thisArg, warns) {
|
|
451
|
-
|
|
452
|
-
for (let i = 0; i < warns.length; i++) {
|
|
453
|
-
const warn = warns[i];
|
|
458
|
+
return Reflect.apply(target, thisArg, processWarningsHook.call(warns).map(warn => {
|
|
454
459
|
inner.pushDiagnostic(RspackError_1.JsDiagnostic.__to_binding(warn, binding_1.JsRspackSeverity.Warn));
|
|
455
|
-
|
|
456
|
-
|
|
460
|
+
return warn;
|
|
461
|
+
}));
|
|
457
462
|
}
|
|
458
463
|
},
|
|
459
464
|
{
|
|
@@ -473,12 +478,11 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
473
478
|
{
|
|
474
479
|
method: "unshift",
|
|
475
480
|
handler(target, thisArg, warns) {
|
|
476
|
-
|
|
477
|
-
|
|
481
|
+
const warnings = processWarningsHook.call(warns);
|
|
482
|
+
inner.spliceDiagnostic(0, 0, warnings.map(warn => {
|
|
478
483
|
return RspackError_1.JsDiagnostic.__to_binding(warn, binding_1.JsRspackSeverity.Warn);
|
|
479
|
-
});
|
|
480
|
-
|
|
481
|
-
return Reflect.apply(target, thisArg, warns);
|
|
484
|
+
}));
|
|
485
|
+
return Reflect.apply(target, thisArg, warnings);
|
|
482
486
|
}
|
|
483
487
|
},
|
|
484
488
|
{
|
|
@@ -521,11 +525,12 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
521
525
|
if (!name) {
|
|
522
526
|
throw new TypeError("Compilation.getLogger(name) called without a name");
|
|
523
527
|
}
|
|
528
|
+
let logName = name;
|
|
524
529
|
let logEntries;
|
|
525
530
|
return new Logger_1.Logger((type, args) => {
|
|
526
|
-
if (typeof
|
|
527
|
-
|
|
528
|
-
if (!
|
|
531
|
+
if (typeof logName === "function") {
|
|
532
|
+
logName = logName();
|
|
533
|
+
if (!logName) {
|
|
529
534
|
throw new TypeError("Compilation.getLogger(name) called with a function not returning a name");
|
|
530
535
|
}
|
|
531
536
|
}
|
|
@@ -545,67 +550,68 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
545
550
|
args,
|
|
546
551
|
trace
|
|
547
552
|
};
|
|
548
|
-
if (this.hooks.log.call(
|
|
553
|
+
if (this.hooks.log.call(logName, logEntry) === undefined) {
|
|
549
554
|
if (logEntry.type === Logger_1.LogType.profileEnd) {
|
|
550
555
|
if (typeof console.profileEnd === "function") {
|
|
551
|
-
console.profileEnd(`[${
|
|
556
|
+
console.profileEnd(`[${logName}] ${logEntry.args[0]}`);
|
|
552
557
|
}
|
|
553
558
|
}
|
|
554
559
|
if (logEntries === undefined) {
|
|
555
|
-
logEntries = this.logging.get(
|
|
560
|
+
logEntries = this.logging.get(logName);
|
|
556
561
|
if (logEntries === undefined) {
|
|
557
562
|
logEntries = [];
|
|
558
|
-
this.logging.set(
|
|
563
|
+
this.logging.set(logName, logEntries);
|
|
559
564
|
}
|
|
560
565
|
}
|
|
561
566
|
logEntries.push(logEntry);
|
|
562
567
|
if (logEntry.type === Logger_1.LogType.profile) {
|
|
563
568
|
if (typeof console.profile === "function") {
|
|
564
|
-
console.profile(`[${
|
|
569
|
+
console.profile(`[${logName}] ${logEntry.args[0]}`);
|
|
565
570
|
}
|
|
566
571
|
}
|
|
567
572
|
}
|
|
568
573
|
}, (childName) => {
|
|
569
|
-
|
|
570
|
-
|
|
574
|
+
let normalizedChildName = childName;
|
|
575
|
+
if (typeof logName === "function") {
|
|
576
|
+
if (typeof normalizedChildName === "function") {
|
|
571
577
|
return this.getLogger(() => {
|
|
572
|
-
if (typeof
|
|
573
|
-
|
|
574
|
-
if (!
|
|
578
|
+
if (typeof logName === "function") {
|
|
579
|
+
logName = logName();
|
|
580
|
+
if (!logName) {
|
|
575
581
|
throw new TypeError("Compilation.getLogger(name) called with a function not returning a name");
|
|
576
582
|
}
|
|
577
583
|
}
|
|
578
|
-
if (typeof
|
|
579
|
-
|
|
580
|
-
if (!
|
|
584
|
+
if (typeof normalizedChildName === "function") {
|
|
585
|
+
normalizedChildName = normalizedChildName();
|
|
586
|
+
if (!normalizedChildName) {
|
|
581
587
|
throw new TypeError("Logger.getChildLogger(name) called with a function not returning a name");
|
|
582
588
|
}
|
|
583
589
|
}
|
|
584
|
-
return `${
|
|
590
|
+
return `${logName}/${normalizedChildName}`;
|
|
585
591
|
});
|
|
586
592
|
}
|
|
587
593
|
return this.getLogger(() => {
|
|
588
|
-
if (typeof
|
|
589
|
-
|
|
590
|
-
if (!
|
|
594
|
+
if (typeof logName === "function") {
|
|
595
|
+
logName = logName();
|
|
596
|
+
if (!logName) {
|
|
591
597
|
throw new TypeError("Compilation.getLogger(name) called with a function not returning a name");
|
|
592
598
|
}
|
|
593
599
|
}
|
|
594
|
-
return `${
|
|
600
|
+
return `${logName}/${normalizedChildName}`;
|
|
595
601
|
});
|
|
596
602
|
}
|
|
597
|
-
if (typeof
|
|
603
|
+
if (typeof normalizedChildName === "function") {
|
|
598
604
|
return this.getLogger(() => {
|
|
599
|
-
if (typeof
|
|
600
|
-
|
|
601
|
-
if (!
|
|
605
|
+
if (typeof normalizedChildName === "function") {
|
|
606
|
+
normalizedChildName = normalizedChildName();
|
|
607
|
+
if (!normalizedChildName) {
|
|
602
608
|
throw new TypeError("Logger.getChildLogger(name) called with a function not returning a name");
|
|
603
609
|
}
|
|
604
610
|
}
|
|
605
|
-
return `${
|
|
611
|
+
return `${logName}/${normalizedChildName}`;
|
|
606
612
|
});
|
|
607
613
|
}
|
|
608
|
-
return this.getLogger(`${
|
|
614
|
+
return this.getLogger(`${logName}/${normalizedChildName}`);
|
|
609
615
|
});
|
|
610
616
|
}
|
|
611
617
|
getStats() {
|
|
@@ -759,3 +765,62 @@ Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER = 3000;
|
|
|
759
765
|
Compilation.PROCESS_ASSETS_STAGE_ANALYSE = 4000;
|
|
760
766
|
Compilation.PROCESS_ASSETS_STAGE_REPORT = 5000;
|
|
761
767
|
exports.Compilation = Compilation;
|
|
768
|
+
class Entries {
|
|
769
|
+
constructor(data) {
|
|
770
|
+
_Entries_data.set(this, void 0);
|
|
771
|
+
__classPrivateFieldSet(this, _Entries_data, data, "f");
|
|
772
|
+
}
|
|
773
|
+
clear() {
|
|
774
|
+
__classPrivateFieldGet(this, _Entries_data, "f").clear();
|
|
775
|
+
}
|
|
776
|
+
forEach(callback, thisArg) {
|
|
777
|
+
for (const [key, value] of this) {
|
|
778
|
+
callback.call(thisArg, value, key, this);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
get size() {
|
|
782
|
+
return __classPrivateFieldGet(this, _Entries_data, "f").size;
|
|
783
|
+
}
|
|
784
|
+
entries() {
|
|
785
|
+
const self = this;
|
|
786
|
+
const keys = this.keys();
|
|
787
|
+
return {
|
|
788
|
+
[Symbol.iterator]() {
|
|
789
|
+
return this;
|
|
790
|
+
},
|
|
791
|
+
next() {
|
|
792
|
+
const { done, value } = keys.next();
|
|
793
|
+
return {
|
|
794
|
+
done,
|
|
795
|
+
value: done ? undefined : [value, self.get(value)]
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
values() {
|
|
801
|
+
return __classPrivateFieldGet(this, _Entries_data, "f").values()[Symbol.iterator]();
|
|
802
|
+
}
|
|
803
|
+
[(_Entries_data = new WeakMap(), Symbol.iterator)]() {
|
|
804
|
+
return this.entries();
|
|
805
|
+
}
|
|
806
|
+
get [Symbol.toStringTag]() {
|
|
807
|
+
return "Map";
|
|
808
|
+
}
|
|
809
|
+
has(key) {
|
|
810
|
+
return __classPrivateFieldGet(this, _Entries_data, "f").has(key);
|
|
811
|
+
}
|
|
812
|
+
set(key, value) {
|
|
813
|
+
__classPrivateFieldGet(this, _Entries_data, "f").set(key, value);
|
|
814
|
+
return this;
|
|
815
|
+
}
|
|
816
|
+
delete(key) {
|
|
817
|
+
return __classPrivateFieldGet(this, _Entries_data, "f").delete(key);
|
|
818
|
+
}
|
|
819
|
+
get(key) {
|
|
820
|
+
return __classPrivateFieldGet(this, _Entries_data, "f").get(key);
|
|
821
|
+
}
|
|
822
|
+
keys() {
|
|
823
|
+
return __classPrivateFieldGet(this, _Entries_data, "f").keys()[Symbol.iterator]();
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
exports.Entries = Entries;
|
package/dist/Compiler.d.ts
CHANGED
package/dist/Compiler.js
CHANGED
|
@@ -137,6 +137,7 @@ class Compiler {
|
|
|
137
137
|
entryOption: new liteTapable.SyncBailHook(["context", "entry"])
|
|
138
138
|
};
|
|
139
139
|
this.webpack = index_1.rspack;
|
|
140
|
+
this.rspack = index_1.rspack;
|
|
140
141
|
this.root = this;
|
|
141
142
|
this.outputPath = "";
|
|
142
143
|
this.inputFileSystem = null;
|
|
@@ -199,62 +200,65 @@ class Compiler {
|
|
|
199
200
|
if (!name) {
|
|
200
201
|
throw new TypeError("Compiler.getInfrastructureLogger(name) called without a name");
|
|
201
202
|
}
|
|
203
|
+
let normalizedName = name;
|
|
202
204
|
return new Logger_1.Logger((type, args) => {
|
|
203
|
-
if (typeof
|
|
204
|
-
|
|
205
|
-
if (!
|
|
205
|
+
if (typeof normalizedName === "function") {
|
|
206
|
+
normalizedName = normalizedName();
|
|
207
|
+
if (!normalizedName) {
|
|
206
208
|
throw new TypeError("Compiler.getInfrastructureLogger(name) called with a function not returning a name");
|
|
207
209
|
}
|
|
208
210
|
}
|
|
209
211
|
else {
|
|
210
|
-
if (this.hooks.infrastructureLog.call(
|
|
212
|
+
if (this.hooks.infrastructureLog.call(normalizedName, type, args) ===
|
|
213
|
+
undefined) {
|
|
211
214
|
if (this.infrastructureLogger !== undefined) {
|
|
212
|
-
this.infrastructureLogger(
|
|
215
|
+
this.infrastructureLogger(normalizedName, type, args);
|
|
213
216
|
}
|
|
214
217
|
}
|
|
215
218
|
}
|
|
216
219
|
}, (childName) => {
|
|
217
|
-
|
|
218
|
-
|
|
220
|
+
let normalizedChildName = childName;
|
|
221
|
+
if (typeof normalizedName === "function") {
|
|
222
|
+
if (typeof normalizedChildName === "function") {
|
|
219
223
|
// @ts-expect-error
|
|
220
224
|
return this.getInfrastructureLogger(_ => {
|
|
221
|
-
if (typeof
|
|
222
|
-
|
|
223
|
-
if (!
|
|
225
|
+
if (typeof normalizedName === "function") {
|
|
226
|
+
normalizedName = normalizedName();
|
|
227
|
+
if (!normalizedName) {
|
|
224
228
|
throw new TypeError("Compiler.getInfrastructureLogger(name) called with a function not returning a name");
|
|
225
229
|
}
|
|
226
230
|
}
|
|
227
|
-
if (typeof
|
|
228
|
-
|
|
229
|
-
if (!
|
|
231
|
+
if (typeof normalizedChildName === "function") {
|
|
232
|
+
normalizedChildName = normalizedChildName();
|
|
233
|
+
if (!normalizedChildName) {
|
|
230
234
|
throw new TypeError("Logger.getChildLogger(name) called with a function not returning a name");
|
|
231
235
|
}
|
|
232
236
|
}
|
|
233
|
-
return `${
|
|
237
|
+
return `${normalizedName}/${normalizedChildName}`;
|
|
234
238
|
});
|
|
235
239
|
}
|
|
236
240
|
return this.getInfrastructureLogger(() => {
|
|
237
|
-
if (typeof
|
|
238
|
-
|
|
239
|
-
if (!
|
|
241
|
+
if (typeof normalizedName === "function") {
|
|
242
|
+
normalizedName = normalizedName();
|
|
243
|
+
if (!normalizedName) {
|
|
240
244
|
throw new TypeError("Compiler.getInfrastructureLogger(name) called with a function not returning a name");
|
|
241
245
|
}
|
|
242
246
|
}
|
|
243
|
-
return `${
|
|
247
|
+
return `${normalizedName}/${normalizedChildName}`;
|
|
244
248
|
});
|
|
245
249
|
}
|
|
246
|
-
if (typeof
|
|
250
|
+
if (typeof normalizedChildName === "function") {
|
|
247
251
|
return this.getInfrastructureLogger(() => {
|
|
248
|
-
if (typeof
|
|
249
|
-
|
|
250
|
-
if (!
|
|
252
|
+
if (typeof normalizedChildName === "function") {
|
|
253
|
+
normalizedChildName = normalizedChildName();
|
|
254
|
+
if (!normalizedChildName) {
|
|
251
255
|
throw new TypeError("Logger.getChildLogger(name) called with a function not returning a name");
|
|
252
256
|
}
|
|
253
257
|
}
|
|
254
|
-
return `${
|
|
258
|
+
return `${normalizedName}/${normalizedChildName}`;
|
|
255
259
|
});
|
|
256
260
|
}
|
|
257
|
-
return this.getInfrastructureLogger(`${
|
|
261
|
+
return this.getInfrastructureLogger(`${normalizedName}/${normalizedChildName}`);
|
|
258
262
|
});
|
|
259
263
|
}
|
|
260
264
|
/**
|
|
@@ -665,6 +669,7 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
665
669
|
registerCompilationChunkAssetTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationChunkAsset, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.chunkAsset, queried => ({ chunk, filename }) => queried.call(Chunk_1.Chunk.__from_binding(chunk, __classPrivateFieldGet(this, _Compiler_compilation, "f")), filename)),
|
|
666
670
|
registerCompilationProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationProcessAssets, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.processAssets, queried => async () => await queried.promise(__classPrivateFieldGet(this, _Compiler_compilation, "f").assets)),
|
|
667
671
|
registerCompilationAfterProcessAssetsTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterProcessAssets, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.afterProcessAssets, queried => () => queried.call(__classPrivateFieldGet(this, _Compiler_compilation, "f").assets)),
|
|
672
|
+
registerCompilationSealTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationSeal, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.seal, queried => () => queried.call()),
|
|
668
673
|
registerCompilationAfterSealTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationAfterSeal, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.afterSeal, queried => async () => await queried.promise()),
|
|
669
674
|
registerNormalModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.NormalModuleFactoryBeforeResolve, () => __classPrivateFieldGet(this, _Compiler_compilationParams, "f").normalModuleFactory.hooks.beforeResolve, queried => async (resolveData) => {
|
|
670
675
|
const normalizedResolveData = {
|
package/dist/MultiCompiler.js
CHANGED
|
@@ -51,21 +51,25 @@ const ArrayQueue_1 = __importDefault(require("./util/ArrayQueue"));
|
|
|
51
51
|
class MultiCompiler {
|
|
52
52
|
constructor(compilers, options) {
|
|
53
53
|
_MultiCompiler_instances.add(this);
|
|
54
|
+
let normalizedCompilers;
|
|
54
55
|
if (!Array.isArray(compilers)) {
|
|
55
|
-
|
|
56
|
+
normalizedCompilers = Object.entries(compilers).map(([name, compiler]) => {
|
|
56
57
|
compiler.name = name;
|
|
57
58
|
return compiler;
|
|
58
59
|
});
|
|
59
60
|
}
|
|
61
|
+
else {
|
|
62
|
+
normalizedCompilers = compilers;
|
|
63
|
+
}
|
|
60
64
|
this.hooks = {
|
|
61
65
|
done: new liteTapable.SyncHook(["stats"]),
|
|
62
|
-
invalid: new liteTapable.MultiHook(
|
|
63
|
-
run: new liteTapable.MultiHook(
|
|
66
|
+
invalid: new liteTapable.MultiHook(normalizedCompilers.map(c => c.hooks.invalid)),
|
|
67
|
+
run: new liteTapable.MultiHook(normalizedCompilers.map(c => c.hooks.run)),
|
|
64
68
|
watchClose: new liteTapable.SyncHook([]),
|
|
65
|
-
watchRun: new liteTapable.MultiHook(
|
|
66
|
-
infrastructureLog: new liteTapable.MultiHook(
|
|
69
|
+
watchRun: new liteTapable.MultiHook(normalizedCompilers.map(c => c.hooks.watchRun)),
|
|
70
|
+
infrastructureLog: new liteTapable.MultiHook(normalizedCompilers.map(c => c.hooks.infrastructureLog))
|
|
67
71
|
};
|
|
68
|
-
this.compilers =
|
|
72
|
+
this.compilers = normalizedCompilers;
|
|
69
73
|
this._options = {
|
|
70
74
|
parallelism: options?.parallelism || Number.POSITIVE_INFINITY
|
|
71
75
|
};
|
package/dist/MultiStats.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export default class MultiStats {
|
|
|
16
16
|
get hash(): string;
|
|
17
17
|
hasErrors(): boolean;
|
|
18
18
|
hasWarnings(): boolean;
|
|
19
|
-
toJson(options
|
|
19
|
+
toJson(options: any): StatsCompilation;
|
|
20
20
|
toString(options: any): string;
|
|
21
21
|
}
|
|
22
22
|
export { MultiStats };
|
package/dist/MultiStats.js
CHANGED
|
@@ -56,21 +56,23 @@ class MultiStats {
|
|
|
56
56
|
return this.stats.some(stat => stat.hasWarnings());
|
|
57
57
|
}
|
|
58
58
|
toJson(options) {
|
|
59
|
-
|
|
59
|
+
const childOptions = __classPrivateFieldGet(this, _MultiStats_instances, "m", _MultiStats_createChildOptions).call(this, options || {}, {
|
|
60
|
+
forToString: false
|
|
61
|
+
});
|
|
60
62
|
const obj = {};
|
|
61
63
|
obj.children = this.stats.map((stat, idx) => {
|
|
62
|
-
const obj = stat.toJson(
|
|
64
|
+
const obj = stat.toJson(childOptions.children[idx]);
|
|
63
65
|
const compilationName = stat.compilation.name;
|
|
64
66
|
const name = compilationName &&
|
|
65
|
-
identifierUtils.makePathsRelative(
|
|
67
|
+
identifierUtils.makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root);
|
|
66
68
|
obj.name = name;
|
|
67
69
|
return obj;
|
|
68
70
|
});
|
|
69
|
-
if (
|
|
71
|
+
if (childOptions.version) {
|
|
70
72
|
obj.rspackVersion = require("../package.json").version;
|
|
71
73
|
obj.version = require("../package.json").webpackVersion;
|
|
72
74
|
}
|
|
73
|
-
if (
|
|
75
|
+
if (childOptions.hash) {
|
|
74
76
|
obj.hash = obj.children.map(j => j.hash).join("");
|
|
75
77
|
}
|
|
76
78
|
const mapError = (j, obj) => {
|
|
@@ -81,7 +83,7 @@ class MultiStats {
|
|
|
81
83
|
: j.name
|
|
82
84
|
};
|
|
83
85
|
};
|
|
84
|
-
if (
|
|
86
|
+
if (childOptions.errors) {
|
|
85
87
|
obj.errors = [];
|
|
86
88
|
for (const j of obj.children) {
|
|
87
89
|
for (const i of j.errors || []) {
|
|
@@ -89,7 +91,7 @@ class MultiStats {
|
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
|
-
if (
|
|
94
|
+
if (childOptions.warnings) {
|
|
93
95
|
obj.warnings = [];
|
|
94
96
|
for (const j of obj.children) {
|
|
95
97
|
for (const i of j.warnings || []) {
|
|
@@ -97,13 +99,13 @@ class MultiStats {
|
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
|
-
if (
|
|
102
|
+
if (childOptions.errorsCount) {
|
|
101
103
|
obj.errorsCount = 0;
|
|
102
104
|
for (const j of obj.children) {
|
|
103
105
|
obj.errorsCount += j.errorsCount || 0;
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
|
-
if (
|
|
108
|
+
if (childOptions.warningsCount) {
|
|
107
109
|
obj.warningsCount = 0;
|
|
108
110
|
for (const j of obj.children) {
|
|
109
111
|
obj.warningsCount += j.warningsCount || 0;
|
|
@@ -112,13 +114,15 @@ class MultiStats {
|
|
|
112
114
|
return obj;
|
|
113
115
|
}
|
|
114
116
|
toString(options) {
|
|
115
|
-
|
|
117
|
+
const childOptions = __classPrivateFieldGet(this, _MultiStats_instances, "m", _MultiStats_createChildOptions).call(this, options || {}, {
|
|
118
|
+
forToString: true
|
|
119
|
+
});
|
|
116
120
|
const results = this.stats.map((stat, idx) => {
|
|
117
|
-
const str = stat.toString(
|
|
121
|
+
const str = stat.toString(childOptions.children[idx]);
|
|
118
122
|
const compilationName = stat.compilation.name;
|
|
119
123
|
const name = compilationName &&
|
|
120
124
|
identifierUtils
|
|
121
|
-
.makePathsRelative(
|
|
125
|
+
.makePathsRelative(childOptions.context, compilationName, stat.compilation.compiler.root)
|
|
122
126
|
.replace(/\|/g, " ");
|
|
123
127
|
if (!str)
|
|
124
128
|
return str;
|
|
@@ -130,9 +134,6 @@ class MultiStats {
|
|
|
130
134
|
exports.default = MultiStats;
|
|
131
135
|
exports.MultiStats = MultiStats;
|
|
132
136
|
_MultiStats_instances = new WeakSet(), _MultiStats_createChildOptions = function _MultiStats_createChildOptions(options, context) {
|
|
133
|
-
if (!options) {
|
|
134
|
-
options = {};
|
|
135
|
-
}
|
|
136
137
|
const { children: childrenOptions = undefined, ...baseOptions } = typeof options === "string" ? { preset: options } : options;
|
|
137
138
|
const children = this.stats.map((stat, idx) => {
|
|
138
139
|
const childOptions = Array.isArray(childrenOptions)
|
|
@@ -153,6 +154,8 @@ _MultiStats_instances = new WeakSet(), _MultiStats_createChildOptions = function
|
|
|
153
154
|
warningsCount: children.every(o => o.warningsCount),
|
|
154
155
|
errors: children.every(o => o.errors),
|
|
155
156
|
warnings: children.every(o => o.warnings),
|
|
156
|
-
children
|
|
157
|
+
children,
|
|
158
|
+
context: "",
|
|
159
|
+
version: ""
|
|
157
160
|
};
|
|
158
161
|
};
|
package/dist/NormalModule.js
CHANGED
|
@@ -32,10 +32,9 @@ const liteTapable = __importStar(require("@rspack/lite-tapable"));
|
|
|
32
32
|
const Compilation_1 = require("./Compilation");
|
|
33
33
|
const compilationHooksMap = new WeakMap();
|
|
34
34
|
const createFakeHook = (fakeHook, message, code) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return Object.freeze(Object.assign(fakeHook, { _fakeHook: true }));
|
|
35
|
+
return Object.freeze(Object.assign(message && code
|
|
36
|
+
? deprecateAllProperties(fakeHook, message, code)
|
|
37
|
+
: fakeHook, { _fakeHook: true }));
|
|
39
38
|
};
|
|
40
39
|
const deprecateAllProperties = (obj, message, code) => {
|
|
41
40
|
const newObj = {};
|
package/dist/Stats.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Compilation } from "./Compilation";
|
|
2
2
|
import type { StatsOptions, StatsValue } from "./config";
|
|
3
3
|
import type { StatsCompilation } from "./stats/statsFactoryUtils";
|
|
4
|
-
export type { StatsAsset, StatsChunk, StatsCompilation, StatsError, StatsModule
|
|
4
|
+
export type { StatsAsset, StatsChunk, StatsCompilation, StatsError, StatsModule } from "./stats/statsFactoryUtils";
|
|
5
5
|
export declare class Stats {
|
|
6
6
|
#private;
|
|
7
7
|
compilation: Compilation;
|
package/dist/Template.d.ts
CHANGED
|
@@ -37,15 +37,15 @@ declare class Template {
|
|
|
37
37
|
*/
|
|
38
38
|
static toPath(str: string): string;
|
|
39
39
|
/**
|
|
40
|
-
* @param
|
|
40
|
+
* @param num number to convert to ident
|
|
41
41
|
* @returns returns single character ident
|
|
42
42
|
*/
|
|
43
|
-
static numberToIdentifier(
|
|
43
|
+
static numberToIdentifier(num: number): string;
|
|
44
44
|
/**
|
|
45
|
-
* @param
|
|
45
|
+
* @param num number to convert to ident
|
|
46
46
|
* @returns returns single character ident
|
|
47
47
|
*/
|
|
48
|
-
static numberToIdentifierContinuation(
|
|
48
|
+
static numberToIdentifierContinuation(num: number): string;
|
|
49
49
|
/**
|
|
50
50
|
*
|
|
51
51
|
* @param s string to convert to identity
|
package/dist/Template.js
CHANGED
|
@@ -80,10 +80,11 @@ class Template {
|
|
|
80
80
|
}
|
|
81
81
|
// map number to a single character a-z, A-Z or multiple characters if number is too big
|
|
82
82
|
/**
|
|
83
|
-
* @param
|
|
83
|
+
* @param num number to convert to ident
|
|
84
84
|
* @returns returns single character ident
|
|
85
85
|
*/
|
|
86
|
-
static numberToIdentifier(
|
|
86
|
+
static numberToIdentifier(num) {
|
|
87
|
+
let n = num;
|
|
87
88
|
if (n >= NUMBER_OF_IDENTIFIER_START_CHARS) {
|
|
88
89
|
// use multiple letters
|
|
89
90
|
return (Template.numberToIdentifier(n % NUMBER_OF_IDENTIFIER_START_CHARS) +
|
|
@@ -103,10 +104,11 @@ class Template {
|
|
|
103
104
|
return "$";
|
|
104
105
|
}
|
|
105
106
|
/**
|
|
106
|
-
* @param
|
|
107
|
+
* @param num number to convert to ident
|
|
107
108
|
* @returns returns single character ident
|
|
108
109
|
*/
|
|
109
|
-
static numberToIdentifierContinuation(
|
|
110
|
+
static numberToIdentifierContinuation(num) {
|
|
111
|
+
let n = num;
|
|
110
112
|
if (n >= NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS) {
|
|
111
113
|
// use multiple letters
|
|
112
114
|
return (Template.numberToIdentifierContinuation(n % NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS) +
|