@lynx-js/rspeedy-canary 0.10.8 → 0.10.9-canary-20250826-d65ef500
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 +46 -40
- package/dist/src_cli_build_ts.js +74 -13
- package/dist/src_cli_commands_ts.js +1 -1
- package/dist/src_cli_dev_ts.js +48 -37
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lynx-js/rspeedy
|
|
2
2
|
|
|
3
|
+
## 0.10.9-canary-20250826132859-d65ef500d012f108f150e9a1a3f3e399e25bfde4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Support `rspeedy build --watch` ([#1579](https://github.com/lynx-family/lynx-stack/pull/1579))
|
|
8
|
+
|
|
3
9
|
## 0.10.8
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -93,28 +99,28 @@
|
|
|
93
99
|
|
|
94
100
|
```ts
|
|
95
101
|
type InlineChunkTestFunction = (params: {
|
|
96
|
-
size: number
|
|
97
|
-
name: string
|
|
98
|
-
}) => boolean
|
|
102
|
+
size: number;
|
|
103
|
+
name: string;
|
|
104
|
+
}) => boolean;
|
|
99
105
|
|
|
100
|
-
type InlineChunkTest = RegExp | InlineChunkTestFunction
|
|
106
|
+
type InlineChunkTest = RegExp | InlineChunkTestFunction;
|
|
101
107
|
|
|
102
108
|
type InlineChunkConfig =
|
|
103
109
|
| boolean
|
|
104
110
|
| InlineChunkTest
|
|
105
|
-
| { enable?: boolean |
|
|
111
|
+
| { enable?: boolean | "auto"; test: InlineChunkTest };
|
|
106
112
|
```
|
|
107
113
|
|
|
108
114
|
```ts
|
|
109
|
-
import { defineConfig } from
|
|
115
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
110
116
|
|
|
111
117
|
export default defineConfig({
|
|
112
118
|
output: {
|
|
113
119
|
inlineScripts: ({ name, size }) => {
|
|
114
|
-
return name.includes(
|
|
120
|
+
return name.includes("foo") && size < 1000;
|
|
115
121
|
},
|
|
116
122
|
},
|
|
117
|
-
})
|
|
123
|
+
});
|
|
118
124
|
```
|
|
119
125
|
|
|
120
126
|
- docs: remove chunks: 'all' in comments ([#1168](https://github.com/lynx-family/lynx-stack/pull/1168))
|
|
@@ -157,13 +163,13 @@
|
|
|
157
163
|
example:
|
|
158
164
|
|
|
159
165
|
```js
|
|
160
|
-
import { defineConfig } from
|
|
166
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
161
167
|
|
|
162
168
|
export default defineConfig({
|
|
163
169
|
output: {
|
|
164
170
|
inlineScripts: false,
|
|
165
171
|
},
|
|
166
|
-
})
|
|
172
|
+
});
|
|
167
173
|
```
|
|
168
174
|
|
|
169
175
|
- Bump Rsbuild v1.3.21 with Rspack v1.3.11. ([#863](https://github.com/lynx-family/lynx-stack/pull/863))
|
|
@@ -183,12 +189,12 @@
|
|
|
183
189
|
example:
|
|
184
190
|
|
|
185
191
|
```js
|
|
186
|
-
import { defineConfig } from
|
|
192
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
187
193
|
export default defineConfig({
|
|
188
194
|
source: {
|
|
189
|
-
preEntry:
|
|
195
|
+
preEntry: "./src/polyfill.ts",
|
|
190
196
|
},
|
|
191
|
-
})
|
|
197
|
+
});
|
|
192
198
|
```
|
|
193
199
|
|
|
194
200
|
- Bump Rsbuild v1.3.20 with Rspack v1.3.10. ([#799](https://github.com/lynx-family/lynx-stack/pull/799))
|
|
@@ -199,17 +205,17 @@
|
|
|
199
205
|
|
|
200
206
|
```js
|
|
201
207
|
export const myPlugin = {
|
|
202
|
-
name:
|
|
208
|
+
name: "my-plugin",
|
|
203
209
|
setup(api) {
|
|
204
|
-
const { callerName } = api.context
|
|
210
|
+
const { callerName } = api.context;
|
|
205
211
|
|
|
206
|
-
if (callerName ===
|
|
212
|
+
if (callerName === "rslib") {
|
|
207
213
|
// ...
|
|
208
|
-
} else if (callerName ===
|
|
214
|
+
} else if (callerName === "rspeedy") {
|
|
209
215
|
// ...
|
|
210
216
|
}
|
|
211
217
|
},
|
|
212
|
-
}
|
|
218
|
+
};
|
|
213
219
|
```
|
|
214
220
|
|
|
215
221
|
- Support `performance.buildCache`. ([#766](https://github.com/lynx-family/lynx-stack/pull/766))
|
|
@@ -232,7 +238,7 @@
|
|
|
232
238
|
Set `tools.rsdoctor.experiments.enableNativePlugin` to `false` to use the old JS plugin.
|
|
233
239
|
|
|
234
240
|
```js
|
|
235
|
-
import { defineConfig } from
|
|
241
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
236
242
|
|
|
237
243
|
export default defineConfig({
|
|
238
244
|
tools: {
|
|
@@ -242,7 +248,7 @@
|
|
|
242
248
|
},
|
|
243
249
|
},
|
|
244
250
|
},
|
|
245
|
-
})
|
|
251
|
+
});
|
|
246
252
|
```
|
|
247
253
|
|
|
248
254
|
See [Rsdoctor - 1.0](https://rsdoctor.dev/blog/release/release-note-1_0#-faster-analysis) for more details.
|
|
@@ -374,12 +380,12 @@
|
|
|
374
380
|
example:
|
|
375
381
|
|
|
376
382
|
```js
|
|
377
|
-
import { defineConfig } from
|
|
383
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
378
384
|
export default defineConfig({
|
|
379
385
|
server: {
|
|
380
|
-
base:
|
|
386
|
+
base: "/dist",
|
|
381
387
|
},
|
|
382
|
-
})
|
|
388
|
+
});
|
|
383
389
|
```
|
|
384
390
|
|
|
385
391
|
- Updated dependencies [[`b026c8b`](https://github.com/lynx-family/lynx-stack/commit/b026c8bdcbf7bdcda73e170477297213b447d876)]:
|
|
@@ -432,11 +438,11 @@
|
|
|
432
438
|
You can switch to other tools by using:
|
|
433
439
|
|
|
434
440
|
```js
|
|
435
|
-
import { defineConfig } from
|
|
441
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
436
442
|
import {
|
|
437
443
|
CssMinimizerWebpackPlugin,
|
|
438
444
|
pluginCssMinimizer,
|
|
439
|
-
} from
|
|
445
|
+
} from "@rsbuild/plugin-css-minimizer";
|
|
440
446
|
|
|
441
447
|
export default defineConfig({
|
|
442
448
|
plugins: [
|
|
@@ -449,7 +455,7 @@
|
|
|
449
455
|
},
|
|
450
456
|
}),
|
|
451
457
|
],
|
|
452
|
-
})
|
|
458
|
+
});
|
|
453
459
|
```
|
|
454
460
|
|
|
455
461
|
See [@rsbuild/plugin-css-minimizer](https://github.com/rspack-contrib/rsbuild-plugin-css-minimizer) for details.
|
|
@@ -459,8 +465,8 @@
|
|
|
459
465
|
You can use custom options with [@rsbuild/plugin-css-minimizer](https://github.com/rspack-contrib/rsbuild-plugin-css-minimizer):
|
|
460
466
|
|
|
461
467
|
```js
|
|
462
|
-
import { defineConfig } from
|
|
463
|
-
import { pluginCssMinimizer } from
|
|
468
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
469
|
+
import { pluginCssMinimizer } from "@rsbuild/plugin-css-minimizer";
|
|
464
470
|
|
|
465
471
|
export default defineConfig({
|
|
466
472
|
plugins: [
|
|
@@ -472,7 +478,7 @@
|
|
|
472
478
|
},
|
|
473
479
|
}),
|
|
474
480
|
],
|
|
475
|
-
})
|
|
481
|
+
});
|
|
476
482
|
```
|
|
477
483
|
|
|
478
484
|
## 0.7.1
|
|
@@ -492,7 +498,7 @@
|
|
|
492
498
|
You may turn it off using `output.minify.css: false`:
|
|
493
499
|
|
|
494
500
|
```js
|
|
495
|
-
import { defineConfig } from
|
|
501
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
496
502
|
|
|
497
503
|
export default defineConfig({
|
|
498
504
|
output: {
|
|
@@ -500,18 +506,18 @@
|
|
|
500
506
|
css: false,
|
|
501
507
|
},
|
|
502
508
|
},
|
|
503
|
-
})
|
|
509
|
+
});
|
|
504
510
|
```
|
|
505
511
|
|
|
506
512
|
Or you may use [@rsbuild/plugin-css-minimizer](https://github.com/rspack-contrib/rsbuild-plugin-css-minimizer) to use `cssnano` as CSS minimizer.
|
|
507
513
|
|
|
508
514
|
```js
|
|
509
|
-
import { defineConfig } from
|
|
510
|
-
import { pluginCssMinimizer } from
|
|
515
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
516
|
+
import { pluginCssMinimizer } from "@rsbuild/plugin-css-minimizer";
|
|
511
517
|
|
|
512
518
|
export default defineConfig({
|
|
513
519
|
plugins: [pluginCssMinimizer()],
|
|
514
|
-
})
|
|
520
|
+
});
|
|
515
521
|
```
|
|
516
522
|
|
|
517
523
|
- 525554c: **BREAKING CHANGE**: Bump ts-blank-space to ^0.6.0.
|
|
@@ -538,22 +544,22 @@
|
|
|
538
544
|
- The new `type: 'reload-server'` will restart the development server when it detects changes in the specified files.
|
|
539
545
|
|
|
540
546
|
```js
|
|
541
|
-
import { defineConfig } from
|
|
547
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
542
548
|
|
|
543
549
|
export default defineConfig({
|
|
544
550
|
dev: {
|
|
545
551
|
watchFiles: [
|
|
546
552
|
{
|
|
547
|
-
type:
|
|
548
|
-
paths: [
|
|
553
|
+
type: "reload-server",
|
|
554
|
+
paths: ["public/**/*.txt"],
|
|
549
555
|
},
|
|
550
556
|
{
|
|
551
|
-
type:
|
|
552
|
-
paths: [
|
|
557
|
+
type: "reload-page",
|
|
558
|
+
paths: ["public/**/*.json"],
|
|
553
559
|
},
|
|
554
560
|
],
|
|
555
561
|
},
|
|
556
|
-
})
|
|
562
|
+
});
|
|
557
563
|
```
|
|
558
564
|
|
|
559
565
|
- be9b003: Add `source.exclude`.
|
package/dist/src_cli_build_ts.js
CHANGED
|
@@ -7,23 +7,42 @@ export const __webpack_modules__ = {
|
|
|
7
7
|
__webpack_require__.d(__webpack_exports__, {
|
|
8
8
|
build: ()=>build
|
|
9
9
|
});
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
10
|
+
var node_path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:path");
|
|
11
|
+
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("@rsbuild/core");
|
|
12
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
13
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_7__);
|
|
14
|
+
var _exit_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/cli/exit.ts");
|
|
15
|
+
var _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/create-rspeedy.ts");
|
|
16
|
+
var _init_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/cli/init.ts");
|
|
17
|
+
var _watch_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./src/cli/watch.ts");
|
|
18
|
+
var _utils_is_ci_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("./src/utils/is-ci.ts");
|
|
15
19
|
async function build(cwd, buildOptions) {
|
|
16
|
-
const shouldExit = 'true' !== process.env['RSDOCTOR'] || (0,
|
|
20
|
+
const shouldExit = 'true' !== process.env['RSDOCTOR'] || (0, _utils_is_ci_js__WEBPACK_IMPORTED_MODULE_6__.y)();
|
|
21
|
+
const isWatch = buildOptions.watch ?? false;
|
|
22
|
+
let onBeforeRestart = [];
|
|
17
23
|
try {
|
|
18
|
-
const { createRspeedyOptions } = await (0,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
const { rspeedyConfig, configPath, createRspeedyOptions } = await (0, _init_js__WEBPACK_IMPORTED_MODULE_4__.S)(cwd, buildOptions);
|
|
25
|
+
if (isWatch) {
|
|
26
|
+
const watchedFiles = (0, _watch_js__WEBPACK_IMPORTED_MODULE_5__.z)(configPath, rspeedyConfig);
|
|
27
|
+
await (0, _watch_js__WEBPACK_IMPORTED_MODULE_5__.s)(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)=>{
|
|
28
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_1__.logger.info(`Restart because ${picocolors__WEBPACK_IMPORTED_MODULE_7___default().yellow(filename)} is changed.\n`);
|
|
29
|
+
const cleanup = onBeforeRestart.map((f)=>f());
|
|
30
|
+
onBeforeRestart = [];
|
|
31
|
+
await Promise.all(cleanup);
|
|
32
|
+
await build.call(this, cwd, buildOptions);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_3__.S)(createRspeedyOptions);
|
|
36
|
+
const { close } = await rspeedy.build({
|
|
37
|
+
watch: isWatch
|
|
38
|
+
});
|
|
39
|
+
if (isWatch) onBeforeRestart.push(close);
|
|
40
|
+
else await close();
|
|
22
41
|
} catch (error) {
|
|
23
|
-
|
|
24
|
-
if (shouldExit) return void (0,
|
|
42
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_1__.logger.error(error);
|
|
43
|
+
if (shouldExit) return void (0, _exit_js__WEBPACK_IMPORTED_MODULE_2__.exit)(1);
|
|
25
44
|
}
|
|
26
|
-
if (shouldExit) (0,
|
|
45
|
+
if (shouldExit && !isWatch) (0, _exit_js__WEBPACK_IMPORTED_MODULE_2__.exit)();
|
|
27
46
|
}
|
|
28
47
|
},
|
|
29
48
|
"./src/cli/init.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
@@ -144,6 +163,48 @@ export const __webpack_modules__ = {
|
|
|
144
163
|
};
|
|
145
164
|
}
|
|
146
165
|
},
|
|
166
|
+
"./src/cli/watch.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
167
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
168
|
+
s: ()=>watchFiles,
|
|
169
|
+
z: ()=>getWatchedFiles
|
|
170
|
+
});
|
|
171
|
+
async function watchFiles(files, callback) {
|
|
172
|
+
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"));
|
|
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
|
+
},
|
|
147
208
|
"./src/create-rspeedy.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
148
209
|
__webpack_require__.d(__webpack_exports__, {
|
|
149
210
|
S: ()=>createRspeedy
|
|
@@ -15,7 +15,7 @@ export const __webpack_modules__ = {
|
|
|
15
15
|
const cwd = process.cwd();
|
|
16
16
|
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
17
|
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)));
|
|
18
|
+
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
19
|
const devCommand = program.command('dev');
|
|
20
20
|
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
21
|
const inspectCommand = program.command('inspect');
|
package/dist/src_cli_dev_ts.js
CHANGED
|
@@ -9,27 +9,19 @@ export const __webpack_modules__ = {
|
|
|
9
9
|
});
|
|
10
10
|
var node_path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:path");
|
|
11
11
|
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("@rsbuild/core");
|
|
12
|
-
var
|
|
13
|
-
var
|
|
12
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
13
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_6__);
|
|
14
14
|
var _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/create-rspeedy.ts");
|
|
15
15
|
var _exit_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/cli/exit.ts");
|
|
16
16
|
var _init_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/cli/init.ts");
|
|
17
|
+
var _watch_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./src/cli/watch.ts");
|
|
17
18
|
async function dev(cwd, devOptions) {
|
|
18
19
|
let onBeforeRestart = [];
|
|
19
20
|
try {
|
|
20
21
|
const { rspeedyConfig, configPath, createRspeedyOptions } = await (0, _init_js__WEBPACK_IMPORTED_MODULE_4__.S)(cwd, devOptions);
|
|
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`);
|
|
22
|
+
const watchedFiles = (0, _watch_js__WEBPACK_IMPORTED_MODULE_5__.z)(configPath, rspeedyConfig);
|
|
23
|
+
await (0, _watch_js__WEBPACK_IMPORTED_MODULE_5__.s)(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)=>{
|
|
24
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_1__.logger.info(`Restart because ${picocolors__WEBPACK_IMPORTED_MODULE_6___default().yellow(filename)} is changed.\n`);
|
|
33
25
|
const cleanup = onBeforeRestart.map((f)=>f());
|
|
34
26
|
onBeforeRestart = [];
|
|
35
27
|
await Promise.all(cleanup);
|
|
@@ -44,29 +36,6 @@ export const __webpack_modules__ = {
|
|
|
44
36
|
(0, _exit_js__WEBPACK_IMPORTED_MODULE_3__.exit)(1);
|
|
45
37
|
}
|
|
46
38
|
}
|
|
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
39
|
},
|
|
71
40
|
"./src/cli/init.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
72
41
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -186,6 +155,48 @@ export const __webpack_modules__ = {
|
|
|
186
155
|
};
|
|
187
156
|
}
|
|
188
157
|
},
|
|
158
|
+
"./src/cli/watch.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
159
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
160
|
+
s: ()=>watchFiles,
|
|
161
|
+
z: ()=>getWatchedFiles
|
|
162
|
+
});
|
|
163
|
+
async function watchFiles(files, callback) {
|
|
164
|
+
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"));
|
|
165
|
+
const watcher = chokidar.default.watch(files, {
|
|
166
|
+
ignoreInitial: true,
|
|
167
|
+
ignorePermissionErrors: true
|
|
168
|
+
});
|
|
169
|
+
const cb = debounce((event, filePath)=>{
|
|
170
|
+
const startTime = Date.now();
|
|
171
|
+
watcher.close().then(()=>callback(filePath, startTime, event));
|
|
172
|
+
}, 300);
|
|
173
|
+
watcher.once('add', cb.bind(null, 'add'));
|
|
174
|
+
watcher.once('change', cb.bind(null, 'change'));
|
|
175
|
+
watcher.once('unlink', cb.bind(null, 'unlink'));
|
|
176
|
+
}
|
|
177
|
+
function debounce(func, wait) {
|
|
178
|
+
let timeoutId = null;
|
|
179
|
+
return (...args)=>{
|
|
180
|
+
if (null !== timeoutId) clearTimeout(timeoutId);
|
|
181
|
+
timeoutId = setTimeout(()=>{
|
|
182
|
+
func(...args);
|
|
183
|
+
}, wait);
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function getWatchedFiles(configPath, rspeedyConfig) {
|
|
187
|
+
const watchedFiles = [
|
|
188
|
+
configPath
|
|
189
|
+
];
|
|
190
|
+
if (Array.isArray(rspeedyConfig.dev?.watchFiles)) watchedFiles.push(...rspeedyConfig.dev.watchFiles.filter((item)=>'reload-server' === item.type).flatMap((item)=>item.paths));
|
|
191
|
+
else if (rspeedyConfig.dev?.watchFiles?.type === 'reload-server') {
|
|
192
|
+
const { paths } = rspeedyConfig.dev.watchFiles;
|
|
193
|
+
watchedFiles.push(...Array.isArray(paths) ? paths : [
|
|
194
|
+
paths
|
|
195
|
+
]);
|
|
196
|
+
}
|
|
197
|
+
return watchedFiles;
|
|
198
|
+
}
|
|
199
|
+
},
|
|
189
200
|
"./src/create-rspeedy.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
190
201
|
__webpack_require__.d(__webpack_exports__, {
|
|
191
202
|
S: ()=>createRspeedy
|