@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
@@ -0,0 +1,149 @@
1
+ import * as __rspack_external_node_process_786449bf from "node:process";
2
+ import { __webpack_require__ } from "./rslib-runtime.js";
3
+ import { debug, logger } from "./src_debug_ts.js";
4
+ __webpack_require__.add({
5
+ "node:process" (module) {
6
+ module.exports = __rspack_external_node_process_786449bf;
7
+ }
8
+ });
9
+ const external_node_process_ = __webpack_require__("node:process");
10
+ const asyncCallbacks = new Set();
11
+ const callbacks = new Set();
12
+ let isCalled = false;
13
+ let isRegistered = false;
14
+ async function exit(shouldManuallyExit, isSynchronous, signal) {
15
+ if (isCalled) return;
16
+ isCalled = true;
17
+ if (asyncCallbacks.size > 0 && isSynchronous) console.error("SYNCHRONOUS TERMINATION NOTICE: When explicitly exiting the process via process.exit or via a parent process, asynchronous tasks in your exitHooks will not run. Either remove these tasks, use gracefulExit() instead of process.exit(), or ensure your parent process sends a SIGINT to the process running this code.");
18
+ const exitCode = 128 + signal;
19
+ const done = (force = false)=>{
20
+ if (true === force || true === shouldManuallyExit) external_node_process_["default"].exit(exitCode);
21
+ };
22
+ for (const callback of callbacks)callback(exitCode);
23
+ if (isSynchronous) return void done();
24
+ const promises = [];
25
+ let forceAfter = 0;
26
+ for (const [callback, wait] of asyncCallbacks){
27
+ forceAfter = Math.max(forceAfter, wait);
28
+ promises.push(Promise.resolve(callback(exitCode)));
29
+ }
30
+ const asyncTimer = setTimeout(()=>{
31
+ done(true);
32
+ }, forceAfter);
33
+ await Promise.all(promises);
34
+ clearTimeout(asyncTimer);
35
+ done();
36
+ }
37
+ function addHook(options) {
38
+ const { onExit, wait, isSynchronous } = options;
39
+ const asyncCallbackConfig = [
40
+ onExit,
41
+ wait
42
+ ];
43
+ if (isSynchronous) callbacks.add(onExit);
44
+ else asyncCallbacks.add(asyncCallbackConfig);
45
+ if (!isRegistered) {
46
+ isRegistered = true;
47
+ external_node_process_["default"].once('beforeExit', exit.bind(void 0, true, false, -128));
48
+ external_node_process_["default"].once('SIGINT', exit.bind(void 0, true, false, 2));
49
+ external_node_process_["default"].once('SIGTERM', exit.bind(void 0, true, false, 15));
50
+ external_node_process_["default"].once('exit', exit.bind(void 0, false, true, 0));
51
+ external_node_process_["default"].on('message', (message)=>{
52
+ if ('shutdown' === message) exit(true, true, -128);
53
+ });
54
+ }
55
+ return ()=>{
56
+ if (isSynchronous) callbacks.delete(onExit);
57
+ else asyncCallbacks.delete(asyncCallbackConfig);
58
+ };
59
+ }
60
+ function asyncExitHook(onExit, options = {}) {
61
+ if ('function' != typeof onExit) throw new TypeError('onExit must be a function');
62
+ if (!('number' == typeof options.wait && options.wait > 0)) throw new TypeError('wait must be set to a positive numeric value');
63
+ return addHook({
64
+ onExit,
65
+ wait: options.wait,
66
+ isSynchronous: false
67
+ });
68
+ }
69
+ function gracefulExit(signal = 0) {
70
+ exit(true, false, -128 + signal);
71
+ }
72
+ const picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
73
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
74
+ const start = Date.now();
75
+ const exitPromises = [];
76
+ const unsubscribe = asyncExitHook(exit_onExit, {
77
+ wait: 1000
78
+ });
79
+ process.on('unhandledRejection', async (reason)=>{
80
+ logger.error('Unhandled Rejection with reason:', reason instanceof Error ? reason : new Error(JSON.stringify(reason)));
81
+ unsubscribe();
82
+ await exit_onExit(1);
83
+ process.exit(1);
84
+ });
85
+ let interrupted = false;
86
+ process.on('SIGINT', ()=>{
87
+ if (interrupted) {
88
+ logger.info("Force exiting Rspeedy.");
89
+ return process.exit(130);
90
+ }
91
+ interrupted = true;
92
+ logger.info(`Gracefully shutting down. Please wait... (Press ${picocolors_default().cyan('Ctrl+C')} again to force exit)`);
93
+ exit_exit(130);
94
+ });
95
+ let previousSignal = null;
96
+ const exit_exit = (signal = 0)=>{
97
+ if (null !== previousSignal) debug(`graceful exit called multiple times, current: ${signal}, previous: ${previousSignal}`);
98
+ previousSignal = signal;
99
+ debug(`graceful exit process with signal: ${signal}`);
100
+ gracefulExit(signal);
101
+ };
102
+ async function exit_onExit(signal) {
103
+ const duration = Date.now() - start;
104
+ debug(`exit hook fired with signal: ${signal}, duration: ${duration}`);
105
+ debug(`awaiting exit promises(length: ${exitPromises.length})...`);
106
+ await Promise.allSettled(exitPromises);
107
+ }
108
+ function initNodeEnv(argv) {
109
+ if (!process.env['NODE_ENV']) {
110
+ const NODE_ENV = argv.includes('dev') || argv.includes('preview') ? 'development' : 'production';
111
+ process.env['NODE_ENV'] = NODE_ENV;
112
+ debug(`No NODE_ENV found, set to ${NODE_ENV}`);
113
+ }
114
+ }
115
+ async function main(argv) {
116
+ initNodeEnv(argv);
117
+ const { npm_execpath } = process.env;
118
+ if (!npm_execpath || npm_execpath.includes('npm-cli.js') || npm_execpath.includes('npx-cli.js')) console.log();
119
+ const { version, rsbuildVersion, rspackVersion } = await import("./1~src_version_ts.js").then((mod)=>({
120
+ version: mod.version,
121
+ rsbuildVersion: mod.version,
122
+ rspackVersion: mod.rspackVersion
123
+ }));
124
+ logger.greet(` Rspeedy v${version} (Rsbuild v${rsbuildVersion}, Rspack v${rspackVersion})\n`);
125
+ try {
126
+ const [{ Command }, { apply }] = await Promise.all([
127
+ import("./1~node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js").then((mod)=>({
128
+ Argument: mod.Argument,
129
+ Command: mod.Command,
130
+ CommanderError: mod.CommanderError,
131
+ Help: mod.Help,
132
+ InvalidArgumentError: mod.InvalidArgumentError,
133
+ InvalidOptionArgumentError: mod.InvalidOptionArgumentError,
134
+ Option: mod.Option,
135
+ createArgument: mod.createArgument,
136
+ createCommand: mod.createCommand,
137
+ createOption: mod.createOption,
138
+ program: mod.program
139
+ })),
140
+ import("./1~src_cli_commands_ts.js").then((mod)=>({
141
+ apply: mod.apply
142
+ }))
143
+ ]);
144
+ apply(new Command('rspeedy')).parse(argv);
145
+ } catch {
146
+ return exit_exit(1);
147
+ }
148
+ }
149
+ export { exit_exit, main };
@@ -0,0 +1,93 @@
1
+ import { __webpack_require__ } from "./rslib-runtime.js";
2
+ import { createRsbuild, logger, mergeRsbuildConfig, rspack, version } from "@rsbuild/core";
3
+ __webpack_require__.add({
4
+ "../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js" (module) {
5
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
6
+ let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || "win32" === p.platform || (p.stdout || {}).isTTY && "dumb" !== env.TERM || !!env.CI);
7
+ let formatter = (open, close, replace = open)=>(input)=>{
8
+ let string = "" + input, index = string.indexOf(close, open.length);
9
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
10
+ };
11
+ let replaceClose = (string, close, replace, index)=>{
12
+ let result = "", cursor = 0;
13
+ do {
14
+ result += string.substring(cursor, index) + replace;
15
+ cursor = index + close.length;
16
+ index = string.indexOf(close, cursor);
17
+ }while (~index);
18
+ return result + string.substring(cursor);
19
+ };
20
+ let createColors = (enabled = isColorSupported)=>{
21
+ let f = enabled ? formatter : ()=>String;
22
+ return {
23
+ isColorSupported: enabled,
24
+ reset: f("\x1b[0m", "\x1b[0m"),
25
+ bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
26
+ dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
27
+ italic: f("\x1b[3m", "\x1b[23m"),
28
+ underline: f("\x1b[4m", "\x1b[24m"),
29
+ inverse: f("\x1b[7m", "\x1b[27m"),
30
+ hidden: f("\x1b[8m", "\x1b[28m"),
31
+ strikethrough: f("\x1b[9m", "\x1b[29m"),
32
+ black: f("\x1b[30m", "\x1b[39m"),
33
+ red: f("\x1b[31m", "\x1b[39m"),
34
+ green: f("\x1b[32m", "\x1b[39m"),
35
+ yellow: f("\x1b[33m", "\x1b[39m"),
36
+ blue: f("\x1b[34m", "\x1b[39m"),
37
+ magenta: f("\x1b[35m", "\x1b[39m"),
38
+ cyan: f("\x1b[36m", "\x1b[39m"),
39
+ white: f("\x1b[37m", "\x1b[39m"),
40
+ gray: f("\x1b[90m", "\x1b[39m"),
41
+ bgBlack: f("\x1b[40m", "\x1b[49m"),
42
+ bgRed: f("\x1b[41m", "\x1b[49m"),
43
+ bgGreen: f("\x1b[42m", "\x1b[49m"),
44
+ bgYellow: f("\x1b[43m", "\x1b[49m"),
45
+ bgBlue: f("\x1b[44m", "\x1b[49m"),
46
+ bgMagenta: f("\x1b[45m", "\x1b[49m"),
47
+ bgCyan: f("\x1b[46m", "\x1b[49m"),
48
+ bgWhite: f("\x1b[47m", "\x1b[49m"),
49
+ blackBright: f("\x1b[90m", "\x1b[39m"),
50
+ redBright: f("\x1b[91m", "\x1b[39m"),
51
+ greenBright: f("\x1b[92m", "\x1b[39m"),
52
+ yellowBright: f("\x1b[93m", "\x1b[39m"),
53
+ blueBright: f("\x1b[94m", "\x1b[39m"),
54
+ magentaBright: f("\x1b[95m", "\x1b[39m"),
55
+ cyanBright: f("\x1b[96m", "\x1b[39m"),
56
+ whiteBright: f("\x1b[97m", "\x1b[39m"),
57
+ bgBlackBright: f("\x1b[100m", "\x1b[49m"),
58
+ bgRedBright: f("\x1b[101m", "\x1b[49m"),
59
+ bgGreenBright: f("\x1b[102m", "\x1b[49m"),
60
+ bgYellowBright: f("\x1b[103m", "\x1b[49m"),
61
+ bgBlueBright: f("\x1b[104m", "\x1b[49m"),
62
+ bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
63
+ bgCyanBright: f("\x1b[106m", "\x1b[49m"),
64
+ bgWhiteBright: f("\x1b[107m", "\x1b[49m")
65
+ };
66
+ };
67
+ module.exports = createColors();
68
+ module.exports.createColors = createColors;
69
+ }
70
+ });
71
+ const picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
72
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
73
+ const isDebug = ()=>{
74
+ if (!process.env['DEBUG']) return false;
75
+ const values = process.env['DEBUG'].toLocaleLowerCase().split(',');
76
+ return [
77
+ 'rsbuild',
78
+ 'rspeedy',
79
+ '*'
80
+ ].some((key)=>values.includes(key));
81
+ };
82
+ const label = picocolors_default().bgCyan('lynx');
83
+ const debug = (message)=>{
84
+ if (isDebug()) {
85
+ const result = 'string' == typeof message ? message : message();
86
+ logger.level = 'verbose';
87
+ logger.debug(`${label} ${result}`);
88
+ }
89
+ };
90
+ const debugList = (prefix, messages)=>debug(()=>`${prefix} ${[
91
+ ''
92
+ ].concat(messages).join('\n - ')}`);
93
+ export { createRsbuild, debug, debugList, isDebug, logger, mergeRsbuildConfig, rspack, version };
@@ -0,0 +1,381 @@
1
+ import { __webpack_require__ } from "./rslib-runtime.js";
2
+ import node_path, { dirname, extname, isAbsolute, join } from "node:path";
3
+ import { createRsbuild, logger, mergeRsbuildConfig, rspack, version } from "@rsbuild/core";
4
+ import node_fs from "node:fs";
5
+ import { pathToFileURL } from "node:url";
6
+ import { register } from "#register";
7
+ __webpack_require__.add({
8
+ "../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js" (module) {
9
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
10
+ let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || "win32" === p.platform || (p.stdout || {}).isTTY && "dumb" !== env.TERM || !!env.CI);
11
+ let formatter = (open, close, replace = open)=>(input)=>{
12
+ let string = "" + input, index = string.indexOf(close, open.length);
13
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
14
+ };
15
+ let replaceClose = (string, close, replace, index)=>{
16
+ let result = "", cursor = 0;
17
+ do {
18
+ result += string.substring(cursor, index) + replace;
19
+ cursor = index + close.length;
20
+ index = string.indexOf(close, cursor);
21
+ }while (~index);
22
+ return result + string.substring(cursor);
23
+ };
24
+ let createColors = (enabled = isColorSupported)=>{
25
+ let f = enabled ? formatter : ()=>String;
26
+ return {
27
+ isColorSupported: enabled,
28
+ reset: f("\x1b[0m", "\x1b[0m"),
29
+ bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
30
+ dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
31
+ italic: f("\x1b[3m", "\x1b[23m"),
32
+ underline: f("\x1b[4m", "\x1b[24m"),
33
+ inverse: f("\x1b[7m", "\x1b[27m"),
34
+ hidden: f("\x1b[8m", "\x1b[28m"),
35
+ strikethrough: f("\x1b[9m", "\x1b[29m"),
36
+ black: f("\x1b[30m", "\x1b[39m"),
37
+ red: f("\x1b[31m", "\x1b[39m"),
38
+ green: f("\x1b[32m", "\x1b[39m"),
39
+ yellow: f("\x1b[33m", "\x1b[39m"),
40
+ blue: f("\x1b[34m", "\x1b[39m"),
41
+ magenta: f("\x1b[35m", "\x1b[39m"),
42
+ cyan: f("\x1b[36m", "\x1b[39m"),
43
+ white: f("\x1b[37m", "\x1b[39m"),
44
+ gray: f("\x1b[90m", "\x1b[39m"),
45
+ bgBlack: f("\x1b[40m", "\x1b[49m"),
46
+ bgRed: f("\x1b[41m", "\x1b[49m"),
47
+ bgGreen: f("\x1b[42m", "\x1b[49m"),
48
+ bgYellow: f("\x1b[43m", "\x1b[49m"),
49
+ bgBlue: f("\x1b[44m", "\x1b[49m"),
50
+ bgMagenta: f("\x1b[45m", "\x1b[49m"),
51
+ bgCyan: f("\x1b[46m", "\x1b[49m"),
52
+ bgWhite: f("\x1b[47m", "\x1b[49m"),
53
+ blackBright: f("\x1b[90m", "\x1b[39m"),
54
+ redBright: f("\x1b[91m", "\x1b[39m"),
55
+ greenBright: f("\x1b[92m", "\x1b[39m"),
56
+ yellowBright: f("\x1b[93m", "\x1b[39m"),
57
+ blueBright: f("\x1b[94m", "\x1b[39m"),
58
+ magentaBright: f("\x1b[95m", "\x1b[39m"),
59
+ cyanBright: f("\x1b[96m", "\x1b[39m"),
60
+ whiteBright: f("\x1b[97m", "\x1b[39m"),
61
+ bgBlackBright: f("\x1b[100m", "\x1b[49m"),
62
+ bgRedBright: f("\x1b[101m", "\x1b[49m"),
63
+ bgGreenBright: f("\x1b[102m", "\x1b[49m"),
64
+ bgYellowBright: f("\x1b[103m", "\x1b[49m"),
65
+ bgBlueBright: f("\x1b[104m", "\x1b[49m"),
66
+ bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
67
+ bgCyanBright: f("\x1b[106m", "\x1b[49m"),
68
+ bgWhiteBright: f("\x1b[107m", "\x1b[49m")
69
+ };
70
+ };
71
+ module.exports = createColors();
72
+ module.exports.createColors = createColors;
73
+ }
74
+ });
75
+ const picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
76
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
77
+ const isDebug = ()=>{
78
+ if (!process.env['DEBUG']) return false;
79
+ const values = process.env['DEBUG'].toLocaleLowerCase().split(',');
80
+ return [
81
+ 'rsbuild',
82
+ 'rspeedy',
83
+ '*'
84
+ ].some((key)=>values.includes(key));
85
+ };
86
+ const label = picocolors_default().bgCyan('lynx');
87
+ const debug = (message)=>{
88
+ if (isDebug()) {
89
+ const result = 'string' == typeof message ? message : message();
90
+ logger.level = 'verbose';
91
+ logger.debug(`${label} ${result}`);
92
+ }
93
+ };
94
+ const debugList = (prefix, messages)=>debug(()=>`${prefix} ${[
95
+ ''
96
+ ].concat(messages).join('\n - ')}`);
97
+ function applyDefaultRspeedyConfig(config) {
98
+ const enableChunkSplitting = config.performance?.chunkSplit?.strategy && config.performance?.chunkSplit?.strategy !== 'all-in-one';
99
+ return mergeRsbuildConfig({
100
+ mode: (()=>{
101
+ if (config.mode) return config.mode;
102
+ const nodeEnv = process.env['NODE_ENV'];
103
+ return 'production' === nodeEnv || 'development' === nodeEnv ? nodeEnv : 'none';
104
+ })(),
105
+ output: {
106
+ filename: getFilename(config.output?.filename),
107
+ inlineScripts: !enableChunkSplitting,
108
+ cssModules: {
109
+ localIdentName: '[local]-[hash:base64:6]'
110
+ }
111
+ },
112
+ performance: {
113
+ profile: isDebug() ? true : void 0
114
+ },
115
+ tools: {
116
+ rsdoctor: {
117
+ experiments: {
118
+ enableNativePlugin: true
119
+ }
120
+ }
121
+ }
122
+ }, config);
123
+ }
124
+ const DEFAULT_FILENAME = '[name].[platform].bundle';
125
+ function getFilename(filename) {
126
+ if ('string' == typeof filename) return {
127
+ bundle: filename,
128
+ template: filename
129
+ };
130
+ const finalFilename = filename?.bundle ?? filename?.template ?? DEFAULT_FILENAME;
131
+ return {
132
+ bundle: finalFilename,
133
+ template: finalFilename
134
+ };
135
+ }
136
+ const DEFAULT_ENTRY = './src/index.js';
137
+ function toRsbuildEntry(entry) {
138
+ if (void 0 === entry) {
139
+ debug(`Using default entry ${DEFAULT_ENTRY}`);
140
+ return {
141
+ main: DEFAULT_ENTRY
142
+ };
143
+ }
144
+ if (Array.isArray(entry) || 'string' == typeof entry) {
145
+ debug(()=>`Using single entry ${[
146
+ ''
147
+ ].concat(entry).join('\n - ')}`);
148
+ return {
149
+ main: entry
150
+ };
151
+ }
152
+ return Object.fromEntries(Object.entries(entry).map(([key, value])=>{
153
+ if (Array.isArray(value) || 'string' == typeof value) {
154
+ debugList(`Using multiple entries - ${key}`, value);
155
+ return [
156
+ key,
157
+ {
158
+ import: value
159
+ }
160
+ ];
161
+ }
162
+ debugList(`Using multiple entries - ${key}`, value.import ?? DEFAULT_ENTRY);
163
+ if (void 0 === value.import) return [
164
+ key,
165
+ {
166
+ ...value,
167
+ import: DEFAULT_ENTRY
168
+ }
169
+ ];
170
+ return [
171
+ key,
172
+ value
173
+ ];
174
+ }));
175
+ }
176
+ const defaultDataUriLimit = 2048;
177
+ function toRsbuildConfig(config) {
178
+ return {
179
+ dev: {
180
+ hmr: config.dev?.hmr ?? true,
181
+ lazyCompilation: false,
182
+ liveReload: config.dev?.liveReload ?? true,
183
+ watchFiles: config.dev?.watchFiles,
184
+ writeToDisk: config.dev?.writeToDisk ?? true,
185
+ progressBar: config.dev?.progressBar ?? true
186
+ },
187
+ environments: config.environments ?? {
188
+ lynx: {}
189
+ },
190
+ mode: config.mode,
191
+ output: {
192
+ assetPrefix: config.output?.assetPrefix,
193
+ charset: 'utf8',
194
+ cleanDistPath: config.output?.cleanDistPath,
195
+ copy: config.output?.copy,
196
+ cssModules: config.output?.cssModules,
197
+ dataUriLimit: config.output?.dataUriLimit ?? defaultDataUriLimit,
198
+ distPath: config.output?.distPath,
199
+ filenameHash: config.output?.filenameHash,
200
+ inlineScripts: config.output?.inlineScripts,
201
+ legalComments: config.output?.legalComments ?? 'none',
202
+ polyfill: 'off',
203
+ sourceMap: config.output?.sourceMap
204
+ },
205
+ resolve: {
206
+ alias: config.resolve?.alias,
207
+ aliasStrategy: config.resolve?.aliasStrategy,
208
+ dedupe: config.resolve?.dedupe,
209
+ extensions: config.resolve?.extensions
210
+ },
211
+ source: {
212
+ alias: config.source?.alias,
213
+ assetsInclude: config.source?.assetsInclude,
214
+ decorators: config.source?.decorators,
215
+ define: config.source?.define,
216
+ entry: toRsbuildEntry(config.source?.entry),
217
+ exclude: config.source?.exclude,
218
+ include: config.source?.include,
219
+ preEntry: config.source?.preEntry,
220
+ transformImport: config.source?.transformImport,
221
+ tsconfigPath: config.source?.tsconfigPath
222
+ },
223
+ server: {
224
+ base: config.server?.base,
225
+ compress: config.server?.compress,
226
+ cors: config.server?.cors,
227
+ headers: config.server?.headers,
228
+ host: config.server?.host,
229
+ port: config.server?.port,
230
+ proxy: config.server?.proxy,
231
+ strictPort: config.server?.strictPort
232
+ },
233
+ plugins: config.plugins,
234
+ performance: {
235
+ buildCache: config.performance?.buildCache,
236
+ chunkSplit: config.performance?.chunkSplit,
237
+ profile: config.performance?.profile,
238
+ removeConsole: toRsbuildRemoveConsole(config),
239
+ printFileSize: config.performance?.printFileSize ?? true
240
+ },
241
+ tools: {
242
+ bundlerChain: config.tools?.bundlerChain,
243
+ cssExtract: config.tools?.cssExtract,
244
+ cssLoader: config.tools?.cssLoader,
245
+ htmlPlugin: false,
246
+ rspack: config.tools?.rspack,
247
+ swc: config.tools?.swc
248
+ }
249
+ };
250
+ }
251
+ function toRsbuildRemoveConsole(config) {
252
+ if (config.performance?.removeConsole === true) return [
253
+ 'log',
254
+ 'warn',
255
+ 'error',
256
+ 'info',
257
+ 'debug',
258
+ 'profile',
259
+ 'profileEnd'
260
+ ];
261
+ return config.performance?.removeConsole;
262
+ }
263
+ async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [], callerName = 'rspeedy' }) {
264
+ const config = applyDefaultRspeedyConfig(rspeedyConfig);
265
+ const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
266
+ createRsbuild({
267
+ cwd,
268
+ loadEnv,
269
+ rsbuildConfig: toRsbuildConfig(config),
270
+ environment,
271
+ callerName
272
+ }),
273
+ import("./0~src_plugins_index_ts.js").then((mod)=>({
274
+ applyDefaultPlugins: mod.applyDefaultPlugins
275
+ }))
276
+ ]);
277
+ await applyDefaultPlugins(rspeedy, config);
278
+ const inspectConfig = rspeedy.inspectConfig.bind(rspeedy);
279
+ return Object.assign(rspeedy, {
280
+ getRspeedyConfig: ()=>config,
281
+ async inspectConfig (options) {
282
+ const result = await inspectConfig(options);
283
+ const { inspectRspeedyConfig } = await import("./0~src_plugins_inspect_plugin_ts.js").then((mod)=>({
284
+ inspectRspeedyConfig: mod.inspectRspeedyConfig
285
+ }));
286
+ await inspectRspeedyConfig(rspeedyConfig, node_path.resolve(options.outputPath ?? rspeedy.context.distPath, '.rsbuild/rspeedy.config.js'), options.verbose ?? false);
287
+ return result;
288
+ }
289
+ });
290
+ }
291
+ function mergeRspeedyConfig(...configs) {
292
+ return mergeRsbuildConfig(...configs);
293
+ }
294
+ function defineConfig(config) {
295
+ return config;
296
+ }
297
+ const resolveConfigPath = (root, customConfig)=>{
298
+ if (customConfig) {
299
+ debug(`load custom config file ${customConfig} from ${root}`);
300
+ const customConfigPath = isAbsolute(customConfig) ? customConfig : join(root, customConfig);
301
+ if (node_fs.existsSync(customConfigPath)) return customConfigPath;
302
+ throw new Error(`Cannot find config file: ${picocolors_default().dim(customConfigPath)}`);
303
+ }
304
+ const CONFIG_FILES = [
305
+ 'lynx.config.ts',
306
+ 'lynx.config.js',
307
+ 'lynx.config.mts',
308
+ 'lynx.config.mjs'
309
+ ];
310
+ for (const file of CONFIG_FILES){
311
+ debug(`load default config file ${file} from ${root}`);
312
+ const configFile = join(root, file);
313
+ if (node_fs.existsSync(configFile)) {
314
+ debug(`default config ${configFile} found`);
315
+ return configFile;
316
+ }
317
+ }
318
+ throw new Error([
319
+ `Cannot find the default config file: ${picocolors_default().dim(join(root, CONFIG_FILES[0]))}.`,
320
+ `Use custom config with ${picocolors_default().green('`--config <config>`')} options.`
321
+ ].join(' '));
322
+ };
323
+ async function loadConfig(loadConfigOptions) {
324
+ let { configPath } = loadConfigOptions;
325
+ if (!configPath || !isAbsolute(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
326
+ const specifier = pathToFileURL(configPath).toString();
327
+ let unregister;
328
+ unregister = shouldUseNativeImport(configPath) ? ()=>{} : register({
329
+ load: !hasNativeTSSupport(),
330
+ resolve: true
331
+ });
332
+ try {
333
+ const [exports, { validate }] = await Promise.all([
334
+ import(`${specifier}?t=${Date.now()}`),
335
+ import("./0~src_config_validate_ts.js").then((mod)=>({
336
+ validate: mod.validate,
337
+ validateConfig: mod.validateConfig
338
+ }))
339
+ ]);
340
+ const configExport = 'default' in exports ? exports.default : exports;
341
+ const rawContent = 'function' == typeof configExport ? await configExport({
342
+ command: process.argv[2] ?? 'build',
343
+ env: process.env['NODE_ENV'] ?? 'production'
344
+ }) : await configExport;
345
+ return {
346
+ configPath,
347
+ content: validate(rawContent, configPath)
348
+ };
349
+ } finally{
350
+ unregister();
351
+ }
352
+ }
353
+ function shouldUseNativeImport(configPath) {
354
+ return isJavaScriptPath(configPath) || isDeno();
355
+ }
356
+ function hasNativeTSSupport() {
357
+ if (isDeno()) return true;
358
+ if (process.features.typescript) return true;
359
+ if (false === process.features.typescript) return false;
360
+ const { NODE_OPTIONS } = process.env;
361
+ if (!NODE_OPTIONS) return false;
362
+ return NODE_OPTIONS.includes('--experimental-transform-types') || NODE_OPTIONS.includes('--experimental-strip-types');
363
+ }
364
+ function isJavaScriptPath(configPath) {
365
+ const ext = extname(configPath);
366
+ return [
367
+ '.js',
368
+ '.mjs',
369
+ '.cjs'
370
+ ].includes(ext);
371
+ }
372
+ function isDeno() {
373
+ if ("u" > typeof Deno || process.versions?.deno) return true;
374
+ return false;
375
+ }
376
+ var package_namespaceObject = {
377
+ rE: "0.12.5"
378
+ };
379
+ const version_version = package_namespaceObject.rE;
380
+ const rspackVersion = rspack.rspackVersion;
381
+ export { createRspeedy, debug, defineConfig, dirname, isDebug, loadConfig, logger, mergeRsbuildConfig, mergeRspeedyConfig, node_path, rspack, rspackVersion, version as rsbuildVersion, version_version as version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/rspeedy-canary",
3
- "version": "0.13.0-canary-20260105-ec1caf1a",
3
+ "version": "0.13.0-canary-20260105-03ea61ec",
4
4
  "description": "A webpack/rspack-based frontend toolchain for Lynx",
5
5
  "keywords": [
6
6
  "webpack",