@lynx-js/rspeedy 0.9.3 → 0.9.4
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 +36 -4
- package/dist/index.d.ts +46 -12
- package/dist/index.js +11 -3
- package/dist/src_cli_build_ts.js +63 -43
- package/dist/src_cli_commands_ts.js +4 -4
- package/dist/src_cli_dev_ts.js +65 -50
- package/dist/src_cli_exit_ts.js +1 -1
- package/dist/src_cli_inspect_ts.js +85 -64
- package/dist/src_cli_preview_ts.js +87 -71
- package/dist/src_config_validate_ts.js +1143 -1043
- package/dist/src_plugins_api_plugin_ts.js +1 -1
- package/dist/src_plugins_chunkLoading_plugin_ts.js +1 -1
- package/dist/src_plugins_dev_plugin_ts.js +1 -1
- package/dist/src_plugins_index_ts.js +1 -1
- package/dist/src_plugins_inspect_plugin_ts.js +1 -1
- package/dist/src_plugins_minify_plugin_ts.js +1 -1
- package/dist/src_plugins_optimization_plugin_ts.js +1 -1
- package/dist/src_plugins_output_plugin_ts.js +1 -1
- package/dist/src_plugins_resolve_plugin_ts.js +1 -1
- package/dist/src_plugins_rsdoctor_plugin_ts.js +1 -1
- package/dist/src_plugins_sourcemap_plugin_ts.js +1 -1
- package/dist/src_plugins_stats_plugin_ts.js +2 -5
- package/dist/src_plugins_swc_plugin_ts.js +1 -1
- package/dist/src_plugins_target_plugin_ts.js +1 -1
- package/dist/src_version_ts.js +2 -2
- package/dist/vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +1 -1
- package/dist/vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js +1 -1
- package/dist/vendors-node_modules_pnpm_ipaddr_js_2_2_0_node_modules_ipaddr_js_lib_ipaddr_js.js +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @lynx-js/rspeedy
|
|
2
2
|
|
|
3
|
+
## 0.9.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Bump Rsbuild v1.3.17 with Rspack v1.3.9. ([#708](https://github.com/lynx-family/lynx-stack/pull/708))
|
|
8
|
+
|
|
9
|
+
- Support `performance.profile`. ([#691](https://github.com/lynx-family/lynx-stack/pull/691))
|
|
10
|
+
|
|
11
|
+
- Support CLI flag `--mode` to specify the build mode. ([#723](https://github.com/lynx-family/lynx-stack/pull/723))
|
|
12
|
+
|
|
13
|
+
- Enable native Rsdoctor plugin by default. ([#688](https://github.com/lynx-family/lynx-stack/pull/688))
|
|
14
|
+
|
|
15
|
+
Set `tools.rsdoctor.experiments.enableNativePlugin` to `false` to use the old JS plugin.
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { defineConfig } from '@lynx-js/rspeedy'
|
|
19
|
+
|
|
20
|
+
export default defineConfig({
|
|
21
|
+
tools: {
|
|
22
|
+
rsdoctor: {
|
|
23
|
+
experiments: {
|
|
24
|
+
enableNativePlugin: false,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
See [Rsdoctor - 1.0](https://rsdoctor.dev/blog/release/release-note-1_0#-faster-analysis) for more details.
|
|
32
|
+
|
|
33
|
+
- Bump Rsbuild v1.3.14 with Rspack v1.3.8. ([#630](https://github.com/lynx-family/lynx-stack/pull/630))
|
|
34
|
+
|
|
3
35
|
## 0.9.3
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
|
@@ -10,7 +42,7 @@
|
|
|
10
42
|
|
|
11
43
|
### Patch Changes
|
|
12
44
|
|
|
13
|
-
- Support
|
|
45
|
+
- Support CLI option `--no-env` to disable loading of `.env` files ([#483](https://github.com/lynx-family/lynx-stack/pull/483))
|
|
14
46
|
|
|
15
47
|
- Bump Rsbuild v1.3.8 with Rspack v1.3.5. ([#579](https://github.com/lynx-family/lynx-stack/pull/579))
|
|
16
48
|
|
|
@@ -46,9 +78,9 @@
|
|
|
46
78
|
|
|
47
79
|
### Patch Changes
|
|
48
80
|
|
|
49
|
-
- Support
|
|
81
|
+
- Support CLI flag `--base` to specify the base path of the server. ([#387](https://github.com/lynx-family/lynx-stack/pull/387))
|
|
50
82
|
|
|
51
|
-
- Support
|
|
83
|
+
- Support CLI flag `--environment` to specify the name of environment to build ([#462](https://github.com/lynx-family/lynx-stack/pull/462))
|
|
52
84
|
|
|
53
85
|
- Select the most appropriate network interface. ([#457](https://github.com/lynx-family/lynx-stack/pull/457))
|
|
54
86
|
|
|
@@ -58,7 +90,7 @@
|
|
|
58
90
|
|
|
59
91
|
See [Node.js - TypeScript](https://nodejs.org/api/typescript.html) for more details.
|
|
60
92
|
|
|
61
|
-
- Support
|
|
93
|
+
- Support CLI flag `--env-mode` to specify the env mode to load the `.env.[mode]` file. ([#453](https://github.com/lynx-family/lynx-stack/pull/453))
|
|
62
94
|
|
|
63
95
|
- Support `dev.hmr` and `dev.liveReload`. ([#458](https://github.com/lynx-family/lynx-stack/pull/458))
|
|
64
96
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1104,7 +1104,9 @@ export declare interface DistPath extends DistPathConfig {
|
|
|
1104
1104
|
* ```js
|
|
1105
1105
|
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
1106
1106
|
* export default defineConfig({
|
|
1107
|
-
*
|
|
1107
|
+
* source: {
|
|
1108
|
+
* entry: './src/pages/main/index.js',
|
|
1109
|
+
* }
|
|
1108
1110
|
* })
|
|
1109
1111
|
* ```
|
|
1110
1112
|
*
|
|
@@ -1115,7 +1117,9 @@ export declare interface DistPath extends DistPathConfig {
|
|
|
1115
1117
|
* ```js
|
|
1116
1118
|
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
1117
1119
|
* export default defineConfig({
|
|
1118
|
-
*
|
|
1120
|
+
* source: {
|
|
1121
|
+
* entry: ['./src/prefetch.js', './src/pages/main/index.js'],
|
|
1122
|
+
* }
|
|
1119
1123
|
* })
|
|
1120
1124
|
* ```
|
|
1121
1125
|
*
|
|
@@ -1126,10 +1130,12 @@ export declare interface DistPath extends DistPathConfig {
|
|
|
1126
1130
|
* ```js
|
|
1127
1131
|
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
1128
1132
|
* export default defineConfig({
|
|
1129
|
-
*
|
|
1130
|
-
*
|
|
1131
|
-
*
|
|
1132
|
-
*
|
|
1133
|
+
* source: {
|
|
1134
|
+
* entry: {
|
|
1135
|
+
* foo: './src/pages/foo/index.js',
|
|
1136
|
+
* bar: ['./src/pages/bar/index.js', './src/post.js'], // multiple entry modules is allowed
|
|
1137
|
+
* }
|
|
1138
|
+
* }
|
|
1133
1139
|
* })
|
|
1134
1140
|
* ```
|
|
1135
1141
|
*
|
|
@@ -1140,12 +1146,14 @@ export declare interface DistPath extends DistPathConfig {
|
|
|
1140
1146
|
* ```js
|
|
1141
1147
|
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
1142
1148
|
* export default defineConfig({
|
|
1143
|
-
*
|
|
1144
|
-
*
|
|
1145
|
-
*
|
|
1146
|
-
*
|
|
1147
|
-
*
|
|
1148
|
-
*
|
|
1149
|
+
* source: {
|
|
1150
|
+
* entry: {
|
|
1151
|
+
* foo: './src/pages/foo/index.js',
|
|
1152
|
+
* bar: {
|
|
1153
|
+
* import: ['./src/prefetch.js', './src/pages/bar'],
|
|
1154
|
+
* }
|
|
1155
|
+
* }
|
|
1156
|
+
* }
|
|
1149
1157
|
* })
|
|
1150
1158
|
* ```
|
|
1151
1159
|
* @public
|
|
@@ -1891,6 +1899,32 @@ export declare interface Performance {
|
|
|
1891
1899
|
* {@link Performance.chunkSplit} is used to configure the chunk splitting strategy.
|
|
1892
1900
|
*/
|
|
1893
1901
|
chunkSplit?: ChunkSplit | ChunkSplitBySize | ChunkSplitCustom | undefined;
|
|
1902
|
+
/**
|
|
1903
|
+
* Whether capture timing information in the build time and the runtime, the same as the {@link https://rspack.dev/config/other-options#profile | profile} config of Rspack.
|
|
1904
|
+
*
|
|
1905
|
+
* @remarks
|
|
1906
|
+
*
|
|
1907
|
+
* This option would be `true` when `DEBUG` environment variable contains `rspeedy`.
|
|
1908
|
+
*
|
|
1909
|
+
* @example
|
|
1910
|
+
*
|
|
1911
|
+
* Enable profile.
|
|
1912
|
+
*
|
|
1913
|
+
* - Rsbuild will auto-generate `dist/stats.json` file through bundle analyzer.
|
|
1914
|
+
*
|
|
1915
|
+
* - Rspack will include the build time information when generating `stats.json`.
|
|
1916
|
+
*
|
|
1917
|
+
* - Frameworks like ReactLynx will include runtime information using `console.profile`.
|
|
1918
|
+
*
|
|
1919
|
+
* ```ts
|
|
1920
|
+
* import { defineConfig } from '@lynx-js/rspeedy'
|
|
1921
|
+
*
|
|
1922
|
+
* export default defineConfig({
|
|
1923
|
+
* performance: { profile: true },
|
|
1924
|
+
* })
|
|
1925
|
+
* ```
|
|
1926
|
+
*/
|
|
1927
|
+
profile?: boolean | undefined;
|
|
1894
1928
|
/**
|
|
1895
1929
|
* Whether to remove `console.[methodName]` in production build.
|
|
1896
1930
|
*
|
package/dist/index.js
CHANGED
|
@@ -112,7 +112,7 @@ var __webpack_modules__ = {
|
|
|
112
112
|
});
|
|
113
113
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
114
114
|
var package_namespaceObject = {
|
|
115
|
-
i8: "0.9.
|
|
115
|
+
i8: "0.9.4"
|
|
116
116
|
};
|
|
117
117
|
const version = package_namespaceObject.i8;
|
|
118
118
|
const rspackVersion = core_.rspack.rspackVersion;
|
|
@@ -254,11 +254,18 @@ __webpack_require__.m = __webpack_modules__;
|
|
|
254
254
|
var external_node_path_ = __webpack_require__("node:path");
|
|
255
255
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
256
256
|
function applyDefaultRspeedyConfig(config) {
|
|
257
|
-
const ret = (0, core_.mergeRsbuildConfig)(
|
|
257
|
+
const ret = (0, core_.mergeRsbuildConfig)({
|
|
258
258
|
output: {
|
|
259
259
|
filename: getFilename(config.output?.filename)
|
|
260
|
+
},
|
|
261
|
+
tools: {
|
|
262
|
+
rsdoctor: {
|
|
263
|
+
experiments: {
|
|
264
|
+
enableNativePlugin: true
|
|
265
|
+
}
|
|
266
|
+
}
|
|
260
267
|
}
|
|
261
|
-
});
|
|
268
|
+
}, config);
|
|
262
269
|
return ret;
|
|
263
270
|
}
|
|
264
271
|
const DEFAULT_FILENAME = '[name].[platform].bundle';
|
|
@@ -361,6 +368,7 @@ function toRsbuildConfig(config) {
|
|
|
361
368
|
plugins: config.plugins,
|
|
362
369
|
performance: {
|
|
363
370
|
chunkSplit: config.performance?.chunkSplit,
|
|
371
|
+
profile: config.performance?.profile,
|
|
364
372
|
removeConsole: toRsbuildRemoveConsole(config),
|
|
365
373
|
printFileSize: config.performance?.printFileSize ?? true
|
|
366
374
|
},
|
package/dist/src_cli_build_ts.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const __webpack_ids__ = [
|
|
2
|
-
|
|
2
|
+
"src_cli_build_ts"
|
|
3
3
|
];
|
|
4
4
|
export const __webpack_modules__ = {
|
|
5
5
|
"./src/cli/build.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
@@ -9,26 +9,14 @@ export const __webpack_modules__ = {
|
|
|
9
9
|
});
|
|
10
10
|
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("@rsbuild/core");
|
|
11
11
|
var _exit_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/cli/exit.ts");
|
|
12
|
-
var
|
|
13
|
-
var
|
|
12
|
+
var _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/create-rspeedy.ts");
|
|
13
|
+
var _init_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/cli/init.ts");
|
|
14
14
|
var _utils_is_ci_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/utils/is-ci.ts");
|
|
15
15
|
async function build(cwd, buildOptions) {
|
|
16
16
|
const shouldExit = 'true' !== process.env['RSDOCTOR'] || (0, _utils_is_ci_js__WEBPACK_IMPORTED_MODULE_4__.y)();
|
|
17
17
|
try {
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
configPath: buildOptions.config
|
|
21
|
-
});
|
|
22
|
-
const options = {
|
|
23
|
-
cwd,
|
|
24
|
-
rspeedyConfig
|
|
25
|
-
};
|
|
26
|
-
if (buildOptions.noEnv) options.loadEnv = false;
|
|
27
|
-
else if (buildOptions.envMode) options.loadEnv = {
|
|
28
|
-
mode: buildOptions.envMode
|
|
29
|
-
};
|
|
30
|
-
if (buildOptions.environment) options.environment = buildOptions.environment;
|
|
31
|
-
const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_3__.S)(options);
|
|
18
|
+
const { createRspeedyOptions } = await (0, _init_js__WEBPACK_IMPORTED_MODULE_3__.S)(cwd, buildOptions);
|
|
19
|
+
const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_2__.S)(createRspeedyOptions);
|
|
32
20
|
await rspeedy.build();
|
|
33
21
|
} catch (error) {
|
|
34
22
|
_rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.logger.error(error);
|
|
@@ -37,24 +25,23 @@ export const __webpack_modules__ = {
|
|
|
37
25
|
if (shouldExit) (0, _exit_js__WEBPACK_IMPORTED_MODULE_1__.exit)();
|
|
38
26
|
}
|
|
39
27
|
},
|
|
40
|
-
"./src/
|
|
28
|
+
"./src/cli/init.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
41
29
|
__webpack_require__.d(__webpack_exports__, {
|
|
42
|
-
|
|
43
|
-
Mk: ()=>resolveConfigPath
|
|
30
|
+
S: ()=>init
|
|
44
31
|
});
|
|
45
|
-
var
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var
|
|
32
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
33
|
+
var external_node_path_ = __webpack_require__("node:path");
|
|
34
|
+
var external_node_url_ = __webpack_require__("node:url");
|
|
35
|
+
var picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
36
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
37
|
+
var register_ = __webpack_require__("@lynx-js/rspeedy/register");
|
|
38
|
+
var debug = __webpack_require__("./src/debug.ts");
|
|
52
39
|
const resolveConfigPath = (root, customConfig)=>{
|
|
53
40
|
if (customConfig) {
|
|
54
|
-
(0,
|
|
55
|
-
const customConfigPath = (0,
|
|
56
|
-
if (
|
|
57
|
-
throw new Error(`Cannot find config file: ${
|
|
41
|
+
(0, debug.fF)(`load custom config file ${customConfig} from ${root}`);
|
|
42
|
+
const customConfigPath = (0, external_node_path_.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_.join)(root, customConfig);
|
|
43
|
+
if (external_node_fs_["default"].existsSync(customConfigPath)) return customConfigPath;
|
|
44
|
+
throw new Error(`Cannot find config file: ${picocolors_default().dim(customConfigPath)}`);
|
|
58
45
|
}
|
|
59
46
|
const CONFIG_FILES = [
|
|
60
47
|
'lynx.config.ts',
|
|
@@ -63,23 +50,23 @@ export const __webpack_modules__ = {
|
|
|
63
50
|
'lynx.config.mjs'
|
|
64
51
|
];
|
|
65
52
|
for (const file of CONFIG_FILES){
|
|
66
|
-
(0,
|
|
67
|
-
const configFile = (0,
|
|
68
|
-
if (
|
|
69
|
-
(0,
|
|
53
|
+
(0, debug.fF)(`load default config file ${file} from ${root}`);
|
|
54
|
+
const configFile = (0, external_node_path_.join)(root, file);
|
|
55
|
+
if (external_node_fs_["default"].existsSync(configFile)) {
|
|
56
|
+
(0, debug.fF)(`default config ${configFile} found`);
|
|
70
57
|
return configFile;
|
|
71
58
|
}
|
|
72
59
|
}
|
|
73
60
|
throw new Error([
|
|
74
|
-
`Cannot find the default config file: ${
|
|
75
|
-
`Use custom config with ${
|
|
61
|
+
`Cannot find the default config file: ${picocolors_default().dim((0, external_node_path_.join)(root, CONFIG_FILES[0]))}.`,
|
|
62
|
+
`Use custom config with ${picocolors_default().green('`--config <config>`')} options.`
|
|
76
63
|
].join(' '));
|
|
77
64
|
};
|
|
78
65
|
async function loadConfig(loadConfigOptions) {
|
|
79
66
|
let { configPath } = loadConfigOptions;
|
|
80
|
-
if (!configPath || !(0,
|
|
81
|
-
const specifier = (0,
|
|
82
|
-
const unregister = shouldUseNativeImport(configPath) ? ()=>void 0 : (0,
|
|
67
|
+
if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
|
|
68
|
+
const specifier = (0, external_node_url_.pathToFileURL)(configPath).toString();
|
|
69
|
+
const unregister = shouldUseNativeImport(configPath) ? ()=>void 0 : (0, register_.register)();
|
|
83
70
|
try {
|
|
84
71
|
const [exports, { validate }] = await Promise.all([
|
|
85
72
|
import(`${specifier}?t=${Date.now()}`),
|
|
@@ -105,13 +92,38 @@ export const __webpack_modules__ = {
|
|
|
105
92
|
return NODE_OPTIONS.includes('--experimental-transform-types') || NODE_OPTIONS.includes('--experimental-strip-types');
|
|
106
93
|
}
|
|
107
94
|
function isJavaScriptPath(configPath) {
|
|
108
|
-
const ext = (0,
|
|
95
|
+
const ext = (0, external_node_path_.extname)(configPath);
|
|
109
96
|
return [
|
|
110
97
|
'.js',
|
|
111
98
|
'.mjs',
|
|
112
99
|
'.cjs'
|
|
113
100
|
].includes(ext);
|
|
114
101
|
}
|
|
102
|
+
async function init(cwd, options) {
|
|
103
|
+
const { content: rspeedyConfig, configPath } = await loadConfig({
|
|
104
|
+
cwd,
|
|
105
|
+
configPath: options.config
|
|
106
|
+
});
|
|
107
|
+
const createRspeedyOptions = {
|
|
108
|
+
cwd,
|
|
109
|
+
rspeedyConfig
|
|
110
|
+
};
|
|
111
|
+
if (options.noEnv) createRspeedyOptions.loadEnv = false;
|
|
112
|
+
else if (options.envMode) createRspeedyOptions.loadEnv = {
|
|
113
|
+
mode: options.envMode
|
|
114
|
+
};
|
|
115
|
+
if ('base' in options && options.base) {
|
|
116
|
+
rspeedyConfig.server ??= {};
|
|
117
|
+
rspeedyConfig.server.base = options.base;
|
|
118
|
+
}
|
|
119
|
+
if ('environment' in options && options.environment) createRspeedyOptions.environment = options.environment;
|
|
120
|
+
if (options.mode) rspeedyConfig.mode = options.mode;
|
|
121
|
+
return {
|
|
122
|
+
createRspeedyOptions,
|
|
123
|
+
configPath,
|
|
124
|
+
rspeedyConfig
|
|
125
|
+
};
|
|
126
|
+
}
|
|
115
127
|
},
|
|
116
128
|
"./src/create-rspeedy.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
117
129
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -120,11 +132,18 @@ export const __webpack_modules__ = {
|
|
|
120
132
|
var external_node_path_ = __webpack_require__("node:path");
|
|
121
133
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
122
134
|
function applyDefaultRspeedyConfig(config) {
|
|
123
|
-
const ret = (0, core_.mergeRsbuildConfig)(
|
|
135
|
+
const ret = (0, core_.mergeRsbuildConfig)({
|
|
124
136
|
output: {
|
|
125
137
|
filename: getFilename(config.output?.filename)
|
|
138
|
+
},
|
|
139
|
+
tools: {
|
|
140
|
+
rsdoctor: {
|
|
141
|
+
experiments: {
|
|
142
|
+
enableNativePlugin: true
|
|
143
|
+
}
|
|
144
|
+
}
|
|
126
145
|
}
|
|
127
|
-
});
|
|
146
|
+
}, config);
|
|
128
147
|
return ret;
|
|
129
148
|
}
|
|
130
149
|
const DEFAULT_FILENAME = '[name].[platform].bundle';
|
|
@@ -227,6 +246,7 @@ export const __webpack_modules__ = {
|
|
|
227
246
|
plugins: config.plugins,
|
|
228
247
|
performance: {
|
|
229
248
|
chunkSplit: config.performance?.chunkSplit,
|
|
249
|
+
profile: config.performance?.profile,
|
|
230
250
|
removeConsole: toRsbuildRemoveConsole(config),
|
|
231
251
|
printFileSize: config.performance?.printFileSize ?? true
|
|
232
252
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const __webpack_ids__ = [
|
|
2
|
-
|
|
2
|
+
"src_cli_commands_ts"
|
|
3
3
|
];
|
|
4
4
|
export const __webpack_modules__ = {
|
|
5
5
|
"./src/cli/commands.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
@@ -9,7 +9,7 @@ export const __webpack_modules__ = {
|
|
|
9
9
|
});
|
|
10
10
|
var _version_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/version.ts");
|
|
11
11
|
function applyCommonOptions(command) {
|
|
12
|
-
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"');
|
|
12
|
+
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`');
|
|
13
13
|
}
|
|
14
14
|
function apply(program) {
|
|
15
15
|
const cwd = process.cwd();
|
|
@@ -19,7 +19,7 @@ export const __webpack_modules__ = {
|
|
|
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');
|
|
22
|
-
inspectCommand.description('View the Rsbuild config and Rspack config of the project.').option('--
|
|
22
|
+
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((inspectOptions)=>__webpack_require__.e("src_cli_inspect_ts").then(__webpack_require__.bind(__webpack_require__, "./src/cli/inspect.ts")).then(({ inspect })=>inspect.call(inspectCommand, cwd, inspectOptions)));
|
|
23
23
|
const previewCommand = program.command('preview');
|
|
24
24
|
previewCommand.description('Preview the production build outputs locally.').option('--base <base>', 'specify the base path of the server').action((previewOptions)=>__webpack_require__.e("src_cli_preview_ts").then(__webpack_require__.bind(__webpack_require__, "./src/cli/preview.ts")).then(({ preview })=>preview.call(previewCommand, cwd, previewOptions)));
|
|
25
25
|
const commonCommands = [
|
|
@@ -40,7 +40,7 @@ export const __webpack_modules__ = {
|
|
|
40
40
|
});
|
|
41
41
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
42
42
|
var package_namespaceObject = {
|
|
43
|
-
i8: "0.9.
|
|
43
|
+
i8: "0.9.4"
|
|
44
44
|
};
|
|
45
45
|
const version = package_namespaceObject.i8;
|
|
46
46
|
const rspackVersion = core_.rspack.rspackVersion;
|
package/dist/src_cli_dev_ts.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const __webpack_ids__ = [
|
|
2
|
-
|
|
2
|
+
"src_cli_dev_ts"
|
|
3
3
|
];
|
|
4
4
|
export const __webpack_modules__ = {
|
|
5
5
|
"./src/cli/dev.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
@@ -11,21 +11,13 @@ export const __webpack_modules__ = {
|
|
|
11
11
|
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("@rsbuild/core");
|
|
12
12
|
var picocolors__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
13
13
|
var picocolors__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_5__);
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
14
|
+
var _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/create-rspeedy.ts");
|
|
15
|
+
var _exit_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/cli/exit.ts");
|
|
16
|
+
var _init_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/cli/init.ts");
|
|
17
17
|
async function dev(cwd, devOptions) {
|
|
18
18
|
let onBeforeRestart = [];
|
|
19
19
|
try {
|
|
20
|
-
const configPath = (0,
|
|
21
|
-
const { content: rspeedyConfig } = await (0, _config_loadConfig_js__WEBPACK_IMPORTED_MODULE_2__.ME)({
|
|
22
|
-
cwd,
|
|
23
|
-
configPath
|
|
24
|
-
});
|
|
25
|
-
if (devOptions.base) {
|
|
26
|
-
rspeedyConfig.server ??= {};
|
|
27
|
-
rspeedyConfig.server.base = devOptions.base;
|
|
28
|
-
}
|
|
20
|
+
const { rspeedyConfig, configPath, createRspeedyOptions } = await (0, _init_js__WEBPACK_IMPORTED_MODULE_4__.S)(cwd, devOptions);
|
|
29
21
|
const watchedFiles = [
|
|
30
22
|
configPath
|
|
31
23
|
];
|
|
@@ -43,22 +35,13 @@ export const __webpack_modules__ = {
|
|
|
43
35
|
await Promise.all(cleanup);
|
|
44
36
|
await dev.call(this, cwd, devOptions);
|
|
45
37
|
});
|
|
46
|
-
const
|
|
47
|
-
cwd,
|
|
48
|
-
rspeedyConfig
|
|
49
|
-
};
|
|
50
|
-
if (devOptions.noEnv) options.loadEnv = false;
|
|
51
|
-
else if (devOptions.envMode) options.loadEnv = {
|
|
52
|
-
mode: devOptions.envMode
|
|
53
|
-
};
|
|
54
|
-
if (devOptions.environment) options.environment = devOptions.environment;
|
|
55
|
-
const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_3__.S)(options);
|
|
38
|
+
const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_2__.S)(createRspeedyOptions);
|
|
56
39
|
const server = await rspeedy.createDevServer();
|
|
57
40
|
const { server: { close } } = await server.listen();
|
|
58
41
|
onBeforeRestart.push(close);
|
|
59
42
|
} catch (error) {
|
|
60
43
|
_rsbuild_core__WEBPACK_IMPORTED_MODULE_1__.logger.error(error);
|
|
61
|
-
(0,
|
|
44
|
+
(0, _exit_js__WEBPACK_IMPORTED_MODULE_3__.exit)(1);
|
|
62
45
|
}
|
|
63
46
|
}
|
|
64
47
|
async function watchFiles(files, callback) {
|
|
@@ -85,24 +68,23 @@ export const __webpack_modules__ = {
|
|
|
85
68
|
};
|
|
86
69
|
}
|
|
87
70
|
},
|
|
88
|
-
"./src/
|
|
71
|
+
"./src/cli/init.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
89
72
|
__webpack_require__.d(__webpack_exports__, {
|
|
90
|
-
|
|
91
|
-
Mk: ()=>resolveConfigPath
|
|
73
|
+
S: ()=>init
|
|
92
74
|
});
|
|
93
|
-
var
|
|
94
|
-
var
|
|
95
|
-
var
|
|
96
|
-
var
|
|
97
|
-
var
|
|
98
|
-
var
|
|
99
|
-
var
|
|
75
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
76
|
+
var external_node_path_ = __webpack_require__("node:path");
|
|
77
|
+
var external_node_url_ = __webpack_require__("node:url");
|
|
78
|
+
var picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
79
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
80
|
+
var register_ = __webpack_require__("@lynx-js/rspeedy/register");
|
|
81
|
+
var debug = __webpack_require__("./src/debug.ts");
|
|
100
82
|
const resolveConfigPath = (root, customConfig)=>{
|
|
101
83
|
if (customConfig) {
|
|
102
|
-
(0,
|
|
103
|
-
const customConfigPath = (0,
|
|
104
|
-
if (
|
|
105
|
-
throw new Error(`Cannot find config file: ${
|
|
84
|
+
(0, debug.fF)(`load custom config file ${customConfig} from ${root}`);
|
|
85
|
+
const customConfigPath = (0, external_node_path_.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_.join)(root, customConfig);
|
|
86
|
+
if (external_node_fs_["default"].existsSync(customConfigPath)) return customConfigPath;
|
|
87
|
+
throw new Error(`Cannot find config file: ${picocolors_default().dim(customConfigPath)}`);
|
|
106
88
|
}
|
|
107
89
|
const CONFIG_FILES = [
|
|
108
90
|
'lynx.config.ts',
|
|
@@ -111,23 +93,23 @@ export const __webpack_modules__ = {
|
|
|
111
93
|
'lynx.config.mjs'
|
|
112
94
|
];
|
|
113
95
|
for (const file of CONFIG_FILES){
|
|
114
|
-
(0,
|
|
115
|
-
const configFile = (0,
|
|
116
|
-
if (
|
|
117
|
-
(0,
|
|
96
|
+
(0, debug.fF)(`load default config file ${file} from ${root}`);
|
|
97
|
+
const configFile = (0, external_node_path_.join)(root, file);
|
|
98
|
+
if (external_node_fs_["default"].existsSync(configFile)) {
|
|
99
|
+
(0, debug.fF)(`default config ${configFile} found`);
|
|
118
100
|
return configFile;
|
|
119
101
|
}
|
|
120
102
|
}
|
|
121
103
|
throw new Error([
|
|
122
|
-
`Cannot find the default config file: ${
|
|
123
|
-
`Use custom config with ${
|
|
104
|
+
`Cannot find the default config file: ${picocolors_default().dim((0, external_node_path_.join)(root, CONFIG_FILES[0]))}.`,
|
|
105
|
+
`Use custom config with ${picocolors_default().green('`--config <config>`')} options.`
|
|
124
106
|
].join(' '));
|
|
125
107
|
};
|
|
126
108
|
async function loadConfig(loadConfigOptions) {
|
|
127
109
|
let { configPath } = loadConfigOptions;
|
|
128
|
-
if (!configPath || !(0,
|
|
129
|
-
const specifier = (0,
|
|
130
|
-
const unregister = shouldUseNativeImport(configPath) ? ()=>void 0 : (0,
|
|
110
|
+
if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
|
|
111
|
+
const specifier = (0, external_node_url_.pathToFileURL)(configPath).toString();
|
|
112
|
+
const unregister = shouldUseNativeImport(configPath) ? ()=>void 0 : (0, register_.register)();
|
|
131
113
|
try {
|
|
132
114
|
const [exports, { validate }] = await Promise.all([
|
|
133
115
|
import(`${specifier}?t=${Date.now()}`),
|
|
@@ -153,13 +135,38 @@ export const __webpack_modules__ = {
|
|
|
153
135
|
return NODE_OPTIONS.includes('--experimental-transform-types') || NODE_OPTIONS.includes('--experimental-strip-types');
|
|
154
136
|
}
|
|
155
137
|
function isJavaScriptPath(configPath) {
|
|
156
|
-
const ext = (0,
|
|
138
|
+
const ext = (0, external_node_path_.extname)(configPath);
|
|
157
139
|
return [
|
|
158
140
|
'.js',
|
|
159
141
|
'.mjs',
|
|
160
142
|
'.cjs'
|
|
161
143
|
].includes(ext);
|
|
162
144
|
}
|
|
145
|
+
async function init(cwd, options) {
|
|
146
|
+
const { content: rspeedyConfig, configPath } = await loadConfig({
|
|
147
|
+
cwd,
|
|
148
|
+
configPath: options.config
|
|
149
|
+
});
|
|
150
|
+
const createRspeedyOptions = {
|
|
151
|
+
cwd,
|
|
152
|
+
rspeedyConfig
|
|
153
|
+
};
|
|
154
|
+
if (options.noEnv) createRspeedyOptions.loadEnv = false;
|
|
155
|
+
else if (options.envMode) createRspeedyOptions.loadEnv = {
|
|
156
|
+
mode: options.envMode
|
|
157
|
+
};
|
|
158
|
+
if ('base' in options && options.base) {
|
|
159
|
+
rspeedyConfig.server ??= {};
|
|
160
|
+
rspeedyConfig.server.base = options.base;
|
|
161
|
+
}
|
|
162
|
+
if ('environment' in options && options.environment) createRspeedyOptions.environment = options.environment;
|
|
163
|
+
if (options.mode) rspeedyConfig.mode = options.mode;
|
|
164
|
+
return {
|
|
165
|
+
createRspeedyOptions,
|
|
166
|
+
configPath,
|
|
167
|
+
rspeedyConfig
|
|
168
|
+
};
|
|
169
|
+
}
|
|
163
170
|
},
|
|
164
171
|
"./src/create-rspeedy.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
165
172
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -168,11 +175,18 @@ export const __webpack_modules__ = {
|
|
|
168
175
|
var external_node_path_ = __webpack_require__("node:path");
|
|
169
176
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
170
177
|
function applyDefaultRspeedyConfig(config) {
|
|
171
|
-
const ret = (0, core_.mergeRsbuildConfig)(
|
|
178
|
+
const ret = (0, core_.mergeRsbuildConfig)({
|
|
172
179
|
output: {
|
|
173
180
|
filename: getFilename(config.output?.filename)
|
|
181
|
+
},
|
|
182
|
+
tools: {
|
|
183
|
+
rsdoctor: {
|
|
184
|
+
experiments: {
|
|
185
|
+
enableNativePlugin: true
|
|
186
|
+
}
|
|
187
|
+
}
|
|
174
188
|
}
|
|
175
|
-
});
|
|
189
|
+
}, config);
|
|
176
190
|
return ret;
|
|
177
191
|
}
|
|
178
192
|
const DEFAULT_FILENAME = '[name].[platform].bundle';
|
|
@@ -275,6 +289,7 @@ export const __webpack_modules__ = {
|
|
|
275
289
|
plugins: config.plugins,
|
|
276
290
|
performance: {
|
|
277
291
|
chunkSplit: config.performance?.chunkSplit,
|
|
292
|
+
profile: config.performance?.profile,
|
|
278
293
|
removeConsole: toRsbuildRemoveConsole(config),
|
|
279
294
|
printFileSize: config.performance?.printFileSize ?? true
|
|
280
295
|
},
|
package/dist/src_cli_exit_ts.js
CHANGED