@rsbuild/core 2.0.8 → 2.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/1~rslib-runtime.js +8 -5
- package/dist/756.js +13 -7
- package/dist/memfs.js +4 -4
- package/dist-types/build.d.ts +1 -1
- package/dist-types/cli/init.d.ts +1 -1
- package/dist-types/configChain.d.ts +59 -118
- package/dist-types/constants.d.ts +35 -31
- package/dist-types/createContext.d.ts +1 -2
- package/dist-types/createRsbuild.d.ts +1 -2
- package/dist-types/defaultConfig.d.ts +2 -4
- package/dist-types/helpers/exitHook.d.ts +1 -1
- package/dist-types/helpers/format.d.ts +2 -1
- package/dist-types/helpers/fs.d.ts +2 -4
- package/dist-types/helpers/index.d.ts +1 -2
- package/dist-types/helpers/path.d.ts +4 -8
- package/dist-types/helpers/stats.d.ts +3 -5
- package/dist-types/helpers/url.d.ts +1 -0
- package/dist-types/helpers/vendors.d.ts +2 -3
- package/dist-types/helpers/version.d.ts +2 -3
- package/dist-types/hooks.d.ts +6 -8
- package/dist-types/index.d.ts +10 -5
- package/dist-types/initConfigs.d.ts +2 -3
- package/dist-types/initPlugins.d.ts +1 -1
- package/dist-types/inspectConfig.d.ts +1 -1
- package/dist-types/loadConfig.d.ts +24 -32
- package/dist-types/loadEnv.d.ts +48 -57
- package/dist-types/loader/transformRawLoader.d.ts +1 -0
- package/dist-types/logger.d.ts +1 -2
- package/dist-types/mergeConfig.d.ts +1 -2
- package/dist-types/pluginHelper.d.ts +1 -2
- package/dist-types/pluginManager.d.ts +4 -7
- package/dist-types/plugins/basic.d.ts +1 -2
- package/dist-types/plugins/css.d.ts +4 -0
- package/dist-types/plugins/fileSize.d.ts +6 -5
- package/dist-types/plugins/rspackProfile.d.ts +2 -0
- package/dist-types/plugins/server.d.ts +1 -0
- package/dist-types/plugins/swc.d.ts +1 -2
- package/dist-types/restart.d.ts +4 -5
- package/dist-types/rspack-plugins/RsbuildHtmlPlugin.d.ts +2 -3
- package/dist-types/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +2 -3
- package/dist-types/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +3 -4
- package/dist-types/rspack-plugins/resource-hints/extractChunks.d.ts +1 -2
- package/dist-types/rspack-plugins/resource-hints/getResourceType.d.ts +2 -3
- package/dist-types/rspackConfig.d.ts +1 -1
- package/dist-types/server/ansiHTML.d.ts +1 -2
- package/dist-types/server/assets-middleware/getFileFromUrl.d.ts +1 -2
- package/dist-types/server/assets-middleware/index.d.ts +3 -5
- package/dist-types/server/assets-middleware/setupWriteToDisk.d.ts +1 -2
- package/dist-types/server/browserLogs.d.ts +1 -2
- package/dist-types/server/buildManager.d.ts +4 -6
- package/dist-types/server/cliShortcuts.d.ts +3 -1
- package/dist-types/server/devMiddlewares.d.ts +2 -3
- package/dist-types/server/devServer.d.ts +18 -23
- package/dist-types/server/gracefulShutdown.d.ts +2 -4
- package/dist-types/server/gzipMiddleware.d.ts +1 -1
- package/dist-types/server/helper.d.ts +36 -45
- package/dist-types/server/historyApiFallback.d.ts +8 -1
- package/dist-types/server/httpServer.d.ts +1 -1
- package/dist-types/server/middlewares.d.ts +4 -8
- package/dist-types/server/open.d.ts +1 -1
- package/dist-types/server/runner/basic.d.ts +4 -5
- package/dist-types/server/runner/index.d.ts +3 -1
- package/dist-types/server/socketServer.d.ts +24 -18
- package/dist-types/server/watchFiles.d.ts +1 -1
- package/dist-types/types/config.d.ts +1192 -1465
- package/dist-types/types/context.d.ts +63 -92
- package/dist-types/types/hooks.d.ts +106 -150
- package/dist-types/types/plugin.d.ts +359 -444
- package/dist-types/types/rsbuild.d.ts +156 -191
- package/dist-types/types/thirdParty.d.ts +101 -132
- package/dist-types/types/utils.d.ts +2 -5
- package/package.json +3 -3
- package/dist-types/client/hmr.d.ts +0 -3
- package/dist-types/client/log.d.ts +0 -13
- package/dist-types/client/overlay.d.ts +0 -1
|
@@ -7,108 +7,79 @@ import type { RsbuildPluginAPI } from './plugin';
|
|
|
7
7
|
import type { RsbuildStats } from './rsbuild';
|
|
8
8
|
export type BundlerType = 'rspack';
|
|
9
9
|
export type ActionType = 'dev' | 'build' | 'preview';
|
|
10
|
-
/** The public context */
|
|
11
|
-
|
|
12
|
-
/** The
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
rootPath: string;
|
|
16
|
-
/** Absolute path of output files. */
|
|
17
|
-
distPath: string;
|
|
18
|
-
/** Absolute path of cache files. */
|
|
19
|
-
cachePath: string;
|
|
10
|
+
/** The public context */ export type RsbuildContext = {
|
|
11
|
+
/** The Rsbuild core version. */ version: string;
|
|
12
|
+
/** The root path of current project. */ rootPath: string;
|
|
13
|
+
/** Absolute path of output files. */ distPath: string;
|
|
14
|
+
/** Absolute path of cache files. */ cachePath: string;
|
|
20
15
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
/** The
|
|
40
|
-
|
|
41
|
-
/** The actual port number the server is listening on. */
|
|
42
|
-
port: number;
|
|
43
|
-
/** Whether the server is using HTTPS protocol. */
|
|
44
|
-
https: boolean;
|
|
16
|
+
* Dev server information when running in dev mode.
|
|
17
|
+
* Available after the dev server has been created.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { createRsbuild } from '@rsbuild/core';
|
|
22
|
+
*
|
|
23
|
+
* async function main() {
|
|
24
|
+
* const rsbuild = createRsbuild({
|
|
25
|
+
* // ...
|
|
26
|
+
* });
|
|
27
|
+
* await rsbuild.startDevServer();
|
|
28
|
+
* console.log(rsbuild.context.devServer);
|
|
29
|
+
* // { hostname: 'localhost', port: 3000, https: false }
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/ devServer?: {
|
|
33
|
+
/** The hostname the server is running on. */ hostname: string;
|
|
34
|
+
/** The actual port number the server is listening on. */ port: number;
|
|
35
|
+
/** Whether the server is using HTTPS protocol. */ https: boolean;
|
|
45
36
|
};
|
|
46
37
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
action?: ActionType;
|
|
38
|
+
* The current action type.
|
|
39
|
+
* - dev: will be set when running `rsbuild dev` or `rsbuild.startDevServer()`
|
|
40
|
+
* - build: will be set when running `rsbuild build` or `rsbuild.build()`
|
|
41
|
+
* - preview: will be set when running `rsbuild preview` or `rsbuild.preview()`
|
|
42
|
+
*/ action?: ActionType;
|
|
53
43
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
bundlerType: BundlerType;
|
|
44
|
+
* The bundler type, currently only `rspack` is supported.
|
|
45
|
+
* @deprecated Do not use this field, it will be removed in future versions.
|
|
46
|
+
*/ bundlerType: BundlerType;
|
|
58
47
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
callerName: string;
|
|
48
|
+
* The name of the framework or tool that is currently invoking Rsbuild,
|
|
49
|
+
* same as the `callerName` option in the `createRsbuild` method.
|
|
50
|
+
* @example
|
|
51
|
+
* - `rslib` is set when Rslib calls Rsbuild.
|
|
52
|
+
* - `rspress` is set when Rspress calls Rsbuild.
|
|
53
|
+
*/ callerName: string;
|
|
66
54
|
};
|
|
67
55
|
export type BuildStatus = 'idle' | 'building' | 'done';
|
|
68
56
|
export type BuildState = {
|
|
69
57
|
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
|
|
76
|
-
/** Whether there are build errors */
|
|
77
|
-
hasErrors: boolean;
|
|
78
|
-
/** The build time of each environment */
|
|
79
|
-
time: Record<string, number>;
|
|
58
|
+
* The stats object of the last build.
|
|
59
|
+
* Available after the build has been done.
|
|
60
|
+
*/ stats: RsbuildStats | null;
|
|
61
|
+
/** Current build status */ status: BuildStatus;
|
|
62
|
+
/** Whether there are build errors */ hasErrors: boolean;
|
|
63
|
+
/** The build time of each environment */ time: Record<string, number>;
|
|
80
64
|
};
|
|
81
|
-
/** The inner context. */
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
/** Current Rsbuild config. */
|
|
88
|
-
config: Readonly<RsbuildConfig>;
|
|
89
|
-
/** The original Rsbuild config passed from the createRsbuild method. */
|
|
90
|
-
originalConfig: Readonly<RsbuildConfig>;
|
|
91
|
-
/** The normalized Rsbuild config. */
|
|
92
|
-
normalizedConfig?: NormalizedConfig;
|
|
65
|
+
/** The inner context. */ export type InternalContext = RsbuildContext & {
|
|
66
|
+
/** The logger associated with current Rsbuild instance. */ logger: Logger;
|
|
67
|
+
/** All hooks. */ hooks: Readonly<Hooks>;
|
|
68
|
+
/** Current Rsbuild config. */ config: Readonly<RsbuildConfig>;
|
|
69
|
+
/** The original Rsbuild config passed from the createRsbuild method. */ originalConfig: Readonly<RsbuildConfig>;
|
|
70
|
+
/** The normalized Rsbuild config. */ normalizedConfig?: NormalizedConfig;
|
|
93
71
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
|
|
103
|
-
/** Only build specified environment. */
|
|
104
|
-
specifiedEnvironments?: string[];
|
|
105
|
-
/** Build state information */
|
|
106
|
-
buildState: BuildState;
|
|
107
|
-
/** The socket server instance. */
|
|
108
|
-
socketServer?: SocketServer;
|
|
72
|
+
* Get the plugin API.
|
|
73
|
+
* When environment is undefined, the global plugin API is returned, which
|
|
74
|
+
* can be used in all environments.
|
|
75
|
+
*/ getPluginAPI?: (environment?: string) => RsbuildPluginAPI;
|
|
76
|
+
/** Context information for all environments. */ environments: Record<string, EnvironmentContext>;
|
|
77
|
+
/** Array of all environments. */ environmentList: EnvironmentContext[];
|
|
78
|
+
/** Only build specified environment. */ specifiedEnvironments?: string[];
|
|
79
|
+
/** Build state information */ buildState: BuildState;
|
|
80
|
+
/** The socket server instance. */ socketServer?: SocketServer;
|
|
109
81
|
/**
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
publicPathnames: string[];
|
|
82
|
+
* Pathnames derived from public paths, stripped of `server.base`.
|
|
83
|
+
* Used for static asset serving.
|
|
84
|
+
*/ publicPathnames: string[];
|
|
114
85
|
};
|
|
@@ -20,64 +20,54 @@ export type OnCloseBuildFn = () => MaybePromise<void>;
|
|
|
20
20
|
export type OnBeforeBuildFn = (params: CompileCommonParams & {
|
|
21
21
|
/**
|
|
22
22
|
* Context information for all environments.
|
|
23
|
-
*/
|
|
24
|
-
environments: Record<string, EnvironmentContext>;
|
|
23
|
+
*/ environments: Record<string, EnvironmentContext>;
|
|
25
24
|
bundlerConfigs?: Rspack.Configuration[];
|
|
26
25
|
}) => MaybePromise<void>;
|
|
27
26
|
export type OnBeforeDevCompileFn = (params: CompileCommonParams & {
|
|
28
27
|
/**
|
|
29
28
|
* Context information for all environments.
|
|
30
|
-
*/
|
|
31
|
-
environments: Record<string, EnvironmentContext>;
|
|
29
|
+
*/ environments: Record<string, EnvironmentContext>;
|
|
32
30
|
bundlerConfigs?: Rspack.Configuration[];
|
|
33
31
|
}) => MaybePromise<void>;
|
|
34
32
|
export type OnAfterEnvironmentCompileFn = (params: CompileCommonParams & {
|
|
35
33
|
stats?: Rspack.Stats;
|
|
36
34
|
/**
|
|
37
35
|
* The time it takes to build the current environment in milliseconds.
|
|
38
|
-
*/
|
|
39
|
-
time: number;
|
|
36
|
+
*/ time: number;
|
|
40
37
|
environment: EnvironmentContext;
|
|
41
38
|
}) => MaybePromise<void>;
|
|
42
39
|
export type OnAfterBuildFn = (params: CompileCommonParams & {
|
|
43
40
|
stats?: Rspack.Stats | Rspack.MultiStats;
|
|
44
41
|
/**
|
|
45
42
|
* Context information for all environments.
|
|
46
|
-
*/
|
|
47
|
-
environments: Record<string, EnvironmentContext>;
|
|
43
|
+
*/ environments: Record<string, EnvironmentContext>;
|
|
48
44
|
}) => MaybePromise<void>;
|
|
49
45
|
export type OnCloseDevServerFn = () => MaybePromise<void>;
|
|
50
46
|
export type OnAfterDevCompileFn = (params: {
|
|
51
47
|
isFirstCompile: boolean;
|
|
52
48
|
stats: Rspack.Stats | Rspack.MultiStats;
|
|
53
49
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
environments: Record<string, EnvironmentContext>;
|
|
50
|
+
* Context information for all environments.
|
|
51
|
+
*/ environments: Record<string, EnvironmentContext>;
|
|
57
52
|
}) => MaybePromise<void>;
|
|
58
53
|
/**
|
|
59
54
|
* @deprecated Use `OnAfterDevCompileFn` instead.
|
|
60
|
-
*/
|
|
61
|
-
export type OnDevCompileDoneFn = OnAfterDevCompileFn;
|
|
55
|
+
*/ export type OnDevCompileDoneFn = OnAfterDevCompileFn;
|
|
62
56
|
export type OnBeforeStartDevServerFn = (params: {
|
|
63
57
|
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
server: RsbuildDevServer;
|
|
58
|
+
* The dev server instance, the same as the return value of `createDevServer`.
|
|
59
|
+
*/ server: RsbuildDevServer;
|
|
67
60
|
/**
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
environments: Record<string, EnvironmentContext>;
|
|
61
|
+
* Context information for all environments.
|
|
62
|
+
*/ environments: Record<string, EnvironmentContext>;
|
|
71
63
|
}) => MaybePromise<(() => MaybePromise<void>) | void>;
|
|
72
64
|
export type OnBeforeStartPreviewServerFn = (params: {
|
|
73
65
|
/**
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
server: RsbuildPreviewServer;
|
|
66
|
+
* The preview server instance.
|
|
67
|
+
*/ server: RsbuildPreviewServer;
|
|
77
68
|
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
environments: Record<string, EnvironmentContext>;
|
|
69
|
+
* Context information for all environments.
|
|
70
|
+
*/ environments: Record<string, EnvironmentContext>;
|
|
81
71
|
}) => MaybePromise<void>;
|
|
82
72
|
export type Routes = {
|
|
83
73
|
entryName: string;
|
|
@@ -87,53 +77,45 @@ export type OnAfterStartDevServerFn = (params: {
|
|
|
87
77
|
port: number;
|
|
88
78
|
routes: Routes;
|
|
89
79
|
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
environments: Record<string, EnvironmentContext>;
|
|
80
|
+
* Context information for all environments.
|
|
81
|
+
*/ environments: Record<string, EnvironmentContext>;
|
|
93
82
|
}) => MaybePromise<void>;
|
|
94
83
|
export type OnAfterStartPreviewServerFn = (params: {
|
|
95
84
|
port: number;
|
|
96
85
|
routes: Routes;
|
|
97
86
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
environments: Record<string, EnvironmentContext>;
|
|
87
|
+
* Context information for all environments.
|
|
88
|
+
*/ environments: Record<string, EnvironmentContext>;
|
|
101
89
|
}) => MaybePromise<void>;
|
|
102
90
|
export type OnBeforeCreateCompilerFn = (params: {
|
|
103
91
|
bundlerConfigs: Rspack.Configuration[];
|
|
104
92
|
/**
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
environments: Record<string, EnvironmentContext>;
|
|
93
|
+
* Context information for all environments.
|
|
94
|
+
*/ environments: Record<string, EnvironmentContext>;
|
|
108
95
|
}) => MaybePromise<void>;
|
|
109
96
|
export type OnAfterCreateCompilerFn<Compiler = Rspack.Compiler | Rspack.MultiCompiler> = (params: {
|
|
110
97
|
compiler: Compiler;
|
|
111
98
|
/**
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
environments: Record<string, EnvironmentContext>;
|
|
99
|
+
* Context information for all environments.
|
|
100
|
+
*/ environments: Record<string, EnvironmentContext>;
|
|
115
101
|
}) => MaybePromise<void>;
|
|
116
102
|
export type OnExitFn = (context: {
|
|
117
103
|
exitCode: number;
|
|
118
104
|
}) => void;
|
|
119
105
|
export type ModifyHTMLContext = {
|
|
120
106
|
/**
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
compilation: Rspack.Compilation;
|
|
107
|
+
* The Compilation object of Rspack.
|
|
108
|
+
*/ compilation: Rspack.Compilation;
|
|
124
109
|
/**
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
compiler: Rspack.Compiler;
|
|
110
|
+
* The Compiler object of Rspack.
|
|
111
|
+
*/ compiler: Rspack.Compiler;
|
|
128
112
|
/**
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
filename: string;
|
|
113
|
+
* The name of the HTML file, relative to the dist directory.
|
|
114
|
+
* @example 'index.html'
|
|
115
|
+
*/ filename: string;
|
|
133
116
|
/**
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
environment: EnvironmentContext;
|
|
117
|
+
* The environment context for current build.
|
|
118
|
+
*/ environment: EnvironmentContext;
|
|
137
119
|
};
|
|
138
120
|
export type ModifyHTMLFn = (html: string, context: ModifyHTMLContext) => MaybePromise<string>;
|
|
139
121
|
type HTMLTags = {
|
|
@@ -142,136 +124,110 @@ type HTMLTags = {
|
|
|
142
124
|
};
|
|
143
125
|
export type ModifyHTMLTagsContext = Pick<ModifyHTMLContext, 'compilation' | 'compiler' | 'filename' | 'environment'> & {
|
|
144
126
|
/**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
assetPrefix: string;
|
|
127
|
+
* URL prefix of assets.
|
|
128
|
+
* @example 'https://example.com/'
|
|
129
|
+
*/ assetPrefix: string;
|
|
149
130
|
};
|
|
150
131
|
export type ModifyHTMLTagsFn = (tags: HTMLTags, context: ModifyHTMLTagsContext) => MaybePromise<HTMLTags>;
|
|
151
132
|
export type ModifyRsbuildConfigUtils = {
|
|
152
|
-
/** Merge multiple Rsbuild config objects into one. */
|
|
153
|
-
mergeRsbuildConfig: (...configs: RsbuildConfig[]) => RsbuildConfig;
|
|
133
|
+
/** Merge multiple Rsbuild config objects into one. */ mergeRsbuildConfig: (...configs: RsbuildConfig[]) => RsbuildConfig;
|
|
154
134
|
};
|
|
155
135
|
type ArrayAtLeastOne<A, B> = [A, ...(A | B)[]] | [...(A | B)[], A];
|
|
156
136
|
export type ModifyEnvironmentConfigUtils = {
|
|
157
|
-
/** environment name. */
|
|
158
|
-
|
|
159
|
-
/** Merge multiple Rsbuild environment config objects into one. */
|
|
160
|
-
mergeEnvironmentConfig: (...configs: ArrayAtLeastOne<MergedEnvironmentConfig, EnvironmentConfig>) => MergedEnvironmentConfig;
|
|
137
|
+
/** environment name. */ name: string;
|
|
138
|
+
/** Merge multiple Rsbuild environment config objects into one. */ mergeEnvironmentConfig: (...configs: ArrayAtLeastOne<MergedEnvironmentConfig, EnvironmentConfig>) => MergedEnvironmentConfig;
|
|
161
139
|
};
|
|
162
140
|
export type ModifyRsbuildConfigFn = (config: RsbuildConfig, utils: ModifyRsbuildConfigUtils) => MaybePromise<RsbuildConfig | void>;
|
|
163
141
|
export type ModifyEnvironmentConfigFn = (config: MergedEnvironmentConfig, utils: ModifyEnvironmentConfigUtils) => MaybePromise<MergedEnvironmentConfig | void>;
|
|
164
142
|
export type EnvironmentContext = {
|
|
165
143
|
/**
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
* - The build has completed, accessible in hooks like `onAfterBuild`,
|
|
206
|
-
* `onAfterDevCompile` and `onAfterEnvironmentCompile` or via the environment API
|
|
207
|
-
*/
|
|
208
|
-
manifest?: Record<string, unknown> | ManifestData;
|
|
209
|
-
/**
|
|
210
|
-
* WebSocket authentication token, used to authenticate WebSocket connections and
|
|
211
|
-
* prevent unauthorized access. Only available in the development mode, and is
|
|
212
|
-
* an empty string in the production mode.
|
|
213
|
-
*/
|
|
214
|
-
webSocketToken: string;
|
|
144
|
+
* The index of the current environment.
|
|
145
|
+
*/ index: number;
|
|
146
|
+
/**
|
|
147
|
+
* The unique name of the current environment is used to distinguish and locate the
|
|
148
|
+
* environment, corresponds to the key in the `environments` configuration.
|
|
149
|
+
*/ name: string;
|
|
150
|
+
/**
|
|
151
|
+
* The entry object from the `source.entry` option.
|
|
152
|
+
*/ entry: RsbuildEntry;
|
|
153
|
+
/**
|
|
154
|
+
* The path information for all HTML assets.
|
|
155
|
+
* This value is an object, the key is the entry name and the value is the relative
|
|
156
|
+
* path of the HTML file in the dist directory.
|
|
157
|
+
*/ htmlPaths: Record<string, string>;
|
|
158
|
+
/**
|
|
159
|
+
* The absolute path of the output directory, corresponding to the `output.distPath.root`
|
|
160
|
+
* config of Rsbuild.
|
|
161
|
+
*/ distPath: string;
|
|
162
|
+
/**
|
|
163
|
+
* The browserslist configuration of the current environment.
|
|
164
|
+
*/ browserslist: string[];
|
|
165
|
+
/**
|
|
166
|
+
* The absolute path of the tsconfig.json file, or `undefined` if the tsconfig.json file
|
|
167
|
+
* does not exist in current project.
|
|
168
|
+
*/ tsconfigPath?: string;
|
|
169
|
+
/**
|
|
170
|
+
* The normalized Rsbuild config for the current environment.
|
|
171
|
+
*/ config: NormalizedEnvironmentConfig;
|
|
172
|
+
/**
|
|
173
|
+
* Manifest data. Only available when:
|
|
174
|
+
* - The `output.manifest` config is enabled
|
|
175
|
+
* - The build has completed, accessible in hooks like `onAfterBuild`,
|
|
176
|
+
* `onAfterDevCompile` and `onAfterEnvironmentCompile` or via the environment API
|
|
177
|
+
*/ manifest?: Record<string, unknown> | ManifestData;
|
|
178
|
+
/**
|
|
179
|
+
* WebSocket authentication token, used to authenticate WebSocket connections and
|
|
180
|
+
* prevent unauthorized access. Only available in the development mode, and is
|
|
181
|
+
* an empty string in the production mode.
|
|
182
|
+
*/ webSocketToken: string;
|
|
215
183
|
};
|
|
216
184
|
export type ModifyChainUtils = {
|
|
217
185
|
/**
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
env: string;
|
|
186
|
+
* The value of `process.env.NODE_ENV`
|
|
187
|
+
*/ env: string;
|
|
221
188
|
/**
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
isDev: boolean;
|
|
189
|
+
* A boolean value indicating whether this is a development build.
|
|
190
|
+
* Set to `true` when the `mode` is `development`.
|
|
191
|
+
*/ isDev: boolean;
|
|
226
192
|
/**
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
isProd: boolean;
|
|
193
|
+
* A boolean value indicating whether this is a production build.
|
|
194
|
+
* Set to `true` when the `mode` is `production`.
|
|
195
|
+
*/ isProd: boolean;
|
|
231
196
|
/**
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
target: RsbuildTarget;
|
|
197
|
+
* The current build target.
|
|
198
|
+
*/ target: RsbuildTarget;
|
|
235
199
|
/**
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
isServer: boolean;
|
|
200
|
+
* A boolean value indicating whether the build target is `node`.
|
|
201
|
+
* Equivalent to `target === 'node'`.
|
|
202
|
+
*/ isServer: boolean;
|
|
240
203
|
/**
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
isWebWorker: boolean;
|
|
204
|
+
* A boolean value indicating whether the build target is `web-worker`.
|
|
205
|
+
* Equivalent to `target === 'web-worker'`.
|
|
206
|
+
*/ isWebWorker: boolean;
|
|
245
207
|
/**
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
CHAIN_ID: ChainIdentifier;
|
|
208
|
+
* Predefined chain IDs.
|
|
209
|
+
*/ CHAIN_ID: ChainIdentifier;
|
|
249
210
|
/**
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
environment: EnvironmentContext;
|
|
211
|
+
* The environment context for current build.
|
|
212
|
+
*/ environment: EnvironmentContext;
|
|
253
213
|
/**
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
environments: Record<string, EnvironmentContext>;
|
|
214
|
+
* Context information for all environments.
|
|
215
|
+
*/ environments: Record<string, EnvironmentContext>;
|
|
257
216
|
/**
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
rspack: typeof rspack;
|
|
217
|
+
* The Rspack instance, same as `import { rspack } from '@rsbuild/core'`.
|
|
218
|
+
*/ rspack: typeof rspack;
|
|
261
219
|
/**
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
HtmlPlugin: typeof HtmlRspackPlugin;
|
|
220
|
+
* The default export of `html-rspack-plugin`.
|
|
221
|
+
*/ HtmlPlugin: typeof HtmlRspackPlugin;
|
|
265
222
|
};
|
|
266
223
|
export type ModifyBundlerChainUtils = ModifyChainUtils & {
|
|
267
224
|
/**
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
bundler: typeof rspack;
|
|
225
|
+
* @deprecated Use `rspack` instead.
|
|
226
|
+
*/ bundler: typeof rspack;
|
|
271
227
|
};
|
|
272
228
|
export type ModifyBundlerChainFn = (chain: RspackChain, utils: ModifyBundlerChainUtils) => MaybePromise<void>;
|
|
273
229
|
export type CreateAsyncHook<Callback extends (...args: any[]) => any> = {
|
|
274
230
|
tap: (cb: Callback) => void;
|
|
275
231
|
call: (...args: Parameters<Callback>) => Promise<Parameters<Callback>>;
|
|
276
232
|
};
|
|
277
|
-
export {};
|
|
233
|
+
export { };
|