@lynx-js/rspeedy-canary 0.10.8 → 0.10.9-canary-20250826-1952fc15
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.
- package/CHANGELOG.md +50 -40
- package/dist/cli/main.js +12 -73
- package/dist/events-fs-fs_promises-os-path-stream.js +30 -0
- package/dist/index.js +19 -39
- package/dist/node_child_process-node_events-node_fs-node_path.js +22 -0
- package/dist/src_cli_build_ts.js +101 -28
- package/dist/src_cli_commands_ts.js +4 -3
- package/dist/src_cli_dev_ts.js +76 -53
- package/dist/src_cli_exit_ts.js +12 -11
- package/dist/src_cli_inspect_ts.js +25 -16
- package/dist/src_cli_preview_ts.js +25 -16
- package/dist/src_config_validate_ts.js +86 -49
- package/dist/src_plugins_api_plugin_ts.js +2 -1
- package/dist/src_plugins_chunkLoading_plugin_ts.js +6 -5
- package/dist/src_plugins_dev_plugin_ts.js +4 -3
- package/dist/src_plugins_emitOnErrors_plugin_ts.js +1 -0
- package/dist/src_plugins_index_ts.js +3 -2
- package/dist/src_plugins_inspect_plugin_ts.js +16 -15
- package/dist/src_plugins_minify_plugin_ts.js +3 -2
- package/dist/src_plugins_optimization_plugin_ts.js +1 -0
- package/dist/src_plugins_output_plugin_ts.js +3 -2
- package/dist/src_plugins_resolve_plugin_ts.js +1 -0
- package/dist/src_plugins_rsdoctor_plugin_ts.js +3 -2
- package/dist/src_plugins_sourcemap_plugin_ts.js +1 -0
- package/dist/src_plugins_swc_plugin_ts.js +3 -2
- package/dist/src_plugins_target_plugin_ts.js +6 -5
- package/dist/src_version_ts.js +3 -2
- package/dist/vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +1 -0
- package/dist/vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js +1 -0
- package/dist/vendors-node_modules_pnpm_ipaddr_js_2_2_0_node_modules_ipaddr_js_lib_ipaddr_js.js +1 -0
- package/dist/vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc.js +1 -0
- package/package.json +2 -2
package/dist/src_cli_build_ts.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { pathToFileURL } from "node:url";
|
|
2
|
+
import { register } from "@lynx-js/rspeedy/register";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
5
|
+
export const __webpack_id__ = "src_cli_build_ts";
|
|
1
6
|
export const __webpack_ids__ = [
|
|
2
7
|
"src_cli_build_ts"
|
|
3
8
|
];
|
|
@@ -7,39 +12,56 @@ export const __webpack_modules__ = {
|
|
|
7
12
|
__webpack_require__.d(__webpack_exports__, {
|
|
8
13
|
build: ()=>build
|
|
9
14
|
});
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
+
var node_path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:path");
|
|
16
|
+
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("@rsbuild/core");
|
|
17
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
18
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_7__);
|
|
19
|
+
var _exit_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/cli/exit.ts");
|
|
20
|
+
var _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/create-rspeedy.ts");
|
|
21
|
+
var _init_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/cli/init.ts");
|
|
22
|
+
var _watch_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./src/cli/watch.ts");
|
|
23
|
+
var _utils_is_ci_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("./src/utils/is-ci.ts");
|
|
15
24
|
async function build(cwd, buildOptions) {
|
|
16
|
-
const shouldExit = 'true' !== process.env['RSDOCTOR'] || (0,
|
|
25
|
+
const shouldExit = 'true' !== process.env['RSDOCTOR'] || (0, _utils_is_ci_js__WEBPACK_IMPORTED_MODULE_6__.J)();
|
|
26
|
+
const isWatch = buildOptions.watch ?? false;
|
|
27
|
+
let onBeforeRestart = [];
|
|
17
28
|
try {
|
|
18
|
-
const { createRspeedyOptions } = await (0,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
const { rspeedyConfig, configPath, createRspeedyOptions } = await (0, _init_js__WEBPACK_IMPORTED_MODULE_4__.T)(cwd, buildOptions);
|
|
30
|
+
if (isWatch) {
|
|
31
|
+
const watchedFiles = (0, _watch_js__WEBPACK_IMPORTED_MODULE_5__.G)(configPath, rspeedyConfig);
|
|
32
|
+
await (0, _watch_js__WEBPACK_IMPORTED_MODULE_5__.N)(watchedFiles.map((filePath)=>node_path__WEBPACK_IMPORTED_MODULE_0__["default"].isAbsolute(filePath) ? filePath : node_path__WEBPACK_IMPORTED_MODULE_0__["default"].join(cwd, filePath)), async (filename)=>{
|
|
33
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_1__.logger.info(`Restart because ${picocolors__WEBPACK_IMPORTED_MODULE_7___default().yellow(filename)} is changed.\n`);
|
|
34
|
+
const cleanup = onBeforeRestart.map((f)=>f());
|
|
35
|
+
onBeforeRestart = [];
|
|
36
|
+
await Promise.all(cleanup);
|
|
37
|
+
await build.call(this, cwd, buildOptions);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_3__.x)(createRspeedyOptions);
|
|
41
|
+
const { close } = await rspeedy.build({
|
|
42
|
+
watch: isWatch
|
|
43
|
+
});
|
|
44
|
+
if (isWatch) onBeforeRestart.push(close);
|
|
45
|
+
else await close();
|
|
22
46
|
} catch (error) {
|
|
23
|
-
|
|
24
|
-
if (shouldExit) return void (0,
|
|
47
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_1__.logger.error(error);
|
|
48
|
+
if (shouldExit) return void (0, _exit_js__WEBPACK_IMPORTED_MODULE_2__.exit)(1);
|
|
25
49
|
}
|
|
26
|
-
if (shouldExit) (0,
|
|
50
|
+
if (shouldExit && !isWatch) (0, _exit_js__WEBPACK_IMPORTED_MODULE_2__.exit)();
|
|
27
51
|
}
|
|
28
52
|
},
|
|
29
53
|
"./src/cli/init.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
30
54
|
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
|
|
55
|
+
T: ()=>init
|
|
32
56
|
});
|
|
33
57
|
var external_node_fs_ = __webpack_require__("node:fs");
|
|
34
58
|
var external_node_path_ = __webpack_require__("node:path");
|
|
35
|
-
var external_node_url_ = __webpack_require__("node:url");
|
|
36
59
|
var picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
37
60
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
38
|
-
var register_ = __webpack_require__("@lynx-js/rspeedy/register");
|
|
39
61
|
var debug = __webpack_require__("./src/debug.ts");
|
|
40
62
|
const resolveConfigPath = (root, customConfig)=>{
|
|
41
63
|
if (customConfig) {
|
|
42
|
-
(0, debug.
|
|
64
|
+
(0, debug.Yz)(`load custom config file ${customConfig} from ${root}`);
|
|
43
65
|
const customConfigPath = (0, external_node_path_.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_.join)(root, customConfig);
|
|
44
66
|
if (external_node_fs_["default"].existsSync(customConfigPath)) return customConfigPath;
|
|
45
67
|
throw new Error(`Cannot find config file: ${picocolors_default().dim(customConfigPath)}`);
|
|
@@ -51,10 +73,10 @@ export const __webpack_modules__ = {
|
|
|
51
73
|
'lynx.config.mjs'
|
|
52
74
|
];
|
|
53
75
|
for (const file of CONFIG_FILES){
|
|
54
|
-
(0, debug.
|
|
76
|
+
(0, debug.Yz)(`load default config file ${file} from ${root}`);
|
|
55
77
|
const configFile = (0, external_node_path_.join)(root, file);
|
|
56
78
|
if (external_node_fs_["default"].existsSync(configFile)) {
|
|
57
|
-
(0, debug.
|
|
79
|
+
(0, debug.Yz)(`default config ${configFile} found`);
|
|
58
80
|
return configFile;
|
|
59
81
|
}
|
|
60
82
|
}
|
|
@@ -66,9 +88,9 @@ export const __webpack_modules__ = {
|
|
|
66
88
|
async function loadConfig(loadConfigOptions) {
|
|
67
89
|
let { configPath } = loadConfigOptions;
|
|
68
90
|
if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
|
|
69
|
-
const specifier =
|
|
91
|
+
const specifier = pathToFileURL(configPath).toString();
|
|
70
92
|
let unregister;
|
|
71
|
-
unregister = shouldUseNativeImport(configPath) ? ()=>{} :
|
|
93
|
+
unregister = shouldUseNativeImport(configPath) ? ()=>{} : register({
|
|
72
94
|
load: !hasNativeTSSupport(),
|
|
73
95
|
resolve: true
|
|
74
96
|
});
|
|
@@ -144,9 +166,54 @@ export const __webpack_modules__ = {
|
|
|
144
166
|
};
|
|
145
167
|
}
|
|
146
168
|
},
|
|
169
|
+
"./src/cli/watch.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
170
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
171
|
+
G: ()=>getWatchedFiles,
|
|
172
|
+
N: ()=>watchFiles
|
|
173
|
+
});
|
|
174
|
+
async function watchFiles(files, callback) {
|
|
175
|
+
const chokidar = await Promise.all([
|
|
176
|
+
__webpack_require__.e("vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js"),
|
|
177
|
+
__webpack_require__.e("events-fs-fs_promises-os-path-stream")
|
|
178
|
+
]).then(__webpack_require__.bind(__webpack_require__, "../../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js"));
|
|
179
|
+
const watcher = chokidar.default.watch(files, {
|
|
180
|
+
ignoreInitial: true,
|
|
181
|
+
ignorePermissionErrors: true
|
|
182
|
+
});
|
|
183
|
+
const cb = debounce((event, filePath)=>{
|
|
184
|
+
const startTime = Date.now();
|
|
185
|
+
watcher.close().then(()=>callback(filePath, startTime, event));
|
|
186
|
+
}, 300);
|
|
187
|
+
watcher.once('add', cb.bind(null, 'add'));
|
|
188
|
+
watcher.once('change', cb.bind(null, 'change'));
|
|
189
|
+
watcher.once('unlink', cb.bind(null, 'unlink'));
|
|
190
|
+
}
|
|
191
|
+
function debounce(func, wait) {
|
|
192
|
+
let timeoutId = null;
|
|
193
|
+
return (...args)=>{
|
|
194
|
+
if (null !== timeoutId) clearTimeout(timeoutId);
|
|
195
|
+
timeoutId = setTimeout(()=>{
|
|
196
|
+
func(...args);
|
|
197
|
+
}, wait);
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function getWatchedFiles(configPath, rspeedyConfig) {
|
|
201
|
+
const watchedFiles = [
|
|
202
|
+
configPath
|
|
203
|
+
];
|
|
204
|
+
if (Array.isArray(rspeedyConfig.dev?.watchFiles)) watchedFiles.push(...rspeedyConfig.dev.watchFiles.filter((item)=>'reload-server' === item.type).flatMap((item)=>item.paths));
|
|
205
|
+
else if (rspeedyConfig.dev?.watchFiles?.type === 'reload-server') {
|
|
206
|
+
const { paths } = rspeedyConfig.dev.watchFiles;
|
|
207
|
+
watchedFiles.push(...Array.isArray(paths) ? paths : [
|
|
208
|
+
paths
|
|
209
|
+
]);
|
|
210
|
+
}
|
|
211
|
+
return watchedFiles;
|
|
212
|
+
}
|
|
213
|
+
},
|
|
147
214
|
"./src/create-rspeedy.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
148
215
|
__webpack_require__.d(__webpack_exports__, {
|
|
149
|
-
|
|
216
|
+
x: ()=>createRspeedy
|
|
150
217
|
});
|
|
151
218
|
var external_node_path_ = __webpack_require__("node:path");
|
|
152
219
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
@@ -164,7 +231,7 @@ export const __webpack_modules__ = {
|
|
|
164
231
|
inlineScripts: !enableChunkSplitting
|
|
165
232
|
},
|
|
166
233
|
performance: {
|
|
167
|
-
profile: (0, debug.
|
|
234
|
+
profile: (0, debug._o)() ? true : void 0
|
|
168
235
|
},
|
|
169
236
|
tools: {
|
|
170
237
|
rsdoctor: {
|
|
@@ -190,13 +257,13 @@ export const __webpack_modules__ = {
|
|
|
190
257
|
const DEFAULT_ENTRY = './src/index.js';
|
|
191
258
|
function toRsbuildEntry(entry) {
|
|
192
259
|
if (void 0 === entry) {
|
|
193
|
-
(0, debug.
|
|
260
|
+
(0, debug.Yz)(`Using default entry ${DEFAULT_ENTRY}`);
|
|
194
261
|
return {
|
|
195
262
|
main: DEFAULT_ENTRY
|
|
196
263
|
};
|
|
197
264
|
}
|
|
198
265
|
if (Array.isArray(entry) || 'string' == typeof entry) {
|
|
199
|
-
(0, debug.
|
|
266
|
+
(0, debug.Yz)(()=>`Using single entry ${[
|
|
200
267
|
''
|
|
201
268
|
].concat(entry).join('\n - ')}`);
|
|
202
269
|
return {
|
|
@@ -205,7 +272,7 @@ export const __webpack_modules__ = {
|
|
|
205
272
|
}
|
|
206
273
|
return Object.fromEntries(Object.entries(entry).map(([key, value])=>{
|
|
207
274
|
if (Array.isArray(value) || 'string' == typeof value) {
|
|
208
|
-
(0, debug.
|
|
275
|
+
(0, debug.Iv)(`Using multiple entries - ${key}`, value);
|
|
209
276
|
return [
|
|
210
277
|
key,
|
|
211
278
|
{
|
|
@@ -213,7 +280,7 @@ export const __webpack_modules__ = {
|
|
|
213
280
|
}
|
|
214
281
|
];
|
|
215
282
|
}
|
|
216
|
-
(0, debug.
|
|
283
|
+
(0, debug.Iv)(`Using multiple entries - ${key}`, value.import ?? DEFAULT_ENTRY);
|
|
217
284
|
if (void 0 === value.import) return [
|
|
218
285
|
key,
|
|
219
286
|
{
|
|
@@ -334,10 +401,16 @@ export const __webpack_modules__ = {
|
|
|
334
401
|
},
|
|
335
402
|
"./src/utils/is-ci.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
336
403
|
__webpack_require__.d(__webpack_exports__, {
|
|
337
|
-
|
|
404
|
+
J: ()=>isCI
|
|
338
405
|
});
|
|
339
406
|
function isCI() {
|
|
340
407
|
return !!process.env['CI'] && 'false' !== process.env['CI'];
|
|
341
408
|
}
|
|
409
|
+
},
|
|
410
|
+
"node:fs": function(module) {
|
|
411
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
|
|
412
|
+
},
|
|
413
|
+
"node:path": function(module) {
|
|
414
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__;
|
|
342
415
|
}
|
|
343
416
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export const __webpack_id__ = "src_cli_commands_ts";
|
|
1
2
|
export const __webpack_ids__ = [
|
|
2
3
|
"src_cli_commands_ts"
|
|
3
4
|
];
|
|
@@ -15,7 +16,7 @@ export const __webpack_modules__ = {
|
|
|
15
16
|
const cwd = process.cwd();
|
|
16
17
|
program.name('rspeedy').usage('<command> [options]').version(_version_js__WEBPACK_IMPORTED_MODULE_0__.version).option('--unmanaged', 'Force to use the unmanaged version of Rspeedy, instead of the locally installed.').showHelpAfterError(true).showSuggestionAfterError(true).exitOverride();
|
|
17
18
|
const buildCommand = program.command('build');
|
|
18
|
-
buildCommand.description('Build the project in production mode').option('--environment <name...>', 'specify the name of environment to build').action((buildOptions)=>__webpack_require__.e("src_cli_build_ts").then(__webpack_require__.bind(__webpack_require__, "./src/cli/build.ts")).then(({ build })=>build.call(buildCommand, cwd, buildOptions)));
|
|
19
|
+
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((buildOptions)=>__webpack_require__.e("src_cli_build_ts").then(__webpack_require__.bind(__webpack_require__, "./src/cli/build.ts")).then(({ build })=>build.call(buildCommand, cwd, buildOptions)));
|
|
19
20
|
const devCommand = program.command('dev');
|
|
20
21
|
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((devOptions)=>__webpack_require__.e("src_cli_dev_ts").then(__webpack_require__.bind(__webpack_require__, "./src/cli/dev.ts")).then(({ dev })=>dev.call(devCommand, cwd, devOptions)));
|
|
21
22
|
const inspectCommand = program.command('inspect');
|
|
@@ -40,9 +41,9 @@ export const __webpack_modules__ = {
|
|
|
40
41
|
});
|
|
41
42
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
42
43
|
var package_namespaceObject = {
|
|
43
|
-
|
|
44
|
+
rE: "0.10.8"
|
|
44
45
|
};
|
|
45
|
-
const version = package_namespaceObject.
|
|
46
|
+
const version = package_namespaceObject.rE;
|
|
46
47
|
const rspackVersion = core_.rspack.rspackVersion;
|
|
47
48
|
}
|
|
48
49
|
};
|
package/dist/src_cli_dev_ts.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { pathToFileURL } from "node:url";
|
|
2
|
+
import { register } from "@lynx-js/rspeedy/register";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
5
|
+
export const __webpack_id__ = "src_cli_dev_ts";
|
|
1
6
|
export const __webpack_ids__ = [
|
|
2
7
|
"src_cli_dev_ts"
|
|
3
8
|
];
|
|
@@ -9,33 +14,25 @@ export const __webpack_modules__ = {
|
|
|
9
14
|
});
|
|
10
15
|
var node_path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:path");
|
|
11
16
|
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("@rsbuild/core");
|
|
12
|
-
var
|
|
13
|
-
var
|
|
17
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
18
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_6__);
|
|
14
19
|
var _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/create-rspeedy.ts");
|
|
15
20
|
var _exit_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/cli/exit.ts");
|
|
16
21
|
var _init_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/cli/init.ts");
|
|
22
|
+
var _watch_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./src/cli/watch.ts");
|
|
17
23
|
async function dev(cwd, devOptions) {
|
|
18
24
|
let onBeforeRestart = [];
|
|
19
25
|
try {
|
|
20
|
-
const { rspeedyConfig, configPath, createRspeedyOptions } = await (0, _init_js__WEBPACK_IMPORTED_MODULE_4__.
|
|
21
|
-
const watchedFiles =
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (Array.isArray(rspeedyConfig.dev?.watchFiles)) watchedFiles.push(...rspeedyConfig.dev.watchFiles.filter((item)=>'reload-server' === item.type).flatMap((item)=>item.paths));
|
|
25
|
-
else if (rspeedyConfig.dev?.watchFiles?.type === 'reload-server') {
|
|
26
|
-
const { paths } = rspeedyConfig.dev.watchFiles;
|
|
27
|
-
watchedFiles.push(...Array.isArray(paths) ? paths : [
|
|
28
|
-
paths
|
|
29
|
-
]);
|
|
30
|
-
}
|
|
31
|
-
await watchFiles(watchedFiles.map((filePath)=>node_path__WEBPACK_IMPORTED_MODULE_0__["default"].isAbsolute(filePath) ? filePath : node_path__WEBPACK_IMPORTED_MODULE_0__["default"].join(cwd, filePath)), async (filename)=>{
|
|
32
|
-
_rsbuild_core__WEBPACK_IMPORTED_MODULE_1__.logger.info(`Restart because ${picocolors__WEBPACK_IMPORTED_MODULE_5___default().yellow(filename)} is changed.\n`);
|
|
26
|
+
const { rspeedyConfig, configPath, createRspeedyOptions } = await (0, _init_js__WEBPACK_IMPORTED_MODULE_4__.T)(cwd, devOptions);
|
|
27
|
+
const watchedFiles = (0, _watch_js__WEBPACK_IMPORTED_MODULE_5__.G)(configPath, rspeedyConfig);
|
|
28
|
+
await (0, _watch_js__WEBPACK_IMPORTED_MODULE_5__.N)(watchedFiles.map((filePath)=>node_path__WEBPACK_IMPORTED_MODULE_0__["default"].isAbsolute(filePath) ? filePath : node_path__WEBPACK_IMPORTED_MODULE_0__["default"].join(cwd, filePath)), async (filename)=>{
|
|
29
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_1__.logger.info(`Restart because ${picocolors__WEBPACK_IMPORTED_MODULE_6___default().yellow(filename)} is changed.\n`);
|
|
33
30
|
const cleanup = onBeforeRestart.map((f)=>f());
|
|
34
31
|
onBeforeRestart = [];
|
|
35
32
|
await Promise.all(cleanup);
|
|
36
33
|
await dev.call(this, cwd, devOptions);
|
|
37
34
|
});
|
|
38
|
-
const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_2__.
|
|
35
|
+
const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_2__.x)(createRspeedyOptions);
|
|
39
36
|
const server = await rspeedy.createDevServer();
|
|
40
37
|
const { server: { close } } = await server.listen();
|
|
41
38
|
onBeforeRestart.push(close);
|
|
@@ -44,44 +41,19 @@ export const __webpack_modules__ = {
|
|
|
44
41
|
(0, _exit_js__WEBPACK_IMPORTED_MODULE_3__.exit)(1);
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
|
-
async function watchFiles(files, callback) {
|
|
48
|
-
const chokidar = await __webpack_require__.e("vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js").then(__webpack_require__.bind(__webpack_require__, "../../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js"));
|
|
49
|
-
const watcher = chokidar.default.watch(files, {
|
|
50
|
-
ignoreInitial: true,
|
|
51
|
-
ignorePermissionErrors: true
|
|
52
|
-
});
|
|
53
|
-
const cb = debounce((event, filePath)=>{
|
|
54
|
-
const startTime = Date.now();
|
|
55
|
-
watcher.close().then(()=>callback(filePath, startTime, event));
|
|
56
|
-
}, 300);
|
|
57
|
-
watcher.once('add', cb.bind(null, 'add'));
|
|
58
|
-
watcher.once('change', cb.bind(null, 'change'));
|
|
59
|
-
watcher.once('unlink', cb.bind(null, 'unlink'));
|
|
60
|
-
}
|
|
61
|
-
function debounce(func, wait) {
|
|
62
|
-
let timeoutId = null;
|
|
63
|
-
return (...args)=>{
|
|
64
|
-
if (null !== timeoutId) clearTimeout(timeoutId);
|
|
65
|
-
timeoutId = setTimeout(()=>{
|
|
66
|
-
func(...args);
|
|
67
|
-
}, wait);
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
44
|
},
|
|
71
45
|
"./src/cli/init.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
72
46
|
__webpack_require__.d(__webpack_exports__, {
|
|
73
|
-
|
|
47
|
+
T: ()=>init
|
|
74
48
|
});
|
|
75
49
|
var external_node_fs_ = __webpack_require__("node:fs");
|
|
76
50
|
var external_node_path_ = __webpack_require__("node:path");
|
|
77
|
-
var external_node_url_ = __webpack_require__("node:url");
|
|
78
51
|
var picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
79
52
|
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
80
|
-
var register_ = __webpack_require__("@lynx-js/rspeedy/register");
|
|
81
53
|
var debug = __webpack_require__("./src/debug.ts");
|
|
82
54
|
const resolveConfigPath = (root, customConfig)=>{
|
|
83
55
|
if (customConfig) {
|
|
84
|
-
(0, debug.
|
|
56
|
+
(0, debug.Yz)(`load custom config file ${customConfig} from ${root}`);
|
|
85
57
|
const customConfigPath = (0, external_node_path_.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_.join)(root, customConfig);
|
|
86
58
|
if (external_node_fs_["default"].existsSync(customConfigPath)) return customConfigPath;
|
|
87
59
|
throw new Error(`Cannot find config file: ${picocolors_default().dim(customConfigPath)}`);
|
|
@@ -93,10 +65,10 @@ export const __webpack_modules__ = {
|
|
|
93
65
|
'lynx.config.mjs'
|
|
94
66
|
];
|
|
95
67
|
for (const file of CONFIG_FILES){
|
|
96
|
-
(0, debug.
|
|
68
|
+
(0, debug.Yz)(`load default config file ${file} from ${root}`);
|
|
97
69
|
const configFile = (0, external_node_path_.join)(root, file);
|
|
98
70
|
if (external_node_fs_["default"].existsSync(configFile)) {
|
|
99
|
-
(0, debug.
|
|
71
|
+
(0, debug.Yz)(`default config ${configFile} found`);
|
|
100
72
|
return configFile;
|
|
101
73
|
}
|
|
102
74
|
}
|
|
@@ -108,9 +80,9 @@ export const __webpack_modules__ = {
|
|
|
108
80
|
async function loadConfig(loadConfigOptions) {
|
|
109
81
|
let { configPath } = loadConfigOptions;
|
|
110
82
|
if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
|
|
111
|
-
const specifier =
|
|
83
|
+
const specifier = pathToFileURL(configPath).toString();
|
|
112
84
|
let unregister;
|
|
113
|
-
unregister = shouldUseNativeImport(configPath) ? ()=>{} :
|
|
85
|
+
unregister = shouldUseNativeImport(configPath) ? ()=>{} : register({
|
|
114
86
|
load: !hasNativeTSSupport(),
|
|
115
87
|
resolve: true
|
|
116
88
|
});
|
|
@@ -186,9 +158,54 @@ export const __webpack_modules__ = {
|
|
|
186
158
|
};
|
|
187
159
|
}
|
|
188
160
|
},
|
|
161
|
+
"./src/cli/watch.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
162
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
163
|
+
G: ()=>getWatchedFiles,
|
|
164
|
+
N: ()=>watchFiles
|
|
165
|
+
});
|
|
166
|
+
async function watchFiles(files, callback) {
|
|
167
|
+
const chokidar = await Promise.all([
|
|
168
|
+
__webpack_require__.e("vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js"),
|
|
169
|
+
__webpack_require__.e("events-fs-fs_promises-os-path-stream")
|
|
170
|
+
]).then(__webpack_require__.bind(__webpack_require__, "../../../node_modules/.pnpm/chokidar@4.0.3/node_modules/chokidar/esm/index.js"));
|
|
171
|
+
const watcher = chokidar.default.watch(files, {
|
|
172
|
+
ignoreInitial: true,
|
|
173
|
+
ignorePermissionErrors: true
|
|
174
|
+
});
|
|
175
|
+
const cb = debounce((event, filePath)=>{
|
|
176
|
+
const startTime = Date.now();
|
|
177
|
+
watcher.close().then(()=>callback(filePath, startTime, event));
|
|
178
|
+
}, 300);
|
|
179
|
+
watcher.once('add', cb.bind(null, 'add'));
|
|
180
|
+
watcher.once('change', cb.bind(null, 'change'));
|
|
181
|
+
watcher.once('unlink', cb.bind(null, 'unlink'));
|
|
182
|
+
}
|
|
183
|
+
function debounce(func, wait) {
|
|
184
|
+
let timeoutId = null;
|
|
185
|
+
return (...args)=>{
|
|
186
|
+
if (null !== timeoutId) clearTimeout(timeoutId);
|
|
187
|
+
timeoutId = setTimeout(()=>{
|
|
188
|
+
func(...args);
|
|
189
|
+
}, wait);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
function getWatchedFiles(configPath, rspeedyConfig) {
|
|
193
|
+
const watchedFiles = [
|
|
194
|
+
configPath
|
|
195
|
+
];
|
|
196
|
+
if (Array.isArray(rspeedyConfig.dev?.watchFiles)) watchedFiles.push(...rspeedyConfig.dev.watchFiles.filter((item)=>'reload-server' === item.type).flatMap((item)=>item.paths));
|
|
197
|
+
else if (rspeedyConfig.dev?.watchFiles?.type === 'reload-server') {
|
|
198
|
+
const { paths } = rspeedyConfig.dev.watchFiles;
|
|
199
|
+
watchedFiles.push(...Array.isArray(paths) ? paths : [
|
|
200
|
+
paths
|
|
201
|
+
]);
|
|
202
|
+
}
|
|
203
|
+
return watchedFiles;
|
|
204
|
+
}
|
|
205
|
+
},
|
|
189
206
|
"./src/create-rspeedy.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
190
207
|
__webpack_require__.d(__webpack_exports__, {
|
|
191
|
-
|
|
208
|
+
x: ()=>createRspeedy
|
|
192
209
|
});
|
|
193
210
|
var external_node_path_ = __webpack_require__("node:path");
|
|
194
211
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
@@ -206,7 +223,7 @@ export const __webpack_modules__ = {
|
|
|
206
223
|
inlineScripts: !enableChunkSplitting
|
|
207
224
|
},
|
|
208
225
|
performance: {
|
|
209
|
-
profile: (0, debug.
|
|
226
|
+
profile: (0, debug._o)() ? true : void 0
|
|
210
227
|
},
|
|
211
228
|
tools: {
|
|
212
229
|
rsdoctor: {
|
|
@@ -232,13 +249,13 @@ export const __webpack_modules__ = {
|
|
|
232
249
|
const DEFAULT_ENTRY = './src/index.js';
|
|
233
250
|
function toRsbuildEntry(entry) {
|
|
234
251
|
if (void 0 === entry) {
|
|
235
|
-
(0, debug.
|
|
252
|
+
(0, debug.Yz)(`Using default entry ${DEFAULT_ENTRY}`);
|
|
236
253
|
return {
|
|
237
254
|
main: DEFAULT_ENTRY
|
|
238
255
|
};
|
|
239
256
|
}
|
|
240
257
|
if (Array.isArray(entry) || 'string' == typeof entry) {
|
|
241
|
-
(0, debug.
|
|
258
|
+
(0, debug.Yz)(()=>`Using single entry ${[
|
|
242
259
|
''
|
|
243
260
|
].concat(entry).join('\n - ')}`);
|
|
244
261
|
return {
|
|
@@ -247,7 +264,7 @@ export const __webpack_modules__ = {
|
|
|
247
264
|
}
|
|
248
265
|
return Object.fromEntries(Object.entries(entry).map(([key, value])=>{
|
|
249
266
|
if (Array.isArray(value) || 'string' == typeof value) {
|
|
250
|
-
(0, debug.
|
|
267
|
+
(0, debug.Iv)(`Using multiple entries - ${key}`, value);
|
|
251
268
|
return [
|
|
252
269
|
key,
|
|
253
270
|
{
|
|
@@ -255,7 +272,7 @@ export const __webpack_modules__ = {
|
|
|
255
272
|
}
|
|
256
273
|
];
|
|
257
274
|
}
|
|
258
|
-
(0, debug.
|
|
275
|
+
(0, debug.Iv)(`Using multiple entries - ${key}`, value.import ?? DEFAULT_ENTRY);
|
|
259
276
|
if (void 0 === value.import) return [
|
|
260
277
|
key,
|
|
261
278
|
{
|
|
@@ -373,5 +390,11 @@ export const __webpack_modules__ = {
|
|
|
373
390
|
}
|
|
374
391
|
});
|
|
375
392
|
}
|
|
393
|
+
},
|
|
394
|
+
"node:fs": function(module) {
|
|
395
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__;
|
|
396
|
+
},
|
|
397
|
+
"node:path": function(module) {
|
|
398
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__;
|
|
376
399
|
}
|
|
377
400
|
};
|
package/dist/src_cli_exit_ts.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import node_process from "node:process";
|
|
2
|
+
export const __webpack_id__ = "src_cli_exit_ts";
|
|
1
3
|
export const __webpack_ids__ = [
|
|
2
4
|
"src_cli_exit_ts"
|
|
3
5
|
];
|
|
@@ -7,7 +9,6 @@ export const __webpack_modules__ = {
|
|
|
7
9
|
exit: ()=>exit_exit
|
|
8
10
|
});
|
|
9
11
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
10
|
-
var external_node_process_ = __webpack_require__("node:process");
|
|
11
12
|
const asyncCallbacks = new Set();
|
|
12
13
|
const callbacks = new Set();
|
|
13
14
|
let isCalled = false;
|
|
@@ -18,7 +19,7 @@ export const __webpack_modules__ = {
|
|
|
18
19
|
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.");
|
|
19
20
|
const exitCode = 128 + signal;
|
|
20
21
|
const done = (force = false)=>{
|
|
21
|
-
if (true === force || true === shouldManuallyExit)
|
|
22
|
+
if (true === force || true === shouldManuallyExit) node_process.exit(exitCode);
|
|
22
23
|
};
|
|
23
24
|
for (const callback of callbacks)callback(exitCode);
|
|
24
25
|
if (isSynchronous) return void done();
|
|
@@ -45,11 +46,11 @@ export const __webpack_modules__ = {
|
|
|
45
46
|
else asyncCallbacks.add(asyncCallbackConfig);
|
|
46
47
|
if (!isRegistered) {
|
|
47
48
|
isRegistered = true;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
node_process.once('beforeExit', exit.bind(void 0, true, false, -128));
|
|
50
|
+
node_process.once('SIGINT', exit.bind(void 0, true, false, 2));
|
|
51
|
+
node_process.once('SIGTERM', exit.bind(void 0, true, false, 15));
|
|
52
|
+
node_process.once('exit', exit.bind(void 0, false, true, 0));
|
|
53
|
+
node_process.on('message', (message)=>{
|
|
53
54
|
if ('shutdown' === message) exit(true, true, -128);
|
|
54
55
|
});
|
|
55
56
|
}
|
|
@@ -96,15 +97,15 @@ export const __webpack_modules__ = {
|
|
|
96
97
|
});
|
|
97
98
|
let previousSignal = null;
|
|
98
99
|
const exit_exit = (signal = 0)=>{
|
|
99
|
-
if (null !== previousSignal) (0, debug.
|
|
100
|
+
if (null !== previousSignal) (0, debug.Yz)(`graceful exit called multiple times, current: ${signal}, previous: ${previousSignal}`);
|
|
100
101
|
previousSignal = signal;
|
|
101
|
-
(0, debug.
|
|
102
|
+
(0, debug.Yz)(`graceful exit process with signal: ${signal}`);
|
|
102
103
|
gracefulExit(signal);
|
|
103
104
|
};
|
|
104
105
|
async function exit_onExit(signal) {
|
|
105
106
|
const duration = Date.now() - start;
|
|
106
|
-
(0, debug.
|
|
107
|
-
(0, debug.
|
|
107
|
+
(0, debug.Yz)(`exit hook fired with signal: ${signal}, duration: ${duration}`);
|
|
108
|
+
(0, debug.Yz)(`awaiting exit promises(length: ${exitPromises.length})...`);
|
|
108
109
|
await Promise.allSettled(exitPromises);
|
|
109
110
|
}
|
|
110
111
|
}
|