@lynx-js/rspeedy 0.8.2
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/CHANGELOG.md +208 -0
- package/LICENSE +202 -0
- package/README.md +32 -0
- package/bin/rspeedy.js +33 -0
- package/client/hmr/WebSocketClient.js +65 -0
- package/client.d.ts +5 -0
- package/lib/api.d.ts +46 -0
- package/lib/api.js +2 -0
- package/lib/cli/build.d.ts +4 -0
- package/lib/cli/build.js +32 -0
- package/lib/cli/commands.d.ts +5 -0
- package/lib/cli/commands.js +45 -0
- package/lib/cli/dev.d.ts +4 -0
- package/lib/cli/dev.js +75 -0
- package/lib/cli/exit.d.ts +1 -0
- package/lib/cli/exit.js +51 -0
- package/lib/cli/inspect.d.ts +8 -0
- package/lib/cli/inspect.js +30 -0
- package/lib/cli/main.d.ts +1 -0
- package/lib/cli/main.js +39 -0
- package/lib/cli/preview.d.ts +4 -0
- package/lib/cli/preview.js +31 -0
- package/lib/cli/start.d.ts +6 -0
- package/lib/cli/start.js +88 -0
- package/lib/config/defaults.d.ts +2 -0
- package/lib/config/defaults.js +32 -0
- package/lib/config/defineConfig.d.ts +22 -0
- package/lib/config/defineConfig.js +24 -0
- package/lib/config/dev/client.d.ts +15 -0
- package/lib/config/dev/client.js +2 -0
- package/lib/config/dev/index.d.ts +133 -0
- package/lib/config/dev/index.js +2 -0
- package/lib/config/index.d.ts +172 -0
- package/lib/config/index.js +2 -0
- package/lib/config/loadConfig.d.ts +50 -0
- package/lib/config/loadConfig.js +98 -0
- package/lib/config/output/css-modules.d.ts +84 -0
- package/lib/config/output/css-modules.js +2 -0
- package/lib/config/output/dist-path.d.ts +68 -0
- package/lib/config/output/dist-path.js +2 -0
- package/lib/config/output/filename.d.ts +167 -0
- package/lib/config/output/filename.js +2 -0
- package/lib/config/output/index.d.ts +320 -0
- package/lib/config/output/index.js +2 -0
- package/lib/config/output/minify.d.ts +80 -0
- package/lib/config/output/minify.js +2 -0
- package/lib/config/output/source-map.d.ts +68 -0
- package/lib/config/output/source-map.js +2 -0
- package/lib/config/performance/chunk-split.d.ts +192 -0
- package/lib/config/performance/chunk-split.js +2 -0
- package/lib/config/performance/index.d.ts +50 -0
- package/lib/config/performance/index.js +2 -0
- package/lib/config/rsbuild/entry.d.ts +3 -0
- package/lib/config/rsbuild/entry.js +31 -0
- package/lib/config/rsbuild/index.d.ts +4 -0
- package/lib/config/rsbuild/index.js +70 -0
- package/lib/config/server/index.d.ts +47 -0
- package/lib/config/server/index.js +2 -0
- package/lib/config/source/decorators.d.ts +43 -0
- package/lib/config/source/decorators.js +2 -0
- package/lib/config/source/entry.d.ts +84 -0
- package/lib/config/source/entry.js +2 -0
- package/lib/config/source/index.d.ts +474 -0
- package/lib/config/source/index.js +2 -0
- package/lib/config/source/transformImport.d.ts +106 -0
- package/lib/config/source/transformImport.js +2 -0
- package/lib/config/tools/css-extract.d.ts +72 -0
- package/lib/config/tools/css-extract.js +2 -0
- package/lib/config/tools/css-loader.d.ts +130 -0
- package/lib/config/tools/css-loader.js +2 -0
- package/lib/config/tools/index.d.ts +170 -0
- package/lib/config/tools/index.js +2 -0
- package/lib/config/validate.d.ts +4 -0
- package/lib/config/validate.js +28962 -0
- package/lib/create-rspeedy.d.ts +45 -0
- package/lib/create-rspeedy.js +48 -0
- package/lib/debug.d.ts +3 -0
- package/lib/debug.js +25 -0
- package/lib/index.d.ts +45 -0
- package/lib/index.js +10 -0
- package/lib/plugins/api.plugin.d.ts +3 -0
- package/lib/plugins/api.plugin.js +25 -0
- package/lib/plugins/chunkLoading.plugin.d.ts +2 -0
- package/lib/plugins/chunkLoading.plugin.js +30 -0
- package/lib/plugins/dev.plugin.d.ts +5 -0
- package/lib/plugins/dev.plugin.js +130 -0
- package/lib/plugins/index.d.ts +3 -0
- package/lib/plugins/index.js +49 -0
- package/lib/plugins/inspect.plugin.d.ts +4 -0
- package/lib/plugins/inspect.plugin.js +39 -0
- package/lib/plugins/minify.plugin.d.ts +3 -0
- package/lib/plugins/minify.plugin.js +89 -0
- package/lib/plugins/optimization.plugin.d.ts +2 -0
- package/lib/plugins/optimization.plugin.js +31 -0
- package/lib/plugins/output.plugin.d.ts +3 -0
- package/lib/plugins/output.plugin.js +34 -0
- package/lib/plugins/resolve.plugin.d.ts +2 -0
- package/lib/plugins/resolve.plugin.js +38 -0
- package/lib/plugins/rsdoctor.plugin.d.ts +3 -0
- package/lib/plugins/rsdoctor.plugin.js +41 -0
- package/lib/plugins/sourcemap.plugin.d.ts +2 -0
- package/lib/plugins/sourcemap.plugin.js +84 -0
- package/lib/plugins/stats.plugin.d.ts +2 -0
- package/lib/plugins/stats.plugin.js +20 -0
- package/lib/plugins/swc.plugin.d.ts +2 -0
- package/lib/plugins/swc.plugin.js +21 -0
- package/lib/plugins/target.plugin.d.ts +2 -0
- package/lib/plugins/target.plugin.js +12 -0
- package/lib/utils/getESVersionTarget.d.ts +1 -0
- package/lib/utils/getESVersionTarget.js +7 -0
- package/lib/utils/is-ci.d.ts +1 -0
- package/lib/utils/is-ci.js +7 -0
- package/lib/version.d.ts +4 -0
- package/lib/version.js +15 -0
- package/lib/webpack/CompilationIdPlugin.d.ts +4 -0
- package/lib/webpack/CompilationIdPlugin.js +20 -0
- package/lib/webpack/EvalSourceMapDevToolPlugin.d.ts +9 -0
- package/lib/webpack/EvalSourceMapDevToolPlugin.js +15 -0
- package/lib/webpack/ProvidePlugin.d.ts +9 -0
- package/lib/webpack/ProvidePlugin.js +15 -0
- package/lib/webpack/SourceMapDevToolPlugin.d.ts +9 -0
- package/lib/webpack/SourceMapDevToolPlugin.js +15 -0
- package/package.json +83 -0
- package/register/data.d.ts +9 -0
- package/register/hooks.js +146 -0
- package/register/index.d.ts +4 -0
- package/register/index.js +47 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import type { Rspack } from '@rsbuild/core';
|
|
2
|
+
import type { CssModules } from './css-modules.js';
|
|
3
|
+
import type { DistPath } from './dist-path.js';
|
|
4
|
+
import type { Filename } from './filename.js';
|
|
5
|
+
import type { Minify } from './minify.js';
|
|
6
|
+
import type { SourceMap } from './source-map.js';
|
|
7
|
+
/**
|
|
8
|
+
* {@inheritdoc Config.output}
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export interface Output {
|
|
12
|
+
/**
|
|
13
|
+
* The {@link Output.assetPrefix} is used to set the URL prefix for static assets.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
*
|
|
17
|
+
* The functionality of {@link Output.assetPrefix} is basically the same as the {@link https://www.rspack.dev/config/output#outputpublicpath | output.publicPath}
|
|
18
|
+
* config in Rspack. With the following differences:
|
|
19
|
+
*
|
|
20
|
+
* - `output.assetPrefix` only takes effect in the production build.
|
|
21
|
+
*
|
|
22
|
+
* - `output.assetPrefix` automatically appends a trailing `/` by default.
|
|
23
|
+
*
|
|
24
|
+
* - The value of `output.assetPrefix` is written to the `process.env.ASSET_PREFIX` environment variable.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
*
|
|
28
|
+
* ```js
|
|
29
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
30
|
+
* export default defineConfig({
|
|
31
|
+
* output: {
|
|
32
|
+
* assetPrefix: 'https://cdn.example.com/assets/',
|
|
33
|
+
* },
|
|
34
|
+
* })
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
assetPrefix?: string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* The {@link Output.cleanDistPath} option determines whether all files in the output directory (default: `dist`) are removed before the build starts.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
*
|
|
43
|
+
* By default, if the output directory is a subdirectory of the project root path, Rspeedy will automatically clean all files in the build directory.
|
|
44
|
+
*
|
|
45
|
+
* When {@link DistPath.root | output.distPath.root} is an external directory or the same as the project root directory, `cleanDistPath` is not enabled by default to prevent accidental deletion of files from other directories.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
*
|
|
49
|
+
* - Disable cleaning files:
|
|
50
|
+
*
|
|
51
|
+
* ```js
|
|
52
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
53
|
+
* export default defineConfig({
|
|
54
|
+
* output: {
|
|
55
|
+
* cleanDistPath: false,
|
|
56
|
+
* },
|
|
57
|
+
* })
|
|
58
|
+
* ```
|
|
59
|
+
* @example
|
|
60
|
+
*
|
|
61
|
+
* - Only clean files before the production build:
|
|
62
|
+
*
|
|
63
|
+
* ```js
|
|
64
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
65
|
+
* export default defineConfig({
|
|
66
|
+
* output: {
|
|
67
|
+
* cleanDistPath: process.env.NODE_ENV === 'production',
|
|
68
|
+
* },
|
|
69
|
+
* })
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
cleanDistPath?: boolean | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* The {@link Output.copy} option is used for copying files to the dist directory.
|
|
75
|
+
*
|
|
76
|
+
* @remarks
|
|
77
|
+
*
|
|
78
|
+
* For more options, see {@link https://rspack.dev/plugins/rspack/copy-rspack-plugin | Rspack.CopyRspackPlugin}.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
*
|
|
82
|
+
* - Copy files from `./src/assets` to the `./dist` directory:
|
|
83
|
+
*
|
|
84
|
+
* ```js
|
|
85
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
86
|
+
*
|
|
87
|
+
* export default defineConfig({
|
|
88
|
+
* output: {
|
|
89
|
+
* copy: [
|
|
90
|
+
* // `./src/assets/image.png` -> `./dist/image.png`
|
|
91
|
+
* { from: './src/assets' },
|
|
92
|
+
* ],
|
|
93
|
+
* },
|
|
94
|
+
* })
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
*
|
|
99
|
+
* - Copy files from ./src/assets to the ./dist/assets directory:
|
|
100
|
+
*
|
|
101
|
+
* ```js
|
|
102
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
103
|
+
*
|
|
104
|
+
* export default defineConfig({
|
|
105
|
+
* output: {
|
|
106
|
+
* copy: [
|
|
107
|
+
* // `./src/assets/image.png` -> `./dist/assets/image.png`
|
|
108
|
+
* { from: './src/assets', to: 'assets' },
|
|
109
|
+
* ],
|
|
110
|
+
* },
|
|
111
|
+
* })
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
copy?: Rspack.CopyRspackPluginOptions | Rspack.CopyRspackPluginOptions['patterns'] | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* The {@link CssModules} option is used for the customization of CSS Modules configurations.
|
|
117
|
+
*
|
|
118
|
+
* @remarks
|
|
119
|
+
*
|
|
120
|
+
* The CSS module is enabled for `*.module.css`, `*.module.scss` and `*.module.less`.
|
|
121
|
+
* Use {@link CssModules.auto} to customize the filtering behavior.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
*
|
|
125
|
+
* Disable CSS modules:
|
|
126
|
+
*
|
|
127
|
+
* ```js
|
|
128
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
129
|
+
* export default defineConfig({
|
|
130
|
+
* output: {
|
|
131
|
+
* cssModules: {
|
|
132
|
+
* auto: false,
|
|
133
|
+
* },
|
|
134
|
+
* },
|
|
135
|
+
* })
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
*
|
|
140
|
+
* Enable CSS modules for all CSS files:
|
|
141
|
+
*
|
|
142
|
+
* ```js
|
|
143
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
144
|
+
* export default defineConfig({
|
|
145
|
+
* output: {
|
|
146
|
+
* cssModules: {
|
|
147
|
+
* auto: () => true,
|
|
148
|
+
* },
|
|
149
|
+
* },
|
|
150
|
+
* })
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
cssModules?: CssModules | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* The {@link Output.dataUriLimit} option is used to set the size threshold to inline static assets such as images and fonts.
|
|
156
|
+
*
|
|
157
|
+
* @remarks
|
|
158
|
+
*
|
|
159
|
+
* The default value of `dataUriLimit` is 2kB.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
*
|
|
163
|
+
* Inline all static assets less than 4kB:
|
|
164
|
+
*
|
|
165
|
+
* ```js
|
|
166
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
167
|
+
* export default defineConfig({
|
|
168
|
+
* output: {
|
|
169
|
+
* dataUriLimit: 4 * 1024,
|
|
170
|
+
* },
|
|
171
|
+
* })
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
*
|
|
176
|
+
* Disable inlining of static assets:
|
|
177
|
+
*
|
|
178
|
+
* ```js
|
|
179
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
180
|
+
* export default defineConfig({
|
|
181
|
+
* output: {
|
|
182
|
+
* dataUriLimit: 0,
|
|
183
|
+
* },
|
|
184
|
+
* })
|
|
185
|
+
* ```
|
|
186
|
+
* @example
|
|
187
|
+
*
|
|
188
|
+
* Inline all static assets:
|
|
189
|
+
*
|
|
190
|
+
* ```js
|
|
191
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
192
|
+
* export default defineConfig({
|
|
193
|
+
* output: {
|
|
194
|
+
* dataUriLimit: Number.MAX_SAFE_INTEGER,
|
|
195
|
+
* },
|
|
196
|
+
* })
|
|
197
|
+
* ```
|
|
198
|
+
*/
|
|
199
|
+
dataUriLimit?: number | undefined;
|
|
200
|
+
/**
|
|
201
|
+
* Set the directory of the dist files.
|
|
202
|
+
*
|
|
203
|
+
* @example
|
|
204
|
+
*
|
|
205
|
+
* Use `output` instead of `dist`(the default value):
|
|
206
|
+
*
|
|
207
|
+
* ```js
|
|
208
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
209
|
+
* export default defineConfig({
|
|
210
|
+
* output: {
|
|
211
|
+
* distPath: {
|
|
212
|
+
* root: './output',
|
|
213
|
+
* },
|
|
214
|
+
* },
|
|
215
|
+
* })
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
distPath?: DistPath | undefined;
|
|
219
|
+
/**
|
|
220
|
+
* The {@link Filename} determines the name of the JavaScript bundle file to be output. These bundles will be written to the directory specified by output.path.
|
|
221
|
+
*
|
|
222
|
+
* @remarks
|
|
223
|
+
*
|
|
224
|
+
* If a string is provided, it will be used as {@link Filename.bundle}.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
*
|
|
228
|
+
* ```js
|
|
229
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
230
|
+
* export default defineConfig({
|
|
231
|
+
* output: {
|
|
232
|
+
* filename: '[name]/[name].lynx.bundle',
|
|
233
|
+
* },
|
|
234
|
+
* })
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
filename?: string | Filename | undefined;
|
|
238
|
+
/**
|
|
239
|
+
* The {@link Output.filenameHash} option controls whether to add a hash value to the filename after the production build.
|
|
240
|
+
*
|
|
241
|
+
* @remarks
|
|
242
|
+
*
|
|
243
|
+
* {@link Output.filename} has a higher priority than {@link Output.filenameHash}.
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
*
|
|
247
|
+
* - Disable hash
|
|
248
|
+
*
|
|
249
|
+
* ```js
|
|
250
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
251
|
+
*
|
|
252
|
+
* export default defineConfig({
|
|
253
|
+
* output: {
|
|
254
|
+
* filenameHash: false,
|
|
255
|
+
* },
|
|
256
|
+
* })
|
|
257
|
+
* ```
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
*
|
|
261
|
+
* - Change hash format
|
|
262
|
+
*
|
|
263
|
+
* ```js
|
|
264
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
265
|
+
*
|
|
266
|
+
* export default defineConfig({
|
|
267
|
+
* output: {
|
|
268
|
+
* filenameHash: 'fullhash:16',
|
|
269
|
+
* },
|
|
270
|
+
* })
|
|
271
|
+
* ```
|
|
272
|
+
*
|
|
273
|
+
* The available hash formats are:
|
|
274
|
+
*
|
|
275
|
+
* - `fullhash`: The hash value of the entire compilation. If any file changes, the hash values of all output files in the entire project will change.
|
|
276
|
+
*
|
|
277
|
+
* - `chunkhash`: The hash value of the chunk. The hash value will only change when the content of the chunk (and its included modules) changes.
|
|
278
|
+
*
|
|
279
|
+
* - `contenthash`: The hash value of the file content. The hash value will only change when the content of the file itself changes.
|
|
280
|
+
*/
|
|
281
|
+
filenameHash?: boolean | string | undefined;
|
|
282
|
+
/**
|
|
283
|
+
* The {@link Output.legalComments} controls how to handle the legal comment.
|
|
284
|
+
*
|
|
285
|
+
* @remarks
|
|
286
|
+
*
|
|
287
|
+
* If no value is provided, the default value would be `'none'`.
|
|
288
|
+
*
|
|
289
|
+
* This is different with Rsbuild since we normally do not want a `.LEGAL.txt` file in Lynx outputs.
|
|
290
|
+
*
|
|
291
|
+
* This behavior can be configured by using one of the following options:
|
|
292
|
+
*
|
|
293
|
+
* - `linked`: Extract all legal comments to a `.LEGAL.txt` file and link to them with a comment.
|
|
294
|
+
*
|
|
295
|
+
* - `inline`: Preserve all legal comments in original position.
|
|
296
|
+
*
|
|
297
|
+
* - `none`: Remove all legal comments.
|
|
298
|
+
*/
|
|
299
|
+
legalComments?: 'none' | 'inline' | 'linked' | undefined;
|
|
300
|
+
/**
|
|
301
|
+
* The {@link Minify} configures whether to enable code minification in the production build, or to configure minimizer options.
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
*
|
|
305
|
+
* Disable minification.
|
|
306
|
+
* ```js
|
|
307
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
308
|
+
* export default defineConfig({
|
|
309
|
+
* output: {
|
|
310
|
+
* minify: false,
|
|
311
|
+
* },
|
|
312
|
+
* })
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
minify?: Minify | boolean | undefined;
|
|
316
|
+
/**
|
|
317
|
+
* The {@link SourceMap} configures whether and how to generate source-map for outputs.
|
|
318
|
+
*/
|
|
319
|
+
sourceMap?: boolean | SourceMap | undefined;
|
|
320
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Rspack } from '@rsbuild/core';
|
|
2
|
+
/**
|
|
3
|
+
* {@inheritdoc Output.minify}
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface Minify {
|
|
8
|
+
/**
|
|
9
|
+
* Whether enable the CSS minification.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
*
|
|
13
|
+
* When building for production, {@link https://github.com/rspack-contrib/rsbuild-plugin-css-minimizer | @rsbuild/plugin-css-minimizer} is used to minify CSS assets for better transmission efficiency.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* - Disable the CSS minification.
|
|
18
|
+
*
|
|
19
|
+
* ```js
|
|
20
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
21
|
+
*
|
|
22
|
+
* export default defineConfig({
|
|
23
|
+
* output: {
|
|
24
|
+
* minify: {
|
|
25
|
+
* css: false,
|
|
26
|
+
* },
|
|
27
|
+
* },
|
|
28
|
+
* })
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
css?: boolean | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Whether enable the JavaScript minification.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
*
|
|
37
|
+
* - Disable the JavaScript minification.
|
|
38
|
+
*
|
|
39
|
+
* ```js
|
|
40
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
41
|
+
*
|
|
42
|
+
* export default defineConfig({
|
|
43
|
+
* output: {
|
|
44
|
+
* minify: {
|
|
45
|
+
* js: false,
|
|
46
|
+
* },
|
|
47
|
+
* },
|
|
48
|
+
* })
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
js?: boolean | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* {@link Minify.jsOptions} is used to configure SWC minification options.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
*
|
|
57
|
+
* For detailed configurations, please refer to {@link https://rspack.dev/plugins/rspack/swc-js-minimizer-rspack-plugin | SwcJsMinimizerRspackPlugin}.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
*
|
|
61
|
+
* - Disable the mangle feature.
|
|
62
|
+
*
|
|
63
|
+
* ```js
|
|
64
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
65
|
+
*
|
|
66
|
+
* export default defineConfig({
|
|
67
|
+
* output: {
|
|
68
|
+
* minify: {
|
|
69
|
+
* jsOptions: {
|
|
70
|
+
* minimizerOptions: {
|
|
71
|
+
* mangle: false,
|
|
72
|
+
* },
|
|
73
|
+
* },
|
|
74
|
+
* },
|
|
75
|
+
* },
|
|
76
|
+
* })
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
jsOptions?: Rspack.SwcJsMinimizerRspackPluginOptions | undefined;
|
|
80
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Rspack } from '@rsbuild/core';
|
|
2
|
+
/**
|
|
3
|
+
* {@inheritdoc Output.sourceMap}
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface SourceMap {
|
|
8
|
+
/**
|
|
9
|
+
* How the source map should be generated. Setting it to `false` will disable the source map.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
*
|
|
13
|
+
* Defaults to `'cheap-module-source-map'` at development, `false` at production.
|
|
14
|
+
*
|
|
15
|
+
* See {@link https://rspack.dev/config/devtool | Rspack - Devtool} for details.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
*
|
|
19
|
+
* - Enable high-quality source-maps for production:
|
|
20
|
+
*
|
|
21
|
+
* ```js
|
|
22
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
23
|
+
*
|
|
24
|
+
* export default defineConfig({
|
|
25
|
+
* output: {
|
|
26
|
+
* sourceMap: {
|
|
27
|
+
* js: process.env['NODE_ENV'] === 'production'
|
|
28
|
+
* ? 'source-map'
|
|
29
|
+
* : 'cheap-module-source-map',
|
|
30
|
+
* },
|
|
31
|
+
* },
|
|
32
|
+
* })
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
*
|
|
37
|
+
* - Disable source-map generation:
|
|
38
|
+
*
|
|
39
|
+
* ```js
|
|
40
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
41
|
+
*
|
|
42
|
+
* export default defineConfig({
|
|
43
|
+
* output: {
|
|
44
|
+
* sourceMap: {
|
|
45
|
+
* js: false,
|
|
46
|
+
* },
|
|
47
|
+
* },
|
|
48
|
+
* })
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
*
|
|
53
|
+
* - Use high-quality source-maps for all environments:
|
|
54
|
+
*
|
|
55
|
+
* ```js
|
|
56
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
57
|
+
*
|
|
58
|
+
* export default defineConfig({
|
|
59
|
+
* output: {
|
|
60
|
+
* sourceMap: {
|
|
61
|
+
* js: 'source-map',
|
|
62
|
+
* },
|
|
63
|
+
* },
|
|
64
|
+
* })
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
js?: Rspack.DevTool | undefined;
|
|
68
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import type { Rspack } from '@rsbuild/core';
|
|
2
|
+
/**
|
|
3
|
+
* {@inheritdoc Performance.chunkSplit}
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export interface ChunkSplit {
|
|
8
|
+
/**
|
|
9
|
+
* The ChunkSplitting strategy.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
*
|
|
13
|
+
* - `split-by-experience`(default): an empirical splitting strategy, automatically splits some commonly used npm packages into chunks of moderate size.
|
|
14
|
+
*
|
|
15
|
+
* - `split-by-module`: split by NPM package granularity, each NPM package corresponds to a chunk.
|
|
16
|
+
*
|
|
17
|
+
* - `split-by-size`: automatically split according to module size.
|
|
18
|
+
*
|
|
19
|
+
* - `all-in-one`: bundle all codes into one chunk.
|
|
20
|
+
*
|
|
21
|
+
* - `single-vendor`: bundle all NPM packages into a single chunk.
|
|
22
|
+
*
|
|
23
|
+
* - `custom`: custom chunk splitting strategy.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
*
|
|
27
|
+
* - Use `all-in-one` to put all modules in one chunk.
|
|
28
|
+
*
|
|
29
|
+
* ```js
|
|
30
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
31
|
+
*
|
|
32
|
+
* export default defineConfig({
|
|
33
|
+
* performance: {
|
|
34
|
+
* chunkSplit: {
|
|
35
|
+
* strategy: 'all-in-one',
|
|
36
|
+
* },
|
|
37
|
+
* },
|
|
38
|
+
* })
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
*
|
|
43
|
+
* - Use `single-vendor` to put all third-party dependencies in one chunk. And source code in another chunk.
|
|
44
|
+
*
|
|
45
|
+
* ```js
|
|
46
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
47
|
+
*
|
|
48
|
+
* export default defineConfig({
|
|
49
|
+
* performance: {
|
|
50
|
+
* chunkSplit: {
|
|
51
|
+
* strategy: 'single-vendor',
|
|
52
|
+
* },
|
|
53
|
+
* },
|
|
54
|
+
* })
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
strategy?: 'all-in-one' | 'split-by-module' | 'split-by-experience' | 'single-vendor' | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Custom Rspack chunk splitting config can be specified.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
*
|
|
63
|
+
* - Split `@lynx-js/react` and `react-router` into chunk `lib-react`.
|
|
64
|
+
*
|
|
65
|
+
* ```js
|
|
66
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
67
|
+
*
|
|
68
|
+
* export default defineConfig({
|
|
69
|
+
* performance: {
|
|
70
|
+
* chunkSplit: {
|
|
71
|
+
* strategy: 'split-by-experience',
|
|
72
|
+
* override: {
|
|
73
|
+
* cacheGroups: {
|
|
74
|
+
* react: {
|
|
75
|
+
* test: /node_modules[\\/](@lynx-js[\\/]react|react-router)[\\/]/,
|
|
76
|
+
* name: 'lib-react',
|
|
77
|
+
* chunks: 'all',
|
|
78
|
+
* },
|
|
79
|
+
* },
|
|
80
|
+
* },
|
|
81
|
+
* },
|
|
82
|
+
* },
|
|
83
|
+
* })
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
override?: Rspack.Configuration extends {
|
|
87
|
+
optimization?: {
|
|
88
|
+
splitChunks?: infer P;
|
|
89
|
+
} | undefined;
|
|
90
|
+
} ? P : never;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* {@inheritdoc Performance.chunkSplit}
|
|
94
|
+
*
|
|
95
|
+
* @public
|
|
96
|
+
*/
|
|
97
|
+
export interface ChunkSplitBySize {
|
|
98
|
+
/**
|
|
99
|
+
* {@inheritdoc ChunkSplit.strategy}
|
|
100
|
+
*/
|
|
101
|
+
strategy: 'split-by-size';
|
|
102
|
+
/**
|
|
103
|
+
* The minimum size of a chunk, unit in bytes. Defaults to `10000`.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
*
|
|
107
|
+
* ```js
|
|
108
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
109
|
+
*
|
|
110
|
+
* export default defineConfig({
|
|
111
|
+
* performance: {
|
|
112
|
+
* chunkSplit: {
|
|
113
|
+
* strategy: 'split-by-size',
|
|
114
|
+
* minSize: 20000,
|
|
115
|
+
* },
|
|
116
|
+
* },
|
|
117
|
+
* })
|
|
118
|
+
* ```
|
|
119
|
+
*/
|
|
120
|
+
minSize?: number | undefined;
|
|
121
|
+
/**
|
|
122
|
+
* The maximum size of a chunk, unit in bytes. Defaults to `Number.POSITIVE_INFINITY`.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
*
|
|
126
|
+
* ```js
|
|
127
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
128
|
+
*
|
|
129
|
+
* export default defineConfig({
|
|
130
|
+
* performance: {
|
|
131
|
+
* chunkSplit: {
|
|
132
|
+
* strategy: 'split-by-size',
|
|
133
|
+
* maxSize: 50000,
|
|
134
|
+
* },
|
|
135
|
+
* },
|
|
136
|
+
* })
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
maxSize?: number | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* {@inheritdoc ChunkSplit.override}
|
|
142
|
+
*/
|
|
143
|
+
override?: Rspack.Configuration extends {
|
|
144
|
+
optimization?: {
|
|
145
|
+
splitChunks?: infer P;
|
|
146
|
+
} | undefined;
|
|
147
|
+
} ? P : never;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* {@inheritdoc Performance.chunkSplit}
|
|
151
|
+
*
|
|
152
|
+
* @public
|
|
153
|
+
*/
|
|
154
|
+
export interface ChunkSplitCustom {
|
|
155
|
+
/**
|
|
156
|
+
* {@inheritdoc ChunkSplit.strategy}
|
|
157
|
+
*/
|
|
158
|
+
strategy: 'custom';
|
|
159
|
+
/**
|
|
160
|
+
* {@inheritdoc ChunkSplit.override}
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
*
|
|
164
|
+
* - Split `@lynx-js/react` and `react-router` into chunk `lib-react`.
|
|
165
|
+
*
|
|
166
|
+
* ```js
|
|
167
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
168
|
+
*
|
|
169
|
+
* export default defineConfig({
|
|
170
|
+
* performance: {
|
|
171
|
+
* chunkSplit: {
|
|
172
|
+
* strategy: 'custom',
|
|
173
|
+
* splitChunks: {
|
|
174
|
+
* cacheGroups: {
|
|
175
|
+
* react: {
|
|
176
|
+
* test: /node_modules[\\/](@lynx-js[\\/]react|react-router)[\\/]/,
|
|
177
|
+
* name: 'lib-react',
|
|
178
|
+
* chunks: 'all',
|
|
179
|
+
* },
|
|
180
|
+
* },
|
|
181
|
+
* },
|
|
182
|
+
* },
|
|
183
|
+
* },
|
|
184
|
+
* })
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
splitChunks?: Rspack.Configuration extends {
|
|
188
|
+
optimization?: {
|
|
189
|
+
splitChunks?: infer P;
|
|
190
|
+
} | undefined;
|
|
191
|
+
} ? P : never;
|
|
192
|
+
}
|