@rsbuild/core 2.0.8 → 2.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/compiled/connect-next/package.json +1 -1
- package/compiled/css-loader/index.js +2 -2
- package/compiled/html-rspack-plugin/index.js +14 -14
- package/compiled/html-rspack-plugin/package.json +1 -1
- package/compiled/postcss-loader/index.js +6 -6
- package/compiled/rslog/index.d.ts +3 -3
- package/compiled/rslog/package.json +1 -1
- package/compiled/rspack-chain/package.json +1 -1
- package/dist/1~rslib-runtime.js +8 -5
- package/dist/756.js +25 -21
- package/dist/launch-editor-middleware.js +58 -23
- package/dist/manifest-plugin.js +6 -6
- package/dist/memfs.js +101 -99
- package/dist/tinyglobby.js +11 -9
- 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 +13 -13
- 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
|
@@ -10,86 +10,74 @@ import type { Rspack } from './rspack';
|
|
|
10
10
|
import type { Falsy } from './utils';
|
|
11
11
|
export type StartDevServerOptions = {
|
|
12
12
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
getPortSilently?: boolean;
|
|
13
|
+
* Whether to get port silently and not print any logs.
|
|
14
|
+
* @default false
|
|
15
|
+
*/ getPortSilently?: boolean;
|
|
17
16
|
};
|
|
18
17
|
export type CreateDevServerOptions = StartDevServerOptions & {
|
|
19
18
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
runCompile?: boolean;
|
|
19
|
+
* Whether to trigger Rsbuild compilation
|
|
20
|
+
* @default true
|
|
21
|
+
*/ runCompile?: boolean;
|
|
24
22
|
};
|
|
25
23
|
export type PreviewOptions = {
|
|
26
24
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
getPortSilently?: boolean;
|
|
25
|
+
* Whether to get port silently and not print any logs.
|
|
26
|
+
* @default false
|
|
27
|
+
*/ getPortSilently?: boolean;
|
|
31
28
|
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
checkDistDir?: boolean;
|
|
29
|
+
* Whether to check if the dist directory exists and is not empty.
|
|
30
|
+
* @default true
|
|
31
|
+
*/ checkDistDir?: boolean;
|
|
36
32
|
};
|
|
37
33
|
export type BuildOptions = {
|
|
38
34
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
watch?: boolean;
|
|
35
|
+
* Whether to watch for file changes and rebuild.
|
|
36
|
+
* @default false
|
|
37
|
+
*/ watch?: boolean;
|
|
43
38
|
};
|
|
44
39
|
export type Build = (options?: BuildOptions) => Promise<BuildResult>;
|
|
45
40
|
export type BuildResult = {
|
|
46
41
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
close: () => Promise<void>;
|
|
42
|
+
* Close the build and call the `onCloseBuild` hook.
|
|
43
|
+
* In watch mode, this method will stop watching.
|
|
44
|
+
*/ close: () => Promise<void>;
|
|
51
45
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
stats?: Rspack.Stats | Rspack.MultiStats;
|
|
46
|
+
* Rspack's [stats](https://rspack.rs/api/javascript-api/stats) object.
|
|
47
|
+
*/ stats?: Rspack.Stats | Rspack.MultiStats;
|
|
55
48
|
};
|
|
56
49
|
export type InitConfigsOptions = Pick<RsbuildContext, 'action'>;
|
|
57
50
|
export type InspectConfigOptions = {
|
|
58
51
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
* // ...
|
|
89
|
-
* },
|
|
90
|
-
* }
|
|
91
|
-
*/
|
|
92
|
-
extraConfigs?: Record<string, unknown>;
|
|
52
|
+
* Inspect the config in the specified mode.
|
|
53
|
+
* Available options: 'development' or 'production'.
|
|
54
|
+
* @default 'development'
|
|
55
|
+
*/ mode?: RsbuildMode;
|
|
56
|
+
/**
|
|
57
|
+
* Enables verbose mode to display the complete function
|
|
58
|
+
* content in the configuration.
|
|
59
|
+
* @default false
|
|
60
|
+
*/ verbose?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Specify the output path for inspection results.
|
|
63
|
+
* @default 'output.distPath.root'
|
|
64
|
+
*/ outputPath?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Whether to write the inspection results to disk.
|
|
67
|
+
* @default false
|
|
68
|
+
*/ writeToDisk?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Extra configurations to be output.
|
|
71
|
+
* - key: The name of the configuration
|
|
72
|
+
* - value: The configuration object
|
|
73
|
+
* @example
|
|
74
|
+
* extraConfigs: {
|
|
75
|
+
* // Output `rstest.config.mjs` file
|
|
76
|
+
* 'rstest': {
|
|
77
|
+
* // ...
|
|
78
|
+
* },
|
|
79
|
+
* }
|
|
80
|
+
*/ extraConfigs?: Record<string, unknown>;
|
|
93
81
|
};
|
|
94
82
|
export type InspectConfigResult = {
|
|
95
83
|
rsbuildConfig: string;
|
|
@@ -104,39 +92,33 @@ export type InspectConfigResult = {
|
|
|
104
92
|
export type CreateCompiler = () => Promise<Compiler | MultiCompiler>;
|
|
105
93
|
export type CreateRsbuildOptions = {
|
|
106
94
|
/**
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Whether to call `loadEnv` to load environment variables and define them
|
|
136
|
-
* as global variables via `source.define`.
|
|
137
|
-
* @default false
|
|
138
|
-
*/
|
|
139
|
-
loadEnv?: boolean | LoadEnvOptions;
|
|
95
|
+
* The root path of current project.
|
|
96
|
+
* @default process.cwd()
|
|
97
|
+
*/ cwd?: string;
|
|
98
|
+
/**
|
|
99
|
+
* The name of the framework or tool that is currently invoking Rsbuild.
|
|
100
|
+
* This allows plugins to tailor their behavior based on the calling context.
|
|
101
|
+
* Rsbuild plugins can access this value via `api.context.callerName`.
|
|
102
|
+
* @default 'rsbuild'
|
|
103
|
+
*/ callerName?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Only build specified environments.
|
|
106
|
+
* For example, passing `['web']` will only build the `web` environment.
|
|
107
|
+
* If not specified or passing an empty array, all environments will be built.
|
|
108
|
+
*/ environment?: string[];
|
|
109
|
+
/**
|
|
110
|
+
* Alias for `config`.
|
|
111
|
+
* This option will be deprecated in the future.
|
|
112
|
+
*/ rsbuildConfig?: RsbuildConfig | (() => Promise<RsbuildConfig>);
|
|
113
|
+
/**
|
|
114
|
+
* Rsbuild configurations.
|
|
115
|
+
* Passing a function to load the config asynchronously with custom logic.
|
|
116
|
+
*/ config?: RsbuildConfig | (() => Promise<RsbuildConfig>);
|
|
117
|
+
/**
|
|
118
|
+
* Whether to call `loadEnv` to load environment variables and define them
|
|
119
|
+
* as global variables via `source.define`.
|
|
120
|
+
* @default false
|
|
121
|
+
*/ loadEnv?: boolean | LoadEnvOptions;
|
|
140
122
|
};
|
|
141
123
|
export type ResolvedCreateRsbuildOptions = Required<Pick<CreateRsbuildOptions, 'cwd' | 'callerName'>> & Pick<CreateRsbuildOptions, 'loadEnv' | 'environment'> & {
|
|
142
124
|
rsbuildConfig: RsbuildConfig;
|
|
@@ -146,123 +128,106 @@ export type StartDevServer = (options?: StartDevServerOptions) => Promise<StartD
|
|
|
146
128
|
export type InspectConfig = (options?: InspectConfigOptions) => Promise<InspectConfigResult>;
|
|
147
129
|
export type AddPluginsOptions = {
|
|
148
130
|
/**
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
before?: string;
|
|
131
|
+
* Insert before the specified plugin.
|
|
132
|
+
*/ before?: string;
|
|
152
133
|
/**
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
environment?: string;
|
|
134
|
+
* Specify the environment that the plugin will be applied to.
|
|
135
|
+
* If not specified, the plugin will be be registered as a global plugin and
|
|
136
|
+
* applied to all environments.
|
|
137
|
+
*/ environment?: string;
|
|
158
138
|
};
|
|
159
139
|
export type AddPlugins = (plugins: (RsbuildPlugin | Falsy)[], options?: AddPluginsOptions) => void;
|
|
160
140
|
export type RsbuildInstance = {
|
|
161
141
|
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
* Get all the Rsbuild plugins registered in the current Rsbuild instance.
|
|
175
|
-
*/
|
|
176
|
-
getPlugins: (options?: {
|
|
142
|
+
* The logger associated with the current Rsbuild instance.
|
|
143
|
+
* It reflects `config.customLogger` when provided, otherwise uses a logger
|
|
144
|
+
* created specifically for the current Rsbuild instance.
|
|
145
|
+
*/ logger: Logger;
|
|
146
|
+
/**
|
|
147
|
+
* Register one or more Rsbuild plugins, which can be called multiple times.
|
|
148
|
+
* This method needs to be called before compiling. If it is called after
|
|
149
|
+
* compiling, it will not affect the compilation result.
|
|
150
|
+
*/ addPlugins: AddPlugins;
|
|
151
|
+
/**
|
|
152
|
+
* Get all the Rsbuild plugins registered in the current Rsbuild instance.
|
|
153
|
+
*/ getPlugins: (options?: {
|
|
177
154
|
/**
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
environment: string;
|
|
155
|
+
* Get the plugins in the specified environment.
|
|
156
|
+
* If environment is not specified, get the global plugins.
|
|
157
|
+
*/ environment: string;
|
|
182
158
|
}) => RsbuildPlugin[];
|
|
183
159
|
/**
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
removePlugins: (pluginNames: string[], options?: {
|
|
160
|
+
* Removes one or more Rsbuild plugins, which can be called multiple times.
|
|
161
|
+
* This method needs to be called before compiling. If it is called after
|
|
162
|
+
* compiling, it will not affect the compilation result.
|
|
163
|
+
*/ removePlugins: (pluginNames: string[], options?: {
|
|
189
164
|
/**
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
environment?: string;
|
|
165
|
+
* Remove the plugin in the specified environment.
|
|
166
|
+
* If environment is not specified, remove it in all environments.
|
|
167
|
+
*/ environment?: string;
|
|
194
168
|
}) => void;
|
|
195
169
|
/**
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Start the local dev server. This method will:
|
|
245
|
-
*
|
|
246
|
-
* 1. Start a development server that serves your application.
|
|
247
|
-
* 2. Watch for file changes and trigger recompilation.
|
|
248
|
-
*/
|
|
249
|
-
startDevServer: StartDevServer;
|
|
170
|
+
* Perform a production mode build. This method will generate optimized
|
|
171
|
+
* production bundles and emit them to the output directory.
|
|
172
|
+
*/ build: Build;
|
|
173
|
+
/**
|
|
174
|
+
* Start a server to preview the production build locally.
|
|
175
|
+
* This method should be executed after `rsbuild.build`.
|
|
176
|
+
*/ preview: (options?: PreviewOptions) => Promise<StartPreviewServerResult>;
|
|
177
|
+
/**
|
|
178
|
+
* Initialize and return the internal Rspack configurations used by Rsbuild.
|
|
179
|
+
* This method processes all plugins and configurations to generate the final
|
|
180
|
+
* Rspack configs. Note: You typically don't need to call this method directly
|
|
181
|
+
* since it's automatically invoked by methods like `rsbuild.build` and
|
|
182
|
+
* `rsbuild.startDevServer`.
|
|
183
|
+
*/ initConfigs: (options?: InitConfigsOptions) => Promise<Rspack.Configuration[]>;
|
|
184
|
+
/**
|
|
185
|
+
* Inspect and debug Rsbuild's internal configurations. It provides access to:
|
|
186
|
+
* - The resolved Rsbuild configuration
|
|
187
|
+
* - The environment-specific Rsbuild configurations
|
|
188
|
+
* - The generated Rspack configurations
|
|
189
|
+
*
|
|
190
|
+
* The method serializes these configurations to strings and optionally writes
|
|
191
|
+
* them to disk for inspection.
|
|
192
|
+
*/ inspectConfig: (options?: InspectConfigOptions) => Promise<InspectConfigResult>;
|
|
193
|
+
/**
|
|
194
|
+
* Create an Rspack [Compiler](https://rspack.rs/api/javascript-api/compiler)
|
|
195
|
+
* instance. If there are multiple [environments](/config/environments) for
|
|
196
|
+
* this build, the return value is `MultiCompiler`.
|
|
197
|
+
*/ createCompiler: CreateCompiler;
|
|
198
|
+
/**
|
|
199
|
+
* Rsbuild includes a built-in dev server designed to improve the development
|
|
200
|
+
* experience. When you run the `rsbuild dev` command, the server starts
|
|
201
|
+
* automatically and provides features such as page preview, routing, and hot
|
|
202
|
+
* module reloading.
|
|
203
|
+
*
|
|
204
|
+
* If you want to integrate the Rsbuild dev server into a custom server, you
|
|
205
|
+
* can use the `createDevServer` method to create a dev server instance and
|
|
206
|
+
* call its methods as needed.
|
|
207
|
+
*
|
|
208
|
+
* If you want to directly start the Rsbuild dev server, use the
|
|
209
|
+
* `rsbuild.startDevServer` method.
|
|
210
|
+
*/ createDevServer: CreateDevServer;
|
|
211
|
+
/**
|
|
212
|
+
* Start the local dev server. This method will:
|
|
213
|
+
*
|
|
214
|
+
* 1. Start a development server that serves your application.
|
|
215
|
+
* 2. Watch for file changes and trigger recompilation.
|
|
216
|
+
*/ startDevServer: StartDevServer;
|
|
250
217
|
} & Pick<RsbuildPluginAPI, 'context' | 'expose' | 'getNormalizedConfig' | 'getRsbuildConfig' | 'isPluginExists' | 'modifyEnvironmentConfig' | 'modifyRsbuildConfig' | 'onAfterBuild' | 'onAfterCreateCompiler' | 'onAfterDevCompile' | 'onAfterEnvironmentCompile' | 'onAfterStartDevServer' | 'onAfterStartPreviewServer' | 'onBeforeBuild' | 'onBeforeCreateCompiler' | 'onBeforeDevCompile' | 'onBeforeEnvironmentCompile' | 'onBeforeStartDevServer' | 'onBeforeStartPreviewServer' | 'onCloseBuild' | 'onCloseDevServer' | 'onDevCompileDone' | 'onExit'>;
|
|
251
218
|
export type RsbuildTarget = 'web' | 'node' | 'web-worker';
|
|
252
219
|
export type RsbuildEntryDescription = Rspack.EntryDescription & {
|
|
253
220
|
/**
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
html?: boolean;
|
|
221
|
+
* Whether to generate an HTML file for the entry.
|
|
222
|
+
*
|
|
223
|
+
* @default true
|
|
224
|
+
*/ html?: boolean;
|
|
259
225
|
};
|
|
260
226
|
export type RsbuildEntry = Record<string, string | string[] | RsbuildEntryDescription>;
|
|
261
227
|
export type RsbuildMode = 'development' | 'production' | 'none';
|
|
262
228
|
export type RsbuildStatsItem = Pick<Rspack.StatsCompilation, 'errors' | 'warnings' | 'entrypoints' | 'hash'>;
|
|
263
229
|
/**
|
|
264
230
|
* A subset of Rspack's StatsCompilation with only the fields we need
|
|
265
|
-
*/
|
|
266
|
-
export type RsbuildStats = RsbuildStatsItem & {
|
|
231
|
+
*/ export type RsbuildStats = RsbuildStatsItem & {
|
|
267
232
|
children: RsbuildStatsItem[];
|
|
268
233
|
};
|