@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
|
@@ -1,360 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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/preview.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
130
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
131
|
-
preview: ()=>preview
|
|
132
|
-
});
|
|
133
|
-
var node_fs__rspack_import_0 = __webpack_require__("node:fs");
|
|
134
|
-
var _rsbuild_core__rspack_import_1 = __webpack_require__("@rsbuild/core");
|
|
135
|
-
var picocolors__rspack_import_5 = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
136
|
-
var picocolors__rspack_import_5_default = /*#__PURE__*/ __webpack_require__.n(picocolors__rspack_import_5);
|
|
137
|
-
var _exit_js__rspack_import_2 = __webpack_require__("./src/cli/exit.ts");
|
|
138
|
-
var _create_rspeedy_js__rspack_import_3 = __webpack_require__("./src/create-rspeedy.ts");
|
|
139
|
-
var _init_js__rspack_import_4 = __webpack_require__("./src/cli/init.ts");
|
|
140
|
-
async function preview(cwd, previewOptions) {
|
|
141
|
-
try {
|
|
142
|
-
const { createRspeedyOptions } = await (0, _init_js__rspack_import_4.T)(cwd, previewOptions);
|
|
143
|
-
const rspeedy = await (0, _create_rspeedy_js__rspack_import_3.x)(createRspeedyOptions);
|
|
144
|
-
await rspeedy.initConfigs();
|
|
145
|
-
const { distPath } = rspeedy.context;
|
|
146
|
-
if (!node_fs__rspack_import_0["default"].existsSync(distPath)) throw new Error(`The output directory ${picocolors__rspack_import_5_default().yellow(distPath)} does not exist, please build the project before previewing.`);
|
|
147
|
-
await rspeedy.preview();
|
|
148
|
-
} catch (error) {
|
|
149
|
-
_rsbuild_core__rspack_import_1.logger.error('Failed to start preview server.');
|
|
150
|
-
_rsbuild_core__rspack_import_1.logger.error(error);
|
|
151
|
-
(0, _exit_js__rspack_import_2.exit)(1);
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
"./src/create-rspeedy.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
157
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
158
|
-
x: ()=>createRspeedy
|
|
159
|
-
});
|
|
160
|
-
var external_node_path_ = __webpack_require__("node:path");
|
|
161
|
-
var core_ = __webpack_require__("@rsbuild/core");
|
|
162
|
-
var debug = __webpack_require__("./src/debug.ts");
|
|
163
|
-
function applyDefaultRspeedyConfig(config) {
|
|
164
|
-
const enableChunkSplitting = config.performance?.chunkSplit?.strategy && config.performance?.chunkSplit?.strategy !== 'all-in-one';
|
|
165
|
-
return (0, core_.mergeRsbuildConfig)({
|
|
166
|
-
mode: (()=>{
|
|
167
|
-
if (config.mode) return config.mode;
|
|
168
|
-
const nodeEnv = process.env['NODE_ENV'];
|
|
169
|
-
return 'production' === nodeEnv || 'development' === nodeEnv ? nodeEnv : 'none';
|
|
170
|
-
})(),
|
|
171
|
-
output: {
|
|
172
|
-
filename: getFilename(config.output?.filename),
|
|
173
|
-
inlineScripts: !enableChunkSplitting,
|
|
174
|
-
cssModules: {
|
|
175
|
-
localIdentName: '[local]-[hash:base64:6]'
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
performance: {
|
|
179
|
-
profile: (0, debug._o)() ? true : void 0
|
|
180
|
-
},
|
|
181
|
-
tools: {
|
|
182
|
-
rsdoctor: {
|
|
183
|
-
experiments: {
|
|
184
|
-
enableNativePlugin: true
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}, config);
|
|
189
|
-
}
|
|
190
|
-
const DEFAULT_FILENAME = '[name].[platform].bundle';
|
|
191
|
-
function getFilename(filename) {
|
|
192
|
-
if ('string' == typeof filename) return {
|
|
193
|
-
bundle: filename,
|
|
194
|
-
template: filename
|
|
195
|
-
};
|
|
196
|
-
const finalFilename = filename?.bundle ?? filename?.template ?? DEFAULT_FILENAME;
|
|
197
|
-
return {
|
|
198
|
-
bundle: finalFilename,
|
|
199
|
-
template: finalFilename
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
const DEFAULT_ENTRY = './src/index.js';
|
|
203
|
-
function toRsbuildEntry(entry) {
|
|
204
|
-
if (void 0 === entry) {
|
|
205
|
-
(0, debug.Yz)(`Using default entry ${DEFAULT_ENTRY}`);
|
|
206
|
-
return {
|
|
207
|
-
main: DEFAULT_ENTRY
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
if (Array.isArray(entry) || 'string' == typeof entry) {
|
|
211
|
-
(0, debug.Yz)(()=>`Using single entry ${[
|
|
212
|
-
''
|
|
213
|
-
].concat(entry).join('\n - ')}`);
|
|
214
|
-
return {
|
|
215
|
-
main: entry
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
return Object.fromEntries(Object.entries(entry).map(([key, value])=>{
|
|
219
|
-
if (Array.isArray(value) || 'string' == typeof value) {
|
|
220
|
-
(0, debug.Iv)(`Using multiple entries - ${key}`, value);
|
|
221
|
-
return [
|
|
222
|
-
key,
|
|
223
|
-
{
|
|
224
|
-
import: value
|
|
225
|
-
}
|
|
226
|
-
];
|
|
227
|
-
}
|
|
228
|
-
(0, debug.Iv)(`Using multiple entries - ${key}`, value.import ?? DEFAULT_ENTRY);
|
|
229
|
-
if (void 0 === value.import) return [
|
|
230
|
-
key,
|
|
231
|
-
{
|
|
232
|
-
...value,
|
|
233
|
-
import: DEFAULT_ENTRY
|
|
234
|
-
}
|
|
235
|
-
];
|
|
236
|
-
return [
|
|
237
|
-
key,
|
|
238
|
-
value
|
|
239
|
-
];
|
|
240
|
-
}));
|
|
241
|
-
}
|
|
242
|
-
const defaultDataUriLimit = 2048;
|
|
243
|
-
function toRsbuildConfig(config) {
|
|
244
|
-
return {
|
|
245
|
-
dev: {
|
|
246
|
-
hmr: config.dev?.hmr ?? true,
|
|
247
|
-
lazyCompilation: false,
|
|
248
|
-
liveReload: config.dev?.liveReload ?? true,
|
|
249
|
-
watchFiles: config.dev?.watchFiles,
|
|
250
|
-
writeToDisk: config.dev?.writeToDisk ?? true,
|
|
251
|
-
progressBar: config.dev?.progressBar ?? true
|
|
252
|
-
},
|
|
253
|
-
environments: config.environments ?? {
|
|
254
|
-
lynx: {}
|
|
255
|
-
},
|
|
256
|
-
mode: config.mode,
|
|
257
|
-
output: {
|
|
258
|
-
assetPrefix: config.output?.assetPrefix,
|
|
259
|
-
charset: 'utf8',
|
|
260
|
-
cleanDistPath: config.output?.cleanDistPath,
|
|
261
|
-
copy: config.output?.copy,
|
|
262
|
-
cssModules: config.output?.cssModules,
|
|
263
|
-
dataUriLimit: config.output?.dataUriLimit ?? defaultDataUriLimit,
|
|
264
|
-
distPath: config.output?.distPath,
|
|
265
|
-
filenameHash: config.output?.filenameHash,
|
|
266
|
-
inlineScripts: config.output?.inlineScripts,
|
|
267
|
-
legalComments: config.output?.legalComments ?? 'none',
|
|
268
|
-
polyfill: 'off',
|
|
269
|
-
sourceMap: config.output?.sourceMap
|
|
270
|
-
},
|
|
271
|
-
resolve: {
|
|
272
|
-
alias: config.resolve?.alias,
|
|
273
|
-
aliasStrategy: config.resolve?.aliasStrategy,
|
|
274
|
-
dedupe: config.resolve?.dedupe,
|
|
275
|
-
extensions: config.resolve?.extensions
|
|
276
|
-
},
|
|
277
|
-
source: {
|
|
278
|
-
alias: config.source?.alias,
|
|
279
|
-
assetsInclude: config.source?.assetsInclude,
|
|
280
|
-
decorators: config.source?.decorators,
|
|
281
|
-
define: config.source?.define,
|
|
282
|
-
entry: toRsbuildEntry(config.source?.entry),
|
|
283
|
-
exclude: config.source?.exclude,
|
|
284
|
-
include: config.source?.include,
|
|
285
|
-
preEntry: config.source?.preEntry,
|
|
286
|
-
transformImport: config.source?.transformImport,
|
|
287
|
-
tsconfigPath: config.source?.tsconfigPath
|
|
288
|
-
},
|
|
289
|
-
server: {
|
|
290
|
-
base: config.server?.base,
|
|
291
|
-
compress: config.server?.compress,
|
|
292
|
-
cors: config.server?.cors,
|
|
293
|
-
headers: config.server?.headers,
|
|
294
|
-
host: config.server?.host,
|
|
295
|
-
port: config.server?.port,
|
|
296
|
-
proxy: config.server?.proxy,
|
|
297
|
-
strictPort: config.server?.strictPort
|
|
298
|
-
},
|
|
299
|
-
plugins: config.plugins,
|
|
300
|
-
performance: {
|
|
301
|
-
buildCache: config.performance?.buildCache,
|
|
302
|
-
chunkSplit: config.performance?.chunkSplit,
|
|
303
|
-
profile: config.performance?.profile,
|
|
304
|
-
removeConsole: toRsbuildRemoveConsole(config),
|
|
305
|
-
printFileSize: config.performance?.printFileSize ?? true
|
|
306
|
-
},
|
|
307
|
-
tools: {
|
|
308
|
-
bundlerChain: config.tools?.bundlerChain,
|
|
309
|
-
cssExtract: config.tools?.cssExtract,
|
|
310
|
-
cssLoader: config.tools?.cssLoader,
|
|
311
|
-
htmlPlugin: false,
|
|
312
|
-
rspack: config.tools?.rspack,
|
|
313
|
-
swc: config.tools?.swc
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
function toRsbuildRemoveConsole(config) {
|
|
318
|
-
if (config.performance?.removeConsole === true) return [
|
|
319
|
-
'log',
|
|
320
|
-
'warn',
|
|
321
|
-
'error',
|
|
322
|
-
'info',
|
|
323
|
-
'debug',
|
|
324
|
-
'profile',
|
|
325
|
-
'profileEnd'
|
|
326
|
-
];
|
|
327
|
-
return config.performance?.removeConsole;
|
|
328
|
-
}
|
|
329
|
-
async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [], callerName = 'rspeedy' }) {
|
|
330
|
-
const config = applyDefaultRspeedyConfig(rspeedyConfig);
|
|
331
|
-
const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
|
|
332
|
-
(0, core_.createRsbuild)({
|
|
333
|
-
cwd,
|
|
334
|
-
loadEnv,
|
|
335
|
-
rsbuildConfig: toRsbuildConfig(config),
|
|
336
|
-
environment,
|
|
337
|
-
callerName
|
|
338
|
-
}),
|
|
339
|
-
__webpack_require__.e("src_plugins_index_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/index.ts"))
|
|
340
|
-
]);
|
|
341
|
-
await applyDefaultPlugins(rspeedy, config);
|
|
342
|
-
const inspectConfig = rspeedy.inspectConfig.bind(rspeedy);
|
|
343
|
-
return Object.assign(rspeedy, {
|
|
344
|
-
getRspeedyConfig: ()=>config,
|
|
345
|
-
async inspectConfig (options) {
|
|
346
|
-
const result = await inspectConfig(options);
|
|
347
|
-
const { inspectRspeedyConfig } = await Promise.all([
|
|
348
|
-
__webpack_require__.e("vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-562fbc"),
|
|
349
|
-
__webpack_require__.e("src_plugins_inspect_plugin_ts")
|
|
350
|
-
]).then(__webpack_require__.bind(__webpack_require__, "./src/plugins/inspect.plugin.ts"));
|
|
351
|
-
await inspectRspeedyConfig(rspeedyConfig, external_node_path_["default"].resolve(options.outputPath ?? rspeedy.context.distPath, '.rsbuild/rspeedy.config.js'), options.verbose ?? false);
|
|
352
|
-
return result;
|
|
353
|
-
}
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
},
|
|
357
|
-
"node:fs" (module) {
|
|
358
|
-
module.exports = __rspack_external_node_fs_5ea92f0c;
|
|
1
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
2
|
+
import "./node_fs.js";
|
|
3
|
+
import { logger } from "./src_debug_ts.js";
|
|
4
|
+
import { exit_exit } from "./src_cli_main_ts.js";
|
|
5
|
+
import { createRspeedy, init } from "./1~src_cli_init_ts-src_create-rspeedy_ts.js";
|
|
6
|
+
const external_node_fs_ = __webpack_require__("node:fs");
|
|
7
|
+
const picocolors = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
8
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
9
|
+
async function preview(cwd, previewOptions) {
|
|
10
|
+
try {
|
|
11
|
+
const { createRspeedyOptions } = await init(cwd, previewOptions);
|
|
12
|
+
const rspeedy = await createRspeedy(createRspeedyOptions);
|
|
13
|
+
await rspeedy.initConfigs();
|
|
14
|
+
const { distPath } = rspeedy.context;
|
|
15
|
+
if (!external_node_fs_["default"].existsSync(distPath)) throw new Error(`The output directory ${picocolors_default().yellow(distPath)} does not exist, please build the project before previewing.`);
|
|
16
|
+
await rspeedy.preview();
|
|
17
|
+
} catch (error) {
|
|
18
|
+
logger.error('Failed to start preview server.');
|
|
19
|
+
logger.error(error);
|
|
20
|
+
exit_exit(1);
|
|
21
|
+
return;
|
|
359
22
|
}
|
|
360
|
-
}
|
|
23
|
+
}
|
|
24
|
+
export { preview };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
async function watchFiles(files, callback) {
|
|
2
|
+
const chokidar = await import("./1~node_modules_pnpm_chokidar_4_0_3_node_modules_chokidar_esm_index_js.js").then((mod)=>({
|
|
3
|
+
default: mod.chokidar_esm
|
|
4
|
+
}));
|
|
5
|
+
const watcher = chokidar.default.watch(files, {
|
|
6
|
+
ignoreInitial: true,
|
|
7
|
+
ignorePermissionErrors: true
|
|
8
|
+
});
|
|
9
|
+
const cb = debounce((event, filePath)=>{
|
|
10
|
+
const startTime = Date.now();
|
|
11
|
+
watcher.close().then(()=>callback(filePath, startTime, event));
|
|
12
|
+
}, 300);
|
|
13
|
+
watcher.once('add', cb.bind(null, 'add'));
|
|
14
|
+
watcher.once('change', cb.bind(null, 'change'));
|
|
15
|
+
watcher.once('unlink', cb.bind(null, 'unlink'));
|
|
16
|
+
}
|
|
17
|
+
function debounce(func, wait) {
|
|
18
|
+
let timeoutId = null;
|
|
19
|
+
return (...args)=>{
|
|
20
|
+
if (null !== timeoutId) clearTimeout(timeoutId);
|
|
21
|
+
timeoutId = setTimeout(()=>{
|
|
22
|
+
func(...args);
|
|
23
|
+
}, wait);
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function getWatchedFiles(configPath, rspeedyConfig) {
|
|
27
|
+
const watchedFiles = [
|
|
28
|
+
configPath
|
|
29
|
+
];
|
|
30
|
+
if (Array.isArray(rspeedyConfig.dev?.watchFiles)) watchedFiles.push(...rspeedyConfig.dev.watchFiles.filter((item)=>'reload-server' === item.type).flatMap((item)=>item.paths));
|
|
31
|
+
else if (rspeedyConfig.dev?.watchFiles?.type === 'reload-server') {
|
|
32
|
+
const { paths } = rspeedyConfig.dev.watchFiles;
|
|
33
|
+
watchedFiles.push(...Array.isArray(paths) ? paths : [
|
|
34
|
+
paths
|
|
35
|
+
]);
|
|
36
|
+
}
|
|
37
|
+
return watchedFiles;
|
|
38
|
+
}
|
|
39
|
+
export { getWatchedFiles, watchFiles };
|