@lynx-js/rspeedy-canary 0.13.0-canary-20260105-ec1caf1a → 0.13.0-canary-20260105-03ea61ec

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 (66) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/{0~vendors-node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js → 0~node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js} +3 -6
  3. package/dist/0~src_cli_exit_ts.js +98 -108
  4. package/dist/0~src_config_output_dist-path_ts.js +2 -0
  5. package/dist/0~src_config_validate_ts.js +41917 -41925
  6. package/dist/0~src_plugins_api_plugin_ts.js +21 -31
  7. package/dist/0~src_plugins_chunkLoading_plugin_ts.js +10 -20
  8. package/dist/0~src_plugins_dev_plugin_ts.js +168 -179
  9. package/dist/0~src_plugins_emitOnErrors_plugin_ts.js +10 -20
  10. package/dist/0~src_plugins_index_ts.js +63 -51
  11. package/dist/0~src_plugins_inspect_plugin_ts.js +434 -39
  12. package/dist/0~src_plugins_minify_plugin_ts.js +66 -76
  13. package/dist/0~src_plugins_optimization_plugin_ts.js +14 -24
  14. package/dist/0~src_plugins_output_plugin_ts.js +29 -45
  15. package/dist/0~src_plugins_resolve_plugin_ts.js +10 -20
  16. package/dist/0~src_plugins_rsdoctor_plugin_ts.js +39 -49
  17. package/dist/0~src_plugins_sourcemap_plugin_ts.js +86 -96
  18. package/dist/0~src_plugins_swc_plugin_ts.js +20 -38
  19. package/dist/0~src_plugins_target_plugin_ts.js +21 -39
  20. package/dist/0~src_utils_getESVersionTarget_ts.js +4 -0
  21. package/dist/1~node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +1422 -0
  22. package/dist/{1~vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js → 1~node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js} +17 -24
  23. package/dist/{1~vendors-node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js → 1~node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js} +3 -6
  24. package/dist/1~src_cli_build_ts.js +35 -424
  25. package/dist/1~src_cli_commands_ts.js +56 -74
  26. package/dist/1~src_cli_dev_ts.js +29 -410
  27. package/dist/1~src_cli_init_ts-src_create-rspeedy_ts.js +318 -0
  28. package/dist/1~src_cli_inspect_ts.js +18 -356
  29. package/dist/1~src_cli_preview_ts.js +23 -359
  30. package/dist/1~src_cli_watch_ts.js +39 -0
  31. package/dist/1~src_config_output_dist-path_ts.js +2 -0
  32. package/dist/1~src_config_validate_ts.js +41917 -41925
  33. package/dist/1~src_plugins_api_plugin_ts.js +22 -31
  34. package/dist/1~src_plugins_chunkLoading_plugin_ts.js +10 -20
  35. package/dist/1~src_plugins_dev_plugin_ts.js +170 -179
  36. package/dist/1~src_plugins_emitOnErrors_plugin_ts.js +10 -20
  37. package/dist/1~src_plugins_index_ts.js +63 -51
  38. package/dist/1~src_plugins_inspect_plugin_ts.js +436 -39
  39. package/dist/1~src_plugins_minify_plugin_ts.js +66 -76
  40. package/dist/1~src_plugins_optimization_plugin_ts.js +14 -24
  41. package/dist/1~src_plugins_output_plugin_ts.js +29 -45
  42. package/dist/1~src_plugins_resolve_plugin_ts.js +10 -20
  43. package/dist/1~src_plugins_rsdoctor_plugin_ts.js +37 -55
  44. package/dist/1~src_plugins_sourcemap_plugin_ts.js +86 -96
  45. package/dist/1~src_plugins_swc_plugin_ts.js +20 -38
  46. package/dist/1~src_plugins_target_plugin_ts.js +21 -39
  47. package/dist/1~src_utils_getESVersionTarget_ts.js +4 -0
  48. package/dist/1~src_utils_is-ci_ts.js +4 -0
  49. package/dist/1~src_version_ts.js +6 -18
  50. package/dist/cli/main.js +1 -357
  51. package/dist/cli/start.js +16 -130
  52. package/dist/index.js +1 -524
  53. package/dist/node_fs.js +7 -0
  54. package/dist/node_path.js +7 -0
  55. package/dist/node_url.js +1 -0
  56. package/dist/rslib-runtime.js +75 -0
  57. package/dist/src_cli_main_ts.js +149 -0
  58. package/dist/src_debug_ts.js +93 -0
  59. package/dist/src_index_ts.js +381 -0
  60. package/package.json +1 -1
  61. package/dist/0~vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc.js +0 -417
  62. package/dist/1~events-fs-fs_promises-os-path-stream.js +0 -30
  63. package/dist/1~node_child_process-node_events-node_fs-node_path.js +0 -22
  64. package/dist/1~vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +0 -1432
  65. package/dist/1~vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc.js +0 -417
  66. /package/dist/{1~vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt → 1~node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt} +0 -0
