@rspack/core 1.0.9 → 1.0.10
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/Compiler.js +10 -5
- package/dist/DependenciesBlock.js +1 -1
- package/dist/Dependency.d.ts +7 -6
- package/dist/Dependency.js +35 -24
- package/dist/Module.d.ts +19 -17
- package/dist/Module.js +132 -49
- package/dist/config/types.d.ts +236 -0
- package/dist/config/zod.d.ts +157 -790
- package/dist/config/zod.js +2 -0
- package/dist/loader-runner/index.js +1 -1
- package/package.json +2 -2
package/dist/Compiler.js
CHANGED
|
@@ -754,17 +754,22 @@ _Compiler_instance = new WeakMap(), _Compiler_initial = new WeakMap(), _Compiler
|
|
|
754
754
|
await queried.promise(data, {});
|
|
755
755
|
}),
|
|
756
756
|
registerContextModuleFactoryBeforeResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryBeforeResolve, () => __classPrivateFieldGet(this, _Compiler_compilationParams, "f").contextModuleFactory.hooks.beforeResolve, queried => async (bindingData) => {
|
|
757
|
-
|
|
757
|
+
const data = bindingData
|
|
758
|
+
? Module_1.ContextModuleFactoryBeforeResolveData.__from_binding(bindingData)
|
|
759
|
+
: false;
|
|
760
|
+
const result = await queried.promise(data);
|
|
761
|
+
return result
|
|
762
|
+
? Module_1.ContextModuleFactoryBeforeResolveData.__to_binding(result)
|
|
763
|
+
: false;
|
|
758
764
|
}),
|
|
759
765
|
registerContextModuleFactoryAfterResolveTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.ContextModuleFactoryAfterResolve, () => __classPrivateFieldGet(this, _Compiler_compilationParams, "f").contextModuleFactory.hooks.afterResolve, queried => async (bindingData) => {
|
|
760
766
|
const data = bindingData
|
|
761
767
|
? Module_1.ContextModuleFactoryAfterResolveData.__from_binding(bindingData)
|
|
762
768
|
: false;
|
|
763
|
-
const
|
|
764
|
-
|
|
765
|
-
? Module_1.ContextModuleFactoryAfterResolveData.__to_binding(
|
|
769
|
+
const result = await queried.promise(data);
|
|
770
|
+
return result
|
|
771
|
+
? Module_1.ContextModuleFactoryAfterResolveData.__to_binding(result)
|
|
766
772
|
: false;
|
|
767
|
-
return result;
|
|
768
773
|
}),
|
|
769
774
|
registerJavascriptModulesChunkHashTaps: __classPrivateFieldGet(this, _Compiler_instances, "m", _Compiler_createHookRegisterTaps).call(this, binding.RegisterJsTapKind.JavascriptModulesChunkHash, () => builtin_plugin_1.JavascriptModulesPlugin.getCompilationHooks(__classPrivateFieldGet(this, _Compiler_compilation, "f"))
|
|
770
775
|
.chunkHash, queried => (chunk) => {
|
|
@@ -20,7 +20,7 @@ class DependenciesBlock {
|
|
|
20
20
|
__classPrivateFieldSet(this, _DependenciesBlock_binding, binding, "f");
|
|
21
21
|
}
|
|
22
22
|
get dependencies() {
|
|
23
|
-
return __classPrivateFieldGet(this, _DependenciesBlock_binding, "f").dependencies.map(d =>
|
|
23
|
+
return __classPrivateFieldGet(this, _DependenciesBlock_binding, "f").dependencies.map(d => Dependency_1.Dependency.__from_binding(d));
|
|
24
24
|
}
|
|
25
25
|
get blocks() {
|
|
26
26
|
return __classPrivateFieldGet(this, _DependenciesBlock_binding, "f").blocks.map(b => new DependenciesBlock(b));
|
package/dist/Dependency.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type JsDependency, JsDependencyMut } from "@rspack/binding";
|
|
2
2
|
export declare class Dependency {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
readonly type: string;
|
|
4
|
+
readonly category: string;
|
|
5
|
+
readonly request: string | undefined;
|
|
6
|
+
critical: boolean;
|
|
7
|
+
static __from_binding(binding: JsDependencyMut | JsDependency): Dependency;
|
|
8
|
+
private constructor();
|
|
8
9
|
}
|
package/dist/Dependency.js
CHANGED
|
@@ -1,32 +1,43 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
3
|
exports.Dependency = void 0;
|
|
4
|
+
const binding_1 = require("@rspack/binding");
|
|
16
5
|
class Dependency {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
__classPrivateFieldSet(this, _Dependency_binding, binding, "f");
|
|
20
|
-
}
|
|
21
|
-
get type() {
|
|
22
|
-
return __classPrivateFieldGet(this, _Dependency_binding, "f").type;
|
|
6
|
+
static __from_binding(binding) {
|
|
7
|
+
return new Dependency(binding);
|
|
23
8
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
9
|
+
constructor(binding) {
|
|
10
|
+
Object.defineProperties(this, {
|
|
11
|
+
type: {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get() {
|
|
14
|
+
return binding.type;
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
category: {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get() {
|
|
20
|
+
return binding.category;
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
request: {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get() {
|
|
26
|
+
return binding.request;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
critical: {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get() {
|
|
32
|
+
return binding.critical;
|
|
33
|
+
},
|
|
34
|
+
set(val) {
|
|
35
|
+
if (binding instanceof binding_1.JsDependencyMut) {
|
|
36
|
+
binding.critical = val;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
29
41
|
}
|
|
30
42
|
}
|
|
31
43
|
exports.Dependency = Dependency;
|
|
32
|
-
_Dependency_binding = new WeakMap();
|
package/dist/Module.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { JsCodegenerationResult, JsContextModuleFactoryAfterResolveData, JsCreateData, JsFactoryMeta, JsModule, ModuleDTO } from "@rspack/binding";
|
|
1
|
+
import type { JsCodegenerationResult, JsContextModuleFactoryAfterResolveData, JsContextModuleFactoryBeforeResolveData, 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
|
|
5
|
+
import { Dependency } from "./Dependency";
|
|
6
6
|
export type ResourceData = {
|
|
7
7
|
resource: string;
|
|
8
8
|
path: string;
|
|
@@ -25,26 +25,28 @@ export type ResolveData = {
|
|
|
25
25
|
contextDependencies: string[];
|
|
26
26
|
createData?: CreateData;
|
|
27
27
|
};
|
|
28
|
-
export
|
|
28
|
+
export declare class ContextModuleFactoryBeforeResolveData {
|
|
29
|
+
#private;
|
|
29
30
|
context: string;
|
|
30
|
-
request
|
|
31
|
-
|
|
31
|
+
request: string;
|
|
32
|
+
regExp: RegExp | undefined;
|
|
33
|
+
recursive: boolean;
|
|
34
|
+
static __from_binding(binding: JsContextModuleFactoryBeforeResolveData): ContextModuleFactoryBeforeResolveData;
|
|
35
|
+
static __to_binding(data: ContextModuleFactoryBeforeResolveData): JsContextModuleFactoryBeforeResolveData;
|
|
36
|
+
private constructor();
|
|
37
|
+
}
|
|
38
|
+
export type ContextModuleFactoryBeforeResolveResult = false | ContextModuleFactoryBeforeResolveData;
|
|
32
39
|
export declare class ContextModuleFactoryAfterResolveData {
|
|
33
40
|
#private;
|
|
41
|
+
resource: number;
|
|
42
|
+
context: string;
|
|
43
|
+
request: string;
|
|
44
|
+
regExp: RegExp | undefined;
|
|
45
|
+
recursive: boolean;
|
|
46
|
+
readonly dependencies: Dependency[];
|
|
34
47
|
static __from_binding(binding: JsContextModuleFactoryAfterResolveData): ContextModuleFactoryAfterResolveData;
|
|
35
48
|
static __to_binding(data: ContextModuleFactoryAfterResolveData): JsContextModuleFactoryAfterResolveData;
|
|
36
|
-
constructor(
|
|
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[];
|
|
49
|
+
private constructor();
|
|
48
50
|
}
|
|
49
51
|
export type ContextModuleFactoryAfterResolveResult = false | ContextModuleFactoryAfterResolveData;
|
|
50
52
|
export declare class Module {
|
package/dist/Module.js
CHANGED
|
@@ -10,11 +10,75 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (
|
|
|
10
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");
|
|
11
11
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
12
12
|
};
|
|
13
|
-
var _ContextModuleFactoryAfterResolveData_inner, _Module_inner, _Module_originalSource, _CodeGenerationResult_inner;
|
|
13
|
+
var _ContextModuleFactoryBeforeResolveData_inner, _ContextModuleFactoryAfterResolveData_inner, _Module_inner, _Module_originalSource, _CodeGenerationResult_inner;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.CodeGenerationResults = exports.CodeGenerationResult = exports.Module = exports.ContextModuleFactoryAfterResolveData = void 0;
|
|
15
|
+
exports.CodeGenerationResults = exports.CodeGenerationResult = exports.Module = exports.ContextModuleFactoryAfterResolveData = exports.ContextModuleFactoryBeforeResolveData = void 0;
|
|
16
16
|
const DependenciesBlock_1 = require("./DependenciesBlock");
|
|
17
|
+
const Dependency_1 = require("./Dependency");
|
|
17
18
|
const source_1 = require("./util/source");
|
|
19
|
+
class ContextModuleFactoryBeforeResolveData {
|
|
20
|
+
static __from_binding(binding) {
|
|
21
|
+
return new ContextModuleFactoryBeforeResolveData(binding);
|
|
22
|
+
}
|
|
23
|
+
static __to_binding(data) {
|
|
24
|
+
return __classPrivateFieldGet(data, _ContextModuleFactoryBeforeResolveData_inner, "f");
|
|
25
|
+
}
|
|
26
|
+
constructor(binding) {
|
|
27
|
+
_ContextModuleFactoryBeforeResolveData_inner.set(this, void 0);
|
|
28
|
+
__classPrivateFieldSet(this, _ContextModuleFactoryBeforeResolveData_inner, binding, "f");
|
|
29
|
+
Object.defineProperties(this, {
|
|
30
|
+
context: {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get() {
|
|
33
|
+
return binding.context;
|
|
34
|
+
},
|
|
35
|
+
set(val) {
|
|
36
|
+
binding.context = val;
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
request: {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get() {
|
|
42
|
+
return binding.request;
|
|
43
|
+
},
|
|
44
|
+
set(val) {
|
|
45
|
+
binding.request = val;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
regExp: {
|
|
49
|
+
enumerable: true,
|
|
50
|
+
get() {
|
|
51
|
+
if (!binding.regExp) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
const { source, flags } = binding.regExp;
|
|
55
|
+
return new RegExp(source, flags);
|
|
56
|
+
},
|
|
57
|
+
set(val) {
|
|
58
|
+
if (!val) {
|
|
59
|
+
binding.regExp = undefined;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
binding.regExp = {
|
|
63
|
+
source: val.source,
|
|
64
|
+
flags: val.flags
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
recursive: {
|
|
69
|
+
enumerable: true,
|
|
70
|
+
get() {
|
|
71
|
+
return binding.recursive;
|
|
72
|
+
},
|
|
73
|
+
set(val) {
|
|
74
|
+
binding.recursive = val;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.ContextModuleFactoryBeforeResolveData = ContextModuleFactoryBeforeResolveData;
|
|
81
|
+
_ContextModuleFactoryBeforeResolveData_inner = new WeakMap();
|
|
18
82
|
class ContextModuleFactoryAfterResolveData {
|
|
19
83
|
static __from_binding(binding) {
|
|
20
84
|
return new ContextModuleFactoryAfterResolveData(binding);
|
|
@@ -22,54 +86,73 @@ class ContextModuleFactoryAfterResolveData {
|
|
|
22
86
|
static __to_binding(data) {
|
|
23
87
|
return __classPrivateFieldGet(data, _ContextModuleFactoryAfterResolveData_inner, "f");
|
|
24
88
|
}
|
|
25
|
-
constructor(
|
|
89
|
+
constructor(binding) {
|
|
26
90
|
_ContextModuleFactoryAfterResolveData_inner.set(this, void 0);
|
|
27
|
-
__classPrivateFieldSet(this, _ContextModuleFactoryAfterResolveData_inner,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
91
|
+
__classPrivateFieldSet(this, _ContextModuleFactoryAfterResolveData_inner, binding, "f");
|
|
92
|
+
Object.defineProperties(this, {
|
|
93
|
+
resource: {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
get() {
|
|
96
|
+
return binding.resource;
|
|
97
|
+
},
|
|
98
|
+
set(val) {
|
|
99
|
+
binding.resource = val;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
context: {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
get() {
|
|
105
|
+
return binding.context;
|
|
106
|
+
},
|
|
107
|
+
set(val) {
|
|
108
|
+
binding.context = val;
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
request: {
|
|
112
|
+
enumerable: true,
|
|
113
|
+
get() {
|
|
114
|
+
return binding.request;
|
|
115
|
+
},
|
|
116
|
+
set(val) {
|
|
117
|
+
binding.request = val;
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
regExp: {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get() {
|
|
123
|
+
if (!binding.regExp) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
const { source, flags } = binding.regExp;
|
|
127
|
+
return new RegExp(source, flags);
|
|
128
|
+
},
|
|
129
|
+
set(val) {
|
|
130
|
+
if (!val) {
|
|
131
|
+
binding.regExp = undefined;
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
binding.regExp = {
|
|
135
|
+
source: val.source,
|
|
136
|
+
flags: val.flags
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
recursive: {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
get() {
|
|
143
|
+
return binding.recursive;
|
|
144
|
+
},
|
|
145
|
+
set(val) {
|
|
146
|
+
binding.recursive = val;
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
dependencies: {
|
|
150
|
+
enumerable: true,
|
|
151
|
+
get() {
|
|
152
|
+
return binding.dependencies.map(dep => Dependency_1.Dependency.__from_binding(dep));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
73
156
|
}
|
|
74
157
|
}
|
|
75
158
|
exports.ContextModuleFactoryAfterResolveData = ContextModuleFactoryAfterResolveData;
|
package/dist/config/types.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { JsAssetInfo } from "@rspack/binding";
|
|
2
2
|
import type { PathData } from "../Compilation";
|
|
3
|
+
import type { Compiler } from "../Compiler";
|
|
4
|
+
import type { Module } from "../Module";
|
|
5
|
+
import type { Chunk } from "../exports";
|
|
3
6
|
export type FilenameTemplate = string;
|
|
4
7
|
export type Filename = FilenameTemplate | ((pathData: PathData, assetInfo?: JsAssetInfo) => string);
|
|
5
8
|
/** Name of the configuration. Used when loading multiple configurations. */
|
|
@@ -291,3 +294,236 @@ export type ExternalItem = string | RegExp | ExternalItemObjectUnknown | ((data:
|
|
|
291
294
|
* ```
|
|
292
295
|
* */
|
|
293
296
|
export type Externals = ExternalItem | ExternalItem[];
|
|
297
|
+
export interface RspackPluginInstance {
|
|
298
|
+
apply: (compiler: Compiler) => void;
|
|
299
|
+
[k: string]: any;
|
|
300
|
+
}
|
|
301
|
+
export type RspackPluginFunction = (this: Compiler, compiler: Compiler) => void;
|
|
302
|
+
export type WebpackCompiler = any;
|
|
303
|
+
export interface WebpackPluginInstance {
|
|
304
|
+
apply: (compiler: WebpackCompiler) => void;
|
|
305
|
+
[k: string]: any;
|
|
306
|
+
}
|
|
307
|
+
export type WebpackPluginFunction = (this: WebpackCompiler, compiler: WebpackCompiler) => void;
|
|
308
|
+
export type Plugin = RspackPluginInstance | RspackPluginFunction | WebpackPluginInstance | WebpackPluginFunction | Falsy;
|
|
309
|
+
export type Plugins = Plugin[];
|
|
310
|
+
/** Used to control how the runtime chunk is generated. */
|
|
311
|
+
export type OptimizationRuntimeChunk = boolean | "single" | "multiple" | {
|
|
312
|
+
name?: string | ((value: {
|
|
313
|
+
name: string;
|
|
314
|
+
}) => string);
|
|
315
|
+
};
|
|
316
|
+
export type OptimizationSplitChunksNameFunction = (module?: Module) => unknown;
|
|
317
|
+
type OptimizationSplitChunksName = string | false | OptimizationSplitChunksNameFunction;
|
|
318
|
+
type OptimizationSplitChunksSizes = number | Record<string, number>;
|
|
319
|
+
type OptimizationSplitChunksChunks = "initial" | "async" | "all" | RegExp | ((chunk: Chunk) => boolean);
|
|
320
|
+
type SharedOptimizationSplitChunksCacheGroup = {
|
|
321
|
+
/**
|
|
322
|
+
* This indicates which chunks will be selected for optimization.
|
|
323
|
+
* @default 'async''
|
|
324
|
+
* */
|
|
325
|
+
chunks?: OptimizationSplitChunksChunks;
|
|
326
|
+
/** Sets the size types which are used when a number is used for sizes. */
|
|
327
|
+
defaultSizeTypes?: string[];
|
|
328
|
+
/**
|
|
329
|
+
* The minimum times must a module be shared among chunks before splitting.
|
|
330
|
+
* @default 1
|
|
331
|
+
*/
|
|
332
|
+
minChunks?: number;
|
|
333
|
+
/**
|
|
334
|
+
* Enabling this, the splitting of chunks will be grouped based on the usage of modules exports in different runtimes,
|
|
335
|
+
* ensuring the optimal loading size in each runtime.
|
|
336
|
+
*/
|
|
337
|
+
usedExports?: boolean;
|
|
338
|
+
/**
|
|
339
|
+
* The name of the split chunk.
|
|
340
|
+
* @default false
|
|
341
|
+
* */
|
|
342
|
+
name?: false | OptimizationSplitChunksName;
|
|
343
|
+
/**
|
|
344
|
+
* Minimum size, in bytes, for a chunk to be generated.
|
|
345
|
+
*
|
|
346
|
+
* The value is `20000` in production mode.
|
|
347
|
+
* The value is `10000` in others mode.
|
|
348
|
+
*/
|
|
349
|
+
minSize?: OptimizationSplitChunksSizes;
|
|
350
|
+
/** Maximum size, in bytes, for a chunk to be generated. */
|
|
351
|
+
maxSize?: OptimizationSplitChunksSizes;
|
|
352
|
+
/** Maximum size, in bytes, for a async chunk to be generated. */
|
|
353
|
+
maxAsyncSize?: OptimizationSplitChunksSizes;
|
|
354
|
+
/** Maximum size, in bytes, for a initial chunk to be generated. */
|
|
355
|
+
maxInitialSize?: OptimizationSplitChunksSizes;
|
|
356
|
+
/**
|
|
357
|
+
* Maximum number of parallel requests when on-demand loading.
|
|
358
|
+
* @default 30
|
|
359
|
+
* */
|
|
360
|
+
maxAsyncRequests?: number;
|
|
361
|
+
/**
|
|
362
|
+
* Maximum number of parallel requests at an entry point.
|
|
363
|
+
* @default 30
|
|
364
|
+
*/
|
|
365
|
+
maxInitialRequests?: number;
|
|
366
|
+
/**
|
|
367
|
+
* Tell Rspack what delimiter to use for the generated names.
|
|
368
|
+
*
|
|
369
|
+
* @default '-''
|
|
370
|
+
*/
|
|
371
|
+
automaticNameDelimiter?: string;
|
|
372
|
+
};
|
|
373
|
+
/** How to splitting chunks. */
|
|
374
|
+
export type OptimizationSplitChunksCacheGroup = {
|
|
375
|
+
/** Controls which modules are selected by this cache group. */
|
|
376
|
+
test?: string | RegExp | ((module: Module) => unknown);
|
|
377
|
+
/**
|
|
378
|
+
* A module can belong to multiple cache groups.
|
|
379
|
+
* @default -20
|
|
380
|
+
*/
|
|
381
|
+
priority?: number;
|
|
382
|
+
/**
|
|
383
|
+
* Tells Rspack to ignore `splitChunks.minSize`, `splitChunks.minChunks`, `splitChunks.maxAsyncRequests` and `splitChunks.maxInitialRequests` options and always create chunks for this cache group.
|
|
384
|
+
*/
|
|
385
|
+
enforce?: boolean;
|
|
386
|
+
/** Allows to override the filename when and only when it's an initial chunk. */
|
|
387
|
+
filename?: string;
|
|
388
|
+
/**
|
|
389
|
+
* Whether to reuse existing chunks when possible.
|
|
390
|
+
* @default false
|
|
391
|
+
* */
|
|
392
|
+
reuseExistingChunk?: boolean;
|
|
393
|
+
/** Allows to assign modules to a cache group by module type. */
|
|
394
|
+
type?: string | RegExp;
|
|
395
|
+
/** Sets the hint for chunk id. It will be added to chunk's filename. */
|
|
396
|
+
idHint?: string;
|
|
397
|
+
} & SharedOptimizationSplitChunksCacheGroup;
|
|
398
|
+
/** Tell Rspack how to splitting chunks. */
|
|
399
|
+
export type OptimizationSplitChunksOptions = {
|
|
400
|
+
/**
|
|
401
|
+
* Options for module cache group
|
|
402
|
+
* */
|
|
403
|
+
cacheGroups?: Record<string, false | OptimizationSplitChunksCacheGroup>;
|
|
404
|
+
/**
|
|
405
|
+
* Options for modules not selected by any other group.
|
|
406
|
+
*/
|
|
407
|
+
fallbackCacheGroup?: {
|
|
408
|
+
chunks?: OptimizationSplitChunksChunks;
|
|
409
|
+
minSize?: number;
|
|
410
|
+
maxSize?: number;
|
|
411
|
+
maxAsyncSize?: number;
|
|
412
|
+
maxInitialSize?: number;
|
|
413
|
+
automaticNameDelimiter?: string;
|
|
414
|
+
};
|
|
415
|
+
/**
|
|
416
|
+
* Prevents exposing path info when creating names for parts splitted by maxSize.
|
|
417
|
+
*
|
|
418
|
+
* The value is `true` in production mode.
|
|
419
|
+
* The value is `false` in development mode.
|
|
420
|
+
* */
|
|
421
|
+
hidePathInfo?: boolean;
|
|
422
|
+
} & SharedOptimizationSplitChunksCacheGroup;
|
|
423
|
+
export type Optimization = {
|
|
424
|
+
/**
|
|
425
|
+
* Which algorithm to use when choosing module ids.
|
|
426
|
+
*/
|
|
427
|
+
moduleIds?: "named" | "natural" | "deterministic";
|
|
428
|
+
/**
|
|
429
|
+
* Which algorithm to use when choosing chunk ids.
|
|
430
|
+
*/
|
|
431
|
+
chunkIds?: "natural" | "named" | "deterministic";
|
|
432
|
+
/**
|
|
433
|
+
* Whether to minimize the bundle.
|
|
434
|
+
* The value is `true` in production mode.
|
|
435
|
+
* The value is `false` in development mode.
|
|
436
|
+
*/
|
|
437
|
+
minimize?: boolean;
|
|
438
|
+
/**
|
|
439
|
+
* Customize the minimizer.
|
|
440
|
+
* By default, `rspack.SwcJsMinimizerRspackPlugin` and `rspack.LightningCssMinimizerRspackPlugin` are used.
|
|
441
|
+
*/
|
|
442
|
+
minimizer?: Array<"..." | Plugin>;
|
|
443
|
+
/**
|
|
444
|
+
* Whether to merge chunks which contain the same modules.
|
|
445
|
+
* Setting optimization.mergeDuplicateChunks to false will disable this optimization.
|
|
446
|
+
* @default true
|
|
447
|
+
*/
|
|
448
|
+
mergeDuplicateChunks?: boolean;
|
|
449
|
+
/**
|
|
450
|
+
* Support splitting chunks.
|
|
451
|
+
* It is enabled by default for dynamically imported modules.
|
|
452
|
+
* To turn it off, set it to false.
|
|
453
|
+
* */
|
|
454
|
+
splitChunks?: false | OptimizationSplitChunksOptions;
|
|
455
|
+
/**
|
|
456
|
+
* Used to control how the runtime chunk is generated.
|
|
457
|
+
* Setting it to true or 'multiple' will add an additional chunk containing only the runtime for each entry point.
|
|
458
|
+
* Setting it to 'single' will extract the runtime code of all entry points into a single separate chunk.
|
|
459
|
+
* @default false
|
|
460
|
+
*/
|
|
461
|
+
runtimeChunk?: OptimizationRuntimeChunk;
|
|
462
|
+
/** Detect and remove modules from chunks these modules are already included in all parents. */
|
|
463
|
+
removeAvailableModules?: boolean;
|
|
464
|
+
/**
|
|
465
|
+
* Remove empty chunks generated in the compilation.
|
|
466
|
+
* @default true
|
|
467
|
+
* */
|
|
468
|
+
removeEmptyChunks?: boolean;
|
|
469
|
+
/**
|
|
470
|
+
* Adds an additional hash compilation pass after the assets have been processed to get the correct asset content hashes.
|
|
471
|
+
*
|
|
472
|
+
* The value is `true` in production mode.
|
|
473
|
+
* The value is `false` in development mode.
|
|
474
|
+
*/
|
|
475
|
+
realContentHash?: boolean;
|
|
476
|
+
/**
|
|
477
|
+
* Tells Rspack to recognise the sideEffects flag in package.json or rules to skip over modules which are flagged to contain no side effects when exports are not used.
|
|
478
|
+
*
|
|
479
|
+
* The value is `true` in production mode.
|
|
480
|
+
* The value is `false` in development mode.
|
|
481
|
+
* */
|
|
482
|
+
sideEffects?: "flag" | boolean;
|
|
483
|
+
/**
|
|
484
|
+
* After enabling, Rspack will analyze which exports the module provides, including re-exported modules.
|
|
485
|
+
* @default true
|
|
486
|
+
* */
|
|
487
|
+
providedExports?: boolean;
|
|
488
|
+
/**
|
|
489
|
+
* Tells Rspack to find segments of the module graph which can be safely concatenated into a single module.
|
|
490
|
+
*
|
|
491
|
+
* The value is `true` in production mode.
|
|
492
|
+
* The value is `false` in development mode.
|
|
493
|
+
*/
|
|
494
|
+
concatenateModules?: boolean;
|
|
495
|
+
/**
|
|
496
|
+
* Tells Rspack whether to perform a more detailed analysis of variable assignments.
|
|
497
|
+
*
|
|
498
|
+
* The value is `true` in production mode.
|
|
499
|
+
* The value is `false` in development mode.
|
|
500
|
+
*/
|
|
501
|
+
innerGraph?: boolean;
|
|
502
|
+
/**
|
|
503
|
+
* Tells Rspack to determine used exports for each module.
|
|
504
|
+
*
|
|
505
|
+
* The value is `true` in production mode.
|
|
506
|
+
* The value is `false` in development mode.
|
|
507
|
+
* */
|
|
508
|
+
usedExports?: "global" | boolean;
|
|
509
|
+
/**
|
|
510
|
+
* Allows to control export mangling.
|
|
511
|
+
*
|
|
512
|
+
* The value is `isdeterministic` in production mode.
|
|
513
|
+
* The value is `false` in development mode.
|
|
514
|
+
*/
|
|
515
|
+
mangleExports?: "size" | "deterministic" | boolean;
|
|
516
|
+
/**
|
|
517
|
+
* Tells Rspack to set process.env.NODE_ENV to a given string value.
|
|
518
|
+
* @default false
|
|
519
|
+
*/
|
|
520
|
+
nodeEnv?: string | false;
|
|
521
|
+
/**
|
|
522
|
+
* Emit assets whenever there are errors while compiling.
|
|
523
|
+
*
|
|
524
|
+
* The value is `false` in production mode.
|
|
525
|
+
* The value is `true` in development mode.
|
|
526
|
+
* */
|
|
527
|
+
emitOnErrors?: boolean;
|
|
528
|
+
};
|
|
529
|
+
export {};
|