@lynx-js/rspeedy-canary 0.13.0-canary-20260105-ec1caf1a → 0.13.0-canary-20260105-03ea61ec
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 +1 -1
- package/dist/{0~vendors-node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js → 0~node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js} +3 -6
- package/dist/0~src_cli_exit_ts.js +98 -108
- package/dist/0~src_config_output_dist-path_ts.js +2 -0
- package/dist/0~src_config_validate_ts.js +41917 -41925
- package/dist/0~src_plugins_api_plugin_ts.js +21 -31
- package/dist/0~src_plugins_chunkLoading_plugin_ts.js +10 -20
- package/dist/0~src_plugins_dev_plugin_ts.js +168 -179
- package/dist/0~src_plugins_emitOnErrors_plugin_ts.js +10 -20
- package/dist/0~src_plugins_index_ts.js +63 -51
- package/dist/0~src_plugins_inspect_plugin_ts.js +434 -39
- package/dist/0~src_plugins_minify_plugin_ts.js +66 -76
- package/dist/0~src_plugins_optimization_plugin_ts.js +14 -24
- package/dist/0~src_plugins_output_plugin_ts.js +29 -45
- package/dist/0~src_plugins_resolve_plugin_ts.js +10 -20
- package/dist/0~src_plugins_rsdoctor_plugin_ts.js +39 -49
- package/dist/0~src_plugins_sourcemap_plugin_ts.js +86 -96
- package/dist/0~src_plugins_swc_plugin_ts.js +20 -38
- package/dist/0~src_plugins_target_plugin_ts.js +21 -39
- package/dist/0~src_utils_getESVersionTarget_ts.js +4 -0
- package/dist/1~node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +1422 -0
- package/dist/{1~vendors-node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js → 1~node_modules_pnpm_commander_13_1_0_node_modules_commander_esm_mjs.js} +17 -24
- package/dist/{1~vendors-node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js → 1~node_modules_pnpm_ipaddr_js_2_3_0_node_modules_ipaddr_js_lib_ipaddr_js.js} +3 -6
- package/dist/1~src_cli_build_ts.js +35 -424
- package/dist/1~src_cli_commands_ts.js +56 -74
- package/dist/1~src_cli_dev_ts.js +29 -410
- package/dist/1~src_cli_init_ts-src_create-rspeedy_ts.js +318 -0
- package/dist/1~src_cli_inspect_ts.js +18 -356
- package/dist/1~src_cli_preview_ts.js +23 -359
- package/dist/1~src_cli_watch_ts.js +39 -0
- package/dist/1~src_config_output_dist-path_ts.js +2 -0
- package/dist/1~src_config_validate_ts.js +41917 -41925
- package/dist/1~src_plugins_api_plugin_ts.js +22 -31
- package/dist/1~src_plugins_chunkLoading_plugin_ts.js +10 -20
- package/dist/1~src_plugins_dev_plugin_ts.js +170 -179
- package/dist/1~src_plugins_emitOnErrors_plugin_ts.js +10 -20
- package/dist/1~src_plugins_index_ts.js +63 -51
- package/dist/1~src_plugins_inspect_plugin_ts.js +436 -39
- package/dist/1~src_plugins_minify_plugin_ts.js +66 -76
- package/dist/1~src_plugins_optimization_plugin_ts.js +14 -24
- package/dist/1~src_plugins_output_plugin_ts.js +29 -45
- package/dist/1~src_plugins_resolve_plugin_ts.js +10 -20
- package/dist/1~src_plugins_rsdoctor_plugin_ts.js +37 -55
- package/dist/1~src_plugins_sourcemap_plugin_ts.js +86 -96
- package/dist/1~src_plugins_swc_plugin_ts.js +20 -38
- package/dist/1~src_plugins_target_plugin_ts.js +21 -39
- package/dist/1~src_utils_getESVersionTarget_ts.js +4 -0
- package/dist/1~src_utils_is-ci_ts.js +4 -0
- package/dist/1~src_version_ts.js +6 -18
- package/dist/cli/main.js +1 -357
- package/dist/cli/start.js +16 -130
- package/dist/index.js +1 -524
- package/dist/node_fs.js +7 -0
- package/dist/node_path.js +7 -0
- package/dist/node_url.js +1 -0
- package/dist/rslib-runtime.js +75 -0
- package/dist/src_cli_main_ts.js +149 -0
- package/dist/src_debug_ts.js +93 -0
- package/dist/src_index_ts.js +381 -0
- package/package.json +1 -1
- package/dist/0~vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc.js +0 -417
- package/dist/1~events-fs-fs_promises-os-path-stream.js +0 -30
- package/dist/1~node_child_process-node_events-node_fs-node_path.js +0 -22
- package/dist/1~vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js +0 -1432
- package/dist/1~vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc.js +0 -417
- /package/dist/{1~vendors-node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt → 1~node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
2
|
+
import { register } from "#register";
|
|
3
|
+
import "./node_path.js";
|
|
4
|
+
import "./node_fs.js";
|
|
5
|
+
import { debug, isDebug, createRsbuild, mergeRsbuildConfig, debugList } from "./src_debug_ts.js";
|
|
6
|
+
import { pathToFileURL } from "./node_url.js";
|
|
7
|
+
function applyDefaultRspeedyConfig(config) {
|
|
8
|
+
const enableChunkSplitting = config.performance?.chunkSplit?.strategy && config.performance?.chunkSplit?.strategy !== 'all-in-one';
|
|
9
|
+
return mergeRsbuildConfig({
|
|
10
|
+
mode: (()=>{
|
|
11
|
+
if (config.mode) return config.mode;
|
|
12
|
+
const nodeEnv = process.env['NODE_ENV'];
|
|
13
|
+
return 'production' === nodeEnv || 'development' === nodeEnv ? nodeEnv : 'none';
|
|
14
|
+
})(),
|
|
15
|
+
output: {
|
|
16
|
+
filename: getFilename(config.output?.filename),
|
|
17
|
+
inlineScripts: !enableChunkSplitting,
|
|
18
|
+
cssModules: {
|
|
19
|
+
localIdentName: '[local]-[hash:base64:6]'
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
performance: {
|
|
23
|
+
profile: isDebug() ? true : void 0
|
|
24
|
+
},
|
|
25
|
+
tools: {
|
|
26
|
+
rsdoctor: {
|
|
27
|
+
experiments: {
|
|
28
|
+
enableNativePlugin: true
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}, config);
|
|
33
|
+
}
|
|
34
|
+
const DEFAULT_FILENAME = '[name].[platform].bundle';
|
|
35
|
+
function getFilename(filename) {
|
|
36
|
+
if ('string' == typeof filename) return {
|
|
37
|
+
bundle: filename,
|
|
38
|
+
template: filename
|
|
39
|
+
};
|
|
40
|
+
const finalFilename = filename?.bundle ?? filename?.template ?? DEFAULT_FILENAME;
|
|
41
|
+
return {
|
|
42
|
+
bundle: finalFilename,
|
|
43
|
+
template: finalFilename
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const DEFAULT_ENTRY = './src/index.js';
|
|
47
|
+
function toRsbuildEntry(entry) {
|
|
48
|
+
if (void 0 === entry) {
|
|
49
|
+
debug(`Using default entry ${DEFAULT_ENTRY}`);
|
|
50
|
+
return {
|
|
51
|
+
main: DEFAULT_ENTRY
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (Array.isArray(entry) || 'string' == typeof entry) {
|
|
55
|
+
debug(()=>`Using single entry ${[
|
|
56
|
+
''
|
|
57
|
+
].concat(entry).join('\n - ')}`);
|
|
58
|
+
return {
|
|
59
|
+
main: entry
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return Object.fromEntries(Object.entries(entry).map(([key, value])=>{
|
|
63
|
+
if (Array.isArray(value) || 'string' == typeof value) {
|
|
64
|
+
debugList(`Using multiple entries - ${key}`, value);
|
|
65
|
+
return [
|
|
66
|
+
key,
|
|
67
|
+
{
|
|
68
|
+
import: value
|
|
69
|
+
}
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
debugList(`Using multiple entries - ${key}`, value.import ?? DEFAULT_ENTRY);
|
|
73
|
+
if (void 0 === value.import) return [
|
|
74
|
+
key,
|
|
75
|
+
{
|
|
76
|
+
...value,
|
|
77
|
+
import: DEFAULT_ENTRY
|
|
78
|
+
}
|
|
79
|
+
];
|
|
80
|
+
return [
|
|
81
|
+
key,
|
|
82
|
+
value
|
|
83
|
+
];
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
const defaultDataUriLimit = 2048;
|
|
87
|
+
function toRsbuildConfig(config) {
|
|
88
|
+
return {
|
|
89
|
+
dev: {
|
|
90
|
+
hmr: config.dev?.hmr ?? true,
|
|
91
|
+
lazyCompilation: false,
|
|
92
|
+
liveReload: config.dev?.liveReload ?? true,
|
|
93
|
+
watchFiles: config.dev?.watchFiles,
|
|
94
|
+
writeToDisk: config.dev?.writeToDisk ?? true,
|
|
95
|
+
progressBar: config.dev?.progressBar ?? true
|
|
96
|
+
},
|
|
97
|
+
environments: config.environments ?? {
|
|
98
|
+
lynx: {}
|
|
99
|
+
},
|
|
100
|
+
mode: config.mode,
|
|
101
|
+
output: {
|
|
102
|
+
assetPrefix: config.output?.assetPrefix,
|
|
103
|
+
charset: 'utf8',
|
|
104
|
+
cleanDistPath: config.output?.cleanDistPath,
|
|
105
|
+
copy: config.output?.copy,
|
|
106
|
+
cssModules: config.output?.cssModules,
|
|
107
|
+
dataUriLimit: config.output?.dataUriLimit ?? defaultDataUriLimit,
|
|
108
|
+
distPath: config.output?.distPath,
|
|
109
|
+
filenameHash: config.output?.filenameHash,
|
|
110
|
+
inlineScripts: config.output?.inlineScripts,
|
|
111
|
+
legalComments: config.output?.legalComments ?? 'none',
|
|
112
|
+
polyfill: 'off',
|
|
113
|
+
sourceMap: config.output?.sourceMap
|
|
114
|
+
},
|
|
115
|
+
resolve: {
|
|
116
|
+
alias: config.resolve?.alias,
|
|
117
|
+
aliasStrategy: config.resolve?.aliasStrategy,
|
|
118
|
+
dedupe: config.resolve?.dedupe,
|
|
119
|
+
extensions: config.resolve?.extensions
|
|
120
|
+
},
|
|
121
|
+
source: {
|
|
122
|
+
alias: config.source?.alias,
|
|
123
|
+
assetsInclude: config.source?.assetsInclude,
|
|
124
|
+
decorators: config.source?.decorators,
|
|
125
|
+
define: config.source?.define,
|
|
126
|
+
entry: toRsbuildEntry(config.source?.entry),
|
|
127
|
+
exclude: config.source?.exclude,
|
|
128
|
+
include: config.source?.include,
|
|
129
|
+
preEntry: config.source?.preEntry,
|
|
130
|
+
transformImport: config.source?.transformImport,
|
|
131
|
+
tsconfigPath: config.source?.tsconfigPath
|
|
132
|
+
},
|
|
133
|
+
server: {
|
|
134
|
+
base: config.server?.base,
|
|
135
|
+
compress: config.server?.compress,
|
|
136
|
+
cors: config.server?.cors,
|
|
137
|
+
headers: config.server?.headers,
|
|
138
|
+
host: config.server?.host,
|
|
139
|
+
port: config.server?.port,
|
|
140
|
+
proxy: config.server?.proxy,
|
|
141
|
+
strictPort: config.server?.strictPort
|
|
142
|
+
},
|
|
143
|
+
plugins: config.plugins,
|
|
144
|
+
performance: {
|
|
145
|
+
buildCache: config.performance?.buildCache,
|
|
146
|
+
chunkSplit: config.performance?.chunkSplit,
|
|
147
|
+
profile: config.performance?.profile,
|
|
148
|
+
removeConsole: toRsbuildRemoveConsole(config),
|
|
149
|
+
printFileSize: config.performance?.printFileSize ?? true
|
|
150
|
+
},
|
|
151
|
+
tools: {
|
|
152
|
+
bundlerChain: config.tools?.bundlerChain,
|
|
153
|
+
cssExtract: config.tools?.cssExtract,
|
|
154
|
+
cssLoader: config.tools?.cssLoader,
|
|
155
|
+
htmlPlugin: false,
|
|
156
|
+
rspack: config.tools?.rspack,
|
|
157
|
+
swc: config.tools?.swc
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function toRsbuildRemoveConsole(config) {
|
|
162
|
+
if (config.performance?.removeConsole === true) return [
|
|
163
|
+
'log',
|
|
164
|
+
'warn',
|
|
165
|
+
'error',
|
|
166
|
+
'info',
|
|
167
|
+
'debug',
|
|
168
|
+
'profile',
|
|
169
|
+
'profileEnd'
|
|
170
|
+
];
|
|
171
|
+
return config.performance?.removeConsole;
|
|
172
|
+
}
|
|
173
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
174
|
+
async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [], callerName = 'rspeedy' }) {
|
|
175
|
+
const config = applyDefaultRspeedyConfig(rspeedyConfig);
|
|
176
|
+
const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
|
|
177
|
+
createRsbuild({
|
|
178
|
+
cwd,
|
|
179
|
+
loadEnv,
|
|
180
|
+
rsbuildConfig: toRsbuildConfig(config),
|
|
181
|
+
environment,
|
|
182
|
+
callerName
|
|
183
|
+
}),
|
|
184
|
+
import("./1~src_plugins_index_ts.js").then((mod)=>({
|
|
185
|
+
applyDefaultPlugins: mod.applyDefaultPlugins
|
|
186
|
+
}))
|
|
187
|
+
]);
|
|
188
|
+
await applyDefaultPlugins(rspeedy, config);
|
|
189
|
+
const inspectConfig = rspeedy.inspectConfig.bind(rspeedy);
|
|
190
|
+
return Object.assign(rspeedy, {
|
|
191
|
+
getRspeedyConfig: ()=>config,
|
|
192
|
+
async inspectConfig (options) {
|
|
193
|
+
const result = await inspectConfig(options);
|
|
194
|
+
const { inspectRspeedyConfig } = await import("./1~src_plugins_inspect_plugin_ts.js").then((mod)=>({
|
|
195
|
+
inspectRspeedyConfig: mod.inspectRspeedyConfig
|
|
196
|
+
}));
|
|
197
|
+
await inspectRspeedyConfig(rspeedyConfig, external_node_path_["default"].resolve(options.outputPath ?? rspeedy.context.distPath, '.rsbuild/rspeedy.config.js'), options.verbose ?? false);
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
const external_node_fs_ = __webpack_require__("node:fs");
|
|
203
|
+
const picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
204
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
205
|
+
const resolveConfigPath = (root, customConfig)=>{
|
|
206
|
+
if (customConfig) {
|
|
207
|
+
debug(`load custom config file ${customConfig} from ${root}`);
|
|
208
|
+
const customConfigPath = (0, external_node_path_.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_.join)(root, customConfig);
|
|
209
|
+
if (external_node_fs_["default"].existsSync(customConfigPath)) return customConfigPath;
|
|
210
|
+
throw new Error(`Cannot find config file: ${picocolors_default().dim(customConfigPath)}`);
|
|
211
|
+
}
|
|
212
|
+
const CONFIG_FILES = [
|
|
213
|
+
'lynx.config.ts',
|
|
214
|
+
'lynx.config.js',
|
|
215
|
+
'lynx.config.mts',
|
|
216
|
+
'lynx.config.mjs'
|
|
217
|
+
];
|
|
218
|
+
for (const file of CONFIG_FILES){
|
|
219
|
+
debug(`load default config file ${file} from ${root}`);
|
|
220
|
+
const configFile = (0, external_node_path_.join)(root, file);
|
|
221
|
+
if (external_node_fs_["default"].existsSync(configFile)) {
|
|
222
|
+
debug(`default config ${configFile} found`);
|
|
223
|
+
return configFile;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
throw new Error([
|
|
227
|
+
`Cannot find the default config file: ${picocolors_default().dim((0, external_node_path_.join)(root, CONFIG_FILES[0]))}.`,
|
|
228
|
+
`Use custom config with ${picocolors_default().green('`--config <config>`')} options.`
|
|
229
|
+
].join(' '));
|
|
230
|
+
};
|
|
231
|
+
async function loadConfig(loadConfigOptions) {
|
|
232
|
+
let { configPath } = loadConfigOptions;
|
|
233
|
+
if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
|
|
234
|
+
const specifier = pathToFileURL(configPath).toString();
|
|
235
|
+
let unregister;
|
|
236
|
+
unregister = shouldUseNativeImport(configPath) ? ()=>{} : register({
|
|
237
|
+
load: !hasNativeTSSupport(),
|
|
238
|
+
resolve: true
|
|
239
|
+
});
|
|
240
|
+
try {
|
|
241
|
+
const [exports, { validate }] = await Promise.all([
|
|
242
|
+
import(`${specifier}?t=${Date.now()}`),
|
|
243
|
+
import("./1~src_config_validate_ts.js").then((mod)=>({
|
|
244
|
+
validate: mod.validate,
|
|
245
|
+
validateConfig: mod.validateConfig
|
|
246
|
+
}))
|
|
247
|
+
]);
|
|
248
|
+
const configExport = 'default' in exports ? exports.default : exports;
|
|
249
|
+
const rawContent = 'function' == typeof configExport ? await configExport({
|
|
250
|
+
command: process.argv[2] ?? 'build',
|
|
251
|
+
env: process.env['NODE_ENV'] ?? 'production'
|
|
252
|
+
}) : await configExport;
|
|
253
|
+
return {
|
|
254
|
+
configPath,
|
|
255
|
+
content: validate(rawContent, configPath)
|
|
256
|
+
};
|
|
257
|
+
} finally{
|
|
258
|
+
unregister();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function shouldUseNativeImport(configPath) {
|
|
262
|
+
return isJavaScriptPath(configPath) || isDeno();
|
|
263
|
+
}
|
|
264
|
+
function hasNativeTSSupport() {
|
|
265
|
+
if (isDeno()) return true;
|
|
266
|
+
if (process.features.typescript) return true;
|
|
267
|
+
if (false === process.features.typescript) return false;
|
|
268
|
+
const { NODE_OPTIONS } = process.env;
|
|
269
|
+
if (!NODE_OPTIONS) return false;
|
|
270
|
+
return NODE_OPTIONS.includes('--experimental-transform-types') || NODE_OPTIONS.includes('--experimental-strip-types');
|
|
271
|
+
}
|
|
272
|
+
function isJavaScriptPath(configPath) {
|
|
273
|
+
const ext = (0, external_node_path_.extname)(configPath);
|
|
274
|
+
return [
|
|
275
|
+
'.js',
|
|
276
|
+
'.mjs',
|
|
277
|
+
'.cjs'
|
|
278
|
+
].includes(ext);
|
|
279
|
+
}
|
|
280
|
+
function isDeno() {
|
|
281
|
+
if ("u" > typeof Deno || process.versions?.deno) return true;
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
async function init(cwd, options) {
|
|
285
|
+
const { content: rspeedyConfig, configPath } = await loadConfig({
|
|
286
|
+
cwd,
|
|
287
|
+
configPath: options.config
|
|
288
|
+
});
|
|
289
|
+
if (rspeedyConfig.performance?.buildCache) if (true === rspeedyConfig.performance.buildCache) rspeedyConfig.performance.buildCache = {
|
|
290
|
+
buildDependencies: [
|
|
291
|
+
configPath
|
|
292
|
+
]
|
|
293
|
+
};
|
|
294
|
+
else {
|
|
295
|
+
rspeedyConfig.performance.buildCache.buildDependencies ??= [];
|
|
296
|
+
rspeedyConfig.performance.buildCache.buildDependencies.push(configPath);
|
|
297
|
+
}
|
|
298
|
+
const createRspeedyOptions = {
|
|
299
|
+
cwd,
|
|
300
|
+
rspeedyConfig
|
|
301
|
+
};
|
|
302
|
+
if (options.noEnv) createRspeedyOptions.loadEnv = false;
|
|
303
|
+
else if (options.envMode) createRspeedyOptions.loadEnv = {
|
|
304
|
+
mode: options.envMode
|
|
305
|
+
};
|
|
306
|
+
if ('base' in options && options.base) {
|
|
307
|
+
rspeedyConfig.server ??= {};
|
|
308
|
+
rspeedyConfig.server.base = options.base;
|
|
309
|
+
}
|
|
310
|
+
if ('environment' in options && options.environment) createRspeedyOptions.environment = options.environment;
|
|
311
|
+
if (options.mode) rspeedyConfig.mode = options.mode;
|
|
312
|
+
return {
|
|
313
|
+
createRspeedyOptions,
|
|
314
|
+
configPath,
|
|
315
|
+
rspeedyConfig
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
export { createRspeedy, init };
|
|
@@ -1,358 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { logger } from "./src_debug_ts.js";
|
|
2
|
+
import { exit_exit } from "./src_cli_main_ts.js";
|
|
3
|
+
import { createRspeedy, init } from "./1~src_cli_init_ts-src_create-rspeedy_ts.js";
|
|
4
|
+
async function inspect(cwd, inspectOptions) {
|
|
5
|
+
try {
|
|
6
|
+
const { createRspeedyOptions } = await init(cwd, inspectOptions);
|
|
7
|
+
const rspeedy = await createRspeedy(createRspeedyOptions);
|
|
8
|
+
await rspeedy.inspectConfig({
|
|
9
|
+
mode: inspectOptions.mode ?? rspeedy.getRspeedyConfig().mode ?? 'development',
|
|
10
|
+
verbose: inspectOptions.verbose ?? false,
|
|
11
|
+
outputPath: inspectOptions.output,
|
|
12
|
+
writeToDisk: true
|
|
12
13
|
});
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var debug = __webpack_require__("./src/debug.ts");
|
|
18
|
-
const resolveConfigPath = (root, customConfig)=>{
|
|
19
|
-
if (customConfig) {
|
|
20
|
-
(0, debug.Yz)(`load custom config file ${customConfig} from ${root}`);
|
|
21
|
-
const customConfigPath = (0, external_node_path_.isAbsolute)(customConfig) ? customConfig : (0, external_node_path_.join)(root, customConfig);
|
|
22
|
-
if (external_node_fs_["default"].existsSync(customConfigPath)) return customConfigPath;
|
|
23
|
-
throw new Error(`Cannot find config file: ${picocolors_default().dim(customConfigPath)}`);
|
|
24
|
-
}
|
|
25
|
-
const CONFIG_FILES = [
|
|
26
|
-
'lynx.config.ts',
|
|
27
|
-
'lynx.config.js',
|
|
28
|
-
'lynx.config.mts',
|
|
29
|
-
'lynx.config.mjs'
|
|
30
|
-
];
|
|
31
|
-
for (const file of CONFIG_FILES){
|
|
32
|
-
(0, debug.Yz)(`load default config file ${file} from ${root}`);
|
|
33
|
-
const configFile = (0, external_node_path_.join)(root, file);
|
|
34
|
-
if (external_node_fs_["default"].existsSync(configFile)) {
|
|
35
|
-
(0, debug.Yz)(`default config ${configFile} found`);
|
|
36
|
-
return configFile;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
throw new Error([
|
|
40
|
-
`Cannot find the default config file: ${picocolors_default().dim((0, external_node_path_.join)(root, CONFIG_FILES[0]))}.`,
|
|
41
|
-
`Use custom config with ${picocolors_default().green('`--config <config>`')} options.`
|
|
42
|
-
].join(' '));
|
|
43
|
-
};
|
|
44
|
-
async function loadConfig(loadConfigOptions) {
|
|
45
|
-
let { configPath } = loadConfigOptions;
|
|
46
|
-
if (!configPath || !(0, external_node_path_.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
|
|
47
|
-
const specifier = pathToFileURL(configPath).toString();
|
|
48
|
-
let unregister;
|
|
49
|
-
unregister = shouldUseNativeImport(configPath) ? ()=>{} : register({
|
|
50
|
-
load: !hasNativeTSSupport(),
|
|
51
|
-
resolve: true
|
|
52
|
-
});
|
|
53
|
-
try {
|
|
54
|
-
const [exports, { validate }] = await Promise.all([
|
|
55
|
-
import(`${specifier}?t=${Date.now()}`),
|
|
56
|
-
__webpack_require__.e("src_config_validate_ts").then(__webpack_require__.bind(__webpack_require__, "./src/config/validate.ts"))
|
|
57
|
-
]);
|
|
58
|
-
const configExport = 'default' in exports ? exports.default : exports;
|
|
59
|
-
const rawContent = 'function' == typeof configExport ? await configExport({
|
|
60
|
-
command: process.argv[2] ?? 'build',
|
|
61
|
-
env: process.env['NODE_ENV'] ?? 'production'
|
|
62
|
-
}) : await configExport;
|
|
63
|
-
return {
|
|
64
|
-
configPath,
|
|
65
|
-
content: validate(rawContent, configPath)
|
|
66
|
-
};
|
|
67
|
-
} finally{
|
|
68
|
-
unregister();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function shouldUseNativeImport(configPath) {
|
|
72
|
-
return isJavaScriptPath(configPath) || isDeno();
|
|
73
|
-
}
|
|
74
|
-
function hasNativeTSSupport() {
|
|
75
|
-
if (isDeno()) return true;
|
|
76
|
-
if (process.features.typescript) return true;
|
|
77
|
-
if (false === process.features.typescript) return false;
|
|
78
|
-
const { NODE_OPTIONS } = process.env;
|
|
79
|
-
if (!NODE_OPTIONS) return false;
|
|
80
|
-
return NODE_OPTIONS.includes('--experimental-transform-types') || NODE_OPTIONS.includes('--experimental-strip-types');
|
|
81
|
-
}
|
|
82
|
-
function isJavaScriptPath(configPath) {
|
|
83
|
-
const ext = (0, external_node_path_.extname)(configPath);
|
|
84
|
-
return [
|
|
85
|
-
'.js',
|
|
86
|
-
'.mjs',
|
|
87
|
-
'.cjs'
|
|
88
|
-
].includes(ext);
|
|
89
|
-
}
|
|
90
|
-
function isDeno() {
|
|
91
|
-
if ("u" > typeof Deno || process.versions?.deno) return true;
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
async function init(cwd, options) {
|
|
95
|
-
const { content: rspeedyConfig, configPath } = await loadConfig({
|
|
96
|
-
cwd,
|
|
97
|
-
configPath: options.config
|
|
98
|
-
});
|
|
99
|
-
if (rspeedyConfig.performance?.buildCache) if (true === rspeedyConfig.performance.buildCache) rspeedyConfig.performance.buildCache = {
|
|
100
|
-
buildDependencies: [
|
|
101
|
-
configPath
|
|
102
|
-
]
|
|
103
|
-
};
|
|
104
|
-
else {
|
|
105
|
-
rspeedyConfig.performance.buildCache.buildDependencies ??= [];
|
|
106
|
-
rspeedyConfig.performance.buildCache.buildDependencies.push(configPath);
|
|
107
|
-
}
|
|
108
|
-
const createRspeedyOptions = {
|
|
109
|
-
cwd,
|
|
110
|
-
rspeedyConfig
|
|
111
|
-
};
|
|
112
|
-
if (options.noEnv) createRspeedyOptions.loadEnv = false;
|
|
113
|
-
else if (options.envMode) createRspeedyOptions.loadEnv = {
|
|
114
|
-
mode: options.envMode
|
|
115
|
-
};
|
|
116
|
-
if ('base' in options && options.base) {
|
|
117
|
-
rspeedyConfig.server ??= {};
|
|
118
|
-
rspeedyConfig.server.base = options.base;
|
|
119
|
-
}
|
|
120
|
-
if ('environment' in options && options.environment) createRspeedyOptions.environment = options.environment;
|
|
121
|
-
if (options.mode) rspeedyConfig.mode = options.mode;
|
|
122
|
-
return {
|
|
123
|
-
createRspeedyOptions,
|
|
124
|
-
configPath,
|
|
125
|
-
rspeedyConfig
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
"./src/cli/inspect.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
130
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
131
|
-
inspect: ()=>inspect
|
|
132
|
-
});
|
|
133
|
-
var _rsbuild_core__rspack_import_0 = __webpack_require__("@rsbuild/core");
|
|
134
|
-
var _exit_js__rspack_import_1 = __webpack_require__("./src/cli/exit.ts");
|
|
135
|
-
var _create_rspeedy_js__rspack_import_2 = __webpack_require__("./src/create-rspeedy.ts");
|
|
136
|
-
var _init_js__rspack_import_3 = __webpack_require__("./src/cli/init.ts");
|
|
137
|
-
async function inspect(cwd, inspectOptions) {
|
|
138
|
-
try {
|
|
139
|
-
const { createRspeedyOptions } = await (0, _init_js__rspack_import_3.T)(cwd, inspectOptions);
|
|
140
|
-
const rspeedy = await (0, _create_rspeedy_js__rspack_import_2.x)(createRspeedyOptions);
|
|
141
|
-
await rspeedy.inspectConfig({
|
|
142
|
-
mode: inspectOptions.mode ?? rspeedy.getRspeedyConfig().mode ?? 'development',
|
|
143
|
-
verbose: inspectOptions.verbose ?? false,
|
|
144
|
-
outputPath: inspectOptions.output,
|
|
145
|
-
writeToDisk: true
|
|
146
|
-
});
|
|
147
|
-
return (0, _exit_js__rspack_import_1.exit)();
|
|
148
|
-
} catch (error) {
|
|
149
|
-
_rsbuild_core__rspack_import_0.logger.error(error);
|
|
150
|
-
_rsbuild_core__rspack_import_0.logger.error();
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
"./src/create-rspeedy.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
155
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
156
|
-
x: ()=>createRspeedy
|
|
157
|
-
});
|
|
158
|
-
var external_node_path_ = __webpack_require__("node:path");
|
|
159
|
-
var core_ = __webpack_require__("@rsbuild/core");
|
|
160
|
-
var debug = __webpack_require__("./src/debug.ts");
|
|
161
|
-
function applyDefaultRspeedyConfig(config) {
|
|
162
|
-
const enableChunkSplitting = config.performance?.chunkSplit?.strategy && config.performance?.chunkSplit?.strategy !== 'all-in-one';
|
|
163
|
-
return (0, core_.mergeRsbuildConfig)({
|
|
164
|
-
mode: (()=>{
|
|
165
|
-
if (config.mode) return config.mode;
|
|
166
|
-
const nodeEnv = process.env['NODE_ENV'];
|
|
167
|
-
return 'production' === nodeEnv || 'development' === nodeEnv ? nodeEnv : 'none';
|
|
168
|
-
})(),
|
|
169
|
-
output: {
|
|
170
|
-
filename: getFilename(config.output?.filename),
|
|
171
|
-
inlineScripts: !enableChunkSplitting,
|
|
172
|
-
cssModules: {
|
|
173
|
-
localIdentName: '[local]-[hash:base64:6]'
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
performance: {
|
|
177
|
-
profile: (0, debug._o)() ? true : void 0
|
|
178
|
-
},
|
|
179
|
-
tools: {
|
|
180
|
-
rsdoctor: {
|
|
181
|
-
experiments: {
|
|
182
|
-
enableNativePlugin: true
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}, config);
|
|
187
|
-
}
|
|
188
|
-
const DEFAULT_FILENAME = '[name].[platform].bundle';
|
|
189
|
-
function getFilename(filename) {
|
|
190
|
-
if ('string' == typeof filename) return {
|
|
191
|
-
bundle: filename,
|
|
192
|
-
template: filename
|
|
193
|
-
};
|
|
194
|
-
const finalFilename = filename?.bundle ?? filename?.template ?? DEFAULT_FILENAME;
|
|
195
|
-
return {
|
|
196
|
-
bundle: finalFilename,
|
|
197
|
-
template: finalFilename
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
const DEFAULT_ENTRY = './src/index.js';
|
|
201
|
-
function toRsbuildEntry(entry) {
|
|
202
|
-
if (void 0 === entry) {
|
|
203
|
-
(0, debug.Yz)(`Using default entry ${DEFAULT_ENTRY}`);
|
|
204
|
-
return {
|
|
205
|
-
main: DEFAULT_ENTRY
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
if (Array.isArray(entry) || 'string' == typeof entry) {
|
|
209
|
-
(0, debug.Yz)(()=>`Using single entry ${[
|
|
210
|
-
''
|
|
211
|
-
].concat(entry).join('\n - ')}`);
|
|
212
|
-
return {
|
|
213
|
-
main: entry
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
return Object.fromEntries(Object.entries(entry).map(([key, value])=>{
|
|
217
|
-
if (Array.isArray(value) || 'string' == typeof value) {
|
|
218
|
-
(0, debug.Iv)(`Using multiple entries - ${key}`, value);
|
|
219
|
-
return [
|
|
220
|
-
key,
|
|
221
|
-
{
|
|
222
|
-
import: value
|
|
223
|
-
}
|
|
224
|
-
];
|
|
225
|
-
}
|
|
226
|
-
(0, debug.Iv)(`Using multiple entries - ${key}`, value.import ?? DEFAULT_ENTRY);
|
|
227
|
-
if (void 0 === value.import) return [
|
|
228
|
-
key,
|
|
229
|
-
{
|
|
230
|
-
...value,
|
|
231
|
-
import: DEFAULT_ENTRY
|
|
232
|
-
}
|
|
233
|
-
];
|
|
234
|
-
return [
|
|
235
|
-
key,
|
|
236
|
-
value
|
|
237
|
-
];
|
|
238
|
-
}));
|
|
239
|
-
}
|
|
240
|
-
const defaultDataUriLimit = 2048;
|
|
241
|
-
function toRsbuildConfig(config) {
|
|
242
|
-
return {
|
|
243
|
-
dev: {
|
|
244
|
-
hmr: config.dev?.hmr ?? true,
|
|
245
|
-
lazyCompilation: false,
|
|
246
|
-
liveReload: config.dev?.liveReload ?? true,
|
|
247
|
-
watchFiles: config.dev?.watchFiles,
|
|
248
|
-
writeToDisk: config.dev?.writeToDisk ?? true,
|
|
249
|
-
progressBar: config.dev?.progressBar ?? true
|
|
250
|
-
},
|
|
251
|
-
environments: config.environments ?? {
|
|
252
|
-
lynx: {}
|
|
253
|
-
},
|
|
254
|
-
mode: config.mode,
|
|
255
|
-
output: {
|
|
256
|
-
assetPrefix: config.output?.assetPrefix,
|
|
257
|
-
charset: 'utf8',
|
|
258
|
-
cleanDistPath: config.output?.cleanDistPath,
|
|
259
|
-
copy: config.output?.copy,
|
|
260
|
-
cssModules: config.output?.cssModules,
|
|
261
|
-
dataUriLimit: config.output?.dataUriLimit ?? defaultDataUriLimit,
|
|
262
|
-
distPath: config.output?.distPath,
|
|
263
|
-
filenameHash: config.output?.filenameHash,
|
|
264
|
-
inlineScripts: config.output?.inlineScripts,
|
|
265
|
-
legalComments: config.output?.legalComments ?? 'none',
|
|
266
|
-
polyfill: 'off',
|
|
267
|
-
sourceMap: config.output?.sourceMap
|
|
268
|
-
},
|
|
269
|
-
resolve: {
|
|
270
|
-
alias: config.resolve?.alias,
|
|
271
|
-
aliasStrategy: config.resolve?.aliasStrategy,
|
|
272
|
-
dedupe: config.resolve?.dedupe,
|
|
273
|
-
extensions: config.resolve?.extensions
|
|
274
|
-
},
|
|
275
|
-
source: {
|
|
276
|
-
alias: config.source?.alias,
|
|
277
|
-
assetsInclude: config.source?.assetsInclude,
|
|
278
|
-
decorators: config.source?.decorators,
|
|
279
|
-
define: config.source?.define,
|
|
280
|
-
entry: toRsbuildEntry(config.source?.entry),
|
|
281
|
-
exclude: config.source?.exclude,
|
|
282
|
-
include: config.source?.include,
|
|
283
|
-
preEntry: config.source?.preEntry,
|
|
284
|
-
transformImport: config.source?.transformImport,
|
|
285
|
-
tsconfigPath: config.source?.tsconfigPath
|
|
286
|
-
},
|
|
287
|
-
server: {
|
|
288
|
-
base: config.server?.base,
|
|
289
|
-
compress: config.server?.compress,
|
|
290
|
-
cors: config.server?.cors,
|
|
291
|
-
headers: config.server?.headers,
|
|
292
|
-
host: config.server?.host,
|
|
293
|
-
port: config.server?.port,
|
|
294
|
-
proxy: config.server?.proxy,
|
|
295
|
-
strictPort: config.server?.strictPort
|
|
296
|
-
},
|
|
297
|
-
plugins: config.plugins,
|
|
298
|
-
performance: {
|
|
299
|
-
buildCache: config.performance?.buildCache,
|
|
300
|
-
chunkSplit: config.performance?.chunkSplit,
|
|
301
|
-
profile: config.performance?.profile,
|
|
302
|
-
removeConsole: toRsbuildRemoveConsole(config),
|
|
303
|
-
printFileSize: config.performance?.printFileSize ?? true
|
|
304
|
-
},
|
|
305
|
-
tools: {
|
|
306
|
-
bundlerChain: config.tools?.bundlerChain,
|
|
307
|
-
cssExtract: config.tools?.cssExtract,
|
|
308
|
-
cssLoader: config.tools?.cssLoader,
|
|
309
|
-
htmlPlugin: false,
|
|
310
|
-
rspack: config.tools?.rspack,
|
|
311
|
-
swc: config.tools?.swc
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
function toRsbuildRemoveConsole(config) {
|
|
316
|
-
if (config.performance?.removeConsole === true) return [
|
|
317
|
-
'log',
|
|
318
|
-
'warn',
|
|
319
|
-
'error',
|
|
320
|
-
'info',
|
|
321
|
-
'debug',
|
|
322
|
-
'profile',
|
|
323
|
-
'profileEnd'
|
|
324
|
-
];
|
|
325
|
-
return config.performance?.removeConsole;
|
|
326
|
-
}
|
|
327
|
-
async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [], callerName = 'rspeedy' }) {
|
|
328
|
-
const config = applyDefaultRspeedyConfig(rspeedyConfig);
|
|
329
|
-
const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
|
|
330
|
-
(0, core_.createRsbuild)({
|
|
331
|
-
cwd,
|
|
332
|
-
loadEnv,
|
|
333
|
-
rsbuildConfig: toRsbuildConfig(config),
|
|
334
|
-
environment,
|
|
335
|
-
callerName
|
|
336
|
-
}),
|
|
337
|
-
__webpack_require__.e("src_plugins_index_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/index.ts"))
|
|
338
|
-
]);
|
|
339
|
-
await applyDefaultPlugins(rspeedy, config);
|
|
340
|
-
const inspectConfig = rspeedy.inspectConfig.bind(rspeedy);
|
|
341
|
-
return Object.assign(rspeedy, {
|
|
342
|
-
getRspeedyConfig: ()=>config,
|
|
343
|
-
async inspectConfig (options) {
|
|
344
|
-
const result = await inspectConfig(options);
|
|
345
|
-
const { inspectRspeedyConfig } = await Promise.all([
|
|
346
|
-
__webpack_require__.e("vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc"),
|
|
347
|
-
__webpack_require__.e("src_plugins_inspect_plugin_ts")
|
|
348
|
-
]).then(__webpack_require__.bind(__webpack_require__, "./src/plugins/inspect.plugin.ts"));
|
|
349
|
-
await inspectRspeedyConfig(rspeedyConfig, external_node_path_["default"].resolve(options.outputPath ?? rspeedy.context.distPath, '.rsbuild/rspeedy.config.js'), options.verbose ?? false);
|
|
350
|
-
return result;
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
},
|
|
355
|
-
"node:fs" (module) {
|
|
356
|
-
module.exports = __rspack_external_node_fs_5ea92f0c;
|
|
14
|
+
return exit_exit();
|
|
15
|
+
} catch (error) {
|
|
16
|
+
logger.error(error);
|
|
17
|
+
logger.error();
|
|
357
18
|
}
|
|
358
|
-
}
|
|
19
|
+
}
|
|
20
|
+
export { inspect };
|