@rspack/core 1.0.5 → 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 +9 -21
- package/dist/Module.d.ts +20 -8
- package/dist/Module.js +66 -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/builtin-plugin/ContextReplacementPlugin.d.ts +10 -0
- package/dist/builtin-plugin/ContextReplacementPlugin.js +43 -0
- package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
- package/dist/builtin-plugin/ProgressPlugin.js +10 -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 +40 -3
- package/dist/config/defaults.js +0 -4
- 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 +30 -28
- package/dist/node/NodeEnvironmentPlugin.js +1 -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/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
|
@@ -594,6 +594,13 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
594
594
|
runtimeRequirements: (0, RuntimeGlobals_1.__to_binding_runtime_globals)(set)
|
|
595
595
|
};
|
|
596
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
|
+
}),
|
|
597
604
|
registerCompilationRuntimeModuleTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationRuntimeModule, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.runtimeModule, queried => ({ module, chunk }) => {
|
|
598
605
|
const originSource = module.source?.source;
|
|
599
606
|
queried.call(module, Chunk_1.Chunk.__from_binding(chunk, __classPrivateFieldGet(this, _Compiler_compilation, "f")));
|
|
@@ -748,30 +755,11 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
748
755
|
}),
|
|
749
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) => {
|
|
750
757
|
const data = bindingData
|
|
751
|
-
? (
|
|
752
|
-
resource: bindingData.resource,
|
|
753
|
-
regExp: bindingData.regExp
|
|
754
|
-
? new RegExp(bindingData.regExp.source, bindingData.regExp.flags)
|
|
755
|
-
: undefined,
|
|
756
|
-
request: bindingData.request,
|
|
757
|
-
context: bindingData.context,
|
|
758
|
-
// TODO: Dependencies are not fully supported yet; this is a placeholder to prevent errors in moment-locales-webpack-plugin.
|
|
759
|
-
dependencies: []
|
|
760
|
-
})
|
|
758
|
+
? Module_1.ContextModuleFactoryAfterResolveData.__from_binding(bindingData)
|
|
761
759
|
: false;
|
|
762
760
|
const ret = await queried.promise(data);
|
|
763
761
|
const result = ret
|
|
764
|
-
? (
|
|
765
|
-
resource: ret.resource,
|
|
766
|
-
context: ret.context,
|
|
767
|
-
request: ret.request,
|
|
768
|
-
regExp: ret.regExp
|
|
769
|
-
? {
|
|
770
|
-
source: ret.regExp.source,
|
|
771
|
-
flags: ret.regExp.flags
|
|
772
|
-
}
|
|
773
|
-
: undefined
|
|
774
|
-
})
|
|
762
|
+
? Module_1.ContextModuleFactoryAfterResolveData.__to_binding(ret)
|
|
775
763
|
: false;
|
|
776
764
|
return result;
|
|
777
765
|
}),
|
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/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);
|
package/dist/RspackError.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NonErrorEmittedError = exports.
|
|
3
|
+
exports.NonErrorEmittedError = exports.JsRspackDiagnostic = void 0;
|
|
4
4
|
const util_1 = require("./util");
|
|
5
|
-
class
|
|
5
|
+
class JsRspackDiagnostic {
|
|
6
6
|
static __to_binding(error, severity) {
|
|
7
7
|
return {
|
|
8
8
|
error: (0, util_1.concatErrorMsgAndStack)(error),
|
|
@@ -10,7 +10,7 @@ class JsDiagnostic {
|
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
exports.
|
|
13
|
+
exports.JsRspackDiagnostic = JsRspackDiagnostic;
|
|
14
14
|
class NonErrorEmittedError extends Error {
|
|
15
15
|
constructor(error) {
|
|
16
16
|
super();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { JsAddingRuntimeModule } from "@rspack/binding";
|
|
2
|
+
import type { Chunk } from "./Chunk";
|
|
3
|
+
import type { ChunkGraph } from "./ChunkGraph";
|
|
4
|
+
import type { Compilation } from "./Compilation";
|
|
5
|
+
export declare enum RuntimeModuleStage {
|
|
6
|
+
NORMAL = 0,
|
|
7
|
+
BASIC = 5,
|
|
8
|
+
ATTACH = 10,
|
|
9
|
+
TRIGGER = 20
|
|
10
|
+
}
|
|
11
|
+
export declare class RuntimeModule {
|
|
12
|
+
static STAGE_NORMAL: RuntimeModuleStage;
|
|
13
|
+
static STAGE_BASIC: RuntimeModuleStage;
|
|
14
|
+
static STAGE_ATTACH: RuntimeModuleStage;
|
|
15
|
+
static STAGE_TRIGGER: RuntimeModuleStage;
|
|
16
|
+
static __to_binding(compilation: Compilation, module: RuntimeModule): JsAddingRuntimeModule;
|
|
17
|
+
private _name;
|
|
18
|
+
private _stage;
|
|
19
|
+
fullHash: boolean;
|
|
20
|
+
dependentHash: boolean;
|
|
21
|
+
protected chunk: Chunk | null;
|
|
22
|
+
protected compilation: Compilation | null;
|
|
23
|
+
protected chunkGraph: ChunkGraph | null;
|
|
24
|
+
constructor(name: string, stage?: RuntimeModuleStage);
|
|
25
|
+
attach(compilation: Compilation, chunk: Chunk, chunkGraph: ChunkGraph): void;
|
|
26
|
+
get name(): string;
|
|
27
|
+
get stage(): RuntimeModuleStage;
|
|
28
|
+
identifier(): string;
|
|
29
|
+
readableIdentifier(): string;
|
|
30
|
+
shouldIsolate(): boolean;
|
|
31
|
+
generate(compilation: Compilation): string;
|
|
32
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RuntimeModule = exports.RuntimeModuleStage = void 0;
|
|
4
|
+
var RuntimeModuleStage;
|
|
5
|
+
(function (RuntimeModuleStage) {
|
|
6
|
+
RuntimeModuleStage[RuntimeModuleStage["NORMAL"] = 0] = "NORMAL";
|
|
7
|
+
RuntimeModuleStage[RuntimeModuleStage["BASIC"] = 5] = "BASIC";
|
|
8
|
+
RuntimeModuleStage[RuntimeModuleStage["ATTACH"] = 10] = "ATTACH";
|
|
9
|
+
RuntimeModuleStage[RuntimeModuleStage["TRIGGER"] = 20] = "TRIGGER";
|
|
10
|
+
})(RuntimeModuleStage = exports.RuntimeModuleStage || (exports.RuntimeModuleStage = {}));
|
|
11
|
+
class RuntimeModule {
|
|
12
|
+
static __to_binding(compilation, module) {
|
|
13
|
+
return {
|
|
14
|
+
name: module.name,
|
|
15
|
+
stage: module.stage,
|
|
16
|
+
generator: () => module.generate(compilation),
|
|
17
|
+
cacheable: !(module.fullHash || module.dependentHash),
|
|
18
|
+
isolate: module.shouldIsolate()
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
constructor(name, stage = RuntimeModuleStage.NORMAL) {
|
|
22
|
+
this.fullHash = false;
|
|
23
|
+
this.dependentHash = false;
|
|
24
|
+
this.chunk = null;
|
|
25
|
+
this.compilation = null;
|
|
26
|
+
this.chunkGraph = null;
|
|
27
|
+
this._name = name;
|
|
28
|
+
this._stage = stage;
|
|
29
|
+
}
|
|
30
|
+
attach(compilation, chunk, chunkGraph) {
|
|
31
|
+
this.compilation = compilation;
|
|
32
|
+
this.chunk = chunk;
|
|
33
|
+
this.chunkGraph = chunkGraph;
|
|
34
|
+
}
|
|
35
|
+
get name() {
|
|
36
|
+
return this._name;
|
|
37
|
+
}
|
|
38
|
+
get stage() {
|
|
39
|
+
return this._stage;
|
|
40
|
+
}
|
|
41
|
+
identifier() {
|
|
42
|
+
return `webpack/runtime/${this._name}`;
|
|
43
|
+
}
|
|
44
|
+
readableIdentifier() {
|
|
45
|
+
return `webpack/runtime/${this._name}`;
|
|
46
|
+
}
|
|
47
|
+
shouldIsolate() {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
generate(compilation) {
|
|
51
|
+
throw new Error(`Should implement "generate" method of runtime module "${this.name}"`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
RuntimeModule.STAGE_NORMAL = RuntimeModuleStage.NORMAL;
|
|
55
|
+
RuntimeModule.STAGE_BASIC = RuntimeModuleStage.BASIC;
|
|
56
|
+
RuntimeModule.STAGE_ATTACH = RuntimeModuleStage.ATTACH;
|
|
57
|
+
RuntimeModule.STAGE_TRIGGER = RuntimeModuleStage.TRIGGER;
|
|
58
|
+
exports.RuntimeModule = RuntimeModule;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BuiltinPluginName } from "@rspack/binding";
|
|
2
|
+
export declare const ContextReplacementPlugin: {
|
|
3
|
+
new (resourceRegExp: RegExp, newContentResource?: any, newContentRecursive?: any, newContentRegExp?: any): {
|
|
4
|
+
name: BuiltinPluginName;
|
|
5
|
+
_args: [resourceRegExp: RegExp, newContentResource?: any, newContentRecursive?: any, newContentRegExp?: any];
|
|
6
|
+
affectedHooks: "done" | "make" | "compile" | "emit" | "afterEmit" | "invalid" | "thisCompilation" | "afterDone" | "compilation" | "normalModuleFactory" | "contextModuleFactory" | "initialize" | "shouldEmit" | "infrastructureLog" | "beforeRun" | "run" | "assetEmitted" | "failed" | "shutdown" | "watchRun" | "watchClose" | "environment" | "afterEnvironment" | "afterPlugins" | "afterResolvers" | "beforeCompile" | "afterCompile" | "finishMake" | "entryOption" | undefined;
|
|
7
|
+
raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
|
|
8
|
+
apply(compiler: import("../Compiler").Compiler): void;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContextReplacementPlugin = void 0;
|
|
4
|
+
const binding_1 = require("@rspack/binding");
|
|
5
|
+
const base_1 = require("./base");
|
|
6
|
+
exports.ContextReplacementPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.ContextReplacementPlugin, (resourceRegExp, newContentResource, newContentRecursive, newContentRegExp) => {
|
|
7
|
+
const rawOptions = {
|
|
8
|
+
resourceRegExp
|
|
9
|
+
};
|
|
10
|
+
if (typeof newContentResource === "function") {
|
|
11
|
+
// rawOptions.newContentCallback = newContentResource;
|
|
12
|
+
}
|
|
13
|
+
else if (typeof newContentResource === "string" &&
|
|
14
|
+
typeof newContentRecursive === "object") {
|
|
15
|
+
rawOptions.newContentResource = newContentResource;
|
|
16
|
+
rawOptions.newContentCreateContextMap = newContentRecursive;
|
|
17
|
+
}
|
|
18
|
+
else if (typeof newContentResource === "string" &&
|
|
19
|
+
typeof newContentRecursive === "function") {
|
|
20
|
+
rawOptions.newContentResource = newContentResource;
|
|
21
|
+
// rawOptions.newContentCreateContextMap = newContentRecursive;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
if (typeof newContentResource !== "string") {
|
|
25
|
+
// biome-ignore lint/style/noParameterAssign: based on webpack's logic
|
|
26
|
+
newContentRegExp = newContentRecursive;
|
|
27
|
+
// biome-ignore lint/style/noParameterAssign: based on webpack's logic
|
|
28
|
+
newContentRecursive = newContentResource;
|
|
29
|
+
// biome-ignore lint/style/noParameterAssign: based on webpack's logic
|
|
30
|
+
newContentResource = undefined;
|
|
31
|
+
}
|
|
32
|
+
if (typeof newContentRecursive !== "boolean") {
|
|
33
|
+
// biome-ignore lint/style/noParameterAssign: based on webpack's logic
|
|
34
|
+
newContentRegExp = newContentRecursive;
|
|
35
|
+
// biome-ignore lint/style/noParameterAssign: based on webpack's logic
|
|
36
|
+
newContentRecursive = undefined;
|
|
37
|
+
}
|
|
38
|
+
rawOptions.newContentResource = newContentResource;
|
|
39
|
+
rawOptions.newContentRecursive = newContentRecursive;
|
|
40
|
+
rawOptions.newContentRegExp = newContentRegExp;
|
|
41
|
+
}
|
|
42
|
+
return rawOptions;
|
|
43
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BuiltinPluginName, type RawProgressPluginOptions } from "@rspack/binding";
|
|
2
|
-
export type ProgressPluginArgument = Partial<RawProgressPluginOptions
|
|
2
|
+
export type ProgressPluginArgument = Partial<Omit<RawProgressPluginOptions, "handler">> | ((percentage: number, msg: string, ...args: string[]) => void) | undefined;
|
|
3
3
|
export declare const ProgressPlugin: {
|
|
4
4
|
new (progress?: ProgressPluginArgument): {
|
|
5
5
|
name: BuiltinPluginName;
|
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ProgressPlugin = void 0;
|
|
4
4
|
const binding_1 = require("@rspack/binding");
|
|
5
5
|
const base_1 = require("./base");
|
|
6
|
-
exports.ProgressPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.ProgressPlugin, (progress = {}) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
6
|
+
exports.ProgressPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.ProgressPlugin, (progress = {}) => {
|
|
7
|
+
if (typeof progress === "function") {
|
|
8
|
+
return {
|
|
9
|
+
handler: (percentage, msg, items) => {
|
|
10
|
+
progress(percentage, msg, ...items);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
return progress;
|
|
15
|
+
});
|
|
@@ -81,3 +81,4 @@ __exportStar(require("./WebWorkerTemplatePlugin"), exports);
|
|
|
81
81
|
__exportStar(require("./WorkerPlugin"), exports);
|
|
82
82
|
__exportStar(require("./FetchCompileAsyncWasmPlugin"), exports);
|
|
83
83
|
__exportStar(require("./NoEmitOnErrorsPlugin"), exports);
|
|
84
|
+
__exportStar(require("./ContextReplacementPlugin"), exports);
|