@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
|
@@ -1,62 +1,24 @@
|
|
|
1
1
|
export const __webpack_ids__ = [
|
|
2
|
-
|
|
2
|
+
"src_cli_inspect_ts"
|
|
3
3
|
];
|
|
4
4
|
export const __webpack_modules__ = {
|
|
5
|
-
"./src/cli/
|
|
6
|
-
__webpack_require__.r(__webpack_exports__);
|
|
7
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
-
inspect: ()=>inspect
|
|
9
|
-
});
|
|
10
|
-
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("@rsbuild/core");
|
|
11
|
-
var _exit_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/cli/exit.ts");
|
|
12
|
-
var _config_loadConfig_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/config/loadConfig.ts");
|
|
13
|
-
var _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/create-rspeedy.ts");
|
|
14
|
-
async function inspect(cwd, inspectOptions) {
|
|
15
|
-
try {
|
|
16
|
-
const { content: rspeedyConfig } = await (0, _config_loadConfig_js__WEBPACK_IMPORTED_MODULE_2__.ME)({
|
|
17
|
-
cwd,
|
|
18
|
-
configPath: inspectOptions.config
|
|
19
|
-
});
|
|
20
|
-
const options = {
|
|
21
|
-
cwd,
|
|
22
|
-
rspeedyConfig
|
|
23
|
-
};
|
|
24
|
-
if (inspectOptions.noEnv) options.loadEnv = false;
|
|
25
|
-
else if (inspectOptions.envMode) options.loadEnv = {
|
|
26
|
-
mode: inspectOptions.envMode
|
|
27
|
-
};
|
|
28
|
-
const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_3__.S)(options);
|
|
29
|
-
await rspeedy.inspectConfig({
|
|
30
|
-
mode: inspectOptions.mode ?? process.env['NODE_ENV'] ?? 'development',
|
|
31
|
-
verbose: inspectOptions.verbose ?? false,
|
|
32
|
-
outputPath: inspectOptions.output,
|
|
33
|
-
writeToDisk: true
|
|
34
|
-
});
|
|
35
|
-
return (0, _exit_js__WEBPACK_IMPORTED_MODULE_1__.exit)();
|
|
36
|
-
} catch (error) {
|
|
37
|
-
_rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.logger.error(error);
|
|
38
|
-
_rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.logger.error();
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
"./src/config/loadConfig.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5
|
+
"./src/cli/init.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
43
6
|
__webpack_require__.d(__webpack_exports__, {
|
|
44
|
-
|
|
45
|
-
Mk: ()=>resolveConfigPath
|
|
7
|
+
S: ()=>init
|
|
46
8
|
});
|
|
47
|
-
var
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var
|
|
52
|
-
var
|
|
53
|
-
var
|
|
9
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
10
|
+
var external_node_path_ = __webpack_require__("node:path");
|
|
11
|
+
var external_node_url_ = __webpack_require__("node:url");
|
|
12
|
+
var picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
13
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
14
|
+
var register_ = __webpack_require__("@lynx-js/rspeedy/register");
|
|
15
|
+
var debug = __webpack_require__("./src/debug.ts");
|
|
54
16
|
const resolveConfigPath = (root, customConfig)=>{
|
|
55
17
|
if (customConfig) {
|
|
56
|
-
(0,
|
|
57
|
-
const customConfigPath = (0,
|
|
58
|
-
if (
|
|
59
|
-
throw new Error(`Cannot find config file: ${
|
|
18
|
+
(0, debug.fF)(`load custom config file ${customConfig} from ${root}`);
|
|
19
|
+
const customConfigPath = (0, external_node_path_.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_.join)(root, customConfig);
|
|
20
|
+
if (external_node_fs_["default"].existsSync(customConfigPath)) return customConfigPath;
|
|
21
|
+
throw new Error(`Cannot find config file: ${picocolors_default().dim(customConfigPath)}`);
|
|
60
22
|
}
|
|
61
23
|
const CONFIG_FILES = [
|
|
62
24
|
'lynx.config.ts',
|
|
@@ -65,23 +27,23 @@ export const __webpack_modules__ = {
|
|
|
65
27
|
'lynx.config.mjs'
|
|
66
28
|
];
|
|
67
29
|
for (const file of CONFIG_FILES){
|
|
68
|
-
(0,
|
|
69
|
-
const configFile = (0,
|
|
70
|
-
if (
|
|
71
|
-
(0,
|
|
30
|
+
(0, debug.fF)(`load default config file ${file} from ${root}`);
|
|
31
|
+
const configFile = (0, external_node_path_.join)(root, file);
|
|
32
|
+
if (external_node_fs_["default"].existsSync(configFile)) {
|
|
33
|
+
(0, debug.fF)(`default config ${configFile} found`);
|
|
72
34
|
return configFile;
|
|
73
35
|
}
|
|
74
36
|
}
|
|
75
37
|
throw new Error([
|
|
76
|
-
`Cannot find the default config file: ${
|
|
77
|
-
`Use custom config with ${
|
|
38
|
+
`Cannot find the default config file: ${picocolors_default().dim((0, external_node_path_.join)(root, CONFIG_FILES[0]))}.`,
|
|
39
|
+
`Use custom config with ${picocolors_default().green('`--config <config>`')} options.`
|
|
78
40
|
].join(' '));
|
|
79
41
|
};
|
|
80
42
|
async function loadConfig(loadConfigOptions) {
|
|
81
43
|
let { configPath } = loadConfigOptions;
|
|
82
|
-
if (!configPath || !(0,
|
|
83
|
-
const specifier = (0,
|
|
84
|
-
const unregister = shouldUseNativeImport(configPath) ? ()=>void 0 : (0,
|
|
44
|
+
if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
|
|
45
|
+
const specifier = (0, external_node_url_.pathToFileURL)(configPath).toString();
|
|
46
|
+
const unregister = shouldUseNativeImport(configPath) ? ()=>void 0 : (0, register_.register)();
|
|
85
47
|
try {
|
|
86
48
|
const [exports, { validate }] = await Promise.all([
|
|
87
49
|
import(`${specifier}?t=${Date.now()}`),
|
|
@@ -107,13 +69,64 @@ export const __webpack_modules__ = {
|
|
|
107
69
|
return NODE_OPTIONS.includes('--experimental-transform-types') || NODE_OPTIONS.includes('--experimental-strip-types');
|
|
108
70
|
}
|
|
109
71
|
function isJavaScriptPath(configPath) {
|
|
110
|
-
const ext = (0,
|
|
72
|
+
const ext = (0, external_node_path_.extname)(configPath);
|
|
111
73
|
return [
|
|
112
74
|
'.js',
|
|
113
75
|
'.mjs',
|
|
114
76
|
'.cjs'
|
|
115
77
|
].includes(ext);
|
|
116
78
|
}
|
|
79
|
+
async function init(cwd, options) {
|
|
80
|
+
const { content: rspeedyConfig, configPath } = await loadConfig({
|
|
81
|
+
cwd,
|
|
82
|
+
configPath: options.config
|
|
83
|
+
});
|
|
84
|
+
const createRspeedyOptions = {
|
|
85
|
+
cwd,
|
|
86
|
+
rspeedyConfig
|
|
87
|
+
};
|
|
88
|
+
if (options.noEnv) createRspeedyOptions.loadEnv = false;
|
|
89
|
+
else if (options.envMode) createRspeedyOptions.loadEnv = {
|
|
90
|
+
mode: options.envMode
|
|
91
|
+
};
|
|
92
|
+
if ('base' in options && options.base) {
|
|
93
|
+
rspeedyConfig.server ??= {};
|
|
94
|
+
rspeedyConfig.server.base = options.base;
|
|
95
|
+
}
|
|
96
|
+
if ('environment' in options && options.environment) createRspeedyOptions.environment = options.environment;
|
|
97
|
+
if (options.mode) rspeedyConfig.mode = options.mode;
|
|
98
|
+
return {
|
|
99
|
+
createRspeedyOptions,
|
|
100
|
+
configPath,
|
|
101
|
+
rspeedyConfig
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"./src/cli/inspect.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
106
|
+
__webpack_require__.r(__webpack_exports__);
|
|
107
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
108
|
+
inspect: ()=>inspect
|
|
109
|
+
});
|
|
110
|
+
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("@rsbuild/core");
|
|
111
|
+
var _exit_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/cli/exit.ts");
|
|
112
|
+
var _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/create-rspeedy.ts");
|
|
113
|
+
var _init_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/cli/init.ts");
|
|
114
|
+
async function inspect(cwd, inspectOptions) {
|
|
115
|
+
try {
|
|
116
|
+
const { createRspeedyOptions } = await (0, _init_js__WEBPACK_IMPORTED_MODULE_3__.S)(cwd, inspectOptions);
|
|
117
|
+
const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_2__.S)(createRspeedyOptions);
|
|
118
|
+
await rspeedy.inspectConfig({
|
|
119
|
+
mode: inspectOptions.mode ?? process.env['NODE_ENV'] ?? 'development',
|
|
120
|
+
verbose: inspectOptions.verbose ?? false,
|
|
121
|
+
outputPath: inspectOptions.output,
|
|
122
|
+
writeToDisk: true
|
|
123
|
+
});
|
|
124
|
+
return (0, _exit_js__WEBPACK_IMPORTED_MODULE_1__.exit)();
|
|
125
|
+
} catch (error) {
|
|
126
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.logger.error(error);
|
|
127
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.logger.error();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
117
130
|
},
|
|
118
131
|
"./src/create-rspeedy.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
119
132
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -122,11 +135,18 @@ export const __webpack_modules__ = {
|
|
|
122
135
|
var external_node_path_ = __webpack_require__("node:path");
|
|
123
136
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
124
137
|
function applyDefaultRspeedyConfig(config) {
|
|
125
|
-
const ret = (0, core_.mergeRsbuildConfig)(
|
|
138
|
+
const ret = (0, core_.mergeRsbuildConfig)({
|
|
126
139
|
output: {
|
|
127
140
|
filename: getFilename(config.output?.filename)
|
|
141
|
+
},
|
|
142
|
+
tools: {
|
|
143
|
+
rsdoctor: {
|
|
144
|
+
experiments: {
|
|
145
|
+
enableNativePlugin: true
|
|
146
|
+
}
|
|
147
|
+
}
|
|
128
148
|
}
|
|
129
|
-
});
|
|
149
|
+
}, config);
|
|
130
150
|
return ret;
|
|
131
151
|
}
|
|
132
152
|
const DEFAULT_FILENAME = '[name].[platform].bundle';
|
|
@@ -229,6 +249,7 @@ export const __webpack_modules__ = {
|
|
|
229
249
|
plugins: config.plugins,
|
|
230
250
|
performance: {
|
|
231
251
|
chunkSplit: config.performance?.chunkSplit,
|
|
252
|
+
profile: config.performance?.profile,
|
|
232
253
|
removeConsole: toRsbuildRemoveConsole(config),
|
|
233
254
|
printFileSize: config.performance?.printFileSize ?? true
|
|
234
255
|
},
|
|
@@ -1,69 +1,24 @@
|
|
|
1
1
|
export const __webpack_ids__ = [
|
|
2
|
-
|
|
2
|
+
"src_cli_preview_ts"
|
|
3
3
|
];
|
|
4
4
|
export const __webpack_modules__ = {
|
|
5
|
-
"./src/cli/
|
|
6
|
-
__webpack_require__.r(__webpack_exports__);
|
|
5
|
+
"./src/cli/init.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
7
6
|
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
-
|
|
7
|
+
S: ()=>init
|
|
9
8
|
});
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
async function preview(cwd, previewOptions) {
|
|
18
|
-
try {
|
|
19
|
-
const configPath = (0, _config_loadConfig_js__WEBPACK_IMPORTED_MODULE_3__.Mk)(cwd, previewOptions.config);
|
|
20
|
-
const { content: rspeedyConfig } = await (0, _config_loadConfig_js__WEBPACK_IMPORTED_MODULE_3__.ME)({
|
|
21
|
-
cwd,
|
|
22
|
-
configPath
|
|
23
|
-
});
|
|
24
|
-
if (previewOptions.base) {
|
|
25
|
-
rspeedyConfig.server ??= {};
|
|
26
|
-
rspeedyConfig.server.base = previewOptions.base;
|
|
27
|
-
}
|
|
28
|
-
const options = {
|
|
29
|
-
cwd,
|
|
30
|
-
rspeedyConfig
|
|
31
|
-
};
|
|
32
|
-
if (previewOptions.noEnv) options.loadEnv = false;
|
|
33
|
-
else if (previewOptions.envMode) options.loadEnv = {
|
|
34
|
-
mode: previewOptions.envMode
|
|
35
|
-
};
|
|
36
|
-
const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_4__.S)(options);
|
|
37
|
-
await rspeedy.initConfigs();
|
|
38
|
-
const { distPath } = rspeedy.context;
|
|
39
|
-
if (!node_fs__WEBPACK_IMPORTED_MODULE_0__["default"].existsSync(distPath)) throw new Error(`The output directory ${picocolors__WEBPACK_IMPORTED_MODULE_5___default().yellow(distPath)} does not exist, please build the project before previewing.`);
|
|
40
|
-
await rspeedy.preview();
|
|
41
|
-
} catch (error) {
|
|
42
|
-
_rsbuild_core__WEBPACK_IMPORTED_MODULE_1__.logger.error('Failed to start preview server.');
|
|
43
|
-
_rsbuild_core__WEBPACK_IMPORTED_MODULE_1__.logger.error(error);
|
|
44
|
-
(0, _exit_js__WEBPACK_IMPORTED_MODULE_2__.exit)(1);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
"./src/config/loadConfig.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
50
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
51
|
-
ME: ()=>loadConfig,
|
|
52
|
-
Mk: ()=>resolveConfigPath
|
|
53
|
-
});
|
|
54
|
-
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
55
|
-
var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:path");
|
|
56
|
-
var node_url__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("node:url");
|
|
57
|
-
var picocolors__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
58
|
-
var picocolors__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_5__);
|
|
59
|
-
var _lynx_js_rspeedy_register__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("@lynx-js/rspeedy/register");
|
|
60
|
-
var _debug_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/debug.ts");
|
|
9
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
10
|
+
var external_node_path_ = __webpack_require__("node:path");
|
|
11
|
+
var external_node_url_ = __webpack_require__("node:url");
|
|
12
|
+
var picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
13
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
14
|
+
var register_ = __webpack_require__("@lynx-js/rspeedy/register");
|
|
15
|
+
var debug = __webpack_require__("./src/debug.ts");
|
|
61
16
|
const resolveConfigPath = (root, customConfig)=>{
|
|
62
17
|
if (customConfig) {
|
|
63
|
-
(0,
|
|
64
|
-
const customConfigPath = (0,
|
|
65
|
-
if (
|
|
66
|
-
throw new Error(`Cannot find config file: ${
|
|
18
|
+
(0, debug.fF)(`load custom config file ${customConfig} from ${root}`);
|
|
19
|
+
const customConfigPath = (0, external_node_path_.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_.join)(root, customConfig);
|
|
20
|
+
if (external_node_fs_["default"].existsSync(customConfigPath)) return customConfigPath;
|
|
21
|
+
throw new Error(`Cannot find config file: ${picocolors_default().dim(customConfigPath)}`);
|
|
67
22
|
}
|
|
68
23
|
const CONFIG_FILES = [
|
|
69
24
|
'lynx.config.ts',
|
|
@@ -72,23 +27,23 @@ export const __webpack_modules__ = {
|
|
|
72
27
|
'lynx.config.mjs'
|
|
73
28
|
];
|
|
74
29
|
for (const file of CONFIG_FILES){
|
|
75
|
-
(0,
|
|
76
|
-
const configFile = (0,
|
|
77
|
-
if (
|
|
78
|
-
(0,
|
|
30
|
+
(0, debug.fF)(`load default config file ${file} from ${root}`);
|
|
31
|
+
const configFile = (0, external_node_path_.join)(root, file);
|
|
32
|
+
if (external_node_fs_["default"].existsSync(configFile)) {
|
|
33
|
+
(0, debug.fF)(`default config ${configFile} found`);
|
|
79
34
|
return configFile;
|
|
80
35
|
}
|
|
81
36
|
}
|
|
82
37
|
throw new Error([
|
|
83
|
-
`Cannot find the default config file: ${
|
|
84
|
-
`Use custom config with ${
|
|
38
|
+
`Cannot find the default config file: ${picocolors_default().dim((0, external_node_path_.join)(root, CONFIG_FILES[0]))}.`,
|
|
39
|
+
`Use custom config with ${picocolors_default().green('`--config <config>`')} options.`
|
|
85
40
|
].join(' '));
|
|
86
41
|
};
|
|
87
42
|
async function loadConfig(loadConfigOptions) {
|
|
88
43
|
let { configPath } = loadConfigOptions;
|
|
89
|
-
if (!configPath || !(0,
|
|
90
|
-
const specifier = (0,
|
|
91
|
-
const unregister = shouldUseNativeImport(configPath) ? ()=>void 0 : (0,
|
|
44
|
+
if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
|
|
45
|
+
const specifier = (0, external_node_url_.pathToFileURL)(configPath).toString();
|
|
46
|
+
const unregister = shouldUseNativeImport(configPath) ? ()=>void 0 : (0, register_.register)();
|
|
92
47
|
try {
|
|
93
48
|
const [exports, { validate }] = await Promise.all([
|
|
94
49
|
import(`${specifier}?t=${Date.now()}`),
|
|
@@ -114,13 +69,66 @@ export const __webpack_modules__ = {
|
|
|
114
69
|
return NODE_OPTIONS.includes('--experimental-transform-types') || NODE_OPTIONS.includes('--experimental-strip-types');
|
|
115
70
|
}
|
|
116
71
|
function isJavaScriptPath(configPath) {
|
|
117
|
-
const ext = (0,
|
|
72
|
+
const ext = (0, external_node_path_.extname)(configPath);
|
|
118
73
|
return [
|
|
119
74
|
'.js',
|
|
120
75
|
'.mjs',
|
|
121
76
|
'.cjs'
|
|
122
77
|
].includes(ext);
|
|
123
78
|
}
|
|
79
|
+
async function init(cwd, options) {
|
|
80
|
+
const { content: rspeedyConfig, configPath } = await loadConfig({
|
|
81
|
+
cwd,
|
|
82
|
+
configPath: options.config
|
|
83
|
+
});
|
|
84
|
+
const createRspeedyOptions = {
|
|
85
|
+
cwd,
|
|
86
|
+
rspeedyConfig
|
|
87
|
+
};
|
|
88
|
+
if (options.noEnv) createRspeedyOptions.loadEnv = false;
|
|
89
|
+
else if (options.envMode) createRspeedyOptions.loadEnv = {
|
|
90
|
+
mode: options.envMode
|
|
91
|
+
};
|
|
92
|
+
if ('base' in options && options.base) {
|
|
93
|
+
rspeedyConfig.server ??= {};
|
|
94
|
+
rspeedyConfig.server.base = options.base;
|
|
95
|
+
}
|
|
96
|
+
if ('environment' in options && options.environment) createRspeedyOptions.environment = options.environment;
|
|
97
|
+
if (options.mode) rspeedyConfig.mode = options.mode;
|
|
98
|
+
return {
|
|
99
|
+
createRspeedyOptions,
|
|
100
|
+
configPath,
|
|
101
|
+
rspeedyConfig
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"./src/cli/preview.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
106
|
+
__webpack_require__.r(__webpack_exports__);
|
|
107
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
108
|
+
preview: ()=>preview
|
|
109
|
+
});
|
|
110
|
+
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
111
|
+
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("@rsbuild/core");
|
|
112
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
113
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_5__);
|
|
114
|
+
var _exit_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/cli/exit.ts");
|
|
115
|
+
var _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/create-rspeedy.ts");
|
|
116
|
+
var _init_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/cli/init.ts");
|
|
117
|
+
async function preview(cwd, previewOptions) {
|
|
118
|
+
try {
|
|
119
|
+
const { createRspeedyOptions } = await (0, _init_js__WEBPACK_IMPORTED_MODULE_4__.S)(cwd, previewOptions);
|
|
120
|
+
const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_3__.S)(createRspeedyOptions);
|
|
121
|
+
await rspeedy.initConfigs();
|
|
122
|
+
const { distPath } = rspeedy.context;
|
|
123
|
+
if (!node_fs__WEBPACK_IMPORTED_MODULE_0__["default"].existsSync(distPath)) throw new Error(`The output directory ${picocolors__WEBPACK_IMPORTED_MODULE_5___default().yellow(distPath)} does not exist, please build the project before previewing.`);
|
|
124
|
+
await rspeedy.preview();
|
|
125
|
+
} catch (error) {
|
|
126
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_1__.logger.error('Failed to start preview server.');
|
|
127
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_1__.logger.error(error);
|
|
128
|
+
(0, _exit_js__WEBPACK_IMPORTED_MODULE_2__.exit)(1);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
124
132
|
},
|
|
125
133
|
"./src/create-rspeedy.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
126
134
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -129,11 +137,18 @@ export const __webpack_modules__ = {
|
|
|
129
137
|
var external_node_path_ = __webpack_require__("node:path");
|
|
130
138
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
131
139
|
function applyDefaultRspeedyConfig(config) {
|
|
132
|
-
const ret = (0, core_.mergeRsbuildConfig)(
|
|
140
|
+
const ret = (0, core_.mergeRsbuildConfig)({
|
|
133
141
|
output: {
|
|
134
142
|
filename: getFilename(config.output?.filename)
|
|
143
|
+
},
|
|
144
|
+
tools: {
|
|
145
|
+
rsdoctor: {
|
|
146
|
+
experiments: {
|
|
147
|
+
enableNativePlugin: true
|
|
148
|
+
}
|
|
149
|
+
}
|
|
135
150
|
}
|
|
136
|
-
});
|
|
151
|
+
}, config);
|
|
137
152
|
return ret;
|
|
138
153
|
}
|
|
139
154
|
const DEFAULT_FILENAME = '[name].[platform].bundle';
|
|
@@ -236,6 +251,7 @@ export const __webpack_modules__ = {
|
|
|
236
251
|
plugins: config.plugins,
|
|
237
252
|
performance: {
|
|
238
253
|
chunkSplit: config.performance?.chunkSplit,
|
|
254
|
+
profile: config.performance?.profile,
|
|
239
255
|
removeConsole: toRsbuildRemoveConsole(config),
|
|
240
256
|
printFileSize: config.performance?.printFileSize ?? true
|
|
241
257
|
},
|