@lynx-js/rspeedy 0.9.3 → 0.9.5
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 +82 -4
- package/dist/index.d.ts +232 -22
- package/dist/index.js +16 -5
- package/dist/src_cli_build_ts.js +77 -45
- package/dist/src_cli_commands_ts.js +4 -4
- package/dist/src_cli_dev_ts.js +79 -52
- package/dist/src_cli_exit_ts.js +1 -1
- package/dist/src_cli_inspect_ts.js +99 -66
- package/dist/src_cli_preview_ts.js +101 -73
- package/dist/src_config_validate_ts.js +2674 -2286
- 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 +12 -12
|
@@ -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__);
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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__) {
|
|
43
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
44
|
-
ME: ()=>loadConfig,
|
|
45
|
-
Mk: ()=>resolveConfigPath
|
|
46
|
-
});
|
|
47
|
-
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
48
|
-
var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:path");
|
|
49
|
-
var node_url__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("node:url");
|
|
50
|
-
var picocolors__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
51
|
-
var picocolors__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_5__);
|
|
52
|
-
var _lynx_js_rspeedy_register__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("@lynx-js/rspeedy/register");
|
|
53
|
-
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");
|
|
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,73 @@ 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
|
+
if (rspeedyConfig.performance?.buildCache) if (true === rspeedyConfig.performance.buildCache) rspeedyConfig.performance.buildCache = {
|
|
85
|
+
buildDependencies: [
|
|
86
|
+
configPath
|
|
87
|
+
]
|
|
88
|
+
};
|
|
89
|
+
else {
|
|
90
|
+
rspeedyConfig.performance.buildCache.buildDependencies ??= [];
|
|
91
|
+
rspeedyConfig.performance.buildCache.buildDependencies.push(configPath);
|
|
92
|
+
}
|
|
93
|
+
const createRspeedyOptions = {
|
|
94
|
+
cwd,
|
|
95
|
+
rspeedyConfig
|
|
96
|
+
};
|
|
97
|
+
if (options.noEnv) createRspeedyOptions.loadEnv = false;
|
|
98
|
+
else if (options.envMode) createRspeedyOptions.loadEnv = {
|
|
99
|
+
mode: options.envMode
|
|
100
|
+
};
|
|
101
|
+
if ('base' in options && options.base) {
|
|
102
|
+
rspeedyConfig.server ??= {};
|
|
103
|
+
rspeedyConfig.server.base = options.base;
|
|
104
|
+
}
|
|
105
|
+
if ('environment' in options && options.environment) createRspeedyOptions.environment = options.environment;
|
|
106
|
+
if (options.mode) rspeedyConfig.mode = options.mode;
|
|
107
|
+
return {
|
|
108
|
+
createRspeedyOptions,
|
|
109
|
+
configPath,
|
|
110
|
+
rspeedyConfig
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"./src/cli/inspect.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
115
|
+
__webpack_require__.r(__webpack_exports__);
|
|
116
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
117
|
+
inspect: ()=>inspect
|
|
118
|
+
});
|
|
119
|
+
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("@rsbuild/core");
|
|
120
|
+
var _exit_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./src/cli/exit.ts");
|
|
121
|
+
var _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/create-rspeedy.ts");
|
|
122
|
+
var _init_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/cli/init.ts");
|
|
123
|
+
async function inspect(cwd, inspectOptions) {
|
|
124
|
+
try {
|
|
125
|
+
const { createRspeedyOptions } = await (0, _init_js__WEBPACK_IMPORTED_MODULE_3__.S)(cwd, inspectOptions);
|
|
126
|
+
const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_2__.S)(createRspeedyOptions);
|
|
127
|
+
await rspeedy.inspectConfig({
|
|
128
|
+
mode: inspectOptions.mode ?? process.env['NODE_ENV'] ?? 'development',
|
|
129
|
+
verbose: inspectOptions.verbose ?? false,
|
|
130
|
+
outputPath: inspectOptions.output,
|
|
131
|
+
writeToDisk: true
|
|
132
|
+
});
|
|
133
|
+
return (0, _exit_js__WEBPACK_IMPORTED_MODULE_1__.exit)();
|
|
134
|
+
} catch (error) {
|
|
135
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.logger.error(error);
|
|
136
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.logger.error();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
117
139
|
},
|
|
118
140
|
"./src/create-rspeedy.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
119
141
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -122,11 +144,18 @@ export const __webpack_modules__ = {
|
|
|
122
144
|
var external_node_path_ = __webpack_require__("node:path");
|
|
123
145
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
124
146
|
function applyDefaultRspeedyConfig(config) {
|
|
125
|
-
const ret = (0, core_.mergeRsbuildConfig)(
|
|
147
|
+
const ret = (0, core_.mergeRsbuildConfig)({
|
|
126
148
|
output: {
|
|
127
149
|
filename: getFilename(config.output?.filename)
|
|
150
|
+
},
|
|
151
|
+
tools: {
|
|
152
|
+
rsdoctor: {
|
|
153
|
+
experiments: {
|
|
154
|
+
enableNativePlugin: true
|
|
155
|
+
}
|
|
156
|
+
}
|
|
128
157
|
}
|
|
129
|
-
});
|
|
158
|
+
}, config);
|
|
130
159
|
return ret;
|
|
131
160
|
}
|
|
132
161
|
const DEFAULT_FILENAME = '[name].[platform].bundle';
|
|
@@ -216,6 +245,7 @@ export const __webpack_modules__ = {
|
|
|
216
245
|
entry: toRsbuildEntry(config.source?.entry),
|
|
217
246
|
exclude: config.source?.exclude,
|
|
218
247
|
include: config.source?.include,
|
|
248
|
+
preEntry: config.source?.preEntry,
|
|
219
249
|
transformImport: config.source?.transformImport,
|
|
220
250
|
tsconfigPath: config.source?.tsconfigPath
|
|
221
251
|
},
|
|
@@ -228,7 +258,9 @@ export const __webpack_modules__ = {
|
|
|
228
258
|
},
|
|
229
259
|
plugins: config.plugins,
|
|
230
260
|
performance: {
|
|
261
|
+
buildCache: config.performance?.buildCache,
|
|
231
262
|
chunkSplit: config.performance?.chunkSplit,
|
|
263
|
+
profile: config.performance?.profile,
|
|
232
264
|
removeConsole: toRsbuildRemoveConsole(config),
|
|
233
265
|
printFileSize: config.performance?.printFileSize ?? true
|
|
234
266
|
},
|
|
@@ -254,14 +286,15 @@ export const __webpack_modules__ = {
|
|
|
254
286
|
];
|
|
255
287
|
return config.performance?.removeConsole;
|
|
256
288
|
}
|
|
257
|
-
async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [] }) {
|
|
289
|
+
async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [], callerName = 'rspeedy' }) {
|
|
258
290
|
const config = applyDefaultRspeedyConfig(rspeedyConfig);
|
|
259
291
|
const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
|
|
260
292
|
(0, core_.createRsbuild)({
|
|
261
293
|
cwd,
|
|
262
294
|
loadEnv,
|
|
263
295
|
rsbuildConfig: toRsbuildConfig(config),
|
|
264
|
-
environment
|
|
296
|
+
environment,
|
|
297
|
+
callerName
|
|
265
298
|
}),
|
|
266
299
|
__webpack_require__.e("src_plugins_index_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/index.ts"))
|
|
267
300
|
]);
|
|
@@ -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,75 @@ 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
|
+
if (rspeedyConfig.performance?.buildCache) if (true === rspeedyConfig.performance.buildCache) rspeedyConfig.performance.buildCache = {
|
|
85
|
+
buildDependencies: [
|
|
86
|
+
configPath
|
|
87
|
+
]
|
|
88
|
+
};
|
|
89
|
+
else {
|
|
90
|
+
rspeedyConfig.performance.buildCache.buildDependencies ??= [];
|
|
91
|
+
rspeedyConfig.performance.buildCache.buildDependencies.push(configPath);
|
|
92
|
+
}
|
|
93
|
+
const createRspeedyOptions = {
|
|
94
|
+
cwd,
|
|
95
|
+
rspeedyConfig
|
|
96
|
+
};
|
|
97
|
+
if (options.noEnv) createRspeedyOptions.loadEnv = false;
|
|
98
|
+
else if (options.envMode) createRspeedyOptions.loadEnv = {
|
|
99
|
+
mode: options.envMode
|
|
100
|
+
};
|
|
101
|
+
if ('base' in options && options.base) {
|
|
102
|
+
rspeedyConfig.server ??= {};
|
|
103
|
+
rspeedyConfig.server.base = options.base;
|
|
104
|
+
}
|
|
105
|
+
if ('environment' in options && options.environment) createRspeedyOptions.environment = options.environment;
|
|
106
|
+
if (options.mode) rspeedyConfig.mode = options.mode;
|
|
107
|
+
return {
|
|
108
|
+
createRspeedyOptions,
|
|
109
|
+
configPath,
|
|
110
|
+
rspeedyConfig
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"./src/cli/preview.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
115
|
+
__webpack_require__.r(__webpack_exports__);
|
|
116
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
117
|
+
preview: ()=>preview
|
|
118
|
+
});
|
|
119
|
+
var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
|
|
120
|
+
var _rsbuild_core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("@rsbuild/core");
|
|
121
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
122
|
+
var picocolors__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_5__);
|
|
123
|
+
var _exit_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/cli/exit.ts");
|
|
124
|
+
var _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./src/create-rspeedy.ts");
|
|
125
|
+
var _init_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/cli/init.ts");
|
|
126
|
+
async function preview(cwd, previewOptions) {
|
|
127
|
+
try {
|
|
128
|
+
const { createRspeedyOptions } = await (0, _init_js__WEBPACK_IMPORTED_MODULE_4__.S)(cwd, previewOptions);
|
|
129
|
+
const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_3__.S)(createRspeedyOptions);
|
|
130
|
+
await rspeedy.initConfigs();
|
|
131
|
+
const { distPath } = rspeedy.context;
|
|
132
|
+
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.`);
|
|
133
|
+
await rspeedy.preview();
|
|
134
|
+
} catch (error) {
|
|
135
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_1__.logger.error('Failed to start preview server.');
|
|
136
|
+
_rsbuild_core__WEBPACK_IMPORTED_MODULE_1__.logger.error(error);
|
|
137
|
+
(0, _exit_js__WEBPACK_IMPORTED_MODULE_2__.exit)(1);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
124
141
|
},
|
|
125
142
|
"./src/create-rspeedy.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
126
143
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -129,11 +146,18 @@ export const __webpack_modules__ = {
|
|
|
129
146
|
var external_node_path_ = __webpack_require__("node:path");
|
|
130
147
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
131
148
|
function applyDefaultRspeedyConfig(config) {
|
|
132
|
-
const ret = (0, core_.mergeRsbuildConfig)(
|
|
149
|
+
const ret = (0, core_.mergeRsbuildConfig)({
|
|
133
150
|
output: {
|
|
134
151
|
filename: getFilename(config.output?.filename)
|
|
152
|
+
},
|
|
153
|
+
tools: {
|
|
154
|
+
rsdoctor: {
|
|
155
|
+
experiments: {
|
|
156
|
+
enableNativePlugin: true
|
|
157
|
+
}
|
|
158
|
+
}
|
|
135
159
|
}
|
|
136
|
-
});
|
|
160
|
+
}, config);
|
|
137
161
|
return ret;
|
|
138
162
|
}
|
|
139
163
|
const DEFAULT_FILENAME = '[name].[platform].bundle';
|
|
@@ -223,6 +247,7 @@ export const __webpack_modules__ = {
|
|
|
223
247
|
entry: toRsbuildEntry(config.source?.entry),
|
|
224
248
|
exclude: config.source?.exclude,
|
|
225
249
|
include: config.source?.include,
|
|
250
|
+
preEntry: config.source?.preEntry,
|
|
226
251
|
transformImport: config.source?.transformImport,
|
|
227
252
|
tsconfigPath: config.source?.tsconfigPath
|
|
228
253
|
},
|
|
@@ -235,7 +260,9 @@ export const __webpack_modules__ = {
|
|
|
235
260
|
},
|
|
236
261
|
plugins: config.plugins,
|
|
237
262
|
performance: {
|
|
263
|
+
buildCache: config.performance?.buildCache,
|
|
238
264
|
chunkSplit: config.performance?.chunkSplit,
|
|
265
|
+
profile: config.performance?.profile,
|
|
239
266
|
removeConsole: toRsbuildRemoveConsole(config),
|
|
240
267
|
printFileSize: config.performance?.printFileSize ?? true
|
|
241
268
|
},
|
|
@@ -261,14 +288,15 @@ export const __webpack_modules__ = {
|
|
|
261
288
|
];
|
|
262
289
|
return config.performance?.removeConsole;
|
|
263
290
|
}
|
|
264
|
-
async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [] }) {
|
|
291
|
+
async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [], callerName = 'rspeedy' }) {
|
|
265
292
|
const config = applyDefaultRspeedyConfig(rspeedyConfig);
|
|
266
293
|
const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
|
|
267
294
|
(0, core_.createRsbuild)({
|
|
268
295
|
cwd,
|
|
269
296
|
loadEnv,
|
|
270
297
|
rsbuildConfig: toRsbuildConfig(config),
|
|
271
|
-
environment
|
|
298
|
+
environment,
|
|
299
|
+
callerName
|
|
272
300
|
}),
|
|
273
301
|
__webpack_require__.e("src_plugins_index_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/index.ts"))
|
|
274
302
|
]);
|