@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
package/lib/cli/start.js DELETED
@@ -1,88 +0,0 @@
1
- // Copyright 2024 The Lynx Authors. All rights reserved.
2
- // Licensed under the Apache License Version 2.0 that can be found in the
3
- // LICENSE file in the root directory of this source tree.
4
- // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
5
- // See LICENSE in the project root for license information.
6
- import * as fs from 'node:fs';
7
- import * as path from 'node:path';
8
- import { pathToFileURL } from 'node:url';
9
- import { logger } from '@rsbuild/core';
10
- import { debug } from '../debug.js';
11
- var Constants;
12
- (function (Constants) {
13
- Constants["rspeedyPackageName"] = "@lynx-js/rspeedy";
14
- Constants["unmanagedParameterLongName"] = "--unmanaged";
15
- })(Constants || (Constants = {}));
16
- // Excerpted from PackageJsonLookup.tryGetPackageFolderFor()
17
- function tryGetPackageFolderFor(resolvedFileOrFolderPath) {
18
- // Is resolvedFileOrFolderPath itself a folder with a package.json file? If so, return it.
19
- if (fs.existsSync(path.join(resolvedFileOrFolderPath, 'package.json'))) {
20
- return resolvedFileOrFolderPath;
21
- }
22
- // Otherwise go up one level
23
- const parentFolder = path.dirname(resolvedFileOrFolderPath);
24
- if (!parentFolder || parentFolder === resolvedFileOrFolderPath) {
25
- // We reached the root directory without finding a package.json file,
26
- // so cache the negative result
27
- return undefined; // no match
28
- }
29
- // Recurse upwards
30
- return tryGetPackageFolderFor(parentFolder);
31
- }
32
- /**
33
- * When rspeedy is invoked via the shell path, we examine the project's package.json dependencies and try to load
34
- * the locally installed version of rspeedy. This avoids accidentally building using the wrong version of rspeedy.
35
- * Use "rspeedy --unmanaged" to bypass this feature.
36
- */
37
- export function tryStartLocalRspeedy(root = process.cwd()) {
38
- if (process.argv.includes(Constants.unmanagedParameterLongName)) {
39
- logger.info(`Bypassing the Rspeedy version selector because ${JSON.stringify(Constants.unmanagedParameterLongName)} was specified.`);
40
- logger.info();
41
- return false;
42
- }
43
- // The unmanaged flag could be undiscoverable if it's not in their locally installed version
44
- debug(`Searching for a locally installed version of Rspeedy. Use the ${JSON.stringify(Constants.unmanagedParameterLongName)} flag if you want to avoid this.`);
45
- // Find the package.json file that governs the current folder location
46
- const projectFolder = tryGetPackageFolderFor(root);
47
- if (projectFolder) {
48
- debug(`found project at ${projectFolder}`);
49
- let rspeedyEntryPoint;
50
- let packageJson;
51
- try {
52
- const packageJsonPath = path.join(projectFolder, 'package.json');
53
- const packageJsonContent = fs.readFileSync(packageJsonPath).toString();
54
- try {
55
- packageJson = JSON.parse(packageJsonContent);
56
- }
57
- catch (error) {
58
- throw new Error(`Error parsing ${packageJsonPath}:${error.message}`);
59
- }
60
- // Does package.json have a dependency on Rspeedy?
61
- if (!(packageJson.dependencies?.[Constants.rspeedyPackageName])
62
- && !(packageJson.devDependencies?.[Constants.rspeedyPackageName])) {
63
- // No explicit dependency on rspeedy
64
- debug('The project does not have a dependency on Rspeedy');
65
- return false;
66
- }
67
- // To avoid a loading the "resolve" NPM package, let's assume that the rspeedy dependency must be
68
- // installed as "<projectFolder>/node_modules/@lynx-js/rspeedy".
69
- const rspeedyFolder = path.join(projectFolder, 'node_modules', ...Constants.rspeedyPackageName.split('/'));
70
- rspeedyEntryPoint = path.join(rspeedyFolder, 'lib', 'cli', 'main.js');
71
- if (!fs.existsSync(rspeedyEntryPoint)) {
72
- debug(`Unable to find rspeedy entry point: ${rspeedyEntryPoint}, using the unmanaged version.`);
73
- return false;
74
- }
75
- }
76
- catch (error) {
77
- throw new Error(`Error probing for local rspeedy version: ${error.message}`);
78
- }
79
- debug(`found rspeedy entry point at ${rspeedyEntryPoint}`);
80
- // We found and successfully invoked the local rspeedy
81
- // Note that we are using `pathToFileURL` since absolute paths must be valid file:// URLs on Windows.
82
- return import(pathToFileURL(rspeedyEntryPoint).toString()).then(({ main }) => main(process.argv));
83
- }
84
- debug(`no project folder found from ${process.cwd()}`);
85
- // We couldn't find the package folder
86
- return false;
87
- }
88
- //# sourceMappingURL=start.js.map
@@ -1,2 +0,0 @@
1
- import type { Config } from './index.js';
2
- export declare function applyDefaultRspeedyConfig(config: Config): Config;
@@ -1,32 +0,0 @@
1
- // Copyright 2024 The Lynx Authors. All rights reserved.
2
- // Licensed under the Apache License Version 2.0 that can be found in the
3
- // LICENSE file in the root directory of this source tree.
4
- import { mergeRsbuildConfig } from '@rsbuild/core';
5
- export function applyDefaultRspeedyConfig(config) {
6
- const ret = mergeRsbuildConfig(config, {
7
- output: {
8
- // We are applying the default filename to the config
9
- // since some plugin(e.g.: `@lynx-js/qrcode-rsbuild-plugin`) will read
10
- // from the `output.filename.bundle` field.
11
- filename: getFilename(config.output?.filename),
12
- },
13
- });
14
- return ret;
15
- }
16
- const DEFAULT_FILENAME = '[name].[platform].bundle';
17
- function getFilename(filename) {
18
- if (typeof filename === 'string') {
19
- return {
20
- bundle: filename,
21
- template: filename,
22
- };
23
- }
24
- const finalFilename = filename?.bundle
25
- ?? filename?.template
26
- ?? DEFAULT_FILENAME;
27
- return {
28
- bundle: finalFilename,
29
- template: finalFilename,
30
- };
31
- }
32
- //# sourceMappingURL=defaults.js.map
@@ -1,22 +0,0 @@
1
- import type { Config } from './index.js';
2
- /**
3
- * The `defineConfig` method is a helper function used to get TypeScript intellisense.
4
- *
5
- * @param config - The config of Rspeedy.
6
- * @returns - The identical config as the input config.
7
- *
8
- * @example
9
- *
10
- * Use `defineConfig` in `lynx.config.ts`:
11
- *
12
- * ```ts
13
- * //@ts-check
14
- * import { defineConfig } from '@lynx-js/rspeedy'
15
- * export default defineConfig({
16
- * // autocompletion works here!
17
- * })
18
- * ```
19
- *
20
- * @public
21
- */
22
- export declare function defineConfig(config: Config): Config;
@@ -1,24 +0,0 @@
1
- /**
2
- * The `defineConfig` method is a helper function used to get TypeScript intellisense.
3
- *
4
- * @param config - The config of Rspeedy.
5
- * @returns - The identical config as the input config.
6
- *
7
- * @example
8
- *
9
- * Use `defineConfig` in `lynx.config.ts`:
10
- *
11
- * ```ts
12
- * //@ts-check
13
- * import { defineConfig } from '@lynx-js/rspeedy'
14
- * export default defineConfig({
15
- * // autocompletion works here!
16
- * })
17
- * ```
18
- *
19
- * @public
20
- */
21
- export function defineConfig(config) {
22
- return config;
23
- }
24
- //# sourceMappingURL=defineConfig.js.map
@@ -1,15 +0,0 @@
1
- /**
2
- * {@inheritdoc Dev.client}
3
- *
4
- * @public
5
- */
6
- export interface Client {
7
- /**
8
- * The path to websocket.
9
- *
10
- * @remarks
11
- *
12
- * Defaults to `require.resolve('@lynx-js/websocket')`
13
- */
14
- websocketTransport?: string | undefined;
15
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=client.js.map
@@ -1,173 +0,0 @@
1
- import type { WatchFiles } from '@rsbuild/core';
2
- import type { Client } from './client.js';
3
- /**
4
- * {@inheritdoc Config.dev}
5
- * @public
6
- */
7
- export interface Dev {
8
- /**
9
- * The {@link Dev.assetPrefix} is used to set the URL prefix for static assets during development.
10
- * @remarks
11
- *
12
- * The functionality of {@link Dev.assetPrefix} is basically the same as the {@link https://www.rspack.dev/config/output#outputpublicpath | output.publicPath}
13
- * config in Rspack. With the following differences:
14
- *
15
- * - `dev.assetPrefix` only takes effect during development.
16
- *
17
- * - `dev.assetPrefix` automatically appends a trailing `/` by default.
18
- *
19
- * - The value of `dev.assetPrefix` is written to the `process.env.ASSET_PREFIX` environment variable.
20
- *
21
- * @example
22
- *
23
- * If `dev.assetPrefix` is set to true, the URL prefix will be `http://<host>:<port>/`:
24
- *
25
- * ```js
26
- * import { defineConfig } from '@lynx-js/rspeedy'
27
- * export default defineConfig({
28
- * dev: {
29
- * assetPrefix: true,
30
- * },
31
- * })
32
- * ```
33
- *
34
- * @example
35
- *
36
- * If `dev.assetPrefix` is set to a string, the value will be used as a prefix and automatically appended to the static resource URL.
37
- *
38
- * ```js
39
- * import { defineConfig } from '@lynx-js/rspeedy'
40
- * export default defineConfig({
41
- * dev: {
42
- * assetPrefix: 'https://example.com/assets/',
43
- * },
44
- * })
45
- * ```
46
- *
47
- * @example
48
- *
49
- * 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.
50
- *
51
- * To avoid `dev.assetPrefix` becoming invalid due to port changes, you can use one of the following methods:
52
- *
53
- * - Enable `server.strictPort`.
54
- *
55
- * - 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.
56
- *
57
- * ```js
58
- * import { defineConfig } from '@lynx-js/rspeedy'
59
- * export default defineConfig({
60
- * dev: {
61
- * assetPrefix: 'https://example.com:<port>/assets/',
62
- * },
63
- * })
64
- * ```
65
- */
66
- assetPrefix?: string | boolean | undefined;
67
- /**
68
- * Configuration of the development client.
69
- */
70
- client?: Client | undefined;
71
- /**
72
- * Watch specified files and directories for changes. When a file change is detected, it can trigger a page reload or restart the dev server.
73
- *
74
- * @example
75
- *
76
- * - Specify the files and directories watched for changes.
77
- *
78
- * ```js
79
- * import { defineConfig } from '@lynx-js/rspeedy'
80
- *
81
- * export default defineConfig({
82
- * dev: {
83
- * watchFiles: {
84
- * paths: ['src/**', 'public/**'],
85
- * },
86
- * },
87
- * })
88
- * ```
89
- *
90
- * @example
91
- *
92
- * - Use {@link https://github.com/paulmillr/chokidar#api | chokidar} options for watching.
93
- *
94
- * ```js
95
- * import { defineConfig } from '@lynx-js/rspeedy'
96
- *
97
- * export default defineConfig({
98
- * dev: {
99
- * watchFiles: {
100
- * paths: ['src/**', 'public/**'],
101
- * options: { usePolling: false },
102
- * },
103
- * },
104
- * })
105
- * ```
106
- */
107
- watchFiles?: WatchFiles | WatchFiles[] | undefined;
108
- /**
109
- * Used to control whether the build artifacts of the development environment are written to the disk.
110
- *
111
- * @remarks
112
- *
113
- * This is bypassed to {@link https://github.com/webpack/webpack-dev-middleware?tab=readme-ov-file#writetodisk | `webpack-dev-middleware`}.
114
- *
115
- * 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.
116
- *
117
- * This option also accepts a `Function` value, which can be used to filter which files are written to disk.
118
- *
119
- * 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.
120
- *
121
- * @example
122
- * ```js
123
- * // lynx.config.ts
124
- * import { defineConfig } from '@lynx-js/rspeedy'
125
- * export default defineConfig({
126
- * dev: {
127
- * writeToDisk: (filePath) => /superman\.css$/.test(filePath),
128
- * },
129
- * })
130
- * ```
131
- */
132
- writeToDisk?: boolean | ((filename: string) => boolean) | undefined;
133
- /**
134
- * Whether to display progress bar during compilation.
135
- *
136
- * Defaults to `true`.
137
- *
138
- * @example
139
- *
140
- * Disable the progress bar.
141
- *
142
- * ```js
143
- * import { defineConfig } from '@lynx-js/rspeedy'
144
- *
145
- * export default defineConfig({
146
- * dev: {
147
- * progressBar: false,
148
- * },
149
- * })
150
- * ```
151
- *
152
- * @example
153
- *
154
- * Modify the progress bar `id`
155
- *
156
- * To modify the text displayed on the left side of the progress bar, set the `id` option:
157
- *
158
- * ```js
159
- * import { defineConfig } from '@lynx-js/rspeedy'
160
- *
161
- * export default defineConfig({
162
- * dev: {
163
- * progressBar: {
164
- * id: 'Some Text'
165
- * },
166
- * },
167
- * })
168
- * ```
169
- */
170
- progressBar?: boolean | {
171
- id?: string;
172
- } | undefined;
173
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.js.map
@@ -1,172 +0,0 @@
1
- import type { RsbuildConfig, RsbuildPlugins } from '@rsbuild/core';
2
- import type { Dev } from './dev/index.js';
3
- import type { Output } from './output/index.js';
4
- import type { Performance } from './performance/index.js';
5
- import type { Server } from './server/index.js';
6
- import type { Source } from './source/index.js';
7
- import type { Tools } from './tools/index.js';
8
- /**
9
- * The `Config` is the configuration that `rspeedy` uses.
10
- *
11
- * @public
12
- */
13
- export interface Config {
14
- /**
15
- * The Rsbuild provider.
16
- *
17
- * @example
18
- * You can switch from Rspack to Webpack by:
19
- *
20
- * - Use `webpackProvider` from `@rsbuild/webpack`
21
- * - Add `pluginSwc` from `@rsbuild/plugin-webpack-swc` for TypeScript transpilation
22
- *
23
- * ```ts
24
- * import { defineConfig } from '@lynx-js/rspeedy'
25
- * import { webpackProvider } from '@rsbuild/webpack'
26
- * import { pluginSwc } from '@rsbuild/plugin-webpack-swc'
27
- *
28
- * export default defineConfig({
29
- * provider: webpackProvider,
30
- * plugins: [
31
- * pluginSwc(),
32
- * ],
33
- * })
34
- * ```
35
- *
36
- * @alpha
37
- */
38
- provider?: RsbuildConfig['provider'];
39
- /**
40
- * The {@link Dev} option is used to control the behavior related with development. Including: HMR, DevServer, etc.
41
- */
42
- dev?: Dev | undefined;
43
- /**
44
- * The {@link Config.environments} option is used to set the output environment.
45
- *
46
- * @remarks
47
- *
48
- * Normally you don't need this if you are not using Lynx for Web.
49
- *
50
- * @example
51
- *
52
- * - Using different entries for Lynx and Web.
53
- *
54
- * ```ts
55
- * import { defineConfig } from '@lynx-js/rspeedy'
56
- *
57
- * export default defineConfig({
58
- * environments: {
59
- * lynx: {},
60
- * web: {
61
- * source: { entry: { web: './src/index.web.jsx' } },
62
- * },
63
- * },
64
- * source: {
65
- * entry: './src/index.jsx',
66
- * },
67
- * })
68
- * ```
69
- *
70
- * @example
71
- *
72
- * - Building Web-only outputs.
73
- *
74
- * ```ts
75
- * import { defineConfig } from '@lynx-js/rspeedy'
76
- *
77
- * export default defineConfig({
78
- * environments: {
79
- * web: {
80
- * source: { entry: { web: './src/index.web.jsx' } },
81
- * },
82
- * },
83
- * })
84
- * ```
85
- */
86
- environments?: RsbuildConfig['environments'] | undefined;
87
- /**
88
- * Specify the build mode for Rsbuild and Rspack, as each mode has different default behavior and optimizations.
89
- *
90
- * @remarks
91
- *
92
- * The default value of mode depends on the `process.env.NODE_ENV` environment variable:
93
- *
94
- * - If `NODE_ENV` is production, the default value is production.
95
- *
96
- * - If `NODE_ENV` is development, the default value is development.
97
- *
98
- * - If `NODE_ENV` has any other value, the default value is none.
99
- *
100
- * - If you set the value of mode, the value of `NODE_ENV` will be ignored.
101
- *
102
- * When using Rspeedy's CLI:
103
- *
104
- * - `rspeedy dev` and `rspeedy preview` will set the default values of `NODE_ENV` and `mode` to `'development'`.
105
- *
106
- * - `rspeedy build` will set the default values of `NODE_ENV` and `mode` to `'production'`.
107
- *
108
- * @example
109
- *
110
- * If the value of `mode` is `'development'`:
111
- *
112
- * - Enable HMR and register the {@link https://rspack.dev/plugins/webpack/hot-module-replacement-plugin | HotModuleReplacementPlugin}.
113
- *
114
- * - Generate JavaScript source maps, but do not generate CSS source maps. See {@link Output.sourceMap} for details.
115
- *
116
- * - The `process.env.NODE_ENV` in the source code will be replaced with `'development'`.
117
- *
118
- * - The `import.meta.env.MODE` in the source code will be replaced with `'development'`.
119
- *
120
- * - The `import.meta.env.DEV` in the source code will be replaced with `true`.
121
- *
122
- * - The `import.meta.env.PROD` in the source code will be replaced with `false`.
123
- *
124
- * @example
125
- *
126
- * If the value of `mode` is `'production'`:
127
- *
128
- * - Enable JavaScript code minification and register the {@link https://rspack.dev/plugins/rspack/swc-js-minimizer-rspack-plugin | SwcJsMinimizerRspackPlugin}.
129
- *
130
- * - Generated JavaScript and CSS filenames will have hash suffixes, see {@link Output.filenameHash}.
131
- *
132
- * - Generated CSS Modules classnames will be shorter, see {@link CssModules.localIdentName}.
133
- *
134
- * - Do not generate JavaScript and CSS source maps, see {@link Output.sourceMap}.
135
- *
136
- * - The `process.env.NODE_ENV` in the source code will be replaced with `'production'`.
137
- *
138
- * - The `import.meta.env.MODE` in the source code will be replaced with `'production'`.
139
- *
140
- * - The `import.meta.env.DEV` in the source code will be replaced with `false`.
141
- *
142
- * - The `import.meta.env.PROD` in the source code will be replaced with `true`.
143
- */
144
- mode?: 'development' | 'production' | 'none' | undefined;
145
- /**
146
- * The {@link Output} option is used to set how and where should the bundles and assets output.
147
- */
148
- output?: Output | undefined;
149
- /**
150
- * The {@link Performance} option is used to
151
- */
152
- performance?: Performance | undefined;
153
- /**
154
- * The {@link Server} option changes the behavior of dev-server.
155
- */
156
- server?: Server | undefined;
157
- /**
158
- * The {@link Source} option changes the behavior of source files.
159
- */
160
- source?: Source | undefined;
161
- /**
162
- * The {@link Tools} options changes the behavior of various building tools.
163
- */
164
- tools?: Tools | undefined;
165
- /**
166
- * The `plugins` option is used to customize the build process in a variety of ways.
167
- *
168
- * @remarks
169
- * Rspeedy use the plugin APIs from {@link https://rsbuild.dev/plugins/dev/index | Rsbuild}. See the corresponding document for developing a plugin.
170
- */
171
- plugins?: RsbuildPlugins | undefined;
172
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=index.js.map
@@ -1,50 +0,0 @@
1
- import type { Config } from './index.js';
2
- export declare const resolveConfigPath: (root: string, customConfig?: string) => string;
3
- /**
4
- * The options of loadConfig.
5
- *
6
- * @public
7
- */
8
- export interface LoadConfigOptions {
9
- configPath?: string | undefined;
10
- cwd?: string | undefined;
11
- }
12
- /**
13
- * The result of {@link loadConfig}.
14
- *
15
- * @public
16
- */
17
- export interface LoadConfigResult {
18
- /**
19
- * The configuration object that exported from the configuration file.
20
- *
21
- * @remarks
22
- *
23
- * The returned object has already been validated.
24
- */
25
- content: Config;
26
- /**
27
- * The configuration path that has been loaded.
28
- */
29
- configPath: string;
30
- }
31
- /**
32
- * Load the build config by the config path.
33
- *
34
- * @param loadConfigOptions - the options of `loadConfig` method.
35
- * @returns Build config.
36
- *
37
- * @example
38
- *
39
- * ```ts
40
- * import { loadConfig } from '@lynx-js/rspeedy'
41
- *
42
- * void async function () {
43
- * const config = await loadConfig({ configPath: './lynx.config.js' })
44
- * console.log(config);
45
- * }()
46
- * ```
47
- *
48
- * @public
49
- */
50
- export declare function loadConfig(loadConfigOptions: LoadConfigOptions): Promise<LoadConfigResult>;