@rspack/core 1.0.7 → 1.0.9
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 +2 -1
- package/dist/Chunk.js +8 -0
- package/dist/Compilation.d.ts +22 -9
- package/dist/Compilation.js +32 -12
- 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/ExternalsPlugin.d.ts +3 -58
- package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +64 -110
- package/dist/builtin-plugin/IgnorePlugin.d.ts +3 -0
- package/dist/config/adapter.js +5 -1
- package/dist/config/defaults.js +4 -0
- package/dist/config/types.d.ts +293 -0
- package/dist/config/types.js +3 -0
- package/dist/config/zod.d.ts +879 -2074
- package/dist/config/zod.js +49 -13
- package/dist/container/ContainerPlugin.d.ts +2 -18
- package/dist/container/ContainerReferencePlugin.d.ts +1 -1
- 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
|
@@ -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
|
@@ -489,7 +489,11 @@ function getRawJavascriptParserOptions(parser) {
|
|
|
489
489
|
? ["..."]
|
|
490
490
|
: []
|
|
491
491
|
: parser.worker,
|
|
492
|
-
overrideStrict: parser.overrideStrict
|
|
492
|
+
overrideStrict: parser.overrideStrict,
|
|
493
|
+
requireAsExpression: parser.requireAsExpression,
|
|
494
|
+
requireDynamic: parser.requireDynamic,
|
|
495
|
+
requireResolve: parser.requireResolve,
|
|
496
|
+
importDynamic: parser.importDynamic
|
|
493
497
|
};
|
|
494
498
|
}
|
|
495
499
|
function getRawAssetParserOptions(parser) {
|
package/dist/config/defaults.js
CHANGED
|
@@ -168,6 +168,10 @@ const applyJavascriptParserOptionsDefaults = (parserOptions) => {
|
|
|
168
168
|
D(parserOptions, "exprContextCritical", true);
|
|
169
169
|
D(parserOptions, "wrappedContextCritical", false);
|
|
170
170
|
D(parserOptions, "strictExportPresence", false);
|
|
171
|
+
D(parserOptions, "requireAsExpression", true);
|
|
172
|
+
D(parserOptions, "requireDynamic", true);
|
|
173
|
+
D(parserOptions, "requireResolve", true);
|
|
174
|
+
D(parserOptions, "importDynamic", true);
|
|
171
175
|
D(parserOptions, "worker", ["..."]);
|
|
172
176
|
D(parserOptions, "importMeta", true);
|
|
173
177
|
};
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import type { JsAssetInfo } from "@rspack/binding";
|
|
2
|
+
import type { PathData } from "../Compilation";
|
|
3
|
+
export type FilenameTemplate = string;
|
|
4
|
+
export type Filename = FilenameTemplate | ((pathData: PathData, assetInfo?: JsAssetInfo) => string);
|
|
5
|
+
/** Name of the configuration. Used when loading multiple configurations. */
|
|
6
|
+
export type Name = string;
|
|
7
|
+
/** A list of name defining all sibling configurations it depends on. Dependent configurations need to be compiled first. */
|
|
8
|
+
export type Dependencies = Name[];
|
|
9
|
+
/**
|
|
10
|
+
* The context configuration is used to set the base directory for Rspack builds.
|
|
11
|
+
* @default process.cwd()
|
|
12
|
+
* */
|
|
13
|
+
export type Context = string;
|
|
14
|
+
/**
|
|
15
|
+
* The mode configuration is used to set the build mode of Rspack to enable the default optimization strategy.
|
|
16
|
+
* @default 'production'
|
|
17
|
+
* */
|
|
18
|
+
export type Mode = "development" | "production" | "none";
|
|
19
|
+
export type Falsy = false | "" | 0 | null | undefined;
|
|
20
|
+
/** The publicPath of the resource referenced by this entry. */
|
|
21
|
+
export type PublicPath = "auto" | Filename;
|
|
22
|
+
/** The baseURI of the resource referenced by this entry. */
|
|
23
|
+
export type BaseUri = string;
|
|
24
|
+
/** How this entry load other chunks. */
|
|
25
|
+
export type ChunkLoadingType = string | "jsonp" | "import-scripts" | "require" | "async-node" | "import";
|
|
26
|
+
/** How this entry load other chunks. */
|
|
27
|
+
export type ChunkLoading = false | ChunkLoadingType;
|
|
28
|
+
/** Whether to create a load-on-demand asynchronous chunk for entry. */
|
|
29
|
+
export type AsyncChunks = boolean;
|
|
30
|
+
/** Option to set the method of loading WebAssembly Modules. */
|
|
31
|
+
export type WasmLoadingType = string | "fetch-streaming" | "fetch" | "async-node";
|
|
32
|
+
/** Option to set the method of loading WebAssembly Modules. */
|
|
33
|
+
export type WasmLoading = false | WasmLoadingType;
|
|
34
|
+
export type ScriptType = false | "text/javascript" | "module";
|
|
35
|
+
export type LibraryCustomUmdObject = {
|
|
36
|
+
amd?: string;
|
|
37
|
+
commonjs?: string;
|
|
38
|
+
root?: string | string[];
|
|
39
|
+
};
|
|
40
|
+
/** Specify a name for the library. */
|
|
41
|
+
export type LibraryName = string | string[] | LibraryCustomUmdObject;
|
|
42
|
+
export type LibraryCustomUmdCommentObject = {
|
|
43
|
+
amd?: string;
|
|
44
|
+
commonjs?: string;
|
|
45
|
+
commonjs2?: string;
|
|
46
|
+
root?: string;
|
|
47
|
+
};
|
|
48
|
+
/** Use a container(defined in global space) for calling define/require functions in an AMD module. */
|
|
49
|
+
export type AmdContainer = string;
|
|
50
|
+
/** Add a comment in the UMD wrapper. */
|
|
51
|
+
export type AuxiliaryComment = string | LibraryCustomUmdCommentObject;
|
|
52
|
+
/** Specify which export should be exposed as a library. */
|
|
53
|
+
export type LibraryExport = string | string[];
|
|
54
|
+
/** Configure how the library will be exposed. */
|
|
55
|
+
export type LibraryType = string | "var" | "module" | "assign" | "assign-properties" | "this" | "window" | "self" | "global" | "commonjs" | "commonjs2" | "commonjs-module" | "commonjs-static" | "amd" | "amd-require" | "umd" | "umd2" | "jsonp" | "system";
|
|
56
|
+
/** When using output.library.type: "umd", setting output.library.umdNamedDefine to true will name the AMD module of the UMD build. */
|
|
57
|
+
export type UmdNamedDefine = boolean;
|
|
58
|
+
/** Options for library. */
|
|
59
|
+
export type LibraryOptions = {
|
|
60
|
+
/** Use a container(defined in global space) for calling define/require functions in an AMD module. */
|
|
61
|
+
amdContainer?: AmdContainer;
|
|
62
|
+
/** Add a comment in the UMD wrapper. */
|
|
63
|
+
auxiliaryComment?: AuxiliaryComment;
|
|
64
|
+
/** Specify which export should be exposed as a library. */
|
|
65
|
+
export?: LibraryExport;
|
|
66
|
+
/** Specify a name for the library. */
|
|
67
|
+
name?: LibraryName;
|
|
68
|
+
/** Configure how the library will be exposed. */
|
|
69
|
+
type: LibraryType;
|
|
70
|
+
/**
|
|
71
|
+
* When using output.library.type: "umd", setting output.library.umdNamedDefine to true will name the AMD module of the UMD build.
|
|
72
|
+
* Otherwise, an anonymous define is used.
|
|
73
|
+
* */
|
|
74
|
+
umdNamedDefine?: UmdNamedDefine;
|
|
75
|
+
};
|
|
76
|
+
/** Options for library. */
|
|
77
|
+
export type Library = LibraryName | LibraryOptions | undefined;
|
|
78
|
+
/** The layer of this entry. */
|
|
79
|
+
export type Layer = string | null;
|
|
80
|
+
/** The filename of the entry chunk. */
|
|
81
|
+
export type EntryFilename = Filename;
|
|
82
|
+
/** The name of the runtime chunk. */
|
|
83
|
+
export type EntryRuntime = false | string;
|
|
84
|
+
/** The path to the entry module. */
|
|
85
|
+
export type EntryItem = string | string[];
|
|
86
|
+
/** The entry that the current entry depends on. With dependOn option you can share the modules from one entry chunk to another. */
|
|
87
|
+
export type EntryDependOn = string | string[];
|
|
88
|
+
export type EntryDescription = {
|
|
89
|
+
/**
|
|
90
|
+
* The path to the entry module.
|
|
91
|
+
* @default './src/index.js'
|
|
92
|
+
* */
|
|
93
|
+
import: EntryItem;
|
|
94
|
+
/**
|
|
95
|
+
* The name of the runtime chunk.
|
|
96
|
+
* When runtime is set, a new runtime chunk will be created.
|
|
97
|
+
* You can also set it to false to avoid a new runtime chunk.
|
|
98
|
+
* */
|
|
99
|
+
runtime?: EntryRuntime;
|
|
100
|
+
/** The publicPath of the resource referenced by this entry. */
|
|
101
|
+
publicPath?: PublicPath;
|
|
102
|
+
/** The baseURI of the resource referenced by this entry. */
|
|
103
|
+
baseUri?: BaseUri;
|
|
104
|
+
/** How this entry load other chunks. */
|
|
105
|
+
chunkLoading?: ChunkLoading;
|
|
106
|
+
/** Whether to create a load-on-demand asynchronous chunk for this entry. */
|
|
107
|
+
asyncChunks?: AsyncChunks;
|
|
108
|
+
/** Option to set the method of loading WebAssembly Modules. */
|
|
109
|
+
wasmLoading?: WasmLoading;
|
|
110
|
+
/** The filename of the entry chunk. */
|
|
111
|
+
filename?: EntryFilename;
|
|
112
|
+
/** The format of the chunk generated by this entry as a library. */
|
|
113
|
+
library?: LibraryOptions;
|
|
114
|
+
/** The entry that the current entry depends on. With dependOn option you can share the modules from one entry chunk to another. */
|
|
115
|
+
dependOn?: EntryDependOn;
|
|
116
|
+
/** The layer of this entry, make the corresponding configuration take effect through layer matching in SplitChunks, Rules, Stats, and Externals. */
|
|
117
|
+
layer?: Layer;
|
|
118
|
+
};
|
|
119
|
+
export type EntryUnnamed = EntryItem;
|
|
120
|
+
export type EntryObject = Record<string, EntryItem | EntryDescription>;
|
|
121
|
+
/** A static entry. */
|
|
122
|
+
export type EntryStatic = EntryObject | EntryUnnamed;
|
|
123
|
+
/** A Function returning entry options. */
|
|
124
|
+
export type EntryDynamic = () => EntryStatic | Promise<EntryStatic>;
|
|
125
|
+
/** The entry options for building */
|
|
126
|
+
export type Entry = EntryStatic | EntryDynamic;
|
|
127
|
+
/**
|
|
128
|
+
* Path alias
|
|
129
|
+
* @example
|
|
130
|
+
* ```js
|
|
131
|
+
* {
|
|
132
|
+
* "@": path.resolve(__dirname, './src'),
|
|
133
|
+
* "abc$": path.resolve(__dirname, './node_modules/abc/index.js'),
|
|
134
|
+
* }
|
|
135
|
+
* // - require("@/a") will attempt to resolve <root>/src/a.
|
|
136
|
+
* // - require("abc") will attempt to resolve <root>/src/abc.
|
|
137
|
+
* // - require("abc/file.js") will not match, and it will attempt to resolve node_modules/abc/file.js.
|
|
138
|
+
* ```
|
|
139
|
+
* */
|
|
140
|
+
export type ResolveAlias = {
|
|
141
|
+
[x: string]: string | false | (string | false)[];
|
|
142
|
+
};
|
|
143
|
+
/** The replacement of [tsconfig-paths-webpack-plugin](https://www.npmjs.com/package/tsconfig-paths-webpack-plugin) in Rspack. */
|
|
144
|
+
export type ResolveTsConfig = string | {
|
|
145
|
+
configFile: string;
|
|
146
|
+
references?: string[] | "auto" | undefined;
|
|
147
|
+
};
|
|
148
|
+
/** Used to configure the Rspack module resolution */
|
|
149
|
+
export type ResolveOptions = {
|
|
150
|
+
/** Path alias */
|
|
151
|
+
alias?: ResolveAlias;
|
|
152
|
+
/** Same as node's [conditionNames](https://nodejs.org/api/packages.html#conditional-exports) for the exports and imports fields in package.json. */
|
|
153
|
+
conditionNames?: string[];
|
|
154
|
+
/**
|
|
155
|
+
* Parse modules in order.
|
|
156
|
+
* @default [".js", ".json", ".wasm"]
|
|
157
|
+
* */
|
|
158
|
+
extensions?: string[];
|
|
159
|
+
/** Redirect module requests when normal resolving fails. */
|
|
160
|
+
fallback?: ResolveAlias;
|
|
161
|
+
/** Try to parse the fields in package.json */
|
|
162
|
+
mainFields?: string[];
|
|
163
|
+
/**
|
|
164
|
+
* The filename suffix when resolving directories, e.g. require('. /dir/') will try to resolve '. /dir/index'.
|
|
165
|
+
* @default ['index']
|
|
166
|
+
*/
|
|
167
|
+
mainFiles?: string[];
|
|
168
|
+
/**
|
|
169
|
+
* The name of the directory to use when resolving dependencies.
|
|
170
|
+
* @default ["node_modules"]
|
|
171
|
+
*/
|
|
172
|
+
modules?: string[];
|
|
173
|
+
/**
|
|
174
|
+
* When enabled, require('file') will first look for the . /file file in the current directory, not <modules>/file.
|
|
175
|
+
* @default false
|
|
176
|
+
*/
|
|
177
|
+
preferRelative?: boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Opt for absolute paths when resolving, in relation to resolve.roots.
|
|
180
|
+
* @default false
|
|
181
|
+
*/
|
|
182
|
+
preferAbsolute?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Whether to resolve symlinks to their symlinked location.
|
|
185
|
+
* @default true
|
|
186
|
+
*/
|
|
187
|
+
symlinks?: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* By default, It changes to true if resolve.extensions contains an empty string;
|
|
190
|
+
* otherwise, this value changes to false.
|
|
191
|
+
*/
|
|
192
|
+
enforceExtension?: boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Customize the imports field in package.json which are used to provide the internal requests of a package (requests starting with # are considered internal).
|
|
195
|
+
* @default ["imports"]
|
|
196
|
+
*/
|
|
197
|
+
importsFields?: string[];
|
|
198
|
+
/**
|
|
199
|
+
* The JSON files to use for descriptions.
|
|
200
|
+
* @default ['package.json']
|
|
201
|
+
*/
|
|
202
|
+
descriptionFiles?: string[];
|
|
203
|
+
/** The replacement of [tsconfig-paths-webpack-plugin](https://www.npmjs.com/package/tsconfig-paths-webpack-plugin) in Rspack. */
|
|
204
|
+
tsConfig?: ResolveTsConfig;
|
|
205
|
+
/**
|
|
206
|
+
* No longer resolve extensions, no longer resolve mainFiles in package.json (but does not affect requests from mainFiles, browser, alias).
|
|
207
|
+
* @default false
|
|
208
|
+
* */
|
|
209
|
+
fullySpecified?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Customize the exports field in package.json.
|
|
212
|
+
* @default ["exports"]
|
|
213
|
+
* */
|
|
214
|
+
exportsFields?: string[];
|
|
215
|
+
/** Define alias for the extension. */
|
|
216
|
+
extensionAlias?: Record<string, string | string[]>;
|
|
217
|
+
/**
|
|
218
|
+
* Define a field, such as browser, that should be parsed in accordance with this [specification](https://github.com/defunctzombie/package-browser-field-spec).
|
|
219
|
+
* @default ['browser']
|
|
220
|
+
* */
|
|
221
|
+
aliasFields?: string[];
|
|
222
|
+
/**
|
|
223
|
+
* A list of resolve restrictions to restrict the paths that a request can be resolved on.
|
|
224
|
+
* @default []
|
|
225
|
+
* */
|
|
226
|
+
restrictions?: string[];
|
|
227
|
+
/**
|
|
228
|
+
* A list of directories where server-relative URLs (beginning with '/') are resolved.
|
|
229
|
+
* It defaults to the context configuration option.
|
|
230
|
+
* On systems other than Windows, these requests are initially resolved as an absolute path.
|
|
231
|
+
* @default []
|
|
232
|
+
*/
|
|
233
|
+
roots?: string[];
|
|
234
|
+
/** Customize the Resolve configuration based on the module type. */
|
|
235
|
+
byDependency?: Record<string, ResolveOptions>;
|
|
236
|
+
};
|
|
237
|
+
/** Used to configure the Rspack module resolution */
|
|
238
|
+
export type Resolve = ResolveOptions;
|
|
239
|
+
/**
|
|
240
|
+
* Specify the default type of externals.
|
|
241
|
+
* `amd`, `umd`, `system` and `jsonp` externals depend on the `output.libraryTarget` being set to the same value e.g. you can only consume amd externals within an amd library.
|
|
242
|
+
* @default 'var'
|
|
243
|
+
*/
|
|
244
|
+
export type ExternalsType = "var" | "module" | "assign" | "this" | "window" | "self" | "global" | "commonjs" | "commonjs2" | "commonjs-module" | "commonjs-static" | "amd" | "amd-require" | "umd" | "umd2" | "jsonp" | "system" | "promise" | "import" | "module-import" | "script" | "node-commonjs";
|
|
245
|
+
/**
|
|
246
|
+
* The dependency used for the external.
|
|
247
|
+
*/
|
|
248
|
+
export type ExternalItemValue = string | boolean | string[] | Record<string, string | string[]>;
|
|
249
|
+
/**
|
|
250
|
+
* If an dependency matches exactly a property of the object, the property value is used as dependency.
|
|
251
|
+
*/
|
|
252
|
+
export type ExternalItemObjectUnknown = {
|
|
253
|
+
[x: string]: ExternalItemValue;
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Data object passed as argument when a function is set for 'externals'.
|
|
257
|
+
*/
|
|
258
|
+
export type ExternalItemFunctionData = {
|
|
259
|
+
context?: string;
|
|
260
|
+
dependencyType?: string;
|
|
261
|
+
request?: string;
|
|
262
|
+
contextInfo?: {
|
|
263
|
+
issuer: string;
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* Prevent bundling of certain imported package and instead retrieve these external dependencies at runtime.
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```js
|
|
271
|
+
* // jquery lib will be excluded from bundling.
|
|
272
|
+
* module.exports = {
|
|
273
|
+
* externals: {
|
|
274
|
+
* jquery: 'jQuery',
|
|
275
|
+
* }
|
|
276
|
+
* }
|
|
277
|
+
* ```
|
|
278
|
+
* */
|
|
279
|
+
export type ExternalItem = string | RegExp | ExternalItemObjectUnknown | ((data: ExternalItemFunctionData, callback: (err?: Error, result?: ExternalItemValue, type?: ExternalsType) => void) => void) | ((data: ExternalItemFunctionData) => Promise<ExternalItemValue>);
|
|
280
|
+
/**
|
|
281
|
+
* Prevent bundling of certain imported packages and instead retrieve these external dependencies at runtime.
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```js
|
|
285
|
+
* // jquery lib will be excluded from bundling.
|
|
286
|
+
* module.exports = {
|
|
287
|
+
* externals: {
|
|
288
|
+
* jquery: 'jQuery',
|
|
289
|
+
* }
|
|
290
|
+
* }
|
|
291
|
+
* ```
|
|
292
|
+
* */
|
|
293
|
+
export type Externals = ExternalItem | ExternalItem[];
|