@lynx-js/rspeedy 0.8.7 → 0.9.1

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.
Files changed (163) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/bin/rspeedy.js +2 -2
  3. package/dist/cli/main.js +414 -0
  4. package/dist/cli/start.js +171 -0
  5. package/dist/index.d.ts +2971 -0
  6. package/dist/index.js +39556 -0
  7. package/dist/register/hooks.js +552 -0
  8. package/dist/register/index.js +22 -0
  9. package/dist/src_cli_build_ts.js +47 -0
  10. package/dist/src_cli_commands_ts.js +60 -0
  11. package/dist/src_cli_dev_ts.js +87 -0
  12. package/dist/src_cli_exit_ts.js +111 -0
  13. package/dist/src_cli_inspect_ts.js +42 -0
  14. package/dist/src_cli_preview_ts.js +49 -0
  15. package/dist/src_config_loadConfig_ts-src_create-rspeedy_ts.js +39311 -0
  16. package/dist/src_plugins_api_plugin_ts.js +32 -0
  17. package/dist/src_plugins_chunkLoading_plugin_ts.js +35 -0
  18. package/dist/src_plugins_dev_plugin_ts.js +141 -0
  19. package/dist/src_plugins_index_ts.js +60 -0
  20. package/dist/src_plugins_inspect_plugin_ts.js +48 -0
  21. package/dist/src_plugins_minify_plugin_ts.js +85 -0
  22. package/dist/src_plugins_optimization_plugin_ts.js +25 -0
  23. package/dist/src_plugins_output_plugin_ts.js +46 -0
  24. package/dist/src_plugins_resolve_plugin_ts.js +21 -0
  25. package/dist/src_plugins_rsdoctor_plugin_ts.js +59 -0
  26. package/dist/src_plugins_sourcemap_plugin_ts.js +99 -0
  27. package/dist/src_plugins_stats_plugin_ts.js +26 -0
  28. package/dist/src_plugins_swc_plugin_ts.js +36 -0
  29. package/dist/src_plugins_target_plugin_ts.js +45 -0
  30. package/dist/src_version_ts.js +18 -0
  31. package/dist/vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +1435 -0
  32. package/dist/vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt +1 -0
  33. package/dist/vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js +1761 -0
  34. package/dist/vendors-node_modules_pnpm_ipaddr_js_2_2_0_node_modules_ipaddr_js_lib_ipaddr_js.js +1067 -0
  35. package/dist/vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-b558be.js +416 -0
  36. package/package.json +36 -23
  37. package/LICENSE +0 -202
  38. package/lib/api.d.ts +0 -46
  39. package/lib/api.js +0 -2
  40. package/lib/cli/build.d.ts +0 -4
  41. package/lib/cli/build.js +0 -32
  42. package/lib/cli/commands.d.ts +0 -5
  43. package/lib/cli/commands.js +0 -45
  44. package/lib/cli/dev.d.ts +0 -4
  45. package/lib/cli/dev.js +0 -75
  46. package/lib/cli/exit.d.ts +0 -1
  47. package/lib/cli/exit.js +0 -51
  48. package/lib/cli/inspect.d.ts +0 -8
  49. package/lib/cli/inspect.js +0 -30
  50. package/lib/cli/main.d.ts +0 -1
  51. package/lib/cli/main.js +0 -39
  52. package/lib/cli/preview.d.ts +0 -4
  53. package/lib/cli/preview.js +0 -31
  54. package/lib/cli/start.d.ts +0 -6
  55. package/lib/cli/start.js +0 -88
  56. package/lib/config/defaults.d.ts +0 -2
  57. package/lib/config/defaults.js +0 -32
  58. package/lib/config/defineConfig.d.ts +0 -22
  59. package/lib/config/defineConfig.js +0 -24
  60. package/lib/config/dev/client.d.ts +0 -15
  61. package/lib/config/dev/client.js +0 -2
  62. package/lib/config/dev/index.d.ts +0 -173
  63. package/lib/config/dev/index.js +0 -2
  64. package/lib/config/index.d.ts +0 -172
  65. package/lib/config/index.js +0 -2
  66. package/lib/config/loadConfig.d.ts +0 -50
  67. package/lib/config/loadConfig.js +0 -98
  68. package/lib/config/mergeRspeedyConfig.d.ts +0 -36
  69. package/lib/config/mergeRspeedyConfig.js +0 -42
  70. package/lib/config/output/css-modules.d.ts +0 -84
  71. package/lib/config/output/css-modules.js +0 -2
  72. package/lib/config/output/dist-path.d.ts +0 -19
  73. package/lib/config/output/dist-path.js +0 -2
  74. package/lib/config/output/filename.d.ts +0 -167
  75. package/lib/config/output/filename.js +0 -2
  76. package/lib/config/output/index.d.ts +0 -324
  77. package/lib/config/output/index.js +0 -2
  78. package/lib/config/output/minify.d.ts +0 -80
  79. package/lib/config/output/minify.js +0 -2
  80. package/lib/config/output/source-map.d.ts +0 -68
  81. package/lib/config/output/source-map.js +0 -2
  82. package/lib/config/performance/chunk-split.d.ts +0 -192
  83. package/lib/config/performance/chunk-split.js +0 -2
  84. package/lib/config/performance/index.d.ts +0 -165
  85. package/lib/config/performance/index.js +0 -2
  86. package/lib/config/rsbuild/entry.d.ts +0 -3
  87. package/lib/config/rsbuild/entry.js +0 -31
  88. package/lib/config/rsbuild/index.d.ts +0 -4
  89. package/lib/config/rsbuild/index.js +0 -75
  90. package/lib/config/server/index.d.ts +0 -91
  91. package/lib/config/server/index.js +0 -2
  92. package/lib/config/source/decorators.d.ts +0 -43
  93. package/lib/config/source/decorators.js +0 -2
  94. package/lib/config/source/entry.d.ts +0 -84
  95. package/lib/config/source/entry.js +0 -2
  96. package/lib/config/source/index.d.ts +0 -474
  97. package/lib/config/source/index.js +0 -2
  98. package/lib/config/source/transformImport.d.ts +0 -106
  99. package/lib/config/source/transformImport.js +0 -2
  100. package/lib/config/tools/css-extract.d.ts +0 -72
  101. package/lib/config/tools/css-extract.js +0 -2
  102. package/lib/config/tools/css-loader.d.ts +0 -130
  103. package/lib/config/tools/css-loader.js +0 -2
  104. package/lib/config/tools/index.d.ts +0 -170
  105. package/lib/config/tools/index.js +0 -2
  106. package/lib/config/validate.d.ts +0 -4
  107. package/lib/config/validate.js +0 -28877
  108. package/lib/create-rspeedy.d.ts +0 -52
  109. package/lib/create-rspeedy.js +0 -49
  110. package/lib/debug.d.ts +0 -3
  111. package/lib/debug.js +0 -25
  112. package/lib/index.d.ts +0 -46
  113. package/lib/index.js +0 -11
  114. package/lib/plugins/api.plugin.d.ts +0 -3
  115. package/lib/plugins/api.plugin.js +0 -25
  116. package/lib/plugins/chunkLoading.plugin.d.ts +0 -2
  117. package/lib/plugins/chunkLoading.plugin.js +0 -43
  118. package/lib/plugins/dev.plugin.d.ts +0 -5
  119. package/lib/plugins/dev.plugin.js +0 -137
  120. package/lib/plugins/index.d.ts +0 -3
  121. package/lib/plugins/index.js +0 -49
  122. package/lib/plugins/inspect.plugin.d.ts +0 -4
  123. package/lib/plugins/inspect.plugin.js +0 -39
  124. package/lib/plugins/minify.plugin.d.ts +0 -3
  125. package/lib/plugins/minify.plugin.js +0 -89
  126. package/lib/plugins/optimization.plugin.d.ts +0 -2
  127. package/lib/plugins/optimization.plugin.js +0 -31
  128. package/lib/plugins/output.plugin.d.ts +0 -3
  129. package/lib/plugins/output.plugin.js +0 -34
  130. package/lib/plugins/resolve.plugin.d.ts +0 -2
  131. package/lib/plugins/resolve.plugin.js +0 -38
  132. package/lib/plugins/rsdoctor.plugin.d.ts +0 -3
  133. package/lib/plugins/rsdoctor.plugin.js +0 -48
  134. package/lib/plugins/sourcemap.plugin.d.ts +0 -2
  135. package/lib/plugins/sourcemap.plugin.js +0 -86
  136. package/lib/plugins/stats.plugin.d.ts +0 -2
  137. package/lib/plugins/stats.plugin.js +0 -20
  138. package/lib/plugins/swc.plugin.d.ts +0 -2
  139. package/lib/plugins/swc.plugin.js +0 -21
  140. package/lib/plugins/target.plugin.d.ts +0 -2
  141. package/lib/plugins/target.plugin.js +0 -22
  142. package/lib/utils/getESVersionTarget.d.ts +0 -1
  143. package/lib/utils/getESVersionTarget.js +0 -7
  144. package/lib/utils/is-ci.d.ts +0 -1
  145. package/lib/utils/is-ci.js +0 -7
  146. package/lib/utils/is-lynx.d.ts +0 -2
  147. package/lib/utils/is-lynx.js +0 -6
  148. package/lib/utils/is-web.d.ts +0 -2
  149. package/lib/utils/is-web.js +0 -6
  150. package/lib/version.d.ts +0 -4
  151. package/lib/version.js +0 -15
  152. package/lib/webpack/CompilationIdPlugin.d.ts +0 -4
  153. package/lib/webpack/CompilationIdPlugin.js +0 -20
  154. package/lib/webpack/EvalSourceMapDevToolPlugin.d.ts +0 -9
  155. package/lib/webpack/EvalSourceMapDevToolPlugin.js +0 -15
  156. package/lib/webpack/ProvidePlugin.d.ts +0 -9
  157. package/lib/webpack/ProvidePlugin.js +0 -15
  158. package/lib/webpack/SourceMapDevToolPlugin.d.ts +0 -9
  159. package/lib/webpack/SourceMapDevToolPlugin.js +0 -15
  160. package/register/data.d.ts +0 -9
  161. package/register/hooks.js +0 -146
  162. package/register/index.js +0 -47
  163. /package/{register → dist/register}/index.d.ts +0 -0
