@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
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,47 @@ 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
|
+
if (rspeedyConfig.performance?.buildCache) if (true === rspeedyConfig.performance.buildCache) rspeedyConfig.performance.buildCache = {
|
|
108
|
+
buildDependencies: [
|
|
109
|
+
configPath
|
|
110
|
+
]
|
|
111
|
+
};
|
|
112
|
+
else {
|
|
113
|
+
rspeedyConfig.performance.buildCache.buildDependencies ??= [];
|
|
114
|
+
rspeedyConfig.performance.buildCache.buildDependencies.push(configPath);
|
|
115
|
+
}
|
|
116
|
+
const createRspeedyOptions = {
|
|
117
|
+
cwd,
|
|
118
|
+
rspeedyConfig
|
|
119
|
+
};
|
|
120
|
+
if (options.noEnv) createRspeedyOptions.loadEnv = false;
|
|
121
|
+
else if (options.envMode) createRspeedyOptions.loadEnv = {
|
|
122
|
+
mode: options.envMode
|
|
123
|
+
};
|
|
124
|
+
if ('base' in options && options.base) {
|
|
125
|
+
rspeedyConfig.server ??= {};
|
|
126
|
+
rspeedyConfig.server.base = options.base;
|
|
127
|
+
}
|
|
128
|
+
if ('environment' in options && options.environment) createRspeedyOptions.environment = options.environment;
|
|
129
|
+
if (options.mode) rspeedyConfig.mode = options.mode;
|
|
130
|
+
return {
|
|
131
|
+
createRspeedyOptions,
|
|
132
|
+
configPath,
|
|
133
|
+
rspeedyConfig
|
|
134
|
+
};
|
|
135
|
+
}
|
|
115
136
|
},
|
|
116
137
|
"./src/create-rspeedy.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
117
138
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -120,11 +141,18 @@ export const __webpack_modules__ = {
|
|
|
120
141
|
var external_node_path_ = __webpack_require__("node:path");
|
|
121
142
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
122
143
|
function applyDefaultRspeedyConfig(config) {
|
|
123
|
-
const ret = (0, core_.mergeRsbuildConfig)(
|
|
144
|
+
const ret = (0, core_.mergeRsbuildConfig)({
|
|
124
145
|
output: {
|
|
125
146
|
filename: getFilename(config.output?.filename)
|
|
147
|
+
},
|
|
148
|
+
tools: {
|
|
149
|
+
rsdoctor: {
|
|
150
|
+
experiments: {
|
|
151
|
+
enableNativePlugin: true
|
|
152
|
+
}
|
|
153
|
+
}
|
|
126
154
|
}
|
|
127
|
-
});
|
|
155
|
+
}, config);
|
|
128
156
|
return ret;
|
|
129
157
|
}
|
|
130
158
|
const DEFAULT_FILENAME = '[name].[platform].bundle';
|
|
@@ -214,6 +242,7 @@ export const __webpack_modules__ = {
|
|
|
214
242
|
entry: toRsbuildEntry(config.source?.entry),
|
|
215
243
|
exclude: config.source?.exclude,
|
|
216
244
|
include: config.source?.include,
|
|
245
|
+
preEntry: config.source?.preEntry,
|
|
217
246
|
transformImport: config.source?.transformImport,
|
|
218
247
|
tsconfigPath: config.source?.tsconfigPath
|
|
219
248
|
},
|
|
@@ -226,7 +255,9 @@ export const __webpack_modules__ = {
|
|
|
226
255
|
},
|
|
227
256
|
plugins: config.plugins,
|
|
228
257
|
performance: {
|
|
258
|
+
buildCache: config.performance?.buildCache,
|
|
229
259
|
chunkSplit: config.performance?.chunkSplit,
|
|
260
|
+
profile: config.performance?.profile,
|
|
230
261
|
removeConsole: toRsbuildRemoveConsole(config),
|
|
231
262
|
printFileSize: config.performance?.printFileSize ?? true
|
|
232
263
|
},
|
|
@@ -252,14 +283,15 @@ export const __webpack_modules__ = {
|
|
|
252
283
|
];
|
|
253
284
|
return config.performance?.removeConsole;
|
|
254
285
|
}
|
|
255
|
-
async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [] }) {
|
|
286
|
+
async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [], callerName = 'rspeedy' }) {
|
|
256
287
|
const config = applyDefaultRspeedyConfig(rspeedyConfig);
|
|
257
288
|
const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
|
|
258
289
|
(0, core_.createRsbuild)({
|
|
259
290
|
cwd,
|
|
260
291
|
loadEnv,
|
|
261
292
|
rsbuildConfig: toRsbuildConfig(config),
|
|
262
|
-
environment
|
|
293
|
+
environment,
|
|
294
|
+
callerName
|
|
263
295
|
}),
|
|
264
296
|
__webpack_require__.e("src_plugins_index_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/index.ts"))
|
|
265
297
|
]);
|
|
@@ -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.5"
|
|
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,47 @@ 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
|
+
if (rspeedyConfig.performance?.buildCache) if (true === rspeedyConfig.performance.buildCache) rspeedyConfig.performance.buildCache = {
|
|
151
|
+
buildDependencies: [
|
|
152
|
+
configPath
|
|
153
|
+
]
|
|
154
|
+
};
|
|
155
|
+
else {
|
|
156
|
+
rspeedyConfig.performance.buildCache.buildDependencies ??= [];
|
|
157
|
+
rspeedyConfig.performance.buildCache.buildDependencies.push(configPath);
|
|
158
|
+
}
|
|
159
|
+
const createRspeedyOptions = {
|
|
160
|
+
cwd,
|
|
161
|
+
rspeedyConfig
|
|
162
|
+
};
|
|
163
|
+
if (options.noEnv) createRspeedyOptions.loadEnv = false;
|
|
164
|
+
else if (options.envMode) createRspeedyOptions.loadEnv = {
|
|
165
|
+
mode: options.envMode
|
|
166
|
+
};
|
|
167
|
+
if ('base' in options && options.base) {
|
|
168
|
+
rspeedyConfig.server ??= {};
|
|
169
|
+
rspeedyConfig.server.base = options.base;
|
|
170
|
+
}
|
|
171
|
+
if ('environment' in options && options.environment) createRspeedyOptions.environment = options.environment;
|
|
172
|
+
if (options.mode) rspeedyConfig.mode = options.mode;
|
|
173
|
+
return {
|
|
174
|
+
createRspeedyOptions,
|
|
175
|
+
configPath,
|
|
176
|
+
rspeedyConfig
|
|
177
|
+
};
|
|
178
|
+
}
|
|
163
179
|
},
|
|
164
180
|
"./src/create-rspeedy.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
165
181
|
__webpack_require__.d(__webpack_exports__, {
|
|
@@ -168,11 +184,18 @@ export const __webpack_modules__ = {
|
|
|
168
184
|
var external_node_path_ = __webpack_require__("node:path");
|
|
169
185
|
var core_ = __webpack_require__("@rsbuild/core");
|
|
170
186
|
function applyDefaultRspeedyConfig(config) {
|
|
171
|
-
const ret = (0, core_.mergeRsbuildConfig)(
|
|
187
|
+
const ret = (0, core_.mergeRsbuildConfig)({
|
|
172
188
|
output: {
|
|
173
189
|
filename: getFilename(config.output?.filename)
|
|
190
|
+
},
|
|
191
|
+
tools: {
|
|
192
|
+
rsdoctor: {
|
|
193
|
+
experiments: {
|
|
194
|
+
enableNativePlugin: true
|
|
195
|
+
}
|
|
196
|
+
}
|
|
174
197
|
}
|
|
175
|
-
});
|
|
198
|
+
}, config);
|
|
176
199
|
return ret;
|
|
177
200
|
}
|
|
178
201
|
const DEFAULT_FILENAME = '[name].[platform].bundle';
|
|
@@ -262,6 +285,7 @@ export const __webpack_modules__ = {
|
|
|
262
285
|
entry: toRsbuildEntry(config.source?.entry),
|
|
263
286
|
exclude: config.source?.exclude,
|
|
264
287
|
include: config.source?.include,
|
|
288
|
+
preEntry: config.source?.preEntry,
|
|
265
289
|
transformImport: config.source?.transformImport,
|
|
266
290
|
tsconfigPath: config.source?.tsconfigPath
|
|
267
291
|
},
|
|
@@ -274,7 +298,9 @@ export const __webpack_modules__ = {
|
|
|
274
298
|
},
|
|
275
299
|
plugins: config.plugins,
|
|
276
300
|
performance: {
|
|
301
|
+
buildCache: config.performance?.buildCache,
|
|
277
302
|
chunkSplit: config.performance?.chunkSplit,
|
|
303
|
+
profile: config.performance?.profile,
|
|
278
304
|
removeConsole: toRsbuildRemoveConsole(config),
|
|
279
305
|
printFileSize: config.performance?.printFileSize ?? true
|
|
280
306
|
},
|
|
@@ -300,14 +326,15 @@ export const __webpack_modules__ = {
|
|
|
300
326
|
];
|
|
301
327
|
return config.performance?.removeConsole;
|
|
302
328
|
}
|
|
303
|
-
async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [] }) {
|
|
329
|
+
async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [], callerName = 'rspeedy' }) {
|
|
304
330
|
const config = applyDefaultRspeedyConfig(rspeedyConfig);
|
|
305
331
|
const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
|
|
306
332
|
(0, core_.createRsbuild)({
|
|
307
333
|
cwd,
|
|
308
334
|
loadEnv,
|
|
309
335
|
rsbuildConfig: toRsbuildConfig(config),
|
|
310
|
-
environment
|
|
336
|
+
environment,
|
|
337
|
+
callerName
|
|
311
338
|
}),
|
|
312
339
|
__webpack_require__.e("src_plugins_index_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/index.ts"))
|
|
313
340
|
]);
|
package/dist/src_cli_exit_ts.js
CHANGED