@rspack/core 1.0.0-beta.2 → 1.0.0-beta.4
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 +21 -8
- package/dist/Compilation.js +114 -57
- package/dist/Compiler.d.ts +1 -0
- package/dist/Compiler.js +29 -24
- package/dist/DependenciesBlock.d.ts +8 -0
- package/dist/DependenciesBlock.js +30 -0
- package/dist/Dependency.d.ts +8 -0
- package/dist/Dependency.js +32 -0
- package/dist/Module.d.ts +6 -3
- package/dist/Module.js +13 -0
- 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/ExternalsPlugin.d.ts +4 -4
- 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 +28 -17
- 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/defaults.js +9 -6
- package/dist/config/zod.d.ts +537 -141
- package/dist/config/zod.js +18 -10
- package/dist/container/ContainerReferencePlugin.d.ts +1 -1
- 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/DefaultStatsFactoryPlugin.d.ts +0 -10
- package/dist/stats/DefaultStatsFactoryPlugin.js +130 -90
- package/dist/stats/DefaultStatsPresetPlugin.js +17 -18
- package/dist/stats/StatsFactory.js +8 -10
- package/dist/stats/StatsPrinter.js +3 -4
- package/dist/stats/statsFactoryUtils.d.ts +119 -19
- package/dist/stats/statsFactoryUtils.js +62 -1
- 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
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
9
9
|
*/
|
|
10
10
|
import type * as binding from "@rspack/binding";
|
|
11
|
-
import { type ExternalObject, type JsCompilation, type
|
|
11
|
+
import { type ExternalObject, type JsCompilation, type JsPathData, type JsRuntimeModule } from "@rspack/binding";
|
|
12
12
|
import * as liteTapable from "@rspack/lite-tapable";
|
|
13
13
|
import type { Source } from "../compiled/webpack-sources";
|
|
14
14
|
import { Chunk } from "./Chunk";
|
|
@@ -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
|
/**
|
|
@@ -336,12 +338,6 @@ export declare class Compilation {
|
|
|
336
338
|
* @internal
|
|
337
339
|
*/
|
|
338
340
|
__internal__hasAsset(name: string): boolean;
|
|
339
|
-
/**
|
|
340
|
-
* Note: This is not a webpack public API, maybe removed in future.
|
|
341
|
-
*
|
|
342
|
-
* @internal
|
|
343
|
-
*/
|
|
344
|
-
__internal__getModules(): JsModule[];
|
|
345
341
|
/**
|
|
346
342
|
* Note: This is not a webpack public API, maybe removed in future.
|
|
347
343
|
*
|
|
@@ -373,3 +369,20 @@ export declare class Compilation {
|
|
|
373
369
|
static PROCESS_ASSETS_STAGE_ANALYSE: number;
|
|
374
370
|
static PROCESS_ASSETS_STAGE_REPORT: number;
|
|
375
371
|
}
|
|
372
|
+
export type EntryData = binding.JsEntryData;
|
|
373
|
+
export declare class Entries implements Map<string, EntryData> {
|
|
374
|
+
#private;
|
|
375
|
+
constructor(data: binding.JsEntries);
|
|
376
|
+
clear(): void;
|
|
377
|
+
forEach(callback: (value: binding.JsEntryData, key: string, map: Map<string, binding.JsEntryData>) => void, thisArg?: any): void;
|
|
378
|
+
get size(): number;
|
|
379
|
+
entries(): IterableIterator<[string, binding.JsEntryData]>;
|
|
380
|
+
values(): IterableIterator<binding.JsEntryData>;
|
|
381
|
+
[Symbol.iterator](): IterableIterator<[string, binding.JsEntryData]>;
|
|
382
|
+
get [Symbol.toStringTag](): string;
|
|
383
|
+
has(key: string): boolean;
|
|
384
|
+
set(key: string, value: EntryData): this;
|
|
385
|
+
delete(key: string): boolean;
|
|
386
|
+
get(key: string): EntryData | undefined;
|
|
387
|
+
keys(): IterableIterator<string>;
|
|
388
|
+
}
|
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");
|
|
@@ -72,10 +72,10 @@ class Compilation {
|
|
|
72
72
|
* These fields are generally used within a plugin, so they do not need to be passed back to the Rust side.
|
|
73
73
|
*/
|
|
74
74
|
_Compilation_customModules.set(this, void 0);
|
|
75
|
-
this.fileDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").
|
|
76
|
-
this.contextDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").
|
|
77
|
-
this.missingDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").
|
|
78
|
-
this.buildDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").
|
|
75
|
+
this.fileDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").dependencies().fileDependencies, d => __classPrivateFieldGet(this, _Compilation_inner, "f").addFileDependencies(d));
|
|
76
|
+
this.contextDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").dependencies().contextDependencies, d => __classPrivateFieldGet(this, _Compilation_inner, "f").addContextDependencies(d));
|
|
77
|
+
this.missingDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").dependencies().missingDependencies, d => __classPrivateFieldGet(this, _Compilation_inner, "f").addMissingDependencies(d));
|
|
78
|
+
this.buildDependencies = (0, fake_1.createFakeCompilationDependencies)(() => __classPrivateFieldGet(this, _Compilation_inner, "f").dependencies().buildDependencies, d => __classPrivateFieldGet(this, _Compilation_inner, "f").addBuildDependencies(d));
|
|
79
79
|
_Compilation_rebuildModuleCaller.set(this, ((compilation) => new MergeCaller_1.default((args) => {
|
|
80
80
|
__classPrivateFieldGet(compilation, _Compilation_inner, "f").rebuildModule(args.map(item => item[0]), (err, modules) => {
|
|
81
81
|
for (const [id, callback] of args) {
|
|
@@ -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;
|
|
@@ -213,7 +216,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
213
216
|
};
|
|
214
217
|
}
|
|
215
218
|
get modules() {
|
|
216
|
-
return
|
|
219
|
+
return new Set(__classPrivateFieldGet(this, _Compilation_inner, "f").modules.map(module => Module_1.Module.__from_binding(module, this)));
|
|
217
220
|
}
|
|
218
221
|
get chunks() {
|
|
219
222
|
return (0, memoize_1.memoizeValue)(() => new Set(this.__internal__getChunks()));
|
|
@@ -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() {
|
|
@@ -673,14 +679,6 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
673
679
|
__internal__hasAsset(name) {
|
|
674
680
|
return __classPrivateFieldGet(this, _Compilation_inner, "f").hasAsset(name);
|
|
675
681
|
}
|
|
676
|
-
/**
|
|
677
|
-
* Note: This is not a webpack public API, maybe removed in future.
|
|
678
|
-
*
|
|
679
|
-
* @internal
|
|
680
|
-
*/
|
|
681
|
-
__internal__getModules() {
|
|
682
|
-
return __classPrivateFieldGet(this, _Compilation_inner, "f").getModules();
|
|
683
|
-
}
|
|
684
682
|
/**
|
|
685
683
|
* Note: This is not a webpack public API, maybe removed in future.
|
|
686
684
|
*
|
|
@@ -759,3 +757,62 @@ Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER = 3000;
|
|
|
759
757
|
Compilation.PROCESS_ASSETS_STAGE_ANALYSE = 4000;
|
|
760
758
|
Compilation.PROCESS_ASSETS_STAGE_REPORT = 5000;
|
|
761
759
|
exports.Compilation = Compilation;
|
|
760
|
+
class Entries {
|
|
761
|
+
constructor(data) {
|
|
762
|
+
_Entries_data.set(this, void 0);
|
|
763
|
+
__classPrivateFieldSet(this, _Entries_data, data, "f");
|
|
764
|
+
}
|
|
765
|
+
clear() {
|
|
766
|
+
__classPrivateFieldGet(this, _Entries_data, "f").clear();
|
|
767
|
+
}
|
|
768
|
+
forEach(callback, thisArg) {
|
|
769
|
+
for (const [key, value] of this) {
|
|
770
|
+
callback.call(thisArg, value, key, this);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
get size() {
|
|
774
|
+
return __classPrivateFieldGet(this, _Entries_data, "f").size;
|
|
775
|
+
}
|
|
776
|
+
entries() {
|
|
777
|
+
const self = this;
|
|
778
|
+
const keys = this.keys();
|
|
779
|
+
return {
|
|
780
|
+
[Symbol.iterator]() {
|
|
781
|
+
return this;
|
|
782
|
+
},
|
|
783
|
+
next() {
|
|
784
|
+
const { done, value } = keys.next();
|
|
785
|
+
return {
|
|
786
|
+
done,
|
|
787
|
+
value: done ? undefined : [value, self.get(value)]
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
}
|
|
792
|
+
values() {
|
|
793
|
+
return __classPrivateFieldGet(this, _Entries_data, "f").values()[Symbol.iterator]();
|
|
794
|
+
}
|
|
795
|
+
[(_Entries_data = new WeakMap(), Symbol.iterator)]() {
|
|
796
|
+
return this.entries();
|
|
797
|
+
}
|
|
798
|
+
get [Symbol.toStringTag]() {
|
|
799
|
+
return "Map";
|
|
800
|
+
}
|
|
801
|
+
has(key) {
|
|
802
|
+
return __classPrivateFieldGet(this, _Entries_data, "f").has(key);
|
|
803
|
+
}
|
|
804
|
+
set(key, value) {
|
|
805
|
+
__classPrivateFieldGet(this, _Entries_data, "f").set(key, value);
|
|
806
|
+
return this;
|
|
807
|
+
}
|
|
808
|
+
delete(key) {
|
|
809
|
+
return __classPrivateFieldGet(this, _Entries_data, "f").delete(key);
|
|
810
|
+
}
|
|
811
|
+
get(key) {
|
|
812
|
+
return __classPrivateFieldGet(this, _Entries_data, "f").get(key);
|
|
813
|
+
}
|
|
814
|
+
keys() {
|
|
815
|
+
return __classPrivateFieldGet(this, _Entries_data, "f").keys()[Symbol.iterator]();
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
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 = {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DependenciesBlockDTO } from "@rspack/binding";
|
|
2
|
+
import { Dependency } from "./Dependency";
|
|
3
|
+
export declare class DependenciesBlock {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(binding: DependenciesBlockDTO);
|
|
6
|
+
get dependencies(): Dependency[];
|
|
7
|
+
get blocks(): DependenciesBlock[];
|
|
8
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
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
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
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 _DependenciesBlock_binding;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.DependenciesBlock = void 0;
|
|
16
|
+
const Dependency_1 = require("./Dependency");
|
|
17
|
+
class DependenciesBlock {
|
|
18
|
+
constructor(binding) {
|
|
19
|
+
_DependenciesBlock_binding.set(this, void 0);
|
|
20
|
+
__classPrivateFieldSet(this, _DependenciesBlock_binding, binding, "f");
|
|
21
|
+
}
|
|
22
|
+
get dependencies() {
|
|
23
|
+
return __classPrivateFieldGet(this, _DependenciesBlock_binding, "f").dependencies.map(d => new Dependency_1.Dependency(d));
|
|
24
|
+
}
|
|
25
|
+
get blocks() {
|
|
26
|
+
return __classPrivateFieldGet(this, _DependenciesBlock_binding, "f").blocks.map(b => new DependenciesBlock(b));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.DependenciesBlock = DependenciesBlock;
|
|
30
|
+
_DependenciesBlock_binding = new WeakMap();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
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
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
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 _Dependency_binding;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.Dependency = void 0;
|
|
16
|
+
class Dependency {
|
|
17
|
+
constructor(binding) {
|
|
18
|
+
_Dependency_binding.set(this, void 0);
|
|
19
|
+
__classPrivateFieldSet(this, _Dependency_binding, binding, "f");
|
|
20
|
+
}
|
|
21
|
+
get type() {
|
|
22
|
+
return __classPrivateFieldGet(this, _Dependency_binding, "f").type;
|
|
23
|
+
}
|
|
24
|
+
get category() {
|
|
25
|
+
return __classPrivateFieldGet(this, _Dependency_binding, "f").category;
|
|
26
|
+
}
|
|
27
|
+
get request() {
|
|
28
|
+
return __classPrivateFieldGet(this, _Dependency_binding, "f").request;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.Dependency = Dependency;
|
|
32
|
+
_Dependency_binding = new WeakMap();
|
package/dist/Module.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { JsCodegenerationResult, JsCreateData, JsFactoryMeta, JsModule } from "@rspack/binding";
|
|
1
|
+
import type { JsCodegenerationResult, JsCreateData, JsFactoryMeta, JsModule, ModuleDTO } from "@rspack/binding";
|
|
2
2
|
import type { Source } from "../compiled/webpack-sources";
|
|
3
3
|
import type { Compilation } from "./Compilation";
|
|
4
|
+
import { DependenciesBlock } from "./DependenciesBlock";
|
|
4
5
|
export type ResourceData = {
|
|
5
6
|
resource: string;
|
|
6
7
|
path: string;
|
|
@@ -56,11 +57,13 @@ export declare class Module {
|
|
|
56
57
|
* @see {@link Compilation#customModules}
|
|
57
58
|
*/
|
|
58
59
|
buildMeta: Record<string, any>;
|
|
59
|
-
static __from_binding(module: JsModule, compilation?: Compilation): Module;
|
|
60
|
-
constructor(module: JsModule, compilation?: Compilation);
|
|
60
|
+
static __from_binding(module: JsModule | ModuleDTO, compilation?: Compilation): Module;
|
|
61
|
+
constructor(module: JsModule | ModuleDTO, compilation?: Compilation);
|
|
61
62
|
originalSource(): Source | null;
|
|
62
63
|
identifier(): string;
|
|
63
64
|
nameForCondition(): string | null;
|
|
65
|
+
get blocks(): DependenciesBlock[];
|
|
66
|
+
size(type?: string): number;
|
|
64
67
|
}
|
|
65
68
|
export declare class CodeGenerationResult {
|
|
66
69
|
#private;
|
package/dist/Module.js
CHANGED
|
@@ -13,6 +13,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
13
13
|
var _Module_inner, _Module_originalSource, _CodeGenerationResult_inner;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.CodeGenerationResults = exports.CodeGenerationResult = exports.Module = void 0;
|
|
16
|
+
const DependenciesBlock_1 = require("./DependenciesBlock");
|
|
16
17
|
const source_1 = require("./util/source");
|
|
17
18
|
class Module {
|
|
18
19
|
static __from_binding(module, compilation) {
|
|
@@ -52,6 +53,18 @@ class Module {
|
|
|
52
53
|
}
|
|
53
54
|
return null;
|
|
54
55
|
}
|
|
56
|
+
get blocks() {
|
|
57
|
+
if ("blocks" in __classPrivateFieldGet(this, _Module_inner, "f")) {
|
|
58
|
+
return __classPrivateFieldGet(this, _Module_inner, "f").blocks.map(b => new DependenciesBlock_1.DependenciesBlock(b));
|
|
59
|
+
}
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
size(type) {
|
|
63
|
+
if ("size" in __classPrivateFieldGet(this, _Module_inner, "f")) {
|
|
64
|
+
return __classPrivateFieldGet(this, _Module_inner, "f").size(type);
|
|
65
|
+
}
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
55
68
|
}
|
|
56
69
|
exports.Module = Module;
|
|
57
70
|
_Module_inner = new WeakMap(), _Module_originalSource = new WeakMap();
|