@@ -0,0 +1,2971 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * The document contains all the configurations of the `@lynx-js/rspeedy` package.
5
+ *
6
+ * @example
7
+ *
8
+ * Use `lynx.config.ts` with {@link defineConfig} to get better TypeScript intellisense.
9
+ *
10
+ * ```ts
11
+ * import { defineConfig } from '@lynx-js/rspeedy'
12
+ * export default defineConfig({
13
+ * entry: './src/index.tsx',
14
+ * })
15
+ * ```
16
+ */
17
+
18
+ import type { CreateRsbuildOptions } from '@rsbuild/core';
19
+ import type { DistPathConfig } from '@rsbuild/core';
20
+ import { logger } from '@rsbuild/core';
21
+ import type { PerformanceConfig } from '@rsbuild/core';
22
+ import type { RsbuildConfig } from '@rsbuild/core';
23
+ import type { RsbuildInstance } from '@rsbuild/core';
24
+ import { RsbuildPlugin } from '@rsbuild/core';
25
+ import { RsbuildPluginAPI } from '@rsbuild/core';
26
+ import type { RsbuildPlugins } from '@rsbuild/core';
27
+ import { version as rsbuildVersion } from '@rsbuild/core';
28
+ import type { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
29
+ import { Rspack } from '@rsbuild/core';
30
+ import { rspack } from '@rsbuild/core';
31
+ import type { ToolsConfig } from '@rsbuild/core';
32
+ import type { WatchFiles } from '@rsbuild/core';
33
+
34
+ /**
35
+ * {@inheritdoc Performance.chunkSplit}
36
+ *
37
+ * @public
38
+ */
39
+ export declare interface ChunkSplit {
40
+ /**
41
+ * The ChunkSplitting strategy.
42
+ *
43
+ * @remarks
44
+ *
45
+ * - `split-by-experience`(default): an empirical splitting strategy, automatically splits some commonly used npm packages into chunks of moderate size.
46
+ *
47
+ * - `split-by-module`: split by NPM package granularity, each NPM package corresponds to a chunk.
48
+ *
49
+ * - `split-by-size`: automatically split according to module size.
50
+ *
51
+ * - `all-in-one`: bundle all codes into one chunk.
52
+ *
53
+ * - `single-vendor`: bundle all NPM packages into a single chunk.
54
+ *
55
+ * - `custom`: custom chunk splitting strategy.
56
+ *
57
+ * @example
58
+ *
59
+ * - Use `all-in-one` to put all modules in one chunk.
60
+ *
61
+ * ```js
62
+ * import { defineConfig } from '@lynx-js/rspeedy'
63
+ *
64
+ * export default defineConfig({
65
+ * performance: {
66
+ * chunkSplit: {
67
+ * strategy: 'all-in-one',
68
+ * },
69
+ * },
70
+ * })
71
+ * ```
72
+ *
73
+ * @example
74
+ *
75
+ * - Use `single-vendor` to put all third-party dependencies in one chunk. And source code in another chunk.
76
+ *
77
+ * ```js
78
+ * import { defineConfig } from '@lynx-js/rspeedy'
79
+ *
80
+ * export default defineConfig({
81
+ * performance: {
82
+ * chunkSplit: {
83
+ * strategy: 'single-vendor',
84
+ * },
85
+ * },
86
+ * })
87
+ * ```
88
+ */
89
+ strategy?: 'all-in-one' | 'split-by-module' | 'split-by-experience' | 'single-vendor' | undefined;
90
+ /**
91
+ * Custom Rspack chunk splitting config can be specified.
92
+ *
93
+ * @example
94
+ *
95
+ * - Split `@lynx-js/react` and `react-router` into chunk `lib-react`.
96
+ *
97
+ * ```js
98
+ * import { defineConfig } from '@lynx-js/rspeedy'
99
+ *
100
+ * export default defineConfig({
101
+ * performance: {
102
+ * chunkSplit: {
103
+ * strategy: 'split-by-experience',
104
+ * override: {
105
+ * cacheGroups: {
106
+ * react: {
107
+ * test: /node_modules[\\/](@lynx-js[\\/]react|react-router)[\\/]/,
108
+ * name: 'lib-react',
109
+ * chunks: 'all',
110
+ * },
111
+ * },
112
+ * },
113
+ * },
114
+ * },
115
+ * })
116
+ * ```
117
+ */
118
+ override?: Rspack.Configuration extends {
119
+ optimization?: {
120
+ splitChunks?: infer P;
121
+ } | undefined;
122
+ } ? P : never;
123
+ }
124
+
125
+ /**
126
+ * {@inheritdoc Performance.chunkSplit}
127
+ *
128
+ * @public
129
+ */
130
+ export declare interface ChunkSplitBySize {
131
+ /**
132
+ * {@inheritdoc ChunkSplit.strategy}
133
+ */
134
+ strategy: 'split-by-size';
135
+ /**
136
+ * The minimum size of a chunk, unit in bytes. Defaults to `10000`.
137
+ *
138
+ * @example
139
+ *
140
+ * ```js
141
+ * import { defineConfig } from '@lynx-js/rspeedy'
142
+ *
143
+ * export default defineConfig({
144
+ * performance: {
145
+ * chunkSplit: {
146
+ * strategy: 'split-by-size',
147
+ * minSize: 20000,
148
+ * },
149
+ * },
150
+ * })
151
+ * ```
152
+ */
153
+ minSize?: number | undefined;
154
+ /**
155
+ * The maximum size of a chunk, unit in bytes. Defaults to `Number.POSITIVE_INFINITY`.
156
+ *
157
+ * @example
158
+ *
159
+ * ```js
160
+ * import { defineConfig } from '@lynx-js/rspeedy'
161
+ *
162
+ * export default defineConfig({
163
+ * performance: {
164
+ * chunkSplit: {
165
+ * strategy: 'split-by-size',
166
+ * maxSize: 50000,
167
+ * },
168
+ * },
169
+ * })
170
+ * ```
171
+ */
172
+ maxSize?: number | undefined;
173
+ /**
174
+ * {@inheritdoc ChunkSplit.override}
175
+ */
176
+ override?: Rspack.Configuration extends {
177
+ optimization?: {
178
+ splitChunks?: infer P;
179
+ } | undefined;
180
+ } ? P : never;
181
+ }
182
+
183
+ /**
184
+ * {@inheritdoc Performance.chunkSplit}
185
+ *
186
+ * @public
187
+ */
188
+ export declare interface ChunkSplitCustom {
189
+ /**
190
+ * {@inheritdoc ChunkSplit.strategy}
191
+ */
192
+ strategy: 'custom';
193
+ /**
194
+ * {@inheritdoc ChunkSplit.override}
195
+ *
196
+ * @example
197
+ *
198
+ * - Split `@lynx-js/react` and `react-router` into chunk `lib-react`.
199
+ *
200
+ * ```js
201
+ * import { defineConfig } from '@lynx-js/rspeedy'
202
+ *
203
+ * export default defineConfig({
204
+ * performance: {
205
+ * chunkSplit: {
206
+ * strategy: 'custom',
207
+ * splitChunks: {
208
+ * cacheGroups: {
209
+ * react: {
210
+ * test: /node_modules[\\/](@lynx-js[\\/]react|react-router)[\\/]/,
211
+ * name: 'lib-react',
212
+ * chunks: 'all',
213
+ * },
214
+ * },
215
+ * },
216
+ * },
217
+ * },
218
+ * })
219
+ * ```
220
+ */
221
+ splitChunks?: Rspack.Configuration extends {
222
+ optimization?: {
223
+ splitChunks?: infer P;
224
+ } | undefined;
225
+ } ? P : never;
226
+ }
227
+
228
+ /**
229
+ * The `Config` is the configuration that `rspeedy` uses.
230
+ *
231
+ * @public
232
+ */
233
+ export declare interface Config {
234
+ /**
235
+ * The Rsbuild provider.
236
+ *
237
+ * @example
238
+ * You can switch from Rspack to Webpack by:
239
+ *
240
+ * - Use `webpackProvider` from `@rsbuild/webpack`
241
+ * - Add `pluginSwc` from `@rsbuild/plugin-webpack-swc` for TypeScript transpilation
242
+ *
243
+ * ```ts
244
+ * import { defineConfig } from '@lynx-js/rspeedy'
245
+ * import { webpackProvider } from '@rsbuild/webpack'
246
+ * import { pluginSwc } from '@rsbuild/plugin-webpack-swc'
247
+ *
248
+ * export default defineConfig({
249
+ * provider: webpackProvider,
250
+ * plugins: [
251
+ * pluginSwc(),
252
+ * ],
253
+ * })
254
+ * ```
255
+ *
256
+ * @alpha
257
+ */
258
+ provider?: RsbuildConfig['provider'];
259
+ /**
260
+ * The {@link Dev} option is used to control the behavior related with development. Including: HMR, DevServer, etc.
261
+ */
262
+ dev?: Dev | undefined;
263
+ /**
264
+ * The {@link Config.environments} option is used to set the output environment.
265
+ *
266
+ * @remarks
267
+ *
268
+ * Normally you don't need this if you are not using Lynx for Web.
269
+ *
270
+ * @example
271
+ *
272
+ * - Using different entries for Lynx and Web.
273
+ *
274
+ * ```ts
275
+ * import { defineConfig } from '@lynx-js/rspeedy'
276
+ *
277
+ * export default defineConfig({
278
+ * environments: {
279
+ * lynx: {},
280
+ * web: {
281
+ * source: { entry: { web: './src/index.web.jsx' } },
282
+ * },
283
+ * },
284
+ * source: {
285
+ * entry: './src/index.jsx',
286
+ * },
287
+ * })
288
+ * ```
289
+ *
290
+ * @example
291
+ *
292
+ * - Building Web-only outputs.
293
+ *
294
+ * ```ts
295
+ * import { defineConfig } from '@lynx-js/rspeedy'
296
+ *
297
+ * export default defineConfig({
298
+ * environments: {
299
+ * web: {
300
+ * source: { entry: { web: './src/index.web.jsx' } },
301
+ * },
302
+ * },
303
+ * })
304
+ * ```
305
+ */
306
+ environments?: RsbuildConfig['environments'] | undefined;
307
+ /**
308
+ * Specify the build mode for Rsbuild and Rspack, as each mode has different default behavior and optimizations.
309
+ *
310
+ * @remarks
311
+ *
312
+ * The default value of mode depends on the `process.env.NODE_ENV` environment variable:
313
+ *
314
+ * - If `NODE_ENV` is production, the default value is production.
315
+ *
316
+ * - If `NODE_ENV` is development, the default value is development.
317
+ *
318
+ * - If `NODE_ENV` has any other value, the default value is none.
319
+ *
320
+ * - If you set the value of mode, the value of `NODE_ENV` will be ignored.
321
+ *
322
+ * When using Rspeedy's CLI:
323
+ *
324
+ * - `rspeedy dev` and `rspeedy preview` will set the default values of `NODE_ENV` and `mode` to `'development'`.
325
+ *
326
+ * - `rspeedy build` will set the default values of `NODE_ENV` and `mode` to `'production'`.
327
+ *
328
+ * @example
329
+ *
330
+ * If the value of `mode` is `'development'`:
331
+ *
332
+ * - Enable HMR and register the {@link https://rspack.dev/plugins/webpack/hot-module-replacement-plugin | HotModuleReplacementPlugin}.
333
+ *
334
+ * - Generate JavaScript source maps, but do not generate CSS source maps. See {@link Output.sourceMap} for details.
335
+ *
336
+ * - The `process.env.NODE_ENV` in the source code will be replaced with `'development'`.
337
+ *
338
+ * - The `import.meta.env.MODE` in the source code will be replaced with `'development'`.
339
+ *
340
+ * - The `import.meta.env.DEV` in the source code will be replaced with `true`.
341
+ *
342
+ * - The `import.meta.env.PROD` in the source code will be replaced with `false`.
343
+ *
344
+ * @example
345
+ *
346
+ * If the value of `mode` is `'production'`:
347
+ *
348
+ * - Enable JavaScript code minification and register the {@link https://rspack.dev/plugins/rspack/swc-js-minimizer-rspack-plugin | SwcJsMinimizerRspackPlugin}.
349
+ *
350
+ * - Generated JavaScript and CSS filenames will have hash suffixes, see {@link Output.filenameHash}.
351
+ *
352
+ * - Generated CSS Modules classnames will be shorter, see {@link CssModules.localIdentName}.
353
+ *
354
+ * - Do not generate JavaScript and CSS source maps, see {@link Output.sourceMap}.
355
+ *
356
+ * - The `process.env.NODE_ENV` in the source code will be replaced with `'production'`.
357
+ *
358
+ * - The `import.meta.env.MODE` in the source code will be replaced with `'production'`.
359
+ *
360
+ * - The `import.meta.env.DEV` in the source code will be replaced with `false`.
361
+ *
362
+ * - The `import.meta.env.PROD` in the source code will be replaced with `true`.
363
+ */
364
+ mode?: 'development' | 'production' | 'none' | undefined;
365
+ /**
366
+ * The {@link Output} option is used to set how and where should the bundles and assets output.
367
+ */
368
+ output?: Output | undefined;
369
+ /**
370
+ * The {@link Performance} option is used to
371
+ */
372
+ performance?: Performance | undefined;
373
+ /**
374
+ * The {@link Server} option changes the behavior of dev-server.
375
+ */
376
+ server?: Server | undefined;
377
+ /**
378
+ * The {@link Source} option changes the behavior of source files.
379
+ */
380
+ source?: Source | undefined;
381
+ /**
382
+ * The {@link Tools} options changes the behavior of various building tools.
383
+ */
384
+ tools?: Tools | undefined;
385
+ /**
386
+ * The `plugins` option is used to customize the build process in a variety of ways.
387
+ *
388
+ * @remarks
389
+ * Rspeedy use the plugin APIs from {@link https://rsbuild.dev/plugins/dev/index | Rsbuild}. See the corresponding document for developing a plugin.
390
+ */
391
+ plugins?: RsbuildPlugins | undefined;
392
+ }
393
+
394
+ /**
395
+ * The type of the console method.
396
+ *
397
+ * @public
398
+ */
399
+ export declare type ConsoleType = 'log' | 'warn' | 'error' | 'info' | 'debug' | 'profile' | 'profileEnd' | (string & Record<never, never>);
400
+
401
+ /**
402
+ * The `createRspeedy` method can let you create a Rspeedy instance and you can customize the build or development process in Node.js Runtime.
403
+ *
404
+ * @param options - {@link CreateRspeedyOptions}
405
+ * @returns - Rspeedy instance.
406
+ *
407
+ * @example
408
+ *
409
+ * ```ts
410
+ * import { createRspeedy } from '@lynx-js/rspeedy'
411
+ *
412
+ * void async function () {
413
+ * const rspeedy = await createRspeedy({})
414
+ * await rspeedy.build()
415
+ * }()
416
+ * ```
417
+ *
418
+ * @public
419
+ */
420
+ export declare function createRspeedy({ cwd, rspeedyConfig, loadEnv, environment }: CreateRspeedyOptions): Promise<RspeedyInstance>;
421
+
422
+ /**
423
+ * The options of `createRspeedy` method.
424
+ *
425
+ * @public
426
+ */
427
+ export declare interface CreateRspeedyOptions {
428
+ /**
429
+ * The root path of the current build.
430
+ */
431
+ cwd?: string;
432
+ /**
433
+ * The config of Rspeedy.
434
+ */
435
+ rspeedyConfig?: Config;
436
+ /**
437
+ * Rspeedy automatically loads the .env file by default, utilizing the [Rsbuild API](https://rsbuild.dev/api/javascript-api/core#load-env-variables).
438
+ * You can use the environment variables defined in the .env file within your code by accessing them via `import.meta.env.FOO` or `process.env.Foo`.
439
+ * @see https://rsbuild.dev/guide/advanced/env-vars#env-file
440
+ * @defaultValue true
441
+ */
442
+ loadEnv?: CreateRsbuildOptions['loadEnv'];
443
+ /**
444
+ * Only build specified environments.
445
+ * For example, passing `['lynx']` will only build the `lynx` environment.
446
+ * If not specified or passing an empty array, all environments will be built.
447
+ * @see https://rsbuild.dev/guide/advanced/environments#build-specified-environment
448
+ * @defaultValue []
449
+ */
450
+ environment?: CreateRsbuildOptions['environment'];
451
+ }
452
+
453
+ /**
454
+ * {@inheritdoc Tools.cssExtract}
455
+ *
456
+ * @public
457
+ */
458
+ export declare interface CssExtract {
459
+ /**
460
+ * {@inheritdoc @lynx-js/css-extract-webpack-plugin#LoaderOptions}
461
+ */
462
+ loaderOptions?: CssExtractRspackLoaderOptions | undefined;
463
+ /**
464
+ * {@inheritdoc @lynx-js/css-extract-webpack-plugin#CssExtractRspackPluginOptions}
465
+ */
466
+ pluginOptions?: CssExtractRspackPluginOptions | undefined;
467
+ }
468
+
469
+ /**
470
+ * {@inheritdoc @lynx-js/css-extract-webpack-plugin#LoaderOptions}
471
+ *
472
+ * @public
473
+ */
474
+ export declare interface CssExtractRspackLoaderOptions {
475
+ /**
476
+ * The same as {@link https://github.com/webpack-contrib/mini-css-extract-plugin#esModule}.
477
+ * By default, `@lynx-js/css-extract-webpack-plugin` generates JS modules that use the ES modules syntax.
478
+ * There are some cases in which using ES modules is beneficial,
479
+ * like in the case of module concatenation and tree shaking.
480
+ *
481
+ * @example
482
+ * You can enable a CommonJS syntax using:
483
+ *
484
+ * ```js
485
+ * import {CssExtractWebpackPlugin} from "@lynx-js/css-extract-webpack-plugin";
486
+ * export default {
487
+ * plugins: [new CssExtractWebpackPlugin()],
488
+ * module: {
489
+ * rules: [
490
+ * {
491
+ * test: /\.css$/i,
492
+ * use: [
493
+ * {
494
+ * loader: CssExtractWebpackPlugin.loader,
495
+ * options: {
496
+ * esModule: false,
497
+ * },
498
+ * },
499
+ * "css-loader",
500
+ * ],
501
+ * },
502
+ * ],
503
+ * },
504
+ * };
505
+ * ```
506
+ *
507
+ * @public
508
+ */
509
+ esModule?: boolean | undefined;
510
+ }
511
+
512
+ /**
513
+ * {@inheritdoc @lynx-js/css-extract-webpack-plugin#CssExtractRspackPluginOptions}
514
+ *
515
+ * @public
516
+ */
517
+ export declare interface CssExtractRspackPluginOptions {
518
+ /**
519
+ * {@inheritdoc @lynx-js/css-extract-webpack-plugin#CssExtractRspackPluginOptions.ignoreOrder}
520
+ */
521
+ ignoreOrder?: boolean | undefined;
522
+ /**
523
+ * {@inheritdoc @lynx-js/css-extract-webpack-plugin#CssExtractRspackPluginOptions.pathinfo}
524
+ */
525
+ pathinfo?: boolean | undefined;
526
+ }
527
+
528
+ /**
529
+ * {@inheritdoc Tools.cssLoader}
530
+ *
531
+ * @public
532
+ */
533
+ export declare interface CssLoader {
534
+ /**
535
+ * The option `importLoaders` allows you to configure how many loaders before `css-loader` should be applied to `@imported` resources and CSS modules imports.
536
+ *
537
+ * @remarks
538
+ *
539
+ * The default value of `importLoaders` is:
540
+ *
541
+ * - `1` when compiling CSS files
542
+ *
543
+ * - `2` when compiling Sass or Less files
544
+ *
545
+ * See {@link https://github.com/webpack-contrib/css-loader?tab=readme-ov-file#importloaders | css-loader#import-loaders} for details.
546
+ */
547
+ importLoaders?: 0 | 1 | 2 | undefined;
548
+ /**
549
+ * The {@link CssLoaderModules | cssLoader.modules} option enables/disables the CSS Modules specification and setup basic behavior.
550
+ *
551
+ * @example
552
+ *
553
+ * Using `false` value to increase performance because we avoid parsing CSS Modules features, it will be useful for developers who use vanilla css or use other technologies.
554
+ *
555
+ * ```js
556
+ * import { defineConfig } from '@lynx-js/rspeedy'
557
+ *
558
+ * export default defineConfig({
559
+ * tools: {
560
+ * cssLoader: {
561
+ * modules: false,
562
+ * },
563
+ * },
564
+ * })
565
+ * ```
566
+ *
567
+ * @example
568
+ *
569
+ * Using `() => true` value to enable CSS Modules for all files.
570
+ *
571
+ * ```js
572
+ * import { defineConfig } from '@lynx-js/rspeedy'
573
+ *
574
+ * export default defineConfig({
575
+ * tools: {
576
+ * cssLoader: {
577
+ * modules: () => true,
578
+ * },
579
+ * },
580
+ * })
581
+ * ```
582
+ *
583
+ * @example
584
+ *
585
+ * Using object value to enable CSS Modules based-on {@link CssLoaderModules.auto} option and setup more configurations about CSS Modules.
586
+ *
587
+ * ```js
588
+ * import { defineConfig } from '@lynx-js/rspeedy'
589
+ *
590
+ * export default defineConfig({
591
+ * tools: {
592
+ * cssLoader: {
593
+ * modules: {
594
+ * namedExport: true,
595
+ * },
596
+ * },
597
+ * },
598
+ * })
599
+ * ```
600
+ */
601
+ modules?: boolean | CssLoaderModules | undefined;
602
+ }
603
+
604
+ /**
605
+ * {@inheritdoc CssLoader.modules}
606
+ *
607
+ * @public
608
+ */
609
+ export declare interface CssLoaderModules {
610
+ /**
611
+ * {@inheritdoc CssModules.auto}
612
+ */
613
+ auto?: boolean | RegExp | ((filename: string) => boolean) | undefined;
614
+ /**
615
+ * {@inheritdoc CssModules.exportLocalsConvention}
616
+ */
617
+ exportLocalsConvention?: CssModuleLocalsConvention | undefined;
618
+ /**
619
+ * {@inheritdoc CssModules.localIdentName}
620
+ */
621
+ localIdentName?: string | undefined;
622
+ /**
623
+ * Enables/disables ES modules named export for locals.
624
+ *
625
+ * @example
626
+ *
627
+ * - `style.css`
628
+ *
629
+ * ```css
630
+ * .foo-baz {
631
+ * color: red;
632
+ * }
633
+ * .bar {
634
+ * color: blue;
635
+ * }
636
+ * .default {
637
+ * color: green;
638
+ * }
639
+ * ```
640
+ *
641
+ * - `index.js`
642
+ *
643
+ * ```js
644
+ * import * as styles from "./styles.css";
645
+ *
646
+ * // If using `exportLocalsConvention: "as-is"` (default value):
647
+ * console.log(styles["foo-baz"], styles.bar);
648
+ *
649
+ * // If using `exportLocalsConvention: "camel-case-only"`:
650
+ * console.log(styles.fooBaz, styles.bar);
651
+ *
652
+ * // For the `default` class name
653
+ * console.log(styles["_default"]);
654
+ * ```
655
+ */
656
+ namedExport?: boolean | undefined;
657
+ }
658
+
659
+ /**
660
+ * {@inheritdoc CssModules.exportLocalsConvention}
661
+ *
662
+ * @public
663
+ */
664
+ export declare type CssModuleLocalsConvention = 'asIs' | 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly';
665
+
666
+ /**
667
+ * {@inheritdoc Output.cssModules}
668
+ *
669
+ * @public
670
+ */
671
+ export declare interface CssModules {
672
+ /**
673
+ * The `auto` option allows CSS modules to be automatically enabled based on their filenames.
674
+ *
675
+ * @remarks
676
+ *
677
+ * Given the various `auto` values, the behavior is described as follows:
678
+ *
679
+ * - `true`: enable CSS modules for all files matching `/\.module\.\w+$/i.test(filename)` RegExp.
680
+ *
681
+ * - `false`: disable CSS modules.
682
+ *
683
+ * - `RegExp`: enable CSS modules for all files matching the `auto.test(filename)` RegExp.
684
+ *
685
+ * - `function`: enable CSS modules based on the filter function.
686
+ *
687
+ * See {@link https://github.com/webpack-contrib/css-loader?tab=readme-ov-file#auto | css-loader#auto} for details.
688
+ *
689
+ * @example
690
+ *
691
+ * Enable CSS module for `*.module.css` and `shared/*.css`:
692
+ *
693
+ * ```js
694
+ * import { defineConfig } from '@lynx-js/rspeedy'
695
+ * export default defineConfig({
696
+ * output: {
697
+ * cssModules: {
698
+ * auto: (filename) => {
699
+ * return filename.includes('.module.') || filename.includes('shared/')
700
+ * },
701
+ * },
702
+ * },
703
+ * })
704
+ * ```
705
+ */
706
+ auto?: boolean | RegExp | ((filename: string) => boolean) | undefined;
707
+ /**
708
+ * Allows exporting names from global class names, so you can use them via import.
709
+ *
710
+ * @remarks
711
+ *
712
+ * See {@link https://github.com/webpack-contrib/css-loader?tab=readme-ov-file#exportglobals | css-loader#exportGlobals} for details.
713
+ */
714
+ exportGlobals?: boolean | undefined;
715
+ /**
716
+ * The style of exported class names.
717
+ *
718
+ * @remarks
719
+ *
720
+ * Given the various `exportLocalsConvention` values, the behavior is described as follows:
721
+ *
722
+ * - `'asIs'`: Class names will be exported as is.
723
+ *
724
+ * - `'camelCase'`: Class names will be camelized, the original class name will not to be removed from the locals
725
+ *
726
+ * - `'camelCaseOnly'`: Class names will be camelized, the original class name will be removed from the locals
727
+ *
728
+ * - `'dashes'`: Only dashes in class names will be camelized
729
+ *
730
+ * - `'dashesOnly'`: Dashes in class names will be camelized, the original class name will be removed from the locals
731
+ *
732
+ * See {@link https://github.com/webpack-contrib/css-loader?tab=readme-ov-file#exportlocalsconvention | css-loader#exportLocalsConvention} for details.
733
+ */
734
+ exportLocalsConvention?: CssModuleLocalsConvention | undefined;
735
+ /**
736
+ * Sets the format of the className generated by CSS Modules after compilation.
737
+ *
738
+ * @remarks
739
+ *
740
+ * See {@link https://github.com/webpack-contrib/css-loader?tab=readme-ov-file#localIdentName | css-loader#localIdentName} for details.
741
+ */
742
+ localIdentName?: string | undefined;
743
+ }
744
+
745
+ /**
746
+ * {@inheritdoc Source.decorators}
747
+ *
748
+ * @public
749
+ */
750
+ export declare interface Decorators {
751
+ /**
752
+ * Specify the decorator syntax version to be used.
753
+ *
754
+ * @remarks
755
+ *
756
+ * If you want to know the differences between different decorators versions, you can refer to: {@link https://github.com/tc39/proposal-decorators?tab=readme-ov-file#how-does-this-proposal-compare-to-other-versions-of-decorators | How does this proposal compare to other versions of decorators?}
757
+ *
758
+ * @example
759
+ *
760
+ * `'2022-03'` corresponds to the Stage 3 decorator proposal, equivalent to the decorator syntax supported by TypeScript 5.0 by default.
761
+ *
762
+ * ```js
763
+ * import { defineConfig } from '@lynx-js/rspeedy'
764
+ *
765
+ * export default defineConfig({
766
+ * source: {
767
+ * decorators: { version: '2022-03' },
768
+ * },
769
+ * })
770
+ * ```
771
+ *
772
+ * @example
773
+ *
774
+ * `'legacy'` corresponds to TypeScript's `experimentalDecorators: true`.
775
+ *
776
+ * ```js
777
+ * import { defineConfig } from '@lynx-js/rspeedy'
778
+ *
779
+ * export default defineConfig({
780
+ * source: {
781
+ * decorators: { version: 'legacy' },
782
+ * },
783
+ * })
784
+ * ```
785
+ */
786
+ version?: 'legacy' | '2022-03';
787
+ }
788
+
789
+ /**
790
+ * The `defineConfig` method is a helper function used to get TypeScript intellisense.
791
+ *
792
+ * @param config - The config of Rspeedy.
793
+ * @returns - The identical config as the input config.
794
+ *
795
+ * @example
796
+ *
797
+ * Use `defineConfig` in `lynx.config.ts`:
798
+ *
799
+ * ```ts
800
+ * //@ts-check
801
+ * import { defineConfig } from '@lynx-js/rspeedy'
802
+ * export default defineConfig({
803
+ * // autocompletion works here!
804
+ * })
805
+ * ```
806
+ *
807
+ * @public
808
+ */
809
+ export declare function defineConfig(config: Config): Config;
810
+
811
+ /**
812
+ * {@inheritdoc Config.dev}
813
+ * @public
814
+ */
815
+ export declare interface Dev {
816
+ /**
817
+ * The {@link Dev.assetPrefix} is used to set the URL prefix for static assets during development.
818
+ * @remarks
819
+ *
820
+ * The functionality of {@link Dev.assetPrefix} is basically the same as the {@link https://www.rspack.dev/config/output#outputpublicpath | output.publicPath}
821
+ * config in Rspack. With the following differences:
822
+ *
823
+ * - `dev.assetPrefix` only takes effect during development.
824
+ *
825
+ * - `dev.assetPrefix` automatically appends a trailing `/` by default.
826
+ *
827
+ * - The value of `dev.assetPrefix` is written to the `process.env.ASSET_PREFIX` environment variable.
828
+ *
829
+ * @example
830
+ *
831
+ * If `dev.assetPrefix` is set to true, the URL prefix will be `http://<host>:<port>/`:
832
+ *
833
+ * ```js
834
+ * import { defineConfig } from '@lynx-js/rspeedy'
835
+ * export default defineConfig({
836
+ * dev: {
837
+ * assetPrefix: true,
838
+ * },
839
+ * })
840
+ * ```
841
+ *
842
+ * @example
843
+ *
844
+ * If `dev.assetPrefix` is set to a string, the value will be used as a prefix and automatically appended to the static resource URL.
845
+ *
846
+ * ```js
847
+ * import { defineConfig } from '@lynx-js/rspeedy'
848
+ * export default defineConfig({
849
+ * dev: {
850
+ * assetPrefix: 'https://example.com/assets/',
851
+ * },
852
+ * })
853
+ * ```
854
+ *
855
+ * @example
856
+ *
857
+ * The port number that Rspeedy server listens on may change. For example, if the port is in use, Rspeedy will automatically increment the port number until it finds an available port.
858
+ *
859
+ * To avoid `dev.assetPrefix` becoming invalid due to port changes, you can use one of the following methods:
860
+ *
861
+ * - Enable `server.strictPort`.
862
+ *
863
+ * - Use the `<port>` placeholder to refer to the current port number. Rspeedy will replace the placeholder with the actual port number it is listening on.
864
+ *
865
+ * ```js
866
+ * import { defineConfig } from '@lynx-js/rspeedy'
867
+ * export default defineConfig({
868
+ * dev: {
869
+ * assetPrefix: 'https://example.com:<port>/assets/',
870
+ * },
871
+ * })
872
+ * ```
873
+ */
874
+ assetPrefix?: string | boolean | undefined;
875
+ /**
876
+ * Configuration of the development client.
877
+ */
878
+ client?: DevClient | undefined;
879
+ /**
880
+ * Whether to enable Hot Module Replacement (HMR).
881
+ *
882
+ * @remarks
883
+ *
884
+ * Defaults to `true`.
885
+ *
886
+ * By default, Rspeedy uses HMR as the preferred method to update modules. If HMR is disabled or cannot be used in certain scenarios, it will automatically fallback to {@link Dev.liveReload}.
887
+ *
888
+ * To completely disable both HMR and live reload, set both `dev.hmr` and `dev.liveReload` to `false`. Then, no WebSocket requests will be made to the dev server on the page, and the page will not automatically refresh when file changes.
889
+ *
890
+ * @example
891
+ *
892
+ * Disable HMR:
893
+ *
894
+ * ```js
895
+ * import { defineConfig } from '@lynx-js/rspeedy'
896
+ *
897
+ * export default defineConfig({
898
+ * dev: {
899
+ * hmr: false,
900
+ * },
901
+ * })
902
+ * ```
903
+ *
904
+ * @example
905
+ *
906
+ * Disable both HMR and live reload:
907
+ *
908
+ * ```js
909
+ * import { defineConfig } from '@lynx-js/rspeedy'
910
+ *
911
+ * export default defineConfig({
912
+ * dev: {
913
+ * hmr: false,
914
+ * liveReload: false,
915
+ * },
916
+ * })
917
+ * ```
918
+ */
919
+ hmr?: boolean | undefined;
920
+ /**
921
+ * Whether to enable live reload functionality.
922
+ *
923
+ * Defaults to `true`.
924
+ *
925
+ * Live reload is used as a fallback when {@link Dev.hmr} is disabled or cannot be used in certain scenarios. When enabled, the page will automatically refresh when source files are changed.
926
+ *
927
+ * To completely disable both HMR and live reload, set both `dev.hmr` and `dev.liveReload` to `false`. Then, no WebSocket requests will be made to the dev server on the page, and the page will not automatically refresh when file changes.
928
+ *
929
+ * @example
930
+ *
931
+ * Disable live reload:
932
+ *
933
+ * ```js
934
+ * import { defineConfig } from '@lynx-js/rspeedy'
935
+ *
936
+ * export default defineConfig({
937
+ * dev: {
938
+ * liveReload: false,
939
+ * },
940
+ * })
941
+ * ```
942
+ *
943
+ * @example
944
+ *
945
+ * Disable both HMR and live reload:
946
+ *
947
+ * ```js
948
+ * import { defineConfig } from '@lynx-js/rspeedy'
949
+ *
950
+ * export default defineConfig({
951
+ * dev: {
952
+ * hmr: false,
953
+ * liveReload: false,
954
+ * },
955
+ * })
956
+ * ```
957
+ */
958
+ liveReload?: boolean | undefined;
959
+ /**
960
+ * Watch specified files and directories for changes. When a file change is detected, it can trigger a page reload or restart the dev server.
961
+ *
962
+ * @example
963
+ *
964
+ * - Specify the files and directories watched for changes.
965
+ *
966
+ * ```js
967
+ * import { defineConfig } from '@lynx-js/rspeedy'
968
+ *
969
+ * export default defineConfig({
970
+ * dev: {
971
+ * watchFiles: {
972
+ * paths: ['src/**', 'public/**'],
973
+ * },
974
+ * },
975
+ * })
976
+ * ```
977
+ *
978
+ * @example
979
+ *
980
+ * - Use {@link https://github.com/paulmillr/chokidar#api | chokidar} options for watching.
981
+ *
982
+ * ```js
983
+ * import { defineConfig } from '@lynx-js/rspeedy'
984
+ *
985
+ * export default defineConfig({
986
+ * dev: {
987
+ * watchFiles: {
988
+ * paths: ['src/**', 'public/**'],
989
+ * options: { usePolling: false },
990
+ * },
991
+ * },
992
+ * })
993
+ * ```
994
+ */
995
+ watchFiles?: WatchFiles | WatchFiles[] | undefined;
996
+ /**
997
+ * Used to control whether the build artifacts of the development environment are written to the disk.
998
+ *
999
+ * @remarks
1000
+ *
1001
+ * This is bypassed to {@link https://github.com/webpack/webpack-dev-middleware?tab=readme-ov-file#writetodisk | `webpack-dev-middleware`}.
1002
+ *
1003
+ * Setting `writeToDisk: true` won't change the behavior of the `webpack-dev-middleware`, and bundle files accessed through the browser will still be served from memory.
1004
+ *
1005
+ * This option also accepts a `Function` value, which can be used to filter which files are written to disk.
1006
+ *
1007
+ * The function follows the same premise as `Array#filter` in which a return value of `false` will not write the file, and a return value of `true` will write the file to disk.
1008
+ *
1009
+ * @example
1010
+ * ```js
1011
+ * // lynx.config.ts
1012
+ * import { defineConfig } from '@lynx-js/rspeedy'
1013
+ * export default defineConfig({
1014
+ * dev: {
1015
+ * writeToDisk: (filePath) => /superman\.css$/.test(filePath),
1016
+ * },
1017
+ * })
1018
+ * ```
1019
+ */
1020
+ writeToDisk?: boolean | ((filename: string) => boolean) | undefined;
1021
+ /**
1022
+ * Whether to display progress bar during compilation.
1023
+ *
1024
+ * Defaults to `true`.
1025
+ *
1026
+ * @example
1027
+ *
1028
+ * Disable the progress bar.
1029
+ *
1030
+ * ```js
1031
+ * import { defineConfig } from '@lynx-js/rspeedy'
1032
+ *
1033
+ * export default defineConfig({
1034
+ * dev: {
1035
+ * progressBar: false,
1036
+ * },
1037
+ * })
1038
+ * ```
1039
+ *
1040
+ * @example
1041
+ *
1042
+ * Modify the progress bar `id`
1043
+ *
1044
+ * To modify the text displayed on the left side of the progress bar, set the `id` option:
1045
+ *
1046
+ * ```js
1047
+ * import { defineConfig } from '@lynx-js/rspeedy'
1048
+ *
1049
+ * export default defineConfig({
1050
+ * dev: {
1051
+ * progressBar: {
1052
+ * id: 'Some Text'
1053
+ * },
1054
+ * },
1055
+ * })
1056
+ * ```
1057
+ */
1058
+ progressBar?: boolean | {
1059
+ id?: string;
1060
+ } | undefined;
1061
+ }
1062
+
1063
+ /**
1064
+ * {@inheritdoc Dev.client}
1065
+ *
1066
+ * @public
1067
+ */
1068
+ export declare interface DevClient {
1069
+ /**
1070
+ * The path to websocket.
1071
+ *
1072
+ * @remarks
1073
+ *
1074
+ * Defaults to `require.resolve('@lynx-js/websocket')`
1075
+ */
1076
+ websocketTransport?: string | undefined;
1077
+ }
1078
+
1079
+ /**
1080
+ * {@inheritdoc Output.distPath}
1081
+ *
1082
+ * @public
1083
+ */
1084
+ export declare interface DistPath extends DistPathConfig {
1085
+ /**
1086
+ * The output directory of the intermediate files.
1087
+ *
1088
+ * @remarks
1089
+ *
1090
+ * Default value:
1091
+ *
1092
+ * - `'.rspeedy'`
1093
+ */
1094
+ intermediate?: string | undefined;
1095
+ }
1096
+
1097
+ /**
1098
+ * {@inheritdoc Source.entry}
1099
+ *
1100
+ * @example
1101
+ *
1102
+ * - Use a single entry:
1103
+ *
1104
+ * ```js
1105
+ * import { defineConfig } from '@lynx-js/rspeedy'
1106
+ * export default defineConfig({
1107
+ * entry: './src/pages/main/index.js',
1108
+ * })
1109
+ * ```
1110
+ *
1111
+ * @example
1112
+ *
1113
+ * - Use a single entry with multiple entry modules:
1114
+ *
1115
+ * ```js
1116
+ * import { defineConfig } from '@lynx-js/rspeedy'
1117
+ * export default defineConfig({
1118
+ * entry: ['./src/prefetch.js', './src/pages/main/index.js'],
1119
+ * })
1120
+ * ```
1121
+ *
1122
+ * @example
1123
+ *
1124
+ * - Use multiple entries(with multiple entry modules):
1125
+ *
1126
+ * ```js
1127
+ * import { defineConfig } from '@lynx-js/rspeedy'
1128
+ * export default defineConfig({
1129
+ * entry: {
1130
+ * foo: './src/pages/foo/index.js',
1131
+ * bar: ['./src/pages/bar/index.js', './src/post.js'], // multiple entry modules is allowed
1132
+ * },
1133
+ * })
1134
+ * ```
1135
+ *
1136
+ * @example
1137
+ *
1138
+ * - Use multiple entries with {@link EntryDescription}:
1139
+ *
1140
+ * ```js
1141
+ * import { defineConfig } from '@lynx-js/rspeedy'
1142
+ * export default defineConfig({
1143
+ * entry: {
1144
+ * foo: './src/pages/foo/index.js',
1145
+ * bar: {
1146
+ * import: ['./src/prefetch.js', './src/pages/bar'],
1147
+ * },
1148
+ * },
1149
+ * })
1150
+ * ```
1151
+ * @public
1152
+ */
1153
+ export declare type Entry = string | string[] | Record<string, string | string[] | EntryDescription>;
1154
+
1155
+ /**
1156
+ * The `EntryDescription` describes a entry. It is useful when the project has multiple entries with different configuration.
1157
+ *
1158
+ * @remarks
1159
+ * It is similar with the {@link https://www.rspack.dev/config/entry#entry-description-object | Entry Description Object} of Rspack.
1160
+ * But only a few properties that Lynx supports is allowed.
1161
+ *
1162
+ * @public
1163
+ */
1164
+ export declare interface EntryDescription {
1165
+ /**
1166
+ * The path to the entry module(s).
1167
+ *
1168
+ * @remarks
1169
+ *
1170
+ * If no value is provided, the default value `src/index.js` will be used.
1171
+ *
1172
+ * @defaultValue `'./src/index.js'`
1173
+ */
1174
+ import?: string | string[] | undefined;
1175
+ /**
1176
+ * This is an important option when using on-demand-loading or loading external resources like images, files, etc. If an incorrect value is specified you'll receive 404 errors while loading these resources.
1177
+ *
1178
+ * @see https://webpack.js.org/configuration/output/#outputpublicpath
1179
+ */
1180
+ publicPath?: string | undefined;
1181
+ }
1182
+
1183
+ /**
1184
+ * The exposed API of Rspeedy. Can be used in Rsbuild plugin with {@link https://rsbuild.dev/plugins/dev/core#apiuseexposed | api.useExposed}.
1185
+ *
1186
+ * @public
1187
+ *
1188
+ * @example
1189
+ *
1190
+ * ```ts
1191
+ * import type { ExposedAPI } from '@lynx-js/rspeedy'
1192
+ * const RsbuildPlugin = {
1193
+ * name: 'my-rsbuild-plugin',
1194
+ * pre: ['lynx:rsbuild:plugin-api'],
1195
+ * setup(api) {
1196
+ * const rspeedyAPI = api.useExposed<ExposedAPI>(Symbol.for('rspeedy.api'))
1197
+ * },
1198
+ * }
1199
+ * ```
1200
+ */
1201
+ export declare interface ExposedAPI {
1202
+ /**
1203
+ * The user config.
1204
+ */
1205
+ config: Config;
1206
+ /**
1207
+ * Print debug logs.
1208
+ *
1209
+ * @param message - The printed message.
1210
+ */
1211
+ debug: (message: string | (() => string)) => void;
1212
+ /**
1213
+ * Exit the process.
1214
+ *
1215
+ * @param code - The exit code.
1216
+ */
1217
+ exit: (code?: number) => Promise<void> | void;
1218
+ /**
1219
+ * Get the Rspeedy logger.
1220
+ */
1221
+ logger: typeof logger;
1222
+ /**
1223
+ * The version of Rspeedy.
1224
+ */
1225
+ version: string;
1226
+ }
1227
+
1228
+ /**
1229
+ * {@inheritdoc Output.filename}
1230
+ *
1231
+ * @public
1232
+ */
1233
+ export declare interface Filename {
1234
+ /**
1235
+ * The name of the bundle files.
1236
+ *
1237
+ * @remarks
1238
+ *
1239
+ * Default values:
1240
+ *
1241
+ * - `'[name].[platform].bundle'`
1242
+ *
1243
+ * The following placeholder is supported:
1244
+ *
1245
+ * - `[name]`: the name of the entry.
1246
+ * - `[contenthash]`: the contenthash of the bundle.
1247
+ * - `[platform]`: the environment name of the bundle.
1248
+ *
1249
+ * @example
1250
+ *
1251
+ * - Using content hash in bundle filename:
1252
+ *
1253
+ * ```js
1254
+ * import { defineConfig } from '@lynx-js/rspeedy'
1255
+ *
1256
+ * export default defineConfig({
1257
+ * output: {
1258
+ * filename: {
1259
+ * bundle: '[name].[contenthash].bundle',
1260
+ * },
1261
+ * },
1262
+ * })
1263
+ * ```
1264
+ *
1265
+ * @example
1266
+ *
1267
+ * - Using content hash with length in bundle filename:
1268
+ *
1269
+ * ```js
1270
+ * import { defineConfig } from '@lynx-js/rspeedy'
1271
+ *
1272
+ * export default defineConfig({
1273
+ * output: {
1274
+ * filename: {
1275
+ * bundle: '[name].[contenthash:8].bundle',
1276
+ * },
1277
+ * },
1278
+ * })
1279
+ * ```
1280
+ */
1281
+ bundle?: string | undefined;
1282
+ /**
1283
+ * The name of the template files.
1284
+ *
1285
+ * @deprecated
1286
+ *
1287
+ * Use {@link Filename.bundle} instead.
1288
+ *
1289
+ * @remarks
1290
+ *
1291
+ * Default values:
1292
+ *
1293
+ * - `'[name].lynx.bundle'`
1294
+ *
1295
+ * The following placeholder is supported:
1296
+ *
1297
+ * - `[name]`: the name of the entry.
1298
+ * - `[contenthash]`: the contenthash of the template.
1299
+ *
1300
+ * @example
1301
+ *
1302
+ * - Using content hash in bundle filename:
1303
+ *
1304
+ * ```js
1305
+ * import { defineConfig } from '@lynx-js/rspeedy'
1306
+ *
1307
+ * export default defineConfig({
1308
+ * output: {
1309
+ * filename: {
1310
+ * template: '[name].[contenthash].bundle',
1311
+ * },
1312
+ * },
1313
+ * })
1314
+ * ```
1315
+ *
1316
+ * @example
1317
+ *
1318
+ * - Using content hash with length in bundle filename:
1319
+ *
1320
+ * ```js
1321
+ * import { defineConfig } from '@lynx-js/rspeedy'
1322
+ *
1323
+ * export default defineConfig({
1324
+ * output: {
1325
+ * filename: {
1326
+ * template: '[name].[contenthash:8].bundle',
1327
+ * },
1328
+ * },
1329
+ * })
1330
+ * ```
1331
+ */
1332
+ template?: string | undefined;
1333
+ /**
1334
+ * The name of the JavaScript files.
1335
+ *
1336
+ * @remarks
1337
+ *
1338
+ * Default values:
1339
+ *
1340
+ * - Development: `'[name].js'`
1341
+ * - Production: `'[name].[contenthash:8].js'`
1342
+ */
1343
+ js?: string | undefined;
1344
+ /**
1345
+ * The name of the CSS files.
1346
+ *
1347
+ * @remarks
1348
+ *
1349
+ * Default values:
1350
+ *
1351
+ * - `'[name].css'`
1352
+ */
1353
+ css?: string | undefined;
1354
+ /**
1355
+ * The name of the SVG images.
1356
+ *
1357
+ * @remarks
1358
+ *
1359
+ * Default values:
1360
+ *
1361
+ * - `'[name].[contenthash:8].svg'`
1362
+ */
1363
+ svg?: string | undefined;
1364
+ /**
1365
+ * The name of the font files.
1366
+ *
1367
+ * @remarks
1368
+ *
1369
+ * Default values:
1370
+ *
1371
+ * - `'[name].[contenthash:8][ext]'`
1372
+ */
1373
+ font?: string | undefined;
1374
+ /**
1375
+ * The name of non-SVG images.
1376
+ *
1377
+ * @remarks
1378
+ *
1379
+ * Default values:
1380
+ *
1381
+ * - `'[name].[contenthash:8][ext]'`
1382
+ */
1383
+ image?: string | undefined;
1384
+ /**
1385
+ * The name of media assets, such as video.
1386
+ *
1387
+ * @remarks
1388
+ *
1389
+ * Default values:
1390
+ *
1391
+ * - `'[name].[contenthash:8][ext]'`
1392
+ */
1393
+ media?: string | undefined;
1394
+ }
1395
+
1396
+ /**
1397
+ * Load the build config by the config path.
1398
+ *
1399
+ * @param loadConfigOptions - the options of `loadConfig` method.
1400
+ * @returns Build config.
1401
+ *
1402
+ * @example
1403
+ *
1404
+ * ```ts
1405
+ * import { loadConfig } from '@lynx-js/rspeedy'
1406
+ *
1407
+ * void async function () {
1408
+ * const config = await loadConfig({ configPath: './lynx.config.js' })
1409
+ * console.log(config);
1410
+ * }()
1411
+ * ```
1412
+ *
1413
+ * @public
1414
+ */
1415
+ export declare function loadConfig(loadConfigOptions: LoadConfigOptions): Promise<LoadConfigResult>;
1416
+
1417
+ /**
1418
+ * The options of loadConfig.
1419
+ *
1420
+ * @public
1421
+ */
1422
+ export declare interface LoadConfigOptions {
1423
+ configPath?: string | undefined;
1424
+ cwd?: string | undefined;
1425
+ }
1426
+
1427
+ /**
1428
+ * The result of {@link loadConfig}.
1429
+ *
1430
+ * @public
1431
+ */
1432
+ export declare interface LoadConfigResult {
1433
+ /**
1434
+ * The configuration object that exported from the configuration file.
1435
+ *
1436
+ * @remarks
1437
+ *
1438
+ * The returned object has already been validated.
1439
+ */
1440
+ content: Config;
1441
+ /**
1442
+ * The configuration path that has been loaded.
1443
+ */
1444
+ configPath: string;
1445
+ }
1446
+
1447
+ export { logger }
1448
+
1449
+ /**
1450
+ * Merge multiple Rspeedy configuration objects.
1451
+ *
1452
+ * @param configs - The Rspeedy configuration objects to merge.
1453
+ *
1454
+ * @returns The merged Rspeedy configuration object.
1455
+ *
1456
+ * @example
1457
+ *
1458
+ * ```ts
1459
+ * import { mergeRspeedyConfig } from '@lynx-js/rspeedy';
1460
+ *
1461
+ * const config1 = {
1462
+ * dev: {
1463
+ * writeToDisk: false,
1464
+ * },
1465
+ * };
1466
+ * const config2 = {
1467
+ * dev: {
1468
+ * writeToDisk: true,
1469
+ * },
1470
+ * };
1471
+ *
1472
+ * const mergedConfig = mergeRspeedyConfig(config1, config2);
1473
+ *
1474
+ * console.log(mergedConfig); // { dev: { writeToDisk: true } }
1475
+ * ```
1476
+ *
1477
+ * @remarks
1478
+ *
1479
+ * This is actually an alias of {@link https://rsbuild.dev/api/javascript-api/core#mergersbuildconfig | mergeRsbuildConfig}.
1480
+ *
1481
+ * @public
1482
+ */
1483
+ export declare function mergeRspeedyConfig(...configs: Config[]): Config;
1484
+
1485
+ /**
1486
+ * {@inheritdoc Output.minify}
1487
+ *
1488
+ * @public
1489
+ */
1490
+ export declare interface Minify {
1491
+ /**
1492
+ * Whether enable the CSS minification.
1493
+ *
1494
+ * @remarks
1495
+ *
1496
+ * 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.
1497
+ *
1498
+ * @example
1499
+ *
1500
+ * - Disable the CSS minification.
1501
+ *
1502
+ * ```js
1503
+ * import { defineConfig } from '@lynx-js/rspeedy'
1504
+ *
1505
+ * export default defineConfig({
1506
+ * output: {
1507
+ * minify: {
1508
+ * css: false,
1509
+ * },
1510
+ * },
1511
+ * })
1512
+ * ```
1513
+ */
1514
+ css?: boolean | undefined;
1515
+ /**
1516
+ * Whether enable the JavaScript minification.
1517
+ *
1518
+ * @example
1519
+ *
1520
+ * - Disable the JavaScript minification.
1521
+ *
1522
+ * ```js
1523
+ * import { defineConfig } from '@lynx-js/rspeedy'
1524
+ *
1525
+ * export default defineConfig({
1526
+ * output: {
1527
+ * minify: {
1528
+ * js: false,
1529
+ * },
1530
+ * },
1531
+ * })
1532
+ * ```
1533
+ */
1534
+ js?: boolean | undefined;
1535
+ /**
1536
+ * {@link Minify.jsOptions} is used to configure SWC minification options.
1537
+ *
1538
+ * @remarks
1539
+ *
1540
+ * For detailed configurations, please refer to {@link https://rspack.dev/plugins/rspack/swc-js-minimizer-rspack-plugin | SwcJsMinimizerRspackPlugin}.
1541
+ *
1542
+ * @example
1543
+ *
1544
+ * - Disable the mangle feature.
1545
+ *
1546
+ * ```js
1547
+ * import { defineConfig } from '@lynx-js/rspeedy'
1548
+ *
1549
+ * export default defineConfig({
1550
+ * output: {
1551
+ * minify: {
1552
+ * jsOptions: {
1553
+ * minimizerOptions: {
1554
+ * mangle: false,
1555
+ * },
1556
+ * },
1557
+ * },
1558
+ * },
1559
+ * })
1560
+ * ```
1561
+ */
1562
+ jsOptions?: Rspack.SwcJsMinimizerRspackPluginOptions | undefined;
1563
+ }
1564
+
1565
+ /**
1566
+ * {@inheritdoc Config.output}
1567
+ * @public
1568
+ */
1569
+ export declare interface Output {
1570
+ /**
1571
+ * The {@link Output.assetPrefix} is used to set the URL prefix for static assets.
1572
+ *
1573
+ * @remarks
1574
+ *
1575
+ * The functionality of {@link Output.assetPrefix} is basically the same as the {@link https://www.rspack.dev/config/output#outputpublicpath | output.publicPath}
1576
+ * config in Rspack. With the following differences:
1577
+ *
1578
+ * - `output.assetPrefix` only takes effect in the production build.
1579
+ *
1580
+ * - `output.assetPrefix` automatically appends a trailing `/` by default.
1581
+ *
1582
+ * - The value of `output.assetPrefix` is written to the `process.env.ASSET_PREFIX` environment variable.
1583
+ *
1584
+ * @example
1585
+ *
1586
+ * ```js
1587
+ * import { defineConfig } from '@lynx-js/rspeedy'
1588
+ * export default defineConfig({
1589
+ * output: {
1590
+ * assetPrefix: 'https://cdn.example.com/assets/',
1591
+ * },
1592
+ * })
1593
+ * ```
1594
+ */
1595
+ assetPrefix?: string | undefined;
1596
+ /**
1597
+ * The {@link Output.cleanDistPath} option determines whether all files in the output directory (default: `dist`) are removed before the build starts.
1598
+ *
1599
+ * @remarks
1600
+ *
1601
+ * By default, if the output directory is a subdirectory of the project root path, Rspeedy will automatically clean all files in the build directory.
1602
+ *
1603
+ * When {@link https://rsbuild.dev/config/output/dist-path#root-directory | 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.
1604
+ *
1605
+ * @example
1606
+ *
1607
+ * - Disable cleaning files:
1608
+ *
1609
+ * ```js
1610
+ * import { defineConfig } from '@lynx-js/rspeedy'
1611
+ * export default defineConfig({
1612
+ * output: {
1613
+ * cleanDistPath: false,
1614
+ * },
1615
+ * })
1616
+ * ```
1617
+ * @example
1618
+ *
1619
+ * - Only clean files before the production build:
1620
+ *
1621
+ * ```js
1622
+ * import { defineConfig } from '@lynx-js/rspeedy'
1623
+ * export default defineConfig({
1624
+ * output: {
1625
+ * cleanDistPath: process.env.NODE_ENV === 'production',
1626
+ * },
1627
+ * })
1628
+ * ```
1629
+ */
1630
+ cleanDistPath?: boolean | undefined;
1631
+ /**
1632
+ * The {@link Output.copy} option is used for copying files to the dist directory.
1633
+ *
1634
+ * @remarks
1635
+ *
1636
+ * For more options, see {@link https://rspack.dev/plugins/rspack/copy-rspack-plugin | Rspack.CopyRspackPlugin}.
1637
+ *
1638
+ * @example
1639
+ *
1640
+ * - Copy files from `./src/assets` to the `./dist` directory:
1641
+ *
1642
+ * ```js
1643
+ * import { defineConfig } from '@lynx-js/rspeedy'
1644
+ *
1645
+ * export default defineConfig({
1646
+ * output: {
1647
+ * copy: [
1648
+ * // `./src/assets/image.png` -> `./dist/image.png`
1649
+ * { from: './src/assets' },
1650
+ * ],
1651
+ * },
1652
+ * })
1653
+ * ```
1654
+ *
1655
+ * @example
1656
+ *
1657
+ * - Copy files from ./src/assets to the ./dist/assets directory:
1658
+ *
1659
+ * ```js
1660
+ * import { defineConfig } from '@lynx-js/rspeedy'
1661
+ *
1662
+ * export default defineConfig({
1663
+ * output: {
1664
+ * copy: [
1665
+ * // `./src/assets/image.png` -> `./dist/assets/image.png`
1666
+ * { from: './src/assets', to: 'assets' },
1667
+ * ],
1668
+ * },
1669
+ * })
1670
+ * ```
1671
+ */
1672
+ copy?: Rspack.CopyRspackPluginOptions | Rspack.CopyRspackPluginOptions['patterns'] | undefined;
1673
+ /**
1674
+ * The {@link CssModules} option is used for the customization of CSS Modules configurations.
1675
+ *
1676
+ * @remarks
1677
+ *
1678
+ * The CSS module is enabled for `*.module.css`, `*.module.scss` and `*.module.less`.
1679
+ * Use {@link CssModules.auto} to customize the filtering behavior.
1680
+ *
1681
+ * @example
1682
+ *
1683
+ * Disable CSS modules:
1684
+ *
1685
+ * ```js
1686
+ * import { defineConfig } from '@lynx-js/rspeedy'
1687
+ * export default defineConfig({
1688
+ * output: {
1689
+ * cssModules: {
1690
+ * auto: false,
1691
+ * },
1692
+ * },
1693
+ * })
1694
+ * ```
1695
+ *
1696
+ * @example
1697
+ *
1698
+ * Enable CSS modules for all CSS files:
1699
+ *
1700
+ * ```js
1701
+ * import { defineConfig } from '@lynx-js/rspeedy'
1702
+ * export default defineConfig({
1703
+ * output: {
1704
+ * cssModules: {
1705
+ * auto: () => true,
1706
+ * },
1707
+ * },
1708
+ * })
1709
+ * ```
1710
+ */
1711
+ cssModules?: CssModules | undefined;
1712
+ /**
1713
+ * The {@link Output.dataUriLimit} option is used to set the size threshold to inline static assets such as images and fonts.
1714
+ *
1715
+ * @remarks
1716
+ *
1717
+ * The default value of `dataUriLimit` is 2kB.
1718
+ *
1719
+ * @example
1720
+ *
1721
+ * Inline all static assets less than 4kB:
1722
+ *
1723
+ * ```js
1724
+ * import { defineConfig } from '@lynx-js/rspeedy'
1725
+ * export default defineConfig({
1726
+ * output: {
1727
+ * dataUriLimit: 4 * 1024,
1728
+ * },
1729
+ * })
1730
+ * ```
1731
+ *
1732
+ * @example
1733
+ *
1734
+ * Disable inlining of static assets:
1735
+ *
1736
+ * ```js
1737
+ * import { defineConfig } from '@lynx-js/rspeedy'
1738
+ * export default defineConfig({
1739
+ * output: {
1740
+ * dataUriLimit: 0,
1741
+ * },
1742
+ * })
1743
+ * ```
1744
+ * @example
1745
+ *
1746
+ * Inline all static assets:
1747
+ *
1748
+ * ```js
1749
+ * import { defineConfig } from '@lynx-js/rspeedy'
1750
+ * export default defineConfig({
1751
+ * output: {
1752
+ * dataUriLimit: Number.MAX_SAFE_INTEGER,
1753
+ * },
1754
+ * })
1755
+ * ```
1756
+ */
1757
+ dataUriLimit?: number | undefined;
1758
+ /**
1759
+ * Set the directory of the dist files.
1760
+ *
1761
+ * @remarks
1762
+ *
1763
+ * More options can be found at {@link https://rsbuild.dev/config/output/dist-path | Rsbuild - distPath}.
1764
+ *
1765
+ * @example
1766
+ *
1767
+ * Use `output` instead of `dist`(the default value):
1768
+ *
1769
+ * ```js
1770
+ * import { defineConfig } from '@lynx-js/rspeedy'
1771
+ * export default defineConfig({
1772
+ * output: {
1773
+ * distPath: {
1774
+ * root: './output',
1775
+ * },
1776
+ * },
1777
+ * })
1778
+ * ```
1779
+ */
1780
+ distPath?: DistPath | undefined;
1781
+ /**
1782
+ * 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.
1783
+ *
1784
+ * @remarks
1785
+ *
1786
+ * If a string is provided, it will be used as {@link Filename.bundle}.
1787
+ *
1788
+ * @example
1789
+ *
1790
+ * ```js
1791
+ * import { defineConfig } from '@lynx-js/rspeedy'
1792
+ * export default defineConfig({
1793
+ * output: {
1794
+ * filename: '[name]/[name].lynx.bundle',
1795
+ * },
1796
+ * })
1797
+ * ```
1798
+ */
1799
+ filename?: string | Filename | undefined;
1800
+ /**
1801
+ * The {@link Output.filenameHash} option controls whether to add a hash value to the filename after the production build.
1802
+ *
1803
+ * @remarks
1804
+ *
1805
+ * {@link Output.filename} has a higher priority than {@link Output.filenameHash}.
1806
+ *
1807
+ * @example
1808
+ *
1809
+ * - Disable hash
1810
+ *
1811
+ * ```js
1812
+ * import { defineConfig } from '@lynx-js/rspeedy'
1813
+ *
1814
+ * export default defineConfig({
1815
+ * output: {
1816
+ * filenameHash: false,
1817
+ * },
1818
+ * })
1819
+ * ```
1820
+ *
1821
+ * @example
1822
+ *
1823
+ * - Change hash format
1824
+ *
1825
+ * ```js
1826
+ * import { defineConfig } from '@lynx-js/rspeedy'
1827
+ *
1828
+ * export default defineConfig({
1829
+ * output: {
1830
+ * filenameHash: 'fullhash:16',
1831
+ * },
1832
+ * })
1833
+ * ```
1834
+ *
1835
+ * The available hash formats are:
1836
+ *
1837
+ * - `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.
1838
+ *
1839
+ * - `chunkhash`: The hash value of the chunk. The hash value will only change when the content of the chunk (and its included modules) changes.
1840
+ *
1841
+ * - `contenthash`: The hash value of the file content. The hash value will only change when the content of the file itself changes.
1842
+ */
1843
+ filenameHash?: boolean | string | undefined;
1844
+ /**
1845
+ * The {@link Output.legalComments} controls how to handle the legal comment.
1846
+ *
1847
+ * @remarks
1848
+ *
1849
+ * If no value is provided, the default value would be `'none'`.
1850
+ *
1851
+ * This is different with Rsbuild since we normally do not want a `.LEGAL.txt` file in Lynx outputs.
1852
+ *
1853
+ * This behavior can be configured by using one of the following options:
1854
+ *
1855
+ * - `linked`: Extract all legal comments to a `.LEGAL.txt` file and link to them with a comment.
1856
+ *
1857
+ * - `inline`: Preserve all legal comments in original position.
1858
+ *
1859
+ * - `none`: Remove all legal comments.
1860
+ */
1861
+ legalComments?: 'none' | 'inline' | 'linked' | undefined;
1862
+ /**
1863
+ * The {@link Minify} configures whether to enable code minification in the production build, or to configure minimizer options.
1864
+ *
1865
+ * @example
1866
+ *
1867
+ * Disable minification.
1868
+ * ```js
1869
+ * import { defineConfig } from '@lynx-js/rspeedy'
1870
+ * export default defineConfig({
1871
+ * output: {
1872
+ * minify: false,
1873
+ * },
1874
+ * })
1875
+ * ```
1876
+ */
1877
+ minify?: Minify | boolean | undefined;
1878
+ /**
1879
+ * The {@link SourceMap} configures whether and how to generate source-map for outputs.
1880
+ */
1881
+ sourceMap?: boolean | SourceMap | undefined;
1882
+ }
1883
+
1884
+ /**
1885
+ * {@inheritdoc Config.performance}
1886
+ *
1887
+ * @public
1888
+ */
1889
+ export declare interface Performance {
1890
+ /**
1891
+ * {@link Performance.chunkSplit} is used to configure the chunk splitting strategy.
1892
+ */
1893
+ chunkSplit?: ChunkSplit | ChunkSplitBySize | ChunkSplitCustom | undefined;
1894
+ /**
1895
+ * Whether to remove `console.[methodName]` in production build.
1896
+ *
1897
+ * @example
1898
+ *
1899
+ * - Remove all `console` methods
1900
+ *
1901
+ * ```ts
1902
+ * import { defineConfig } from '@lynx-js/rspeedy'
1903
+ *
1904
+ * export default defineConfig({
1905
+ * performance: {
1906
+ * removeConsole: true,
1907
+ * },
1908
+ * })
1909
+ * ```
1910
+ *
1911
+ * @example
1912
+ *
1913
+ * - Remove specific `console` methods
1914
+ *
1915
+ * ```ts
1916
+ * import { defineConfig } from '@lynx-js/rspeedy'
1917
+ *
1918
+ * export default defineConfig({
1919
+ * performance: {
1920
+ * removeConsole: ['log', 'warn']
1921
+ * },
1922
+ * })
1923
+ * ```
1924
+ */
1925
+ removeConsole?: boolean | ConsoleType[] | undefined;
1926
+ /**
1927
+ * Whether to print the file sizes after production build.
1928
+ *
1929
+ * {@link Performance.printFileSize}
1930
+ *
1931
+ * See {@link https://rsbuild.dev/config/performance/print-file-size | Rsbuild - performance.printFileSize} for details.
1932
+ *
1933
+ * @example
1934
+ *
1935
+ * If you don't want to print any information, you can disable it by setting printFileSize to false:
1936
+ *
1937
+ * ```ts
1938
+ * import { defineConfig } from '@lynx-js/rspeedy'
1939
+ *
1940
+ * export default defineConfig({
1941
+ * performance: {
1942
+ * printFileSize: false
1943
+ * },
1944
+ * })
1945
+ * ```
1946
+ *
1947
+ * @example
1948
+ *
1949
+ * Set total to false to disable total size output.
1950
+ *
1951
+ * ```ts
1952
+ * import { defineConfig } from '@lynx-js/rspeedy'
1953
+ *
1954
+ * export default defineConfig({
1955
+ * performance: {
1956
+ * printFileSize: {
1957
+ * total: false,
1958
+ * },
1959
+ * },
1960
+ * })
1961
+ * ```
1962
+ *
1963
+ * @example
1964
+ *
1965
+ * Set detail to false to disable per-asset size output.
1966
+ *
1967
+ * If you don't need to view the size of each static asset, you can set detail to false. In this case, only the total size will be output:
1968
+ *
1969
+ * ```ts
1970
+ * import { defineConfig } from '@lynx-js/rspeedy'
1971
+ *
1972
+ * export default defineConfig({
1973
+ * performance: {
1974
+ * printFileSize: {
1975
+ * detail: false,
1976
+ * },
1977
+ * },
1978
+ * })
1979
+ * ```
1980
+ *
1981
+ * @example
1982
+ *
1983
+ * If you don't need to view the gzipped size, you can set compressed to false. This can save some gzip computation time for large projects:
1984
+ *
1985
+ * ```ts
1986
+ * import { defineConfig } from '@lynx-js/rspeedy'
1987
+ *
1988
+ * export default defineConfig({
1989
+ * performance: {
1990
+ * printFileSize: {
1991
+ * compressed: false,
1992
+ * },
1993
+ * },
1994
+ * })
1995
+ * ```
1996
+ *
1997
+ * @example
1998
+ *
1999
+ * To include only static assets that meet certain criteria, use a filter function with include.
2000
+ *
2001
+ * If returned false, the static asset will be excluded and not included in the total size or detailed size.
2002
+ *
2003
+ * only output static assets larger than 10kB:
2004
+ *
2005
+ * ```ts
2006
+ * import { defineConfig } from '@lynx-js/rspeedy'
2007
+ *
2008
+ * export default defineConfig({
2009
+ * performance: {
2010
+ * printFileSize: {
2011
+ * include: (asset) => asset.size > 10 * 1000,
2012
+ * }
2013
+ * },
2014
+ * })
2015
+ * ```
2016
+ *
2017
+ * @example
2018
+ *
2019
+ * To exclude static assets that meet certain criteria, use a filter function with exclude. If both include and exclude are set, exclude will take precedence.
2020
+ *
2021
+ * Rspeedy defaults to excluding source map, license files, and .d.ts type files, as these files do not affect page load performance.
2022
+ *
2023
+ * exclude .html files in addition to the default:
2024
+ *
2025
+ * ```ts
2026
+ * import { defineConfig } from '@lynx-js/rspeedy'
2027
+ *
2028
+ * export default defineConfig({
2029
+ * performance: {
2030
+ * printFileSize: {
2031
+ * exclude: (asset) =>
2032
+ * /\.(?:map|LICENSE\.txt)$/.test(asset.name) ||
2033
+ * /\.html$/.test(asset.name),
2034
+ * }
2035
+ * },
2036
+ * })
2037
+ * ```
2038
+ */
2039
+ printFileSize?: PerformanceConfig['printFileSize'] | undefined;
2040
+ }
2041
+
2042
+ export { RsbuildPlugin }
2043
+
2044
+ export { RsbuildPluginAPI }
2045
+
2046
+ export { rsbuildVersion }
2047
+
2048
+ export declare type RsdoctorRspackPluginOptions = ConstructorParameters<typeof RsdoctorRspackPlugin<[]>>[0];
2049
+
2050
+ export { Rspack }
2051
+
2052
+ export { rspack }
2053
+
2054
+ export declare const rspackVersion: string;
2055
+
2056
+ /**
2057
+ * The instance of Rspeedy.
2058
+ *
2059
+ * @public
2060
+ */
2061
+ export declare type RspeedyInstance = RsbuildInstance & {
2062
+ getRspeedyConfig(): Config;
2063
+ };
2064
+
2065
+ /**
2066
+ * {@inheritdoc Config.server}
2067
+ * @public
2068
+ */
2069
+ export declare interface Server {
2070
+ /**
2071
+ * Configure the base path of the server.
2072
+ *
2073
+ * @remarks
2074
+ * By default, the base path of the server is `/`, and users can access lynx bundle through `http://<host>:<port>/main.lynx.bundle`
2075
+ *
2076
+ * If you want to access lynx bundle through `http://<host>:<port>/foo/main.lynx.bundle`, you can change `server.base` to `/foo`
2077
+ *
2078
+ * you can refer to {@link https://rsbuild.dev/config/server/base | server.base } for more information.
2079
+ *
2080
+ * @example
2081
+ *
2082
+ * ```js
2083
+ * import { defineConfig } from '@lynx-js/rspeedy'
2084
+ * export default defineConfig({
2085
+ * server: {
2086
+ * base: '/dist'
2087
+ * },
2088
+ * })
2089
+ * ```
2090
+ */
2091
+ base?: string | undefined;
2092
+ /**
2093
+ * Adds headers to all responses.
2094
+ *
2095
+ * @example
2096
+ *
2097
+ * ```js
2098
+ * import { defineConfig } from '@lynx-js/rspeedy'
2099
+ * export default defineConfig({
2100
+ * server: {
2101
+ * headers: {
2102
+ * 'Access-Control-Allow-Origin': '**',
2103
+ * },
2104
+ * },
2105
+ * })
2106
+ * ```
2107
+ */
2108
+ headers?: Record<string, string | string[]> | undefined;
2109
+ /**
2110
+ * Specify the host that the Rspeedy Server listens to.
2111
+ *
2112
+ * @remarks
2113
+ * By default, the server listens on local network IP, for example, `192.168.1.50`, verify your local net IP by the command `ifconfig` on your system for (en0 for MacOS and eth0 for LinuxOS users). In case you have multiple local network IP(s) particularly when you are running dockers on the host machine, then you can specify your desired host IP.
2114
+ *
2115
+ * @example
2116
+ *
2117
+ * Set the host to a custom value:
2118
+ *
2119
+ * ```js
2120
+ * import { defineConfig } from '@lynx-js/rspeedy'
2121
+ * export default defineConfig({
2122
+ * server: {
2123
+ * host: "192.168.1.50",
2124
+ * },
2125
+ * })
2126
+ * ```
2127
+ */
2128
+ host?: string | undefined;
2129
+ /**
2130
+ * Specify the port that the Rspeedy Server listens to.
2131
+ *
2132
+ * @remarks
2133
+ * By default, the server listens on port `3000` and automatically increments the port number when the port is occupied.
2134
+ *
2135
+ * @example
2136
+ *
2137
+ * Set the port to a custom value:
2138
+ *
2139
+ * ```js
2140
+ * import { defineConfig } from '@lynx-js/rspeedy'
2141
+ * export default defineConfig({
2142
+ * server: {
2143
+ * port: 3470,
2144
+ * },
2145
+ * })
2146
+ * ```
2147
+ */
2148
+ port?: number | undefined;
2149
+ /**
2150
+ * When a port is occupied, Rspeedy will automatically increment the port number until an available port is found.
2151
+ *
2152
+ * Set strictPort to true and Rspeedy will throw an exception when the port is occupied.
2153
+ */
2154
+ strictPort?: boolean | undefined;
2155
+ }
2156
+
2157
+ /**
2158
+ * {@inheritdoc Config.source}
2159
+ *
2160
+ * @public
2161
+ */
2162
+ export declare interface Source {
2163
+ /**
2164
+ * Create aliases to `import` or `require` certain modules more easily.
2165
+ *
2166
+ * @example
2167
+ *
2168
+ * A trailing `$` can also be added to the given object's keys to signify an exact match:
2169
+ *
2170
+ * ```js
2171
+ * import { defineConfig } from '@lynx-js/rspeedy'
2172
+ * export default defineConfig({
2173
+ * source: {
2174
+ * alias: {
2175
+ * xyz$: 'path/to/file.js',
2176
+ * },
2177
+ * },
2178
+ * })
2179
+ * ```
2180
+ *
2181
+ * which would yield these results:
2182
+ *
2183
+ * ```js
2184
+ * import Test1 from 'xyz'; // Exact match, so path/to/file.js is resolved and imported
2185
+ * import Test2 from 'xyz/file.js'; // Not an exact match, normal resolution takes place
2186
+ * ```
2187
+ *
2188
+ * @example
2189
+ *
2190
+ * `source.alias` is useful to control how a npm package is resolved.
2191
+ *
2192
+ * - Change `react` to `@lynx-js/react`:
2193
+ *
2194
+ * ```js
2195
+ * import { defineConfig } from '@lynx-js/rspeedy'
2196
+ * import { createRequire } from 'module'
2197
+ * const require = createRequire(import.meta.url)
2198
+ * export default defineConfig({
2199
+ * source: {
2200
+ * alias: {
2201
+ * react: require.resolve('@lynx-js/react'),
2202
+ * },
2203
+ * },
2204
+ * })
2205
+ * ```
2206
+ *
2207
+ * This allows you to use some third-party libraries that directly uses `react` as dependencies in ReactLynx.
2208
+ *
2209
+ * - Force using the same version of `dayjs`:
2210
+ *
2211
+ * ```js
2212
+ * import { defineConfig } from '@lynx-js/rspeedy'
2213
+ * import { createRequire } from 'module'
2214
+ * const require = createRequire(import.meta.url)
2215
+ * export default defineConfig({
2216
+ * source: {
2217
+ * alias: {
2218
+ * dayjs: require.resolve('dayjs'),
2219
+ * },
2220
+ * },
2221
+ * })
2222
+ * ```
2223
+ *
2224
+ * Please note that this is dangerous, since all the `dayjs`(including the dependencies of a dependencies) is resolved to the version in the project.
2225
+ * It may cause both compile-time and runtime errors due to version mismatch.
2226
+ *
2227
+ * @example
2228
+ * Setting `source.alias` to `false` will ignore a module.
2229
+ *
2230
+ * ```js
2231
+ * import { defineConfig } from '@lynx-js/rspeedy'
2232
+ * export default defineConfig({
2233
+ * source: {
2234
+ * alias: {
2235
+ * 'ignored-module': false,
2236
+ * './ignored-module': false,
2237
+ * },
2238
+ * },
2239
+ * })
2240
+ * ```
2241
+ */
2242
+ alias?: Record<string, string | false | string[]> | undefined;
2243
+ /**
2244
+ * Include additional files that should be treated as static assets. Defaults to be `undefined`.
2245
+ *
2246
+ * @remarks
2247
+ *
2248
+ * By default, Rsbuild treats common image, font, audio, and video files as static assets.
2249
+ * Through the source.assetsInclude config, you can specify additional file types that should be treated as static assets.
2250
+ * These added static assets are processed using the same rules as the built-in supported static assets。
2251
+ *
2252
+ * The usage of `source.assetsInclude` is consistent with {@link https://rspack.dev/config/module#condition | Condition}
2253
+ * in Rspack, which supports passing in strings, regular expressions, arrays of conditions, or logical conditions
2254
+ * to match the module path or assets.
2255
+ *
2256
+ * @example
2257
+ *
2258
+ * ```js
2259
+ * import { defineConfig } from '@lynx-js/rspeedy'
2260
+ * export default defineConfig({
2261
+ * source: {
2262
+ * assetsInclude: /\.json5$/,
2263
+ * },
2264
+ * })
2265
+ * ```
2266
+ */
2267
+ assetsInclude?: Rspack.RuleSetCondition | undefined;
2268
+ /**
2269
+ * Used to configure the decorators syntax.
2270
+ *
2271
+ * @remarks
2272
+ *
2273
+ * See {@link Decorators.version} for more information.
2274
+ */
2275
+ decorators?: Decorators | undefined;
2276
+ /**
2277
+ * The `define` options is used to define some values or expressions at compile time.
2278
+ *
2279
+ * @example
2280
+ *
2281
+ * Using `define` for environment variables.
2282
+ *
2283
+ * ```js
2284
+ * import { defineConfig } from '@lynx-js/rspeedy'
2285
+ * export default defineConfig({
2286
+ * source: {
2287
+ * define: {
2288
+ * BUILD_VERSION: JSON.stringify(process.env.BUILD_VERSION ?? 'unknown_version'),
2289
+ * 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
2290
+ * },
2291
+ * },
2292
+ * })
2293
+ * ```
2294
+ *
2295
+ * Expressions will be replaced with the corresponding code fragments:
2296
+ *
2297
+ * ```js
2298
+ * const version = BUILD_VERSION;
2299
+ * if (process.env.NODE_ENV === 'development') {}
2300
+ *
2301
+ * // ⬇️ Turn into being...
2302
+ * const version = "unknown_version";
2303
+ * if ("development" === 'development') {}
2304
+ * ```
2305
+ *
2306
+ * @example
2307
+ *
2308
+ * Using `define` for `typeof`.
2309
+ *
2310
+ * ```js
2311
+ * import { defineConfig } from '@lynx-js/rspeedy'
2312
+ * export default defineConfig({
2313
+ * source: {
2314
+ * define: {
2315
+ * 'typeof window': JSON.stringify("undefined"),
2316
+ * },
2317
+ * },
2318
+ * })
2319
+ * ```
2320
+ *
2321
+ * The `typeof` expressions will be replaced with the corresponding code fragments:
2322
+ *
2323
+ * ```js
2324
+ * if (typeof window !== 'undefined') {}
2325
+ *
2326
+ * // ⬇️ Turn into being...
2327
+ * if ("undefined" !== 'undefined') {}
2328
+ * ```
2329
+ *
2330
+ * @example
2331
+ *
2332
+ * Using `define` with objects.
2333
+ *
2334
+ * ```js
2335
+ * import { defineConfig } from '@lynx-js/rspeedy'
2336
+ * export default defineConfig({
2337
+ * source: {
2338
+ * define: {
2339
+ * 'import.meta': {
2340
+ * foo: JSON.stringify('foo'),
2341
+ * bar: { baz: 0 },
2342
+ * },
2343
+ * },
2344
+ * },
2345
+ * })
2346
+ * ```
2347
+ *
2348
+ * Expressions will be replaced with the corresponding code fragments:
2349
+ *
2350
+ * ```js
2351
+ * console.log(import.meta)
2352
+ *
2353
+ * // ⬇️ Turn into being...
2354
+ * console.log({ foo: "foo", bar: { baz: 0 } })
2355
+ * ```
2356
+ *
2357
+ * @remarks
2358
+ *
2359
+ * - If the value provided is a string, it will be utilized as a code fragment.
2360
+ *
2361
+ * - If the value provided is an object, all its keys will be defined in the same manner.
2362
+ *
2363
+ * - If the value isn't a string, it will be stringified, with functions included.
2364
+ *
2365
+ * - Notably, if a `typeof` prefix is attached to the key, it will be exclusively defined for `typeof` calls."
2366
+ */
2367
+ define?: Record<string, string | number | boolean | undefined | Record<string, unknown>> | undefined;
2368
+ /**
2369
+ * The {@link Entry} option is used to set the entry module.
2370
+ *
2371
+ * @remarks
2372
+ *
2373
+ * If no value is provided, the default value `'./src/index.js'` will be used.
2374
+ *
2375
+ * @defaultValue `'./src/index.js'`
2376
+ *
2377
+ * @example
2378
+ *
2379
+ * - Use a single entry:
2380
+ *
2381
+ * ```js
2382
+ * import { defineConfig } from '@lynx-js/rspeedy'
2383
+ * export default defineConfig({
2384
+ * entry: './src/pages/main/index.js',
2385
+ * })
2386
+ * ```
2387
+ *
2388
+ * @example
2389
+ *
2390
+ * - Use a single entry with multiple entry modules:
2391
+ *
2392
+ * ```js
2393
+ * import { defineConfig } from '@lynx-js/rspeedy'
2394
+ * export default defineConfig({
2395
+ * entry: ['./src/prefetch.js', './src/pages/main/index.js'],
2396
+ * })
2397
+ * ```
2398
+ *
2399
+ * @example
2400
+ *
2401
+ * - Use multiple entries(with multiple entry modules):
2402
+ *
2403
+ * ```js
2404
+ * import { defineConfig } from '@lynx-js/rspeedy'
2405
+ * export default defineConfig({
2406
+ * entry: {
2407
+ * foo: './src/pages/foo/index.js',
2408
+ * bar: ['./src/pages/bar/index.js', './src/post.js'], // multiple entry modules is allowed
2409
+ * },
2410
+ * })
2411
+ * ```
2412
+ *
2413
+ * @example
2414
+ *
2415
+ * - Use multiple entries with {@link EntryDescription}:
2416
+ *
2417
+ * ```js
2418
+ * import { defineConfig } from '@lynx-js/rspeedy'
2419
+ * export default defineConfig({
2420
+ * entry: {
2421
+ * foo: './src/pages/foo/index.js',
2422
+ * bar: {
2423
+ * import: ['./src/prefetch.js', './src/pages/bar'],
2424
+ * },
2425
+ * },
2426
+ * })
2427
+ * ```
2428
+ */
2429
+ entry?: Entry | undefined;
2430
+ /**
2431
+ * The `source.exclude` is used to specify JavaScript files that should be excluded from compilation.
2432
+ *
2433
+ * @remarks
2434
+ *
2435
+ * By default, Rsbuild compiles JavaScript files in the current directory and TypeScript/JSX files
2436
+ * in all directories. Through the `source.exclude` config, you can specify files or directories
2437
+ * that should be excluded from compilation.
2438
+ * The usage of `source.exclude` is consistent with {@link https://rspack.dev/config/module#ruleexclude | Rule.exclude}
2439
+ * in Rspack, which supports passing in strings or regular expressions to match module paths.
2440
+ *
2441
+ * @example
2442
+ *
2443
+ * - Exclude specific files or directories
2444
+ *
2445
+ * You can exclude specific files or directories from compilation to improve build performance
2446
+ * or avoid processing certain files:
2447
+ *
2448
+ * ```js
2449
+ * import { defineConfig } from '@lynx-js/rspeedy'
2450
+ *
2451
+ * export default defineConfig({
2452
+ * source: {
2453
+ * exclude: [
2454
+ * // Exclude all files in the test directory
2455
+ * /[\\/]test[\\/]/,
2456
+ * // Exclude specific file
2457
+ * './src/legacy-file.js',
2458
+ * // Exclude files matching a pattern
2459
+ * /\.stories\.(js|ts)x?$/,
2460
+ * ],
2461
+ * },
2462
+ * })
2463
+ * ```
2464
+ *
2465
+ * @example
2466
+ *
2467
+ * - Exclude third-party dependencies
2468
+ *
2469
+ * You can exclude specific third-party dependencies that don't need compilation:
2470
+ *
2471
+ * ```js
2472
+ * import { defineConfig } from '@lynx-js/rspeedy'
2473
+ * import path from 'node:path'
2474
+ * import { createRequire } from 'node:module'
2475
+ *
2476
+ * const require = createRequire(import.meta.url)
2477
+ *
2478
+ * export default defineConfig({
2479
+ * source: {
2480
+ * exclude: [
2481
+ * // Exclude specific package
2482
+ * path.dirname(require.resolve('lodash')),
2483
+ * // Exclude using regex pattern
2484
+ * /node_modules[\\/]lodash-es[\\/]/,
2485
+ * ],
2486
+ * },
2487
+ * })
2488
+ * ```
2489
+ */
2490
+ exclude?: Rspack.RuleSetCondition[] | undefined;
2491
+ /**
2492
+ * The `source.include` is used to specify additional JavaScript files that need to be compiled.
2493
+ *
2494
+ * @remarks
2495
+ *
2496
+ * To avoid redundant compilation, by default, Rsbuild only compiles JavaScript
2497
+ * files in the current directory and TypeScript and JSX files in all directories.
2498
+ * It does not compile JavaScript files under `node_modules`.
2499
+ *
2500
+ * Through the `source.include` config, you can specify directories or modules
2501
+ * that need to be compiled by Rsbuild.
2502
+ * The usage of `source.include` is consistent with {@link https://rspack.dev/config/module#ruleinclude | Rule.include}
2503
+ * in Rspack, which supports passing in strings or regular expressions to match the module path.
2504
+ *
2505
+ * @example
2506
+ *
2507
+ * - Compile Npm Packages
2508
+ *
2509
+ * A typical usage scenario is to compile npm packages under `node_modules`,
2510
+ * because some third-party dependencies have ESNext syntax, which may not be supported in Lynx.
2511
+ * You can solve the problem by using this config to specify the dependencies
2512
+ * that need to be compiled.
2513
+ *
2514
+ * ```js
2515
+ * import { createRequire } from 'node:module'
2516
+ * import path from 'node:path'
2517
+ *
2518
+ * import { defineConfig } from '@lynx-js/rspeedy'
2519
+ *
2520
+ * const require = createRequire(import.meta.url)
2521
+ *
2522
+ * export default defineConfig({
2523
+ * source: {
2524
+ * include: [
2525
+ * // Method 1:
2526
+ * // First get the path of the module by `require.resolve`
2527
+ * // Then pass path.dirname to point to the corresponding directory
2528
+ * path.dirname(require.resolve('query-string')),
2529
+ * // Method 2:
2530
+ * // Match by regular expression
2531
+ * // All paths containing `node_modules/query-string/` will be matched
2532
+ * /node_modules[\\/]query-string[\\/]/,
2533
+ * ],
2534
+ * },
2535
+ * })
2536
+ * ```
2537
+ *
2538
+ * @example
2539
+ *
2540
+ * - Compile Libraries in Monorepo
2541
+ *
2542
+ * ```js
2543
+ * import path from 'node:path'
2544
+ * import { fileURLToPath } from 'node:url'
2545
+ *
2546
+ * import { defineConfig } from '@lynx-js/rspeedy'
2547
+ *
2548
+ * const __dirname = path.dirname(fileURLToPath(import.meta.url))
2549
+ *
2550
+ * const packagesDir = path.resolve(__dirname, '../../packages')
2551
+ *
2552
+ * export default defineConfig({
2553
+ * source: {
2554
+ * include: [
2555
+ * // Compile all files in Monorepo's package directory
2556
+ * // It is recommended to exclude the node_modules
2557
+ * {
2558
+ * and: [packagesDir, { not: /[\\/]node_modules[\\/]/ }],
2559
+ * },
2560
+ * ],
2561
+ * },
2562
+ * })
2563
+ * ```
2564
+ */
2565
+ include?: Rspack.RuleSetCondition[] | undefined;
2566
+ /**
2567
+ * The {@link TransformImport} option transforms the import paths to enable modular imports from subpaths of third-party packages, similar to the functionality provided by {@link https://npmjs.com/package/babel-plugin-import | babel-plugin-import}.
2568
+ *
2569
+ * @example
2570
+ *
2571
+ * When using the TUX component library, you can import components on demand with the following config:
2572
+ *
2573
+ * ```js
2574
+ * import { defineConfig } from '@lynx-js/rspeedy'
2575
+ *
2576
+ * export default defineConfig({
2577
+ * source: {
2578
+ * transformImport: [
2579
+ * {
2580
+ * libraryName: 'foo',
2581
+ * customName: 'foo/src/components/{{ member }}/{{ member }}',
2582
+ * },
2583
+ * ],
2584
+ * },
2585
+ * })
2586
+ * ```
2587
+ *
2588
+ * This will transform the following source code:
2589
+ *
2590
+ * ```js
2591
+ * import { Button } from 'foo'
2592
+ * ```
2593
+ *
2594
+ * to:
2595
+ *
2596
+ * ```js
2597
+ * import { Button } from 'foo/src/components/Button/Button'
2598
+ * ```
2599
+ */
2600
+ transformImport?: TransformImport[] | undefined;
2601
+ /**
2602
+ * Configure a custom `tsconfig.json` file path to use, can be a relative or absolute path. Defaults to be `./tsconfig.json`.
2603
+ *
2604
+ * @remarks
2605
+ *
2606
+ * The `tsconfigPath` configuration affects the following behaviors:
2607
+ *
2608
+ * - The `paths` field is used to configure {@link Source.alias | Path Aliases}.
2609
+ *
2610
+ * - Sets the scope and rules for the {@link https://rsbuild.dev/plugins/list/plugin-type-check | Type Check Plugin}.
2611
+ *
2612
+ * @example
2613
+ *
2614
+ * Relative path will be resolved relative to the project root directory.
2615
+ *
2616
+ * ```js
2617
+ * import { defineConfig } from '@lynx-js/rspeedy'
2618
+ * export default defineConfig({
2619
+ * source: {
2620
+ * tsconfigPath: './tsconfig.build.json',
2621
+ * },
2622
+ * })
2623
+ * ```
2624
+ */
2625
+ tsconfigPath?: string | undefined;
2626
+ }
2627
+
2628
+ /**
2629
+ * {@inheritdoc Output.sourceMap}
2630
+ *
2631
+ * @public
2632
+ */
2633
+ export declare interface SourceMap {
2634
+ /**
2635
+ * How the source map should be generated. Setting it to `false` will disable the source map.
2636
+ *
2637
+ * @remarks
2638
+ *
2639
+ * Defaults to `'cheap-module-source-map'` at development, `false` at production.
2640
+ *
2641
+ * See {@link https://rspack.dev/config/devtool | Rspack - Devtool} for details.
2642
+ *
2643
+ * @example
2644
+ *
2645
+ * - Enable high-quality source-maps for production:
2646
+ *
2647
+ * ```js
2648
+ * import { defineConfig } from '@lynx-js/rspeedy'
2649
+ *
2650
+ * export default defineConfig({
2651
+ * output: {
2652
+ * sourceMap: {
2653
+ * js: process.env['NODE_ENV'] === 'production'
2654
+ * ? 'source-map'
2655
+ * : 'cheap-module-source-map',
2656
+ * },
2657
+ * },
2658
+ * })
2659
+ * ```
2660
+ *
2661
+ * @example
2662
+ *
2663
+ * - Disable source-map generation:
2664
+ *
2665
+ * ```js
2666
+ * import { defineConfig } from '@lynx-js/rspeedy'
2667
+ *
2668
+ * export default defineConfig({
2669
+ * output: {
2670
+ * sourceMap: {
2671
+ * js: false,
2672
+ * },
2673
+ * },
2674
+ * })
2675
+ * ```
2676
+ *
2677
+ * @example
2678
+ *
2679
+ * - Use high-quality source-maps for all environments:
2680
+ *
2681
+ * ```js
2682
+ * import { defineConfig } from '@lynx-js/rspeedy'
2683
+ *
2684
+ * export default defineConfig({
2685
+ * output: {
2686
+ * sourceMap: {
2687
+ * js: 'source-map',
2688
+ * },
2689
+ * },
2690
+ * })
2691
+ * ```
2692
+ */
2693
+ js?: Rspack.DevTool | undefined | `${Exclude<Rspack.DevTool, false | 'eval'>}-debugids`;
2694
+ }
2695
+
2696
+ /**
2697
+ * {@inheritdoc Config.tools}
2698
+ *
2699
+ * @public
2700
+ */
2701
+ export declare interface Tools {
2702
+ /**
2703
+ * The {@link Tools.bundlerChain} changes the options of {@link https://www.rspack.dev | Rspack} using {@link https://github.com/rspack-contrib/rspack-chain | rspack-chain}.
2704
+ *
2705
+ * @example
2706
+ *
2707
+ * ```js
2708
+ * import { defineConfig } from '@lynx-js/rspeedy'
2709
+ *
2710
+ * export default defineConfig({
2711
+ * tools: {
2712
+ * bundlerChain(chain) {
2713
+ * chain.resolve.fullySpecified(true)
2714
+ * },
2715
+ * },
2716
+ * })
2717
+ * ```
2718
+ *
2719
+ * See {@link https://github.com/rspack-contrib/rspack-chain | rspack-chain} for details.
2720
+ */
2721
+ bundlerChain?: ToolsConfig['bundlerChain'] | undefined;
2722
+ /**
2723
+ * The {@link CssLoader} controls the options of {@link https://github.com/webpack-contrib/css-loader | css-loader}.
2724
+ *
2725
+ * @remarks
2726
+ *
2727
+ * The default option is as follow:
2728
+ *
2729
+ * ```js
2730
+ * const defaultOptions = {
2731
+ * modules: {
2732
+ * auto: true,
2733
+ * namedExport: false,
2734
+ * exportLocalsConvention: 'camelCase',
2735
+ * localIdentName: output.cssModules.localIdentName,
2736
+ * },
2737
+ * sourceMap: output.sourceMap,
2738
+ * // importLoaders is `1` when compiling css files, and is `2` when compiling sass/less files
2739
+ * importLoaders: 1 || 2,
2740
+ * };
2741
+ * ```
2742
+ */
2743
+ cssLoader?: CssLoader | undefined;
2744
+ /**
2745
+ * The {@link CssExtract} controls the options of {@link https://www.rspack.dev/plugins/rspack/css-extract-rspack-plugin | CssExtractRspackPlugin}
2746
+ */
2747
+ cssExtract?: CssExtract | undefined;
2748
+ /**
2749
+ * The {@link Tools.rsdoctor} controls the options of {@link https://rsdoctor.dev/ | Rsdoctor}.
2750
+ *
2751
+ * @example
2752
+ *
2753
+ * - Use the built-in Rsdoctor.
2754
+ *
2755
+ * ```js
2756
+ * import { defineConfig } from '@lynx-js/rspeedy'
2757
+ *
2758
+ * export default defineConfig({
2759
+ * tools: {
2760
+ * rsdoctor: {
2761
+ * disableClientServer: true,
2762
+ * },
2763
+ * },
2764
+ * })
2765
+ * ```
2766
+ *
2767
+ * See {@link https://rsdoctor.dev/config/options/options | Rsdoctor - Configuration} for details.
2768
+ */
2769
+ rsdoctor?: RsdoctorRspackPluginOptions | undefined;
2770
+ /**
2771
+ * The {@link Tools.rspack} controls the options of {@link https://www.rspack.dev/ | Rspack}.
2772
+ *
2773
+ * @example
2774
+ *
2775
+ * - Use object config
2776
+ *
2777
+ * ```js
2778
+ * import { defineConfig } from '@lynx-js/rspeedy'
2779
+ *
2780
+ * export default defineConfig({
2781
+ * tools: {
2782
+ * rspack: {
2783
+ * resolve: {
2784
+ * fullySpecified: true,
2785
+ * },
2786
+ * },
2787
+ * },
2788
+ * })
2789
+ * ```
2790
+ *
2791
+ * See {@link https://www.rspack.dev/config/index | Rspack - Configuration} for details.
2792
+ *
2793
+ * @example
2794
+ *
2795
+ * - Use function with `env` utils
2796
+ *
2797
+ * ```js
2798
+ * import { defineConfig } from '@lynx-js/rspeedy'
2799
+ *
2800
+ * export default defineConfig({
2801
+ * tools: {
2802
+ * rspack(config, { env }) {
2803
+ * if (env === 'development') {
2804
+ * config.devtool = 'cheap-source-map'
2805
+ * }
2806
+ * return config
2807
+ * },
2808
+ * },
2809
+ * })
2810
+ * ```
2811
+ *
2812
+ * See {@link https://rsbuild.dev/config/tools/rspack#env | Rsbuild - tools.rspack} for details.
2813
+ *
2814
+ * @example
2815
+ *
2816
+ * - Use function with `mergeConfig` utils
2817
+ *
2818
+ * ```js
2819
+ * import { defineConfig } from '@lynx-js/rspeedy'
2820
+ *
2821
+ * export default defineConfig({
2822
+ * tools: {
2823
+ * rspack(config, { mergeConfig }) {
2824
+ * return mergeConfig(config, {
2825
+ * resolve: {
2826
+ * fullySpecified: true,
2827
+ * },
2828
+ * })
2829
+ * },
2830
+ * },
2831
+ * })
2832
+ * ```
2833
+ *
2834
+ * See {@link https://rsbuild.dev/config/tools/rspack#mergeconfig | Rsbuild - tools.rspack} for details.
2835
+ *
2836
+ * @example
2837
+ *
2838
+ * - Use function with `appendPlugins` utils
2839
+ *
2840
+ * ```js
2841
+ * import { defineConfig } from '@lynx-js/rspeedy'
2842
+ *
2843
+ * export default defineConfig({
2844
+ * tools: {
2845
+ * rspack(config, { appendPlugins, rspack }) {
2846
+ * appendPlugins(new rspack.BannerPlugin({ banner: 'Hello, World!' }))
2847
+ * return config
2848
+ * },
2849
+ * },
2850
+ * })
2851
+ * ```
2852
+ *
2853
+ * See {@link https://rsbuild.dev/config/tools/rspack#appendplugins | Rsbuild - tools.rspack} for details.
2854
+ */
2855
+ rspack?: ToolsConfig['rspack'] | undefined;
2856
+ /**
2857
+ * The {@link Tools.swc} controls the options of {@link https://rspack.dev/guide/features/builtin-swc-loader | builtin:swc-loader}.
2858
+ */
2859
+ swc?: ToolsConfig['swc'] | undefined;
2860
+ }
2861
+
2862
+ /**
2863
+ * {@inheritdoc Source.transformImport}
2864
+ *
2865
+ * @public
2866
+ */
2867
+ export declare interface TransformImport {
2868
+ /**
2869
+ * Whether to convert camelCase imports to kebab-case.
2870
+ *
2871
+ * @example
2872
+ *
2873
+ * - Input:
2874
+ *
2875
+ * ```js
2876
+ * import { ButtonGroup } from 'foo'
2877
+ * ```
2878
+ *
2879
+ * - Output:
2880
+ *
2881
+ * When set to `true`:
2882
+ * ```js
2883
+ * import ButtonGroup from 'foo/button-group'
2884
+ * ```
2885
+ *
2886
+ * When set to `false` or `undefined`:
2887
+ * ```js
2888
+ * import ButtonGroup from 'foo/ButtonGroup'
2889
+ * ```
2890
+ */
2891
+ camelToDashComponentName?: boolean | undefined;
2892
+ /**
2893
+ * Customize the transformed path.
2894
+ *
2895
+ * @remarks
2896
+ *
2897
+ * You you can specify the format of the transformed path.
2898
+ * For example, by setting it to `my-lib/{{ camelCase member }}`, you can convert the member into camelCase.
2899
+ *
2900
+ * The following formats are supported:
2901
+ *
2902
+ * - `kebabCase`: lowercase letters, words joined by hyphens. For example: `my-variable-name`.
2903
+ *
2904
+ * - `snakeCase`: lowercase letters, words joined by underscores. For example: `my_variable_name`.
2905
+ *
2906
+ * - `camelCase`: first letter lowercase, the first letter of each following word uppercase. For example: `myVariableName`.
2907
+ *
2908
+ * - `upperCase`: uppercase letters, other characters unchanged. For example: `MY-VARIABLE-NAME`.
2909
+ *
2910
+ * - `lowerCase`: lowercase letters, other characters unchanged. For example: `my-variable-name`.
2911
+ */
2912
+ customName?: string | undefined;
2913
+ /**
2914
+ * The original import path that needs to be transformed.
2915
+ *
2916
+ * @remarks
2917
+ *
2918
+ * This option is required.
2919
+ */
2920
+ libraryName: string;
2921
+ /**
2922
+ * Used to splice the transformed path, the splicing rule is `${libraryName}/${libraryDirectory}/${member}`, where member is the imported member.
2923
+ *
2924
+ * @remarks
2925
+ *
2926
+ * The default value is `'lib'`.
2927
+ *
2928
+ * @example
2929
+ *
2930
+ * - Input:
2931
+ *
2932
+ * ```js
2933
+ * import { Button } from 'foo'
2934
+ * ```
2935
+ *
2936
+ * - Output:
2937
+ *
2938
+ * ```js
2939
+ * import Button from 'foo/lib/button'
2940
+ * ```
2941
+ */
2942
+ libraryDirectory?: string | undefined;
2943
+ /**
2944
+ * Whether to convert import statements to default imports.
2945
+ *
2946
+ * @example
2947
+ *
2948
+ * - Input:
2949
+ *
2950
+ * ```js
2951
+ * import { Button } from 'foo'
2952
+ * ```
2953
+ *
2954
+ * - Output:
2955
+ *
2956
+ * When set to `true`:
2957
+ * ```js
2958
+ * import Button from 'foo/button'
2959
+ * ```
2960
+ *
2961
+ * When set to `false` or `undefined`:
2962
+ * ```js
2963
+ * import { Button } from 'foo/button'
2964
+ * ```
2965
+ */
2966
+ transformToDefaultImport?: boolean | undefined;
2967
+ }
2968
+
2969
+ export declare const version: string;
2970
+
2971
+ export { }