@@ -1,8 +1,16 @@
1
- export const __rspack_esm_id = "vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs";
2
- export const __rspack_esm_ids = [
3
- "vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs"
4
- ];
5
- export const __webpack_modules__ = {
1
+ import * as __rspack_external_node_child_process_27f17141 from "node:child_process";
2
+ import * as __rspack_external_node_events_0a6aefe7 from "node:events";
3
+ import { __webpack_require__ } from "./rslib-runtime.js";
4
+ import "./node_path.js";
5
+ import "./node_fs.js";
6
+ import "./src_cli_main_ts.js";
7
+ __webpack_require__.add({
8
+ "node:child_process" (module) {
9
+ module.exports = __rspack_external_node_child_process_27f17141;
10
+ },
11
+ "node:events" (module) {
12
+ module.exports = __rspack_external_node_events_0a6aefe7;
13
+ },
6
14
  "../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/index.js" (__unused_rspack_module, exports, __webpack_require__) {
7
15
  const { Argument } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/argument.js");
8
16
  const { Command } = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/lib/command.js");
@@ -1740,23 +1748,8 @@ Expecting one of '${allowedValues.join("', '")}'`);
1740
1748
  return '';
1741
1749
  }
1742
1750
  exports.suggestSimilar = suggestSimilar;
1743
- },
1744
- "../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/esm.mjs" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
1745
- __webpack_require__.r(__webpack_exports__);
1746
- __webpack_require__.d(__webpack_exports__, {
1747
- Argument: ()=>Argument,
1748
- Command: ()=>Command,
1749
- CommanderError: ()=>CommanderError,
1750
- Help: ()=>Help,
1751
- InvalidArgumentError: ()=>InvalidArgumentError,
1752
- InvalidOptionArgumentError: ()=>InvalidOptionArgumentError,
1753
- Option: ()=>Option,
1754
- createArgument: ()=>createArgument,
1755
- createCommand: ()=>createCommand,
1756
- createOption: ()=>createOption,
1757
- program: ()=>program
1758
- });
1759
- var _index_js__rspack_import_0 = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/index.js");
1760
- const { program, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help } = _index_js__rspack_import_0;
1761
1751
  }
1762
- };
1752
+ });
1753
+ const commander = __webpack_require__("../../../node_modules/.pnpm/commander@13.1.0/node_modules/commander/index.js");
1754
+ const { program: program, createCommand: createCommand, createArgument: createArgument, createOption: createOption, CommanderError: CommanderError, InvalidArgumentError: InvalidArgumentError, InvalidOptionArgumentError: InvalidOptionArgumentError, Command: Command, Argument: Argument, Option: Option, Help: Help } = commander;
1755
+ export { Argument, Command, CommanderError, Help, InvalidArgumentError, InvalidOptionArgumentError, Option, createArgument, createCommand, createOption, program };
@@ -1,8 +1,5 @@
1
- export const __rspack_esm_id = "vendors-node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js";
2
- export const __rspack_esm_ids = [
3
- "vendors-node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js"
4
- ];
5
- export const __webpack_modules__ = {
1
+ import { __webpack_require__ } from "./rslib-runtime.js";
2
+ __webpack_require__.add({
6
3
  "../../../node_modules/.pnpm/ipaddr.js@2.3.0/node_modules/ipaddr.js/lib/ipaddr.js" (module) {
7
4
  (function(root) {
8
5
  'use strict';
@@ -1070,4 +1067,4 @@ export const __webpack_modules__ = {
1070
1067
  else root.ipaddr = ipaddr;
1071
1068
  })(this);
1072
1069
  }
1073
- };
1070
+ });
@@ -1,428 +1,39 @@
1
- import { pathToFileURL } from "node:url";
2
- import { register } from "#register";
3
- import * as __rspack_external_node_fs_5ea92f0c from "node:fs";
4
- export const __rspack_esm_id = "src_cli_build_ts";
5
- export const __rspack_esm_ids = [
6
- "src_cli_build_ts"
7
- ];
8
- export const __webpack_modules__ = {
9
- "./src/cli/build.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
10
- __webpack_require__.d(__webpack_exports__, {
11
- build: ()=>build
12
- });
13
- var node_path__rspack_import_0 = __webpack_require__("node:path");
14
- var _rsbuild_core__rspack_import_1 = __webpack_require__("@rsbuild/core");
15
- var picocolors__rspack_import_7 = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
16
- var picocolors__rspack_import_7_default = /*#__PURE__*/ __webpack_require__.n(picocolors__rspack_import_7);
17
- var _exit_js__rspack_import_2 = __webpack_require__("./src/cli/exit.ts");
18
- var _create_rspeedy_js__rspack_import_3 = __webpack_require__("./src/create-rspeedy.ts");
19
- var _init_js__rspack_import_4 = __webpack_require__("./src/cli/init.ts");
20
- var _watch_js__rspack_import_5 = __webpack_require__("./src/cli/watch.ts");
21
- var _utils_is_ci_js__rspack_import_6 = __webpack_require__("./src/utils/is-ci.ts");
22
- async function build(cwd, buildOptions) {
23
- const shouldExit = 'true' !== process.env['RSDOCTOR'] || (0, _utils_is_ci_js__rspack_import_6.J)();
24
- const isWatch = buildOptions.watch ?? false;
25
- let onBeforeRestart = [];
26
- try {
27
- const { rspeedyConfig, configPath, createRspeedyOptions } = await (0, _init_js__rspack_import_4.T)(cwd, buildOptions);
28
- if (isWatch) {
29
- const watchedFiles = (0, _watch_js__rspack_import_5.G)(configPath, rspeedyConfig);
30
- await (0, _watch_js__rspack_import_5.N)(watchedFiles.map((filePath)=>node_path__rspack_import_0["default"].isAbsolute(filePath) ? filePath : node_path__rspack_import_0["default"].join(cwd, filePath)), async (filename)=>{
31
- _rsbuild_core__rspack_import_1.logger.info(`Restart because ${picocolors__rspack_import_7_default().yellow(filename)} is changed.\n`);
32
- const cleanup = onBeforeRestart.map((f)=>f());
33
- onBeforeRestart = [];
34
- await Promise.all(cleanup);
35
- await build.call(this, cwd, buildOptions);
36
- });
37
- }
38
- const rspeedy = await (0, _create_rspeedy_js__rspack_import_3.x)(createRspeedyOptions);
39
- const { close } = await rspeedy.build({
40
- watch: isWatch
41
- });
42
- if (isWatch) onBeforeRestart.push(close);
43
- else await close();
44
- } catch (error) {
45
- _rsbuild_core__rspack_import_1.logger.error(error);
46
- if (shouldExit) return void (0, _exit_js__rspack_import_2.exit)(1);
47
- }
48
- if (shouldExit && !isWatch) (0, _exit_js__rspack_import_2.exit)();
49
- }
50
- },
51
- "./src/cli/init.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
52
- __webpack_require__.d(__webpack_exports__, {
53
- T: ()=>init
54
- });
55
- var external_node_fs_ = __webpack_require__("node:fs");
56
- var external_node_path_ = __webpack_require__("node:path");
57
- var picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
58
- var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
59
- var debug = __webpack_require__("./src/debug.ts");
60
- const resolveConfigPath = (root, customConfig)=>{
61
- if (customConfig) {
62
- (0, debug.Yz)(`load custom config file ${customConfig} from ${root}`);
63
- const customConfigPath = (0, external_node_path_.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_.join)(root, customConfig);
64
- if (external_node_fs_["default"].existsSync(customConfigPath)) return customConfigPath;
65
- throw new Error(`Cannot find config file: ${picocolors_default().dim(customConfigPath)}`);
66
- }
67
- const CONFIG_FILES = [
68
- 'lynx.config.ts',
69
- 'lynx.config.js',
70
- 'lynx.config.mts',
71
- 'lynx.config.mjs'
72
- ];
73
- for (const file of CONFIG_FILES){
74
- (0, debug.Yz)(`load default config file ${file} from ${root}`);
75
- const configFile = (0, external_node_path_.join)(root, file);
76
- if (external_node_fs_["default"].existsSync(configFile)) {
77
- (0, debug.Yz)(`default config ${configFile} found`);
78
- return configFile;
79
- }
80
- }
81
- throw new Error([
82
- `Cannot find the default config file: ${picocolors_default().dim((0, external_node_path_.join)(root, CONFIG_FILES[0]))}.`,
83
- `Use custom config with ${picocolors_default().green('`--config <config>`')} options.`
84
- ].join(' '));
85
- };
86
- async function loadConfig(loadConfigOptions) {
87
- let { configPath } = loadConfigOptions;
88
- if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
89
- const specifier = pathToFileURL(configPath).toString();
90
- let unregister;
91
- unregister = shouldUseNativeImport(configPath) ? ()=>{} : register({
92
- load: !hasNativeTSSupport(),
93
- resolve: true
94
- });
95
- try {
96
- const [exports, { validate }] = await Promise.all([
97
- import(`${specifier}?t=${Date.now()}`),
98
- __webpack_require__.e("src_config_validate_ts").then(__webpack_require__.bind(__webpack_require__, "./src/config/validate.ts"))
99
- ]);
100
- const configExport = 'default' in exports ? exports.default : exports;
101
- const rawContent = 'function' == typeof configExport ? await configExport({
102
- command: process.argv[2] ?? 'build',
103
- env: process.env['NODE_ENV'] ?? 'production'
104
- }) : await configExport;
105
- return {
106
- configPath,
107
- content: validate(rawContent, configPath)
108
- };
109
- } finally{
110
- unregister();
111
- }
112
- }
113
- function shouldUseNativeImport(configPath) {
114
- return isJavaScriptPath(configPath) || isDeno();
115
- }
116
- function hasNativeTSSupport() {
117
- if (isDeno()) return true;
118
- if (process.features.typescript) return true;
119
- if (false === process.features.typescript) return false;
120
- const { NODE_OPTIONS } = process.env;
121
- if (!NODE_OPTIONS) return false;
122
- return NODE_OPTIONS.includes('--experimental-transform-types') || NODE_OPTIONS.includes('--experimental-strip-types');
123
- }
124
- function isJavaScriptPath(configPath) {
125
- const ext = (0, external_node_path_.extname)(configPath);
126
- return [
127
- '.js',
128
- '.mjs',
129
- '.cjs'
130
- ].includes(ext);
131
- }
132
- function isDeno() {
133
- if ("u" > typeof Deno || process.versions?.deno) return true;
134
- return false;
135
- }
136
- async function init(cwd, options) {
137
- const { content: rspeedyConfig, configPath } = await loadConfig({
138
- cwd,
139
- configPath: options.config
1
+ import { __webpack_require__ } from "./rslib-runtime.js";
2
+ import "./node_path.js";
3
+ import { logger } from "./src_debug_ts.js";
4
+ import { exit_exit } from "./src_cli_main_ts.js";
5
+ import { createRspeedy, init } from "./1~src_cli_init_ts-src_create-rspeedy_ts.js";
6
+ import { isCI } from "./1~src_utils_is-ci_ts.js";
7
+ import { watchFiles, getWatchedFiles } from "./1~src_cli_watch_ts.js";
8
+ const external_node_path_ = __webpack_require__("node:path");
9
+ const picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
10
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
11
+ async function build(cwd, buildOptions) {
12
+ const shouldExit = 'true' !== process.env['RSDOCTOR'] || isCI();
13
+ const isWatch = buildOptions.watch ?? false;
14
+ let onBeforeRestart = [];
15
+ try {
16
+ const { rspeedyConfig, configPath, createRspeedyOptions } = await init(cwd, buildOptions);
17
+ if (isWatch) {
18
+ const watchedFiles = getWatchedFiles(configPath, rspeedyConfig);
19
+ await watchFiles(watchedFiles.map((filePath)=>external_node_path_["default"].isAbsolute(filePath) ? filePath : external_node_path_["default"].join(cwd, filePath)), async (filename)=>{
20
+ logger.info(`Restart because ${picocolors_default().yellow(filename)} is changed.\n`);
21
+ const cleanup = onBeforeRestart.map((f)=>f());
22
+ onBeforeRestart = [];
23
+ await Promise.all(cleanup);
24
+ await build.call(this, cwd, buildOptions);
140
25
  });
141
- if (rspeedyConfig.performance?.buildCache) if (true === rspeedyConfig.performance.buildCache) rspeedyConfig.performance.buildCache = {
142
- buildDependencies: [
143
- configPath
144
- ]
145
- };
146
- else {
147
- rspeedyConfig.performance.buildCache.buildDependencies ??= [];
148
- rspeedyConfig.performance.buildCache.buildDependencies.push(configPath);
149
- }
150
- const createRspeedyOptions = {
151
- cwd,
152
- rspeedyConfig
153
- };
154
- if (options.noEnv) createRspeedyOptions.loadEnv = false;
155
- else if (options.envMode) createRspeedyOptions.loadEnv = {
156
- mode: options.envMode
157
- };
158
- if ('base' in options && options.base) {
159
- rspeedyConfig.server ??= {};
160
- rspeedyConfig.server.base = options.base;
161
- }
162
- if ('environment' in options && options.environment) createRspeedyOptions.environment = options.environment;
163
- if (options.mode) rspeedyConfig.mode = options.mode;
164
- return {
165
- createRspeedyOptions,
166
- configPath,
167
- rspeedyConfig
168
- };
169
26
  }
170
- },
171
- "./src/cli/watch.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
172
- __webpack_require__.d(__webpack_exports__, {
173
- G: ()=>getWatchedFiles,
174
- N: ()=>watchFiles
27
+ const rspeedy = await createRspeedy(createRspeedyOptions);
28
+ const { close } = await rspeedy.build({
29
+ watch: isWatch
175
30
  });
176
- async function watchFiles(files, callback) {
177
- const chokidar = await Promise.all([
178
- __webpack_require__.e("vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js"),
179
- __webpack_require__.e("events-fs-fs_promises-os-path-stream")
180
- ]).then(__webpack_require__.bind(__webpack_require__, "../../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js"));
181
- const watcher = chokidar.default.watch(files, {
182
- ignoreInitial: true,
183
- ignorePermissionErrors: true
184
- });
185
- const cb = debounce((event, filePath)=>{
186
- const startTime = Date.now();
187
- watcher.close().then(()=>callback(filePath, startTime, event));
188
- }, 300);
189
- watcher.once('add', cb.bind(null, 'add'));
190
- watcher.once('change', cb.bind(null, 'change'));
191
- watcher.once('unlink', cb.bind(null, 'unlink'));
192
- }
193
- function debounce(func, wait) {
194
- let timeoutId = null;
195
- return (...args)=>{
196
- if (null !== timeoutId) clearTimeout(timeoutId);
197
- timeoutId = setTimeout(()=>{
198
- func(...args);
199
- }, wait);
200
- };
201
- }
202
- function getWatchedFiles(configPath, rspeedyConfig) {
203
- const watchedFiles = [
204
- configPath
205
- ];
206
- if (Array.isArray(rspeedyConfig.dev?.watchFiles)) watchedFiles.push(...rspeedyConfig.dev.watchFiles.filter((item)=>'reload-server' === item.type).flatMap((item)=>item.paths));
207
- else if (rspeedyConfig.dev?.watchFiles?.type === 'reload-server') {
208
- const { paths } = rspeedyConfig.dev.watchFiles;
209
- watchedFiles.push(...Array.isArray(paths) ? paths : [
210
- paths
211
- ]);
212
- }
213
- return watchedFiles;
214
- }
215
- },
216
- "./src/create-rspeedy.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
217
- __webpack_require__.d(__webpack_exports__, {
218
- x: ()=>createRspeedy
219
- });
220
- var external_node_path_ = __webpack_require__("node:path");
221
- var core_ = __webpack_require__("@rsbuild/core");
222
- var debug = __webpack_require__("./src/debug.ts");
223
- function applyDefaultRspeedyConfig(config) {
224
- const enableChunkSplitting = config.performance?.chunkSplit?.strategy && config.performance?.chunkSplit?.strategy !== 'all-in-one';
225
- return (0, core_.mergeRsbuildConfig)({
226
- mode: (()=>{
227
- if (config.mode) return config.mode;
228
- const nodeEnv = process.env['NODE_ENV'];
229
- return 'production' === nodeEnv || 'development' === nodeEnv ? nodeEnv : 'none';
230
- })(),
231
- output: {
232
- filename: getFilename(config.output?.filename),
233
- inlineScripts: !enableChunkSplitting,
234
- cssModules: {
235
- localIdentName: '[local]-[hash:base64:6]'
236
- }
237
- },
238
- performance: {
239
- profile: (0, debug._o)() ? true : void 0
240
- },
241
- tools: {
242
- rsdoctor: {
243
- experiments: {
244
- enableNativePlugin: true
245
- }
246
- }
247
- }
248
- }, config);
249
- }
250
- const DEFAULT_FILENAME = '[name].[platform].bundle';
251
- function getFilename(filename) {
252
- if ('string' == typeof filename) return {
253
- bundle: filename,
254
- template: filename
255
- };
256
- const finalFilename = filename?.bundle ?? filename?.template ?? DEFAULT_FILENAME;
257
- return {
258
- bundle: finalFilename,
259
- template: finalFilename
260
- };
261
- }
262
- const DEFAULT_ENTRY = './src/index.js';
263
- function toRsbuildEntry(entry) {
264
- if (void 0 === entry) {
265
- (0, debug.Yz)(`Using default entry ${DEFAULT_ENTRY}`);
266
- return {
267
- main: DEFAULT_ENTRY
268
- };
269
- }
270
- if (Array.isArray(entry) || 'string' == typeof entry) {
271
- (0, debug.Yz)(()=>`Using single entry ${[
272
- ''
273
- ].concat(entry).join('\n - ')}`);
274
- return {
275
- main: entry
276
- };
277
- }
278
- return Object.fromEntries(Object.entries(entry).map(([key, value])=>{
279
- if (Array.isArray(value) || 'string' == typeof value) {
280
- (0, debug.Iv)(`Using multiple entries - ${key}`, value);
281
- return [
282
- key,
283
- {
284
- import: value
285
- }
286
- ];
287
- }
288
- (0, debug.Iv)(`Using multiple entries - ${key}`, value.import ?? DEFAULT_ENTRY);
289
- if (void 0 === value.import) return [
290
- key,
291
- {
292
- ...value,
293
- import: DEFAULT_ENTRY
294
- }
295
- ];
296
- return [
297
- key,
298
- value
299
- ];
300
- }));
301
- }
302
- const defaultDataUriLimit = 2048;
303
- function toRsbuildConfig(config) {
304
- return {
305
- dev: {
306
- hmr: config.dev?.hmr ?? true,
307
- lazyCompilation: false,
308
- liveReload: config.dev?.liveReload ?? true,
309
- watchFiles: config.dev?.watchFiles,
310
- writeToDisk: config.dev?.writeToDisk ?? true,
311
- progressBar: config.dev?.progressBar ?? true
312
- },
313
- environments: config.environments ?? {
314
- lynx: {}
315
- },
316
- mode: config.mode,
317
- output: {
318
- assetPrefix: config.output?.assetPrefix,
319
- charset: 'utf8',
320
- cleanDistPath: config.output?.cleanDistPath,
321
- copy: config.output?.copy,
322
- cssModules: config.output?.cssModules,
323
- dataUriLimit: config.output?.dataUriLimit ?? defaultDataUriLimit,
324
- distPath: config.output?.distPath,
325
- filenameHash: config.output?.filenameHash,
326
- inlineScripts: config.output?.inlineScripts,
327
- legalComments: config.output?.legalComments ?? 'none',
328
- polyfill: 'off',
329
- sourceMap: config.output?.sourceMap
330
- },
331
- resolve: {
332
- alias: config.resolve?.alias,
333
- aliasStrategy: config.resolve?.aliasStrategy,
334
- dedupe: config.resolve?.dedupe,
335
- extensions: config.resolve?.extensions
336
- },
337
- source: {
338
- alias: config.source?.alias,
339
- assetsInclude: config.source?.assetsInclude,
340
- decorators: config.source?.decorators,
341
- define: config.source?.define,
342
- entry: toRsbuildEntry(config.source?.entry),
343
- exclude: config.source?.exclude,
344
- include: config.source?.include,
345
- preEntry: config.source?.preEntry,
346
- transformImport: config.source?.transformImport,
347
- tsconfigPath: config.source?.tsconfigPath
348
- },
349
- server: {
350
- base: config.server?.base,
351
- compress: config.server?.compress,
352
- cors: config.server?.cors,
353
- headers: config.server?.headers,
354
- host: config.server?.host,
355
- port: config.server?.port,
356
- proxy: config.server?.proxy,
357
- strictPort: config.server?.strictPort
358
- },
359
- plugins: config.plugins,
360
- performance: {
361
- buildCache: config.performance?.buildCache,
362
- chunkSplit: config.performance?.chunkSplit,
363
- profile: config.performance?.profile,
364
- removeConsole: toRsbuildRemoveConsole(config),
365
- printFileSize: config.performance?.printFileSize ?? true
366
- },
367
- tools: {
368
- bundlerChain: config.tools?.bundlerChain,
369
- cssExtract: config.tools?.cssExtract,
370
- cssLoader: config.tools?.cssLoader,
371
- htmlPlugin: false,
372
- rspack: config.tools?.rspack,
373
- swc: config.tools?.swc
374
- }
375
- };
376
- }
377
- function toRsbuildRemoveConsole(config) {
378
- if (config.performance?.removeConsole === true) return [
379
- 'log',
380
- 'warn',
381
- 'error',
382
- 'info',
383
- 'debug',
384
- 'profile',
385
- 'profileEnd'
386
- ];
387
- return config.performance?.removeConsole;
388
- }
389
- async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [], callerName = 'rspeedy' }) {
390
- const config = applyDefaultRspeedyConfig(rspeedyConfig);
391
- const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
392
- (0, core_.createRsbuild)({
393
- cwd,
394
- loadEnv,
395
- rsbuildConfig: toRsbuildConfig(config),
396
- environment,
397
- callerName
398
- }),
399
- __webpack_require__.e("src_plugins_index_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/index.ts"))
400
- ]);
401
- await applyDefaultPlugins(rspeedy, config);
402
- const inspectConfig = rspeedy.inspectConfig.bind(rspeedy);
403
- return Object.assign(rspeedy, {
404
- getRspeedyConfig: ()=>config,
405
- async inspectConfig (options) {
406
- const result = await inspectConfig(options);
407
- const { inspectRspeedyConfig } = await Promise.all([
408
- __webpack_require__.e("vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc"),
409
- __webpack_require__.e("src_plugins_inspect_plugin_ts")
410
- ]).then(__webpack_require__.bind(__webpack_require__, "./src/plugins/inspect.plugin.ts"));
411
- await inspectRspeedyConfig(rspeedyConfig, external_node_path_["default"].resolve(options.outputPath ?? rspeedy.context.distPath, '.rsbuild/rspeedy.config.js'), options.verbose ?? false);
412
- return result;
413
- }
414
- });
415
- }
416
- },
417
- "./src/utils/is-ci.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
418
- __webpack_require__.d(__webpack_exports__, {
419
- J: ()=>isCI
420
- });
421
- function isCI() {
422
- return !!process.env['CI'] && 'false' !== process.env['CI'];
423
- }
424
- },
425
- "node:fs" (module) {
426
- module.exports = __rspack_external_node_fs_5ea92f0c;
31
+ if (isWatch) onBeforeRestart.push(close);
32
+ else await close();
33
+ } catch (error) {
34
+ logger.error(error);
35
+ if (shouldExit) return void exit_exit(1);
427
36
  }
428
- };
37
+ if (shouldExit && !isWatch) exit_exit();
38
+ }
39
+ export { build };