@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,74 +1,56 @@
1
- import * as __rspack_external_node_path_c5b9b54f from "node:path";
2
- export const __rspack_esm_id = "src_cli_commands_ts";
3
- export const __rspack_esm_ids = [
4
- "src_cli_commands_ts"
5
- ];
6
- export const __webpack_modules__ = {
7
- "./src/cli/commands.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
8
- __webpack_require__.r(__webpack_exports__);
9
- __webpack_require__.d(__webpack_exports__, {
10
- apply: ()=>apply
11
- });
12
- var node_path__rspack_import_0 = __webpack_require__("node:path");
13
- var _version_js__rspack_import_1 = __webpack_require__("./src/version.ts");
14
- function applyCommonOptions(command) {
15
- command.option('-c --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--env-mode <mode>', 'specify the env mode to load the .env.[mode] file').option('--no-env', 'disable loading `.env` files"').option('-m --mode <mode>', 'specify the build mode, can be `development`, `production` or `none`').option('-r --root <root>', 'set the project root directory (absolute path or relative to cwd)');
16
- }
17
- function resolveRoot(cwd, root) {
18
- if (!root) return cwd;
19
- return node_path__rspack_import_0["default"].isAbsolute(root) ? root : node_path__rspack_import_0["default"].resolve(cwd, root);
20
- }
21
- function apply(program) {
22
- const cwd = process.cwd();
23
- program.name('rspeedy').usage('<command> [options]').version(_version_js__rspack_import_1.version).option('--unmanaged', 'Force to use the unmanaged version of Rspeedy, instead of the locally installed.').showHelpAfterError(true).showSuggestionAfterError(true).exitOverride();
24
- const buildCommand = program.command('build');
25
- buildCommand.description('Build the project in production mode').option('--environment <name...>', 'specify the name of environment to build').option('--watch', 'Enable watch mode to automatically rebuild on file changes').action(async (buildOptions)=>{
26
- const actualRoot = resolveRoot(cwd, buildOptions.root);
27
- const { build } = await __webpack_require__.e("src_cli_build_ts").then(__webpack_require__.bind(__webpack_require__, "./src/cli/build.ts"));
28
- return await build.call(buildCommand, actualRoot, buildOptions);
29
- });
30
- const devCommand = program.command('dev');
31
- devCommand.description('Run the dev server and watch for source file changes while serving.').option('--base <base>', 'specify the base path of the server').option('--environment <name...>', 'specify the name of environment to build').action(async (devOptions)=>{
32
- const actualRoot = resolveRoot(cwd, devOptions.root);
33
- const { dev } = await __webpack_require__.e("src_cli_dev_ts").then(__webpack_require__.bind(__webpack_require__, "./src/cli/dev.ts"));
34
- return await dev.call(devCommand, actualRoot, devOptions);
35
- });
36
- const inspectCommand = program.command('inspect');
37
- inspectCommand.description('View the Rsbuild config and Rspack config of the project.').option('--output <output>', 'specify inspect content output path').option('--verbose', 'show full function definitions in output').action(async (inspectOptions)=>{
38
- const actualRoot = resolveRoot(cwd, inspectOptions.root);
39
- const { inspect } = await __webpack_require__.e("src_cli_inspect_ts").then(__webpack_require__.bind(__webpack_require__, "./src/cli/inspect.ts"));
40
- return await inspect.call(inspectCommand, actualRoot, inspectOptions);
41
- });
42
- const previewCommand = program.command('preview');
43
- previewCommand.description('Preview the production build outputs locally.').option('--base <base>', 'specify the base path of the server').action(async (previewOptions)=>{
44
- const actualRoot = resolveRoot(cwd, previewOptions.root);
45
- const { preview } = await __webpack_require__.e("src_cli_preview_ts").then(__webpack_require__.bind(__webpack_require__, "./src/cli/preview.ts"));
46
- return await preview.call(previewCommand, actualRoot, previewOptions);
47
- });
48
- const commonCommands = [
49
- devCommand,
50
- buildCommand,
51
- inspectCommand,
52
- previewCommand
53
- ];
54
- commonCommands.forEach((command)=>applyCommonOptions(command));
55
- return program;
56
- }
57
- },
58
- "./src/version.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
59
- __webpack_require__.d(__webpack_exports__, {
60
- version: ()=>version,
61
- rspackVersion: ()=>rspackVersion,
62
- rsbuildVersion: ()=>core_.version
63
- });
64
- var core_ = __webpack_require__("@rsbuild/core");
65
- var package_namespaceObject = {
66
- rE: "0.12.5"
67
- };
68
- const version = package_namespaceObject.rE;
69
- const rspackVersion = core_.rspack.rspackVersion;
70
- },
71
- "node:path" (module) {
72
- module.exports = __rspack_external_node_path_c5b9b54f;
73
- }
74
- };
1
+ import { __webpack_require__ } from "./rslib-runtime.js";
2
+ import "./node_path.js";
3
+ import { version } from "./1~src_version_ts.js";
4
+ const external_node_path_ = __webpack_require__("node:path");
5
+ function applyCommonOptions(command) {
6
+ command.option('-c --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--env-mode <mode>', 'specify the env mode to load the .env.[mode] file').option('--no-env', 'disable loading `.env` files"').option('-m --mode <mode>', 'specify the build mode, can be `development`, `production` or `none`').option('-r --root <root>', 'set the project root directory (absolute path or relative to cwd)');
7
+ }
8
+ function resolveRoot(cwd, root) {
9
+ if (!root) return cwd;
10
+ return external_node_path_["default"].isAbsolute(root) ? root : external_node_path_["default"].resolve(cwd, root);
11
+ }
12
+ function apply(program) {
13
+ const cwd = process.cwd();
14
+ program.name('rspeedy').usage('<command> [options]').version(version).option('--unmanaged', 'Force to use the unmanaged version of Rspeedy, instead of the locally installed.').showHelpAfterError(true).showSuggestionAfterError(true).exitOverride();
15
+ const buildCommand = program.command('build');
16
+ buildCommand.description('Build the project in production mode').option('--environment <name...>', 'specify the name of environment to build').option('--watch', 'Enable watch mode to automatically rebuild on file changes').action(async (buildOptions)=>{
17
+ const actualRoot = resolveRoot(cwd, buildOptions.root);
18
+ const { build } = await import("./1~src_cli_build_ts.js").then((mod)=>({
19
+ build: mod.build
20
+ }));
21
+ return await build.call(buildCommand, actualRoot, buildOptions);
22
+ });
23
+ const devCommand = program.command('dev');
24
+ devCommand.description('Run the dev server and watch for source file changes while serving.').option('--base <base>', 'specify the base path of the server').option('--environment <name...>', 'specify the name of environment to build').action(async (devOptions)=>{
25
+ const actualRoot = resolveRoot(cwd, devOptions.root);
26
+ const { dev } = await import("./1~src_cli_dev_ts.js").then((mod)=>({
27
+ dev: mod.dev
28
+ }));
29
+ return await dev.call(devCommand, actualRoot, devOptions);
30
+ });
31
+ const inspectCommand = program.command('inspect');
32
+ inspectCommand.description('View the Rsbuild config and Rspack config of the project.').option('--output <output>', 'specify inspect content output path').option('--verbose', 'show full function definitions in output').action(async (inspectOptions)=>{
33
+ const actualRoot = resolveRoot(cwd, inspectOptions.root);
34
+ const { inspect } = await import("./1~src_cli_inspect_ts.js").then((mod)=>({
35
+ inspect: mod.inspect
36
+ }));
37
+ return await inspect.call(inspectCommand, actualRoot, inspectOptions);
38
+ });
39
+ const previewCommand = program.command('preview');
40
+ previewCommand.description('Preview the production build outputs locally.').option('--base <base>', 'specify the base path of the server').action(async (previewOptions)=>{
41
+ const actualRoot = resolveRoot(cwd, previewOptions.root);
42
+ const { preview } = await import("./1~src_cli_preview_ts.js").then((mod)=>({
43
+ preview: mod.preview
44
+ }));
45
+ return await preview.call(previewCommand, actualRoot, previewOptions);
46
+ });
47
+ const commonCommands = [
48
+ devCommand,
49
+ buildCommand,
50
+ inspectCommand,
51
+ previewCommand
52
+ ];
53
+ commonCommands.forEach((command)=>applyCommonOptions(command));
54
+ return program;
55
+ }
56
+ export { apply };
@@ -1,412 +1,31 @@
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_dev_ts";
5
- export const __rspack_esm_ids = [
6
- "src_cli_dev_ts"
7
- ];
8
- export const __webpack_modules__ = {
9
- "./src/cli/dev.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
10
- __webpack_require__.d(__webpack_exports__, {
11
- dev: ()=>dev
1
+ import { __webpack_require__ } from "./rslib-runtime.js";
2
+ import "./node_path.js";
3
+ import { logger } from "./src_debug_ts.js";
4
+ import { createRspeedy, init } from "./1~src_cli_init_ts-src_create-rspeedy_ts.js";
5
+ import { exit_exit } from "./src_cli_main_ts.js";
6
+ import { watchFiles, getWatchedFiles } from "./1~src_cli_watch_ts.js";
7
+ const external_node_path_ = __webpack_require__("node:path");
8
+ const picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
9
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
10
+ async function dev(cwd, devOptions) {
11
+ let onBeforeRestart = [];
12
+ try {
13
+ const { rspeedyConfig, configPath, createRspeedyOptions } = await init(cwd, devOptions);
14
+ const watchedFiles = getWatchedFiles(configPath, rspeedyConfig);
15
+ await watchFiles(watchedFiles.map((filePath)=>external_node_path_["default"].isAbsolute(filePath) ? filePath : external_node_path_["default"].join(cwd, filePath)), async (filename)=>{
16
+ logger.info(`Restart because ${picocolors_default().yellow(filename)} is changed.\n`);
17
+ const cleanup = onBeforeRestart.map((f)=>f());
18
+ onBeforeRestart = [];
19
+ await Promise.all(cleanup);
20
+ await dev.call(this, cwd, devOptions);
12
21
  });
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_6 = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
16
- var picocolors__rspack_import_6_default = /*#__PURE__*/ __webpack_require__.n(picocolors__rspack_import_6);
17
- var _create_rspeedy_js__rspack_import_2 = __webpack_require__("./src/create-rspeedy.ts");
18
- var _exit_js__rspack_import_3 = __webpack_require__("./src/cli/exit.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
- async function dev(cwd, devOptions) {
22
- let onBeforeRestart = [];
23
- try {
24
- const { rspeedyConfig, configPath, createRspeedyOptions } = await (0, _init_js__rspack_import_4.T)(cwd, devOptions);
25
- const watchedFiles = (0, _watch_js__rspack_import_5.G)(configPath, rspeedyConfig);
26
- 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)=>{
27
- _rsbuild_core__rspack_import_1.logger.info(`Restart because ${picocolors__rspack_import_6_default().yellow(filename)} is changed.\n`);
28
- const cleanup = onBeforeRestart.map((f)=>f());
29
- onBeforeRestart = [];
30
- await Promise.all(cleanup);
31
- await dev.call(this, cwd, devOptions);
32
- });
33
- const rspeedy = await (0, _create_rspeedy_js__rspack_import_2.x)(createRspeedyOptions);
34
- const server = await rspeedy.createDevServer();
35
- const { server: { close } } = await server.listen();
36
- onBeforeRestart.push(close);
37
- } catch (error) {
38
- _rsbuild_core__rspack_import_1.logger.error(error);
39
- (0, _exit_js__rspack_import_3.exit)(1);
40
- }
41
- }
42
- },
43
- "./src/cli/init.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
44
- __webpack_require__.d(__webpack_exports__, {
45
- T: ()=>init
46
- });
47
- var external_node_fs_ = __webpack_require__("node:fs");
48
- var external_node_path_ = __webpack_require__("node:path");
49
- var picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
50
- var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
51
- var debug = __webpack_require__("./src/debug.ts");
52
- const resolveConfigPath = (root, customConfig)=>{
53
- if (customConfig) {
54
- (0, debug.Yz)(`load custom config file ${customConfig} from ${root}`);
55
- const customConfigPath = (0, external_node_path_.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_.join)(root, customConfig);
56
- if (external_node_fs_["default"].existsSync(customConfigPath)) return customConfigPath;
57
- throw new Error(`Cannot find config file: ${picocolors_default().dim(customConfigPath)}`);
58
- }
59
- const CONFIG_FILES = [
60
- 'lynx.config.ts',
61
- 'lynx.config.js',
62
- 'lynx.config.mts',
63
- 'lynx.config.mjs'
64
- ];
65
- for (const file of CONFIG_FILES){
66
- (0, debug.Yz)(`load default config file ${file} from ${root}`);
67
- const configFile = (0, external_node_path_.join)(root, file);
68
- if (external_node_fs_["default"].existsSync(configFile)) {
69
- (0, debug.Yz)(`default config ${configFile} found`);
70
- return configFile;
71
- }
72
- }
73
- throw new Error([
74
- `Cannot find the default config file: ${picocolors_default().dim((0, external_node_path_.join)(root, CONFIG_FILES[0]))}.`,
75
- `Use custom config with ${picocolors_default().green('`--config <config>`')} options.`
76
- ].join(' '));
77
- };
78
- async function loadConfig(loadConfigOptions) {
79
- let { configPath } = loadConfigOptions;
80
- if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
81
- const specifier = pathToFileURL(configPath).toString();
82
- let unregister;
83
- unregister = shouldUseNativeImport(configPath) ? ()=>{} : register({
84
- load: !hasNativeTSSupport(),
85
- resolve: true
86
- });
87
- try {
88
- const [exports, { validate }] = await Promise.all([
89
- import(`${specifier}?t=${Date.now()}`),
90
- __webpack_require__.e("src_config_validate_ts").then(__webpack_require__.bind(__webpack_require__, "./src/config/validate.ts"))
91
- ]);
92
- const configExport = 'default' in exports ? exports.default : exports;
93
- const rawContent = 'function' == typeof configExport ? await configExport({
94
- command: process.argv[2] ?? 'build',
95
- env: process.env['NODE_ENV'] ?? 'production'
96
- }) : await configExport;
97
- return {
98
- configPath,
99
- content: validate(rawContent, configPath)
100
- };
101
- } finally{
102
- unregister();
103
- }
104
- }
105
- function shouldUseNativeImport(configPath) {
106
- return isJavaScriptPath(configPath) || isDeno();
107
- }
108
- function hasNativeTSSupport() {
109
- if (isDeno()) return true;
110
- if (process.features.typescript) return true;
111
- if (false === process.features.typescript) return false;
112
- const { NODE_OPTIONS } = process.env;
113
- if (!NODE_OPTIONS) return false;
114
- return NODE_OPTIONS.includes('--experimental-transform-types') || NODE_OPTIONS.includes('--experimental-strip-types');
115
- }
116
- function isJavaScriptPath(configPath) {
117
- const ext = (0, external_node_path_.extname)(configPath);
118
- return [
119
- '.js',
120
- '.mjs',
121
- '.cjs'
122
- ].includes(ext);
123
- }
124
- function isDeno() {
125
- if ("u" > typeof Deno || process.versions?.deno) return true;
126
- return false;
127
- }
128
- async function init(cwd, options) {
129
- const { content: rspeedyConfig, configPath } = await loadConfig({
130
- cwd,
131
- configPath: options.config
132
- });
133
- if (rspeedyConfig.performance?.buildCache) if (true === rspeedyConfig.performance.buildCache) rspeedyConfig.performance.buildCache = {
134
- buildDependencies: [
135
- configPath
136
- ]
137
- };
138
- else {
139
- rspeedyConfig.performance.buildCache.buildDependencies ??= [];
140
- rspeedyConfig.performance.buildCache.buildDependencies.push(configPath);
141
- }
142
- const createRspeedyOptions = {
143
- cwd,
144
- rspeedyConfig
145
- };
146
- if (options.noEnv) createRspeedyOptions.loadEnv = false;
147
- else if (options.envMode) createRspeedyOptions.loadEnv = {
148
- mode: options.envMode
149
- };
150
- if ('base' in options && options.base) {
151
- rspeedyConfig.server ??= {};
152
- rspeedyConfig.server.base = options.base;
153
- }
154
- if ('environment' in options && options.environment) createRspeedyOptions.environment = options.environment;
155
- if (options.mode) rspeedyConfig.mode = options.mode;
156
- return {
157
- createRspeedyOptions,
158
- configPath,
159
- rspeedyConfig
160
- };
161
- }
162
- },
163
- "./src/cli/watch.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
164
- __webpack_require__.d(__webpack_exports__, {
165
- G: ()=>getWatchedFiles,
166
- N: ()=>watchFiles
167
- });
168
- async function watchFiles(files, callback) {
169
- const chokidar = await Promise.all([
170
- __webpack_require__.e("vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js"),
171
- __webpack_require__.e("events-fs-fs_promises-os-path-stream")
172
- ]).then(__webpack_require__.bind(__webpack_require__, "../../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js"));
173
- const watcher = chokidar.default.watch(files, {
174
- ignoreInitial: true,
175
- ignorePermissionErrors: true
176
- });
177
- const cb = debounce((event, filePath)=>{
178
- const startTime = Date.now();
179
- watcher.close().then(()=>callback(filePath, startTime, event));
180
- }, 300);
181
- watcher.once('add', cb.bind(null, 'add'));
182
- watcher.once('change', cb.bind(null, 'change'));
183
- watcher.once('unlink', cb.bind(null, 'unlink'));
184
- }
185
- function debounce(func, wait) {
186
- let timeoutId = null;
187
- return (...args)=>{
188
- if (null !== timeoutId) clearTimeout(timeoutId);
189
- timeoutId = setTimeout(()=>{
190
- func(...args);
191
- }, wait);
192
- };
193
- }
194
- function getWatchedFiles(configPath, rspeedyConfig) {
195
- const watchedFiles = [
196
- configPath
197
- ];
198
- if (Array.isArray(rspeedyConfig.dev?.watchFiles)) watchedFiles.push(...rspeedyConfig.dev.watchFiles.filter((item)=>'reload-server' === item.type).flatMap((item)=>item.paths));
199
- else if (rspeedyConfig.dev?.watchFiles?.type === 'reload-server') {
200
- const { paths } = rspeedyConfig.dev.watchFiles;
201
- watchedFiles.push(...Array.isArray(paths) ? paths : [
202
- paths
203
- ]);
204
- }
205
- return watchedFiles;
206
- }
207
- },
208
- "./src/create-rspeedy.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
209
- __webpack_require__.d(__webpack_exports__, {
210
- x: ()=>createRspeedy
211
- });
212
- var external_node_path_ = __webpack_require__("node:path");
213
- var core_ = __webpack_require__("@rsbuild/core");
214
- var debug = __webpack_require__("./src/debug.ts");
215
- function applyDefaultRspeedyConfig(config) {
216
- const enableChunkSplitting = config.performance?.chunkSplit?.strategy && config.performance?.chunkSplit?.strategy !== 'all-in-one';
217
- return (0, core_.mergeRsbuildConfig)({
218
- mode: (()=>{
219
- if (config.mode) return config.mode;
220
- const nodeEnv = process.env['NODE_ENV'];
221
- return 'production' === nodeEnv || 'development' === nodeEnv ? nodeEnv : 'none';
222
- })(),
223
- output: {
224
- filename: getFilename(config.output?.filename),
225
- inlineScripts: !enableChunkSplitting,
226
- cssModules: {
227
- localIdentName: '[local]-[hash:base64:6]'
228
- }
229
- },
230
- performance: {
231
- profile: (0, debug._o)() ? true : void 0
232
- },
233
- tools: {
234
- rsdoctor: {
235
- experiments: {
236
- enableNativePlugin: true
237
- }
238
- }
239
- }
240
- }, config);
241
- }
242
- const DEFAULT_FILENAME = '[name].[platform].bundle';
243
- function getFilename(filename) {
244
- if ('string' == typeof filename) return {
245
- bundle: filename,
246
- template: filename
247
- };
248
- const finalFilename = filename?.bundle ?? filename?.template ?? DEFAULT_FILENAME;
249
- return {
250
- bundle: finalFilename,
251
- template: finalFilename
252
- };
253
- }
254
- const DEFAULT_ENTRY = './src/index.js';
255
- function toRsbuildEntry(entry) {
256
- if (void 0 === entry) {
257
- (0, debug.Yz)(`Using default entry ${DEFAULT_ENTRY}`);
258
- return {
259
- main: DEFAULT_ENTRY
260
- };
261
- }
262
- if (Array.isArray(entry) || 'string' == typeof entry) {
263
- (0, debug.Yz)(()=>`Using single entry ${[
264
- ''
265
- ].concat(entry).join('\n - ')}`);
266
- return {
267
- main: entry
268
- };
269
- }
270
- return Object.fromEntries(Object.entries(entry).map(([key, value])=>{
271
- if (Array.isArray(value) || 'string' == typeof value) {
272
- (0, debug.Iv)(`Using multiple entries - ${key}`, value);
273
- return [
274
- key,
275
- {
276
- import: value
277
- }
278
- ];
279
- }
280
- (0, debug.Iv)(`Using multiple entries - ${key}`, value.import ?? DEFAULT_ENTRY);
281
- if (void 0 === value.import) return [
282
- key,
283
- {
284
- ...value,
285
- import: DEFAULT_ENTRY
286
- }
287
- ];
288
- return [
289
- key,
290
- value
291
- ];
292
- }));
293
- }
294
- const defaultDataUriLimit = 2048;
295
- function toRsbuildConfig(config) {
296
- return {
297
- dev: {
298
- hmr: config.dev?.hmr ?? true,
299
- lazyCompilation: false,
300
- liveReload: config.dev?.liveReload ?? true,
301
- watchFiles: config.dev?.watchFiles,
302
- writeToDisk: config.dev?.writeToDisk ?? true,
303
- progressBar: config.dev?.progressBar ?? true
304
- },
305
- environments: config.environments ?? {
306
- lynx: {}
307
- },
308
- mode: config.mode,
309
- output: {
310
- assetPrefix: config.output?.assetPrefix,
311
- charset: 'utf8',
312
- cleanDistPath: config.output?.cleanDistPath,
313
- copy: config.output?.copy,
314
- cssModules: config.output?.cssModules,
315
- dataUriLimit: config.output?.dataUriLimit ?? defaultDataUriLimit,
316
- distPath: config.output?.distPath,
317
- filenameHash: config.output?.filenameHash,
318
- inlineScripts: config.output?.inlineScripts,
319
- legalComments: config.output?.legalComments ?? 'none',
320
- polyfill: 'off',
321
- sourceMap: config.output?.sourceMap
322
- },
323
- resolve: {
324
- alias: config.resolve?.alias,
325
- aliasStrategy: config.resolve?.aliasStrategy,
326
- dedupe: config.resolve?.dedupe,
327
- extensions: config.resolve?.extensions
328
- },
329
- source: {
330
- alias: config.source?.alias,
331
- assetsInclude: config.source?.assetsInclude,
332
- decorators: config.source?.decorators,
333
- define: config.source?.define,
334
- entry: toRsbuildEntry(config.source?.entry),
335
- exclude: config.source?.exclude,
336
- include: config.source?.include,
337
- preEntry: config.source?.preEntry,
338
- transformImport: config.source?.transformImport,
339
- tsconfigPath: config.source?.tsconfigPath
340
- },
341
- server: {
342
- base: config.server?.base,
343
- compress: config.server?.compress,
344
- cors: config.server?.cors,
345
- headers: config.server?.headers,
346
- host: config.server?.host,
347
- port: config.server?.port,
348
- proxy: config.server?.proxy,
349
- strictPort: config.server?.strictPort
350
- },
351
- plugins: config.plugins,
352
- performance: {
353
- buildCache: config.performance?.buildCache,
354
- chunkSplit: config.performance?.chunkSplit,
355
- profile: config.performance?.profile,
356
- removeConsole: toRsbuildRemoveConsole(config),
357
- printFileSize: config.performance?.printFileSize ?? true
358
- },
359
- tools: {
360
- bundlerChain: config.tools?.bundlerChain,
361
- cssExtract: config.tools?.cssExtract,
362
- cssLoader: config.tools?.cssLoader,
363
- htmlPlugin: false,
364
- rspack: config.tools?.rspack,
365
- swc: config.tools?.swc
366
- }
367
- };
368
- }
369
- function toRsbuildRemoveConsole(config) {
370
- if (config.performance?.removeConsole === true) return [
371
- 'log',
372
- 'warn',
373
- 'error',
374
- 'info',
375
- 'debug',
376
- 'profile',
377
- 'profileEnd'
378
- ];
379
- return config.performance?.removeConsole;
380
- }
381
- async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [], callerName = 'rspeedy' }) {
382
- const config = applyDefaultRspeedyConfig(rspeedyConfig);
383
- const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
384
- (0, core_.createRsbuild)({
385
- cwd,
386
- loadEnv,
387
- rsbuildConfig: toRsbuildConfig(config),
388
- environment,
389
- callerName
390
- }),
391
- __webpack_require__.e("src_plugins_index_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/index.ts"))
392
- ]);
393
- await applyDefaultPlugins(rspeedy, config);
394
- const inspectConfig = rspeedy.inspectConfig.bind(rspeedy);
395
- return Object.assign(rspeedy, {
396
- getRspeedyConfig: ()=>config,
397
- async inspectConfig (options) {
398
- const result = await inspectConfig(options);
399
- const { inspectRspeedyConfig } = await Promise.all([
400
- __webpack_require__.e("vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc"),
401
- __webpack_require__.e("src_plugins_inspect_plugin_ts")
402
- ]).then(__webpack_require__.bind(__webpack_require__, "./src/plugins/inspect.plugin.ts"));
403
- await inspectRspeedyConfig(rspeedyConfig, external_node_path_["default"].resolve(options.outputPath ?? rspeedy.context.distPath, '.rsbuild/rspeedy.config.js'), options.verbose ?? false);
404
- return result;
405
- }
406
- });
407
- }
408
- },
409
- "node:fs" (module) {
410
- module.exports = __rspack_external_node_fs_5ea92f0c;
22
+ const rspeedy = await createRspeedy(createRspeedyOptions);
23
+ const server = await rspeedy.createDevServer();
24
+ const { server: { close } } = await server.listen();
25
+ onBeforeRestart.push(close);
26
+ } catch (error) {
27
+ logger.error(error);
28
+ exit_exit(1);
411
29
  }
412
- };
30
+ }
31
+ export { dev };