@rspack/core 1.0.6 → 1.0.8
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 +2 -4
- package/dist/Compilation.js +8 -8
- package/dist/Compiler.js +5 -2
- package/dist/RuntimeModule.d.ts +1 -1
- package/dist/RuntimeModule.js +2 -2
- package/dist/builtin-plugin/BannerPlugin.d.ts +29 -177
- package/dist/builtin-plugin/BannerPlugin.js +0 -23
- package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +64 -110
- package/dist/builtin-plugin/IgnorePlugin.d.ts +3 -0
- package/dist/config/adapter.js +20 -4
- package/dist/config/browserslistTargetHandler.js +6 -5
- package/dist/config/defaults.js +11 -3
- package/dist/config/normalization.d.ts +2 -1
- package/dist/config/normalization.js +2 -1
- package/dist/config/zod.d.ts +164 -49
- package/dist/config/zod.js +11 -2
- package/dist/loader-runner/index.js +2 -1
- package/dist/util/hash/md4.d.ts +1 -19
- package/dist/util/hash/md4.js +12 -6
- package/dist/util/hash/wasm-hash.d.ts +1 -1
- package/dist/util/hash/wasm-hash.js +2 -1
- package/dist/util/hash/xxhash64.d.ts +1 -19
- package/dist/util/hash/xxhash64.js +12 -6
- package/package.json +3 -3
package/dist/Compilation.d.ts
CHANGED
|
@@ -164,10 +164,7 @@ export declare class Compilation {
|
|
|
164
164
|
Chunk,
|
|
165
165
|
Set<string>
|
|
166
166
|
], void>;
|
|
167
|
-
runtimeRequirementInTree: liteTapable.SyncBailHook<[
|
|
168
|
-
Chunk,
|
|
169
|
-
Set<string>
|
|
170
|
-
], void>;
|
|
167
|
+
runtimeRequirementInTree: liteTapable.HookMap<liteTapable.SyncBailHook<[Chunk, Set<string>], void>>;
|
|
171
168
|
runtimeModule: liteTapable.SyncHook<[JsRuntimeModule, Chunk], void>;
|
|
172
169
|
seal: liteTapable.SyncHook<[], void>;
|
|
173
170
|
afterSeal: liteTapable.AsyncSeriesHook<[], void>;
|
|
@@ -206,6 +203,7 @@ export declare class Compilation {
|
|
|
206
203
|
*/
|
|
207
204
|
get namedChunkGroups(): ReadonlyMap<string, Readonly<ChunkGroup>>;
|
|
208
205
|
get modules(): ReadonlySet<Module>;
|
|
206
|
+
get builtModules(): ReadonlySet<Module>;
|
|
209
207
|
get chunks(): ReadonlySet<Chunk>;
|
|
210
208
|
/**
|
|
211
209
|
* Get the named chunks.
|
package/dist/Compilation.js
CHANGED
|
@@ -160,10 +160,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
160
160
|
"chunk",
|
|
161
161
|
"runtimeRequirements"
|
|
162
162
|
]),
|
|
163
|
-
runtimeRequirementInTree: new liteTapable.SyncBailHook([
|
|
164
|
-
"chunk",
|
|
165
|
-
"runtimeRequirements"
|
|
166
|
-
]),
|
|
163
|
+
runtimeRequirementInTree: new liteTapable.HookMap(() => new liteTapable.SyncBailHook(["chunk", "runtimeRequirements"])),
|
|
167
164
|
runtimeModule: new liteTapable.SyncHook(["module", "chunk"]),
|
|
168
165
|
seal: new liteTapable.SyncHook([]),
|
|
169
166
|
afterSeal: new liteTapable.AsyncSeriesHook([])
|
|
@@ -224,6 +221,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
224
221
|
get modules() {
|
|
225
222
|
return new Set(__classPrivateFieldGet(this, _Compilation_inner, "f").modules.map(module => Module_1.Module.__from_binding(module, this)));
|
|
226
223
|
}
|
|
224
|
+
get builtModules() {
|
|
225
|
+
return new Set(__classPrivateFieldGet(this, _Compilation_inner, "f").builtModules.map(module => Module_1.Module.__from_binding(module, this)));
|
|
226
|
+
}
|
|
227
227
|
get chunks() {
|
|
228
228
|
return (0, memoize_1.memoizeValue)(() => new Set(this.__internal__getChunks()));
|
|
229
229
|
}
|
|
@@ -452,10 +452,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
452
452
|
}
|
|
453
453
|
];
|
|
454
454
|
for (const item of proxyMethod) {
|
|
455
|
-
const
|
|
455
|
+
const proxiedMethod = new Proxy(errors[item.method], {
|
|
456
456
|
apply: item.handler
|
|
457
457
|
});
|
|
458
|
-
errors[item.method] =
|
|
458
|
+
errors[item.method] = proxiedMethod;
|
|
459
459
|
}
|
|
460
460
|
return errors;
|
|
461
461
|
}
|
|
@@ -514,10 +514,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
|
514
514
|
}
|
|
515
515
|
];
|
|
516
516
|
for (const item of proxyMethod) {
|
|
517
|
-
const
|
|
517
|
+
const proxiedMethod = new Proxy(warnings[item.method], {
|
|
518
518
|
apply: item.handler
|
|
519
519
|
});
|
|
520
|
-
warnings[item.method] =
|
|
520
|
+
warnings[item.method] = proxiedMethod;
|
|
521
521
|
}
|
|
522
522
|
return warnings;
|
|
523
523
|
}
|
package/dist/Compiler.js
CHANGED
|
@@ -594,9 +594,12 @@ _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",
|
|
597
|
+
registerCompilationRuntimeRequirementInTree: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookMapRegisterTaps).call(this, binding.RegisterJsTapKind.CompilationRuntimeRequirementInTree, () => __classPrivateFieldGet(this, _Compiler_compilation, "f").hooks.runtimeRequirementInTree, queried => ({ chunk: rawChunk, runtimeRequirements }) => {
|
|
598
598
|
const set = (0, RuntimeGlobals_1.__from_binding_runtime_globals)(runtimeRequirements);
|
|
599
|
-
|
|
599
|
+
const chunk = Chunk_1.Chunk.__from_binding(rawChunk, __classPrivateFieldGet(this, _Compiler_compilation, "f"));
|
|
600
|
+
for (const r of set) {
|
|
601
|
+
queried.for(r).call(chunk, set);
|
|
602
|
+
}
|
|
600
603
|
return {
|
|
601
604
|
runtimeRequirements: (0, RuntimeGlobals_1.__to_binding_runtime_globals)(set)
|
|
602
605
|
};
|
package/dist/RuntimeModule.d.ts
CHANGED
package/dist/RuntimeModule.js
CHANGED
|
@@ -13,7 +13,7 @@ class RuntimeModule {
|
|
|
13
13
|
return {
|
|
14
14
|
name: module.name,
|
|
15
15
|
stage: module.stage,
|
|
16
|
-
generator:
|
|
16
|
+
generator: module.generate.bind(module),
|
|
17
17
|
cacheable: !(module.fullHash || module.dependentHash),
|
|
18
18
|
isolate: module.shouldIsolate()
|
|
19
19
|
};
|
|
@@ -47,7 +47,7 @@ class RuntimeModule {
|
|
|
47
47
|
shouldIsolate() {
|
|
48
48
|
return true;
|
|
49
49
|
}
|
|
50
|
-
generate(
|
|
50
|
+
generate() {
|
|
51
51
|
throw new Error(`Should implement "generate" method of runtime module "${this.name}"`);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -1,188 +1,40 @@
|
|
|
1
1
|
import { BuiltinPluginName, type JsChunk } from "@rspack/binding";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export type
|
|
5
|
-
declare const rules: z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">]>;
|
|
6
|
-
export type Rules = z.infer<typeof rules>;
|
|
7
|
-
declare const bannerFunction: z.ZodFunction<z.ZodTuple<[z.ZodObject<{
|
|
8
|
-
hash: z.ZodString;
|
|
9
|
-
chunk: z.ZodType<JsChunk, z.ZodTypeDef, JsChunk>;
|
|
10
|
-
filename: z.ZodString;
|
|
11
|
-
}, "strip", z.ZodTypeAny, {
|
|
12
|
-
filename: string;
|
|
13
|
-
hash: string;
|
|
14
|
-
chunk: JsChunk;
|
|
15
|
-
}, {
|
|
16
|
-
filename: string;
|
|
17
|
-
hash: string;
|
|
18
|
-
chunk: JsChunk;
|
|
19
|
-
}>], z.ZodUnknown>, z.ZodString>;
|
|
20
|
-
export type BannerFunction = z.infer<typeof bannerFunction>;
|
|
21
|
-
declare const bannerContent: z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodObject<{
|
|
22
|
-
hash: z.ZodString;
|
|
23
|
-
chunk: z.ZodType<JsChunk, z.ZodTypeDef, JsChunk>;
|
|
24
|
-
filename: z.ZodString;
|
|
25
|
-
}, "strip", z.ZodTypeAny, {
|
|
26
|
-
filename: string;
|
|
27
|
-
hash: string;
|
|
28
|
-
chunk: JsChunk;
|
|
29
|
-
}, {
|
|
30
|
-
filename: string;
|
|
31
|
-
hash: string;
|
|
32
|
-
chunk: JsChunk;
|
|
33
|
-
}>], z.ZodUnknown>, z.ZodString>]>;
|
|
34
|
-
export type BannerContent = z.infer<typeof bannerContent>;
|
|
35
|
-
declare const bannerPluginOptions: z.ZodObject<{
|
|
36
|
-
banner: z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodObject<{
|
|
37
|
-
hash: z.ZodString;
|
|
38
|
-
chunk: z.ZodType<JsChunk, z.ZodTypeDef, JsChunk>;
|
|
39
|
-
filename: z.ZodString;
|
|
40
|
-
}, "strip", z.ZodTypeAny, {
|
|
41
|
-
filename: string;
|
|
42
|
-
hash: string;
|
|
43
|
-
chunk: JsChunk;
|
|
44
|
-
}, {
|
|
45
|
-
filename: string;
|
|
46
|
-
hash: string;
|
|
47
|
-
chunk: JsChunk;
|
|
48
|
-
}>], z.ZodUnknown>, z.ZodString>]>;
|
|
49
|
-
entryOnly: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
-
exclude: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">]>>;
|
|
51
|
-
include: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">]>>;
|
|
52
|
-
raw: z.ZodOptional<z.ZodBoolean>;
|
|
53
|
-
footer: z.ZodOptional<z.ZodBoolean>;
|
|
54
|
-
stage: z.ZodOptional<z.ZodNumber>;
|
|
55
|
-
test: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, z.ZodArray<z.ZodUnion<[z.ZodString, z.ZodType<RegExp, z.ZodTypeDef, RegExp>]>, "many">]>>;
|
|
56
|
-
}, "strict", z.ZodTypeAny, {
|
|
57
|
-
banner: string | ((args_0: {
|
|
58
|
-
filename: string;
|
|
59
|
-
hash: string;
|
|
60
|
-
chunk: JsChunk;
|
|
61
|
-
}, ...args_1: unknown[]) => string);
|
|
62
|
-
entryOnly?: boolean | undefined;
|
|
63
|
-
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
64
|
-
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
65
|
-
raw?: boolean | undefined;
|
|
66
|
-
footer?: boolean | undefined;
|
|
67
|
-
stage?: number | undefined;
|
|
68
|
-
test?: string | RegExp | (string | RegExp)[] | undefined;
|
|
69
|
-
}, {
|
|
70
|
-
banner: string | ((args_0: {
|
|
71
|
-
filename: string;
|
|
72
|
-
hash: string;
|
|
73
|
-
chunk: JsChunk;
|
|
74
|
-
}, ...args_1: unknown[]) => string);
|
|
75
|
-
entryOnly?: boolean | undefined;
|
|
76
|
-
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
77
|
-
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
78
|
-
raw?: boolean | undefined;
|
|
79
|
-
footer?: boolean | undefined;
|
|
80
|
-
stage?: number | undefined;
|
|
81
|
-
test?: string | RegExp | (string | RegExp)[] | undefined;
|
|
82
|
-
}>;
|
|
83
|
-
export type BannerPluginOptions = z.infer<typeof bannerPluginOptions>;
|
|
84
|
-
declare const bannerPluginArgument: z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodFunction<z.ZodTuple<[z.ZodObject<{
|
|
85
|
-
hash: z.ZodString;
|
|
86
|
-
chunk: z.ZodType<JsChunk, z.ZodTypeDef, JsChunk>;
|
|
87
|
-
filename: z.ZodString;
|
|
88
|
-
}, "strip", z.ZodTypeAny, {
|
|
89
|
-
filename: string;
|
|
2
|
+
export type Rule = string | RegExp;
|
|
3
|
+
export type Rules = Rule[] | Rule;
|
|
4
|
+
export type BannerFunction = (args: {
|
|
90
5
|
hash: string;
|
|
91
6
|
chunk: JsChunk;
|
|
92
|
-
}, {
|
|
93
7
|
filename: string;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
banner
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
banner: string | ((args_0: {
|
|
119
|
-
filename: string;
|
|
120
|
-
hash: string;
|
|
121
|
-
chunk: JsChunk;
|
|
122
|
-
}, ...args_1: unknown[]) => string);
|
|
123
|
-
entryOnly?: boolean | undefined;
|
|
124
|
-
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
125
|
-
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
126
|
-
raw?: boolean | undefined;
|
|
127
|
-
footer?: boolean | undefined;
|
|
128
|
-
stage?: number | undefined;
|
|
129
|
-
test?: string | RegExp | (string | RegExp)[] | undefined;
|
|
130
|
-
}, {
|
|
131
|
-
banner: string | ((args_0: {
|
|
132
|
-
filename: string;
|
|
133
|
-
hash: string;
|
|
134
|
-
chunk: JsChunk;
|
|
135
|
-
}, ...args_1: unknown[]) => string);
|
|
136
|
-
entryOnly?: boolean | undefined;
|
|
137
|
-
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
138
|
-
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
139
|
-
raw?: boolean | undefined;
|
|
140
|
-
footer?: boolean | undefined;
|
|
141
|
-
stage?: number | undefined;
|
|
142
|
-
test?: string | RegExp | (string | RegExp)[] | undefined;
|
|
143
|
-
}>]>;
|
|
144
|
-
export type BannerPluginArgument = z.infer<typeof bannerPluginArgument>;
|
|
8
|
+
}) => string;
|
|
9
|
+
export type BannerContent = string | BannerFunction;
|
|
10
|
+
export type BannerPluginOptions = {
|
|
11
|
+
/** Specifies the banner, it will be wrapped in a comment. */
|
|
12
|
+
banner: BannerContent;
|
|
13
|
+
/** If true, the banner will only be added to the entry chunks. */
|
|
14
|
+
entryOnly?: boolean;
|
|
15
|
+
/** Exclude all modules matching any of these conditions. */
|
|
16
|
+
exclude?: Rules;
|
|
17
|
+
/** Include all modules matching any of these conditions. */
|
|
18
|
+
include?: Rules;
|
|
19
|
+
/** If true, banner will not be wrapped in a comment. */
|
|
20
|
+
raw?: boolean;
|
|
21
|
+
/** If true, banner will be placed at the end of the output. */
|
|
22
|
+
footer?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The stage of the compilation in which the banner should be injected.
|
|
25
|
+
* @default PROCESS_ASSETS_STAGE_ADDITIONS (-100)
|
|
26
|
+
*/
|
|
27
|
+
stage?: number;
|
|
28
|
+
/** Include all modules that pass test assertion. */
|
|
29
|
+
test?: Rules;
|
|
30
|
+
};
|
|
31
|
+
export type BannerPluginArgument = BannerContent | BannerPluginOptions;
|
|
145
32
|
export declare const BannerPlugin: {
|
|
146
|
-
new (args:
|
|
147
|
-
filename: string;
|
|
148
|
-
hash: string;
|
|
149
|
-
chunk: JsChunk;
|
|
150
|
-
}, ...args_1: unknown[]) => string) | {
|
|
151
|
-
banner: string | ((args_0: {
|
|
152
|
-
filename: string;
|
|
153
|
-
hash: string;
|
|
154
|
-
chunk: JsChunk;
|
|
155
|
-
}, ...args_1: unknown[]) => string);
|
|
156
|
-
entryOnly?: boolean | undefined;
|
|
157
|
-
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
158
|
-
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
159
|
-
raw?: boolean | undefined;
|
|
160
|
-
footer?: boolean | undefined;
|
|
161
|
-
stage?: number | undefined;
|
|
162
|
-
test?: string | RegExp | (string | RegExp)[] | undefined;
|
|
163
|
-
}): {
|
|
33
|
+
new (args: BannerPluginArgument): {
|
|
164
34
|
name: BuiltinPluginName;
|
|
165
|
-
_args: [args:
|
|
166
|
-
filename: string;
|
|
167
|
-
hash: string;
|
|
168
|
-
chunk: JsChunk;
|
|
169
|
-
}, ...args_1: unknown[]) => string) | {
|
|
170
|
-
banner: string | ((args_0: {
|
|
171
|
-
filename: string;
|
|
172
|
-
hash: string;
|
|
173
|
-
chunk: JsChunk;
|
|
174
|
-
}, ...args_1: unknown[]) => string);
|
|
175
|
-
entryOnly?: boolean | undefined;
|
|
176
|
-
exclude?: string | RegExp | (string | RegExp)[] | undefined;
|
|
177
|
-
include?: string | RegExp | (string | RegExp)[] | undefined;
|
|
178
|
-
raw?: boolean | undefined;
|
|
179
|
-
footer?: boolean | undefined;
|
|
180
|
-
stage?: number | undefined;
|
|
181
|
-
test?: string | RegExp | (string | RegExp)[] | undefined;
|
|
182
|
-
}];
|
|
35
|
+
_args: [args: BannerPluginArgument];
|
|
183
36
|
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;
|
|
184
37
|
raw(compiler: import("../Compiler").Compiler): import("@rspack/binding").BuiltinPlugin;
|
|
185
38
|
apply(compiler: import("../Compiler").Compiler): void;
|
|
186
39
|
};
|
|
187
40
|
};
|
|
188
|
-
export {};
|
|
@@ -2,30 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BannerPlugin = void 0;
|
|
4
4
|
const binding_1 = require("@rspack/binding");
|
|
5
|
-
const zod_1 = require("../../compiled/zod");
|
|
6
5
|
const base_1 = require("./base");
|
|
7
|
-
const rule = zod_1.z.string().or(zod_1.z.instanceof(RegExp));
|
|
8
|
-
const rules = rule.or(rule.array());
|
|
9
|
-
const bannerFunction = zod_1.z
|
|
10
|
-
.function()
|
|
11
|
-
.args(zod_1.z.object({
|
|
12
|
-
hash: zod_1.z.string(),
|
|
13
|
-
chunk: zod_1.z.custom(),
|
|
14
|
-
filename: zod_1.z.string()
|
|
15
|
-
}))
|
|
16
|
-
.returns(zod_1.z.string());
|
|
17
|
-
const bannerContent = zod_1.z.string().or(bannerFunction);
|
|
18
|
-
const bannerPluginOptions = zod_1.z.strictObject({
|
|
19
|
-
banner: bannerContent,
|
|
20
|
-
entryOnly: zod_1.z.boolean().optional(),
|
|
21
|
-
exclude: rules.optional(),
|
|
22
|
-
include: rules.optional(),
|
|
23
|
-
raw: zod_1.z.boolean().optional(),
|
|
24
|
-
footer: zod_1.z.boolean().optional(),
|
|
25
|
-
stage: zod_1.z.number().optional(),
|
|
26
|
-
test: rules.optional()
|
|
27
|
-
});
|
|
28
|
-
const bannerPluginArgument = bannerContent.or(bannerPluginOptions);
|
|
29
6
|
exports.BannerPlugin = (0, base_1.create)(binding_1.BuiltinPluginName.BannerPlugin, (args) => {
|
|
30
7
|
if (typeof args === "string" || typeof args === "function") {
|
|
31
8
|
return {
|
|
@@ -1,76 +1,70 @@
|
|
|
1
1
|
import { BuiltinPluginName, type JsAfterEmitData, type JsAfterTemplateExecutionData, type JsAlterAssetTagGroupsData, type JsAlterAssetTagsData, type JsBeforeAssetTagGenerationData, type JsBeforeEmitData, type JsHtmlPluginTag } from "@rspack/binding";
|
|
2
2
|
import * as liteTapable from "@rspack/lite-tapable";
|
|
3
|
-
import { z } from "../../compiled/zod";
|
|
4
3
|
import { Compilation } from "../Compilation";
|
|
5
4
|
import type { Compiler } from "../Compiler";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
publicPath?: string
|
|
35
|
-
|
|
36
|
-
chunks?: string[] | undefined;
|
|
5
|
+
export type TemplateRenderFunction = (params: Record<string, any>) => string | Promise<string>;
|
|
6
|
+
export type TemplateParamFunction = (params: Record<string, any>) => Record<string, any> | Promise<Record<string, any>>;
|
|
7
|
+
export type HtmlRspackPluginOptions = {
|
|
8
|
+
/** The title to use for the generated HTML document. */
|
|
9
|
+
title?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The file to write the HTML to. You can specify a subdirectory here too (eg: pages/index.html).
|
|
12
|
+
* @default 'index.html'
|
|
13
|
+
*/
|
|
14
|
+
filename?: string;
|
|
15
|
+
/** The template file path. */
|
|
16
|
+
template?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The template file content, priority is greater than template.
|
|
19
|
+
* When using a function, pass in the template parameters and use the returned string as the template content.
|
|
20
|
+
*/
|
|
21
|
+
templateContent?: string | TemplateRenderFunction;
|
|
22
|
+
/**
|
|
23
|
+
* Allows to overwrite the parameters used in the template.
|
|
24
|
+
* When using a function, pass in the original template parameters and use the returned object as the final template parameters.
|
|
25
|
+
*/
|
|
26
|
+
templateParameters?: Record<string, string> | boolean | TemplateParamFunction;
|
|
27
|
+
/**
|
|
28
|
+
* The script and link tag inject position in template. Use false to not inject.
|
|
29
|
+
* If not specified, it will be automatically determined based on scriptLoading.
|
|
30
|
+
*/
|
|
31
|
+
inject?: boolean | "head" | "body";
|
|
32
|
+
/** The publicPath used for script and link tags. */
|
|
33
|
+
publicPath?: string;
|
|
34
|
+
/** Inject a [base](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) tag */
|
|
37
35
|
base?: string | {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
favicon?: string | undefined;
|
|
71
|
-
meta?: Record<string, string | Record<string, string>> | undefined;
|
|
72
|
-
}>;
|
|
73
|
-
export type HtmlRspackPluginOptions = z.infer<typeof htmlRspackPluginOptions>;
|
|
36
|
+
href?: string;
|
|
37
|
+
target?: "_self" | "_blank" | "_parent" | "_top";
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Modern browsers support non blocking javascript loading ('defer') to improve the page startup performance.
|
|
41
|
+
* Setting to 'module' adds attribute type='module'.
|
|
42
|
+
* This also implies 'defer', since modules are automatically deferred.
|
|
43
|
+
* @default 'defer'
|
|
44
|
+
* */
|
|
45
|
+
scriptLoading?: "blocking" | "defer" | "module" | "systemjs-module";
|
|
46
|
+
/** Allows you to add only some chunks. */
|
|
47
|
+
chunks?: string[];
|
|
48
|
+
/** Allows you to skip some chunks. */
|
|
49
|
+
excludeChunks?: string[];
|
|
50
|
+
/** The sri hash algorithm, disabled by default. */
|
|
51
|
+
sri?: "sha256" | "sha384" | "sha512";
|
|
52
|
+
/**
|
|
53
|
+
* Controls whether to minify the output.
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
minify?: boolean;
|
|
57
|
+
/** Adds the given favicon path to the output HTML. */
|
|
58
|
+
favicon?: string;
|
|
59
|
+
/**
|
|
60
|
+
* If true then append a unique rspack compilation hash to all included scripts and CSS files.
|
|
61
|
+
* This is useful for cache busting
|
|
62
|
+
* @default false
|
|
63
|
+
* */
|
|
64
|
+
meta?: Record<string, string | Record<string, string>>;
|
|
65
|
+
/** Inject a base tag */
|
|
66
|
+
hash?: boolean;
|
|
67
|
+
};
|
|
74
68
|
type ExtraPluginHookData = {
|
|
75
69
|
plugin: {
|
|
76
70
|
options: HtmlRspackPluginOptions;
|
|
@@ -95,49 +89,9 @@ export type HtmlRspackPluginHooks = {
|
|
|
95
89
|
]>;
|
|
96
90
|
};
|
|
97
91
|
declare const HtmlRspackPlugin: {
|
|
98
|
-
new (c?: {
|
|
99
|
-
filename?: string | undefined;
|
|
100
|
-
publicPath?: string | undefined;
|
|
101
|
-
hash?: boolean | undefined;
|
|
102
|
-
chunks?: string[] | undefined;
|
|
103
|
-
base?: string | {
|
|
104
|
-
target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
|
|
105
|
-
href?: string | undefined;
|
|
106
|
-
} | undefined;
|
|
107
|
-
template?: string | undefined;
|
|
108
|
-
templateContent?: string | ((args_0: Record<string, any>, ...args_1: unknown[]) => string | Promise<string>) | undefined;
|
|
109
|
-
templateParameters?: boolean | Record<string, string> | ((args_0: Record<string, any>, ...args_1: unknown[]) => Record<string, any> | Promise<Record<string, any>>) | undefined;
|
|
110
|
-
inject?: boolean | "head" | "body" | undefined;
|
|
111
|
-
scriptLoading?: "module" | "blocking" | "defer" | "systemjs-module" | undefined;
|
|
112
|
-
excludeChunks?: string[] | undefined;
|
|
113
|
-
sri?: "sha256" | "sha384" | "sha512" | undefined;
|
|
114
|
-
minify?: boolean | undefined;
|
|
115
|
-
title?: string | undefined;
|
|
116
|
-
favicon?: string | undefined;
|
|
117
|
-
meta?: Record<string, string | Record<string, string>> | undefined;
|
|
118
|
-
} | undefined): {
|
|
92
|
+
new (c?: HtmlRspackPluginOptions | undefined): {
|
|
119
93
|
name: BuiltinPluginName;
|
|
120
|
-
_args: [c?:
|
|
121
|
-
filename?: string | undefined;
|
|
122
|
-
publicPath?: string | undefined;
|
|
123
|
-
hash?: boolean | undefined;
|
|
124
|
-
chunks?: string[] | undefined;
|
|
125
|
-
base?: string | {
|
|
126
|
-
target?: "_self" | "_blank" | "_parent" | "_top" | undefined;
|
|
127
|
-
href?: string | undefined;
|
|
128
|
-
} | undefined;
|
|
129
|
-
template?: string | undefined;
|
|
130
|
-
templateContent?: string | ((args_0: Record<string, any>, ...args_1: unknown[]) => string | Promise<string>) | undefined;
|
|
131
|
-
templateParameters?: boolean | Record<string, string> | ((args_0: Record<string, any>, ...args_1: unknown[]) => Record<string, any> | Promise<Record<string, any>>) | undefined;
|
|
132
|
-
inject?: boolean | "head" | "body" | undefined;
|
|
133
|
-
scriptLoading?: "module" | "blocking" | "defer" | "systemjs-module" | undefined;
|
|
134
|
-
excludeChunks?: string[] | undefined;
|
|
135
|
-
sri?: "sha256" | "sha384" | "sha512" | undefined;
|
|
136
|
-
minify?: boolean | undefined;
|
|
137
|
-
title?: string | undefined;
|
|
138
|
-
favicon?: string | undefined;
|
|
139
|
-
meta?: Record<string, string | Record<string, string>> | undefined;
|
|
140
|
-
} | undefined];
|
|
94
|
+
_args: [c?: HtmlRspackPluginOptions | undefined];
|
|
141
95
|
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;
|
|
142
96
|
raw(compiler: Compiler): import("@rspack/binding").BuiltinPlugin;
|
|
143
97
|
apply(compiler: Compiler): void;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { BuiltinPluginName, type RawIgnorePluginOptions } from "@rspack/binding";
|
|
2
2
|
export type IgnorePluginOptions = {
|
|
3
|
+
/** A RegExp to test the resource against. */
|
|
3
4
|
resourceRegExp: NonNullable<RawIgnorePluginOptions["resourceRegExp"]>;
|
|
5
|
+
/** A RegExp to test the context (directory) against. */
|
|
4
6
|
contextRegExp?: RawIgnorePluginOptions["contextRegExp"];
|
|
5
7
|
} | {
|
|
8
|
+
/** A Filter function that receives `resource` and `context` as arguments, must return boolean. */
|
|
6
9
|
checkResource: NonNullable<RawIgnorePluginOptions["checkResource"]>;
|
|
7
10
|
};
|
|
8
11
|
export declare const IgnorePlugin: {
|
package/dist/config/adapter.js
CHANGED
|
@@ -635,19 +635,35 @@ function getRawSnapshotOptions(_snapshot) {
|
|
|
635
635
|
return {};
|
|
636
636
|
}
|
|
637
637
|
function getRawExperiments(experiments) {
|
|
638
|
-
const { topLevelAwait, layers, rspackFuture } = experiments;
|
|
639
|
-
(0, node_assert_1.default)(!(0, util_1.isNil)(topLevelAwait) &&
|
|
638
|
+
const { topLevelAwait, layers, incremental, rspackFuture } = experiments;
|
|
639
|
+
(0, node_assert_1.default)(!(0, util_1.isNil)(topLevelAwait) &&
|
|
640
|
+
!(0, util_1.isNil)(rspackFuture) &&
|
|
641
|
+
!(0, util_1.isNil)(layers) &&
|
|
642
|
+
!(0, util_1.isNil)(incremental));
|
|
640
643
|
return {
|
|
641
644
|
layers,
|
|
642
645
|
topLevelAwait,
|
|
646
|
+
incremental: getRawIncremental(incremental),
|
|
643
647
|
rspackFuture: getRawRspackFutureOptions(rspackFuture)
|
|
644
648
|
};
|
|
645
649
|
}
|
|
646
|
-
function
|
|
650
|
+
function getRawIncremental(incremental) {
|
|
651
|
+
if (incremental === false) {
|
|
652
|
+
return undefined;
|
|
653
|
+
}
|
|
647
654
|
return {
|
|
648
|
-
|
|
655
|
+
make: incremental.make,
|
|
656
|
+
emitAssets: incremental.emitAssets,
|
|
657
|
+
inferAsyncModules: incremental.inferAsyncModules,
|
|
658
|
+
providedExports: incremental.providedExports,
|
|
659
|
+
moduleHashes: incremental.moduleHashes,
|
|
660
|
+
moduleCodegen: incremental.moduleCodegen,
|
|
661
|
+
moduleRuntimeRequirements: incremental.moduleRuntimeRequirements
|
|
649
662
|
};
|
|
650
663
|
}
|
|
664
|
+
function getRawRspackFutureOptions(future) {
|
|
665
|
+
return {};
|
|
666
|
+
}
|
|
651
667
|
function getRawNode(node) {
|
|
652
668
|
if (node === false) {
|
|
653
669
|
return undefined;
|