@lynx-js/rspeedy 0.9.1 → 0.9.3

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.
@@ -17,15 +17,15 @@ export const __webpack_modules__ = {
17
17
  cwd,
18
18
  configPath: inspectOptions.config
19
19
  });
20
- const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_3__.S)({
20
+ const options = {
21
21
  cwd,
22
- rspeedyConfig,
23
- ...inspectOptions.envMode ? {
24
- loadEnv: {
25
- mode: inspectOptions.envMode
26
- }
27
- } : {}
28
- });
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
29
  await rspeedy.inspectConfig({
30
30
  mode: inspectOptions.mode ?? process.env['NODE_ENV'] ?? 'development',
31
31
  verbose: inspectOptions.verbose ?? false,
@@ -38,5 +38,247 @@ export const __webpack_modules__ = {
38
38
  _rsbuild_core__WEBPACK_IMPORTED_MODULE_0__.logger.error();
39
39
  }
40
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");
54
+ const resolveConfigPath = (root, customConfig)=>{
55
+ if (customConfig) {
56
+ (0, _debug_js__WEBPACK_IMPORTED_MODULE_4__.fF)(`load custom config file ${customConfig} from ${root}`);
57
+ const customConfigPath = (0, node_path__WEBPACK_IMPORTED_MODULE_1__.isAbsolute)(customConfig) ? customConfig : (0, node_path__WEBPACK_IMPORTED_MODULE_1__.join)(root, customConfig);
58
+ if (node_fs__WEBPACK_IMPORTED_MODULE_0__["default"].existsSync(customConfigPath)) return customConfigPath;
59
+ throw new Error(`Cannot find config file: ${picocolors__WEBPACK_IMPORTED_MODULE_5___default().dim(customConfigPath)}`);
60
+ }
61
+ const CONFIG_FILES = [
62
+ 'lynx.config.ts',
63
+ 'lynx.config.js',
64
+ 'lynx.config.mts',
65
+ 'lynx.config.mjs'
66
+ ];
67
+ for (const file of CONFIG_FILES){
68
+ (0, _debug_js__WEBPACK_IMPORTED_MODULE_4__.fF)(`load default config file ${file} from ${root}`);
69
+ const configFile = (0, node_path__WEBPACK_IMPORTED_MODULE_1__.join)(root, file);
70
+ if (node_fs__WEBPACK_IMPORTED_MODULE_0__["default"].existsSync(configFile)) {
71
+ (0, _debug_js__WEBPACK_IMPORTED_MODULE_4__.fF)(`default config ${configFile} found`);
72
+ return configFile;
73
+ }
74
+ }
75
+ throw new Error([
76
+ `Cannot find the default config file: ${picocolors__WEBPACK_IMPORTED_MODULE_5___default().dim((0, node_path__WEBPACK_IMPORTED_MODULE_1__.join)(root, CONFIG_FILES[0]))}.`,
77
+ `Use custom config with ${picocolors__WEBPACK_IMPORTED_MODULE_5___default().green('`--config <config>`')} options.`
78
+ ].join(' '));
79
+ };
80
+ async function loadConfig(loadConfigOptions) {
81
+ let { configPath } = loadConfigOptions;
82
+ if (!configPath || !(0, node_path__WEBPACK_IMPORTED_MODULE_1__.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
83
+ const specifier = (0, node_url__WEBPACK_IMPORTED_MODULE_2__.pathToFileURL)(configPath).toString();
84
+ const unregister = shouldUseNativeImport(configPath) ? ()=>void 0 : (0, _lynx_js_rspeedy_register__WEBPACK_IMPORTED_MODULE_3__.register)();
85
+ try {
86
+ const [exports, { validate }] = await Promise.all([
87
+ import(`${specifier}?t=${Date.now()}`),
88
+ __webpack_require__.e("src_config_validate_ts").then(__webpack_require__.bind(__webpack_require__, "./src/config/validate.ts"))
89
+ ]);
90
+ const content = validate('default' in exports ? exports.default : exports, configPath);
91
+ return {
92
+ configPath,
93
+ content
94
+ };
95
+ } finally{
96
+ unregister();
97
+ }
98
+ }
99
+ function shouldUseNativeImport(configPath) {
100
+ return isJavaScriptPath(configPath) || hasNativeTSSupport();
101
+ }
102
+ function hasNativeTSSupport() {
103
+ if (process.features.typescript) return true;
104
+ if (false === process.features.typescript) return false;
105
+ const { NODE_OPTIONS } = process.env;
106
+ if (!NODE_OPTIONS) return false;
107
+ return NODE_OPTIONS.includes('--experimental-transform-types') || NODE_OPTIONS.includes('--experimental-strip-types');
108
+ }
109
+ function isJavaScriptPath(configPath) {
110
+ const ext = (0, node_path__WEBPACK_IMPORTED_MODULE_1__.extname)(configPath);
111
+ return [
112
+ '.js',
113
+ '.mjs',
114
+ '.cjs'
115
+ ].includes(ext);
116
+ }
117
+ },
118
+ "./src/create-rspeedy.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
119
+ __webpack_require__.d(__webpack_exports__, {
120
+ S: ()=>createRspeedy
121
+ });
122
+ var external_node_path_ = __webpack_require__("node:path");
123
+ var core_ = __webpack_require__("@rsbuild/core");
124
+ function applyDefaultRspeedyConfig(config) {
125
+ const ret = (0, core_.mergeRsbuildConfig)(config, {
126
+ output: {
127
+ filename: getFilename(config.output?.filename)
128
+ }
129
+ });
130
+ return ret;
131
+ }
132
+ const DEFAULT_FILENAME = '[name].[platform].bundle';
133
+ function getFilename(filename) {
134
+ if ('string' == typeof filename) return {
135
+ bundle: filename,
136
+ template: filename
137
+ };
138
+ const finalFilename = filename?.bundle ?? filename?.template ?? DEFAULT_FILENAME;
139
+ return {
140
+ bundle: finalFilename,
141
+ template: finalFilename
142
+ };
143
+ }
144
+ var debug = __webpack_require__("./src/debug.ts");
145
+ const DEFAULT_ENTRY = './src/index.js';
146
+ function toRsbuildEntry(entry) {
147
+ if (void 0 === entry) {
148
+ (0, debug.fF)(`Using default entry ${DEFAULT_ENTRY}`);
149
+ return {
150
+ main: DEFAULT_ENTRY
151
+ };
152
+ }
153
+ if (Array.isArray(entry) || 'string' == typeof entry) {
154
+ (0, debug.fF)(()=>`Using single entry ${[
155
+ ''
156
+ ].concat(entry).join('\n - ')}`);
157
+ return {
158
+ main: entry
159
+ };
160
+ }
161
+ return Object.fromEntries(Object.entries(entry).map(([key, value])=>{
162
+ if (Array.isArray(value) || 'string' == typeof value) {
163
+ (0, debug.NW)(`Using multiple entries - ${key}`, value);
164
+ return [
165
+ key,
166
+ {
167
+ import: value
168
+ }
169
+ ];
170
+ }
171
+ (0, debug.NW)(`Using multiple entries - ${key}`, value.import ?? DEFAULT_ENTRY);
172
+ if (void 0 === value.import) return [
173
+ key,
174
+ {
175
+ ...value,
176
+ import: DEFAULT_ENTRY
177
+ }
178
+ ];
179
+ return [
180
+ key,
181
+ value
182
+ ];
183
+ }));
184
+ }
185
+ const defaultDataUriLimit = 2048;
186
+ function toRsbuildConfig(config) {
187
+ return {
188
+ provider: config.provider,
189
+ dev: {
190
+ watchFiles: config.dev?.watchFiles,
191
+ writeToDisk: config.dev?.writeToDisk ?? true,
192
+ progressBar: config.dev?.progressBar ?? true
193
+ },
194
+ environments: config.environments ?? {
195
+ lynx: {}
196
+ },
197
+ mode: config.mode,
198
+ output: {
199
+ assetPrefix: config.output?.assetPrefix,
200
+ charset: 'utf8',
201
+ cleanDistPath: config.output?.cleanDistPath,
202
+ copy: config.output?.copy,
203
+ cssModules: config.output?.cssModules,
204
+ dataUriLimit: config.output?.dataUriLimit ?? defaultDataUriLimit,
205
+ distPath: config.output?.distPath,
206
+ filenameHash: config.output?.filenameHash,
207
+ legalComments: config.output?.legalComments ?? 'none',
208
+ polyfill: 'off',
209
+ sourceMap: config.output?.sourceMap
210
+ },
211
+ source: {
212
+ alias: config.source?.alias,
213
+ assetsInclude: config.source?.assetsInclude,
214
+ decorators: config.source?.decorators,
215
+ define: config.source?.define,
216
+ entry: toRsbuildEntry(config.source?.entry),
217
+ exclude: config.source?.exclude,
218
+ include: config.source?.include,
219
+ transformImport: config.source?.transformImport,
220
+ tsconfigPath: config.source?.tsconfigPath
221
+ },
222
+ server: {
223
+ base: config.server?.base,
224
+ headers: config.server?.headers,
225
+ host: config.server?.host,
226
+ port: config.server?.port,
227
+ strictPort: config.server?.strictPort
228
+ },
229
+ plugins: config.plugins,
230
+ performance: {
231
+ chunkSplit: config.performance?.chunkSplit,
232
+ removeConsole: toRsbuildRemoveConsole(config),
233
+ printFileSize: config.performance?.printFileSize ?? true
234
+ },
235
+ tools: {
236
+ bundlerChain: config.tools?.bundlerChain,
237
+ cssExtract: config.tools?.cssExtract,
238
+ cssLoader: config.tools?.cssLoader,
239
+ htmlPlugin: false,
240
+ rspack: config.tools?.rspack,
241
+ swc: config.tools?.swc
242
+ }
243
+ };
244
+ }
245
+ function toRsbuildRemoveConsole(config) {
246
+ if (config.performance?.removeConsole === true) return [
247
+ 'log',
248
+ 'warn',
249
+ 'error',
250
+ 'info',
251
+ 'debug',
252
+ 'profile',
253
+ 'profileEnd'
254
+ ];
255
+ return config.performance?.removeConsole;
256
+ }
257
+ async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [] }) {
258
+ const config = applyDefaultRspeedyConfig(rspeedyConfig);
259
+ const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
260
+ (0, core_.createRsbuild)({
261
+ cwd,
262
+ loadEnv,
263
+ rsbuildConfig: toRsbuildConfig(config),
264
+ environment
265
+ }),
266
+ __webpack_require__.e("src_plugins_index_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/index.ts"))
267
+ ]);
268
+ await applyDefaultPlugins(rspeedy, config);
269
+ const inspectConfig = rspeedy.inspectConfig.bind(rspeedy);
270
+ return Object.assign(rspeedy, {
271
+ getRspeedyConfig: ()=>config,
272
+ async inspectConfig (options) {
273
+ const result = await inspectConfig(options);
274
+ const { inspectRspeedyConfig } = await Promise.all([
275
+ __webpack_require__.e("vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-b558be"),
276
+ __webpack_require__.e("src_plugins_inspect_plugin_ts")
277
+ ]).then(__webpack_require__.bind(__webpack_require__, "./src/plugins/inspect.plugin.ts"));
278
+ await inspectRspeedyConfig(rspeedyConfig, external_node_path_["default"].resolve(options.outputPath ?? rspeedy.context.distPath, '.rsbuild/rspeedy.config.js'), options.verbose ?? false);
279
+ return result;
280
+ }
281
+ });
282
+ }
41
283
  }
42
284
  };
@@ -25,15 +25,15 @@ export const __webpack_modules__ = {
25
25
  rspeedyConfig.server ??= {};
26
26
  rspeedyConfig.server.base = previewOptions.base;
27
27
  }
28
- const rspeedy = await (0, _create_rspeedy_js__WEBPACK_IMPORTED_MODULE_4__.S)({
28
+ const options = {
29
29
  cwd,
30
- rspeedyConfig,
31
- ...previewOptions.envMode ? {
32
- loadEnv: {
33
- mode: previewOptions.envMode
34
- }
35
- } : {}
36
- });
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
37
  await rspeedy.initConfigs();
38
38
  const { distPath } = rspeedy.context;
39
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.`);
@@ -45,5 +45,247 @@ export const __webpack_modules__ = {
45
45
  return;
46
46
  }
47
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");
61
+ const resolveConfigPath = (root, customConfig)=>{
62
+ if (customConfig) {
63
+ (0, _debug_js__WEBPACK_IMPORTED_MODULE_4__.fF)(`load custom config file ${customConfig} from ${root}`);
64
+ const customConfigPath = (0, node_path__WEBPACK_IMPORTED_MODULE_1__.isAbsolute)(customConfig) ? customConfig : (0, node_path__WEBPACK_IMPORTED_MODULE_1__.join)(root, customConfig);
65
+ if (node_fs__WEBPACK_IMPORTED_MODULE_0__["default"].existsSync(customConfigPath)) return customConfigPath;
66
+ throw new Error(`Cannot find config file: ${picocolors__WEBPACK_IMPORTED_MODULE_5___default().dim(customConfigPath)}`);
67
+ }
68
+ const CONFIG_FILES = [
69
+ 'lynx.config.ts',
70
+ 'lynx.config.js',
71
+ 'lynx.config.mts',
72
+ 'lynx.config.mjs'
73
+ ];
74
+ for (const file of CONFIG_FILES){
75
+ (0, _debug_js__WEBPACK_IMPORTED_MODULE_4__.fF)(`load default config file ${file} from ${root}`);
76
+ const configFile = (0, node_path__WEBPACK_IMPORTED_MODULE_1__.join)(root, file);
77
+ if (node_fs__WEBPACK_IMPORTED_MODULE_0__["default"].existsSync(configFile)) {
78
+ (0, _debug_js__WEBPACK_IMPORTED_MODULE_4__.fF)(`default config ${configFile} found`);
79
+ return configFile;
80
+ }
81
+ }
82
+ throw new Error([
83
+ `Cannot find the default config file: ${picocolors__WEBPACK_IMPORTED_MODULE_5___default().dim((0, node_path__WEBPACK_IMPORTED_MODULE_1__.join)(root, CONFIG_FILES[0]))}.`,
84
+ `Use custom config with ${picocolors__WEBPACK_IMPORTED_MODULE_5___default().green('`--config <config>`')} options.`
85
+ ].join(' '));
86
+ };
87
+ async function loadConfig(loadConfigOptions) {
88
+ let { configPath } = loadConfigOptions;
89
+ if (!configPath || !(0, node_path__WEBPACK_IMPORTED_MODULE_1__.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
90
+ const specifier = (0, node_url__WEBPACK_IMPORTED_MODULE_2__.pathToFileURL)(configPath).toString();
91
+ const unregister = shouldUseNativeImport(configPath) ? ()=>void 0 : (0, _lynx_js_rspeedy_register__WEBPACK_IMPORTED_MODULE_3__.register)();
92
+ try {
93
+ const [exports, { validate }] = await Promise.all([
94
+ import(`${specifier}?t=${Date.now()}`),
95
+ __webpack_require__.e("src_config_validate_ts").then(__webpack_require__.bind(__webpack_require__, "./src/config/validate.ts"))
96
+ ]);
97
+ const content = validate('default' in exports ? exports.default : exports, configPath);
98
+ return {
99
+ configPath,
100
+ content
101
+ };
102
+ } finally{
103
+ unregister();
104
+ }
105
+ }
106
+ function shouldUseNativeImport(configPath) {
107
+ return isJavaScriptPath(configPath) || hasNativeTSSupport();
108
+ }
109
+ function hasNativeTSSupport() {
110
+ if (process.features.typescript) return true;
111
+ if (false === process.features.typescript) return false;
112
+ const { NODE_OPTIONS } = process.env;
113
+ if (!NODE_OPTIONS) return false;
114
+ return NODE_OPTIONS.includes('--experimental-transform-types') || NODE_OPTIONS.includes('--experimental-strip-types');
115
+ }
116
+ function isJavaScriptPath(configPath) {
117
+ const ext = (0, node_path__WEBPACK_IMPORTED_MODULE_1__.extname)(configPath);
118
+ return [
119
+ '.js',
120
+ '.mjs',
121
+ '.cjs'
122
+ ].includes(ext);
123
+ }
124
+ },
125
+ "./src/create-rspeedy.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
126
+ __webpack_require__.d(__webpack_exports__, {
127
+ S: ()=>createRspeedy
128
+ });
129
+ var external_node_path_ = __webpack_require__("node:path");
130
+ var core_ = __webpack_require__("@rsbuild/core");
131
+ function applyDefaultRspeedyConfig(config) {
132
+ const ret = (0, core_.mergeRsbuildConfig)(config, {
133
+ output: {
134
+ filename: getFilename(config.output?.filename)
135
+ }
136
+ });
137
+ return ret;
138
+ }
139
+ const DEFAULT_FILENAME = '[name].[platform].bundle';
140
+ function getFilename(filename) {
141
+ if ('string' == typeof filename) return {
142
+ bundle: filename,
143
+ template: filename
144
+ };
145
+ const finalFilename = filename?.bundle ?? filename?.template ?? DEFAULT_FILENAME;
146
+ return {
147
+ bundle: finalFilename,
148
+ template: finalFilename
149
+ };
150
+ }
151
+ var debug = __webpack_require__("./src/debug.ts");
152
+ const DEFAULT_ENTRY = './src/index.js';
153
+ function toRsbuildEntry(entry) {
154
+ if (void 0 === entry) {
155
+ (0, debug.fF)(`Using default entry ${DEFAULT_ENTRY}`);
156
+ return {
157
+ main: DEFAULT_ENTRY
158
+ };
159
+ }
160
+ if (Array.isArray(entry) || 'string' == typeof entry) {
161
+ (0, debug.fF)(()=>`Using single entry ${[
162
+ ''
163
+ ].concat(entry).join('\n - ')}`);
164
+ return {
165
+ main: entry
166
+ };
167
+ }
168
+ return Object.fromEntries(Object.entries(entry).map(([key, value])=>{
169
+ if (Array.isArray(value) || 'string' == typeof value) {
170
+ (0, debug.NW)(`Using multiple entries - ${key}`, value);
171
+ return [
172
+ key,
173
+ {
174
+ import: value
175
+ }
176
+ ];
177
+ }
178
+ (0, debug.NW)(`Using multiple entries - ${key}`, value.import ?? DEFAULT_ENTRY);
179
+ if (void 0 === value.import) return [
180
+ key,
181
+ {
182
+ ...value,
183
+ import: DEFAULT_ENTRY
184
+ }
185
+ ];
186
+ return [
187
+ key,
188
+ value
189
+ ];
190
+ }));
191
+ }
192
+ const defaultDataUriLimit = 2048;
193
+ function toRsbuildConfig(config) {
194
+ return {
195
+ provider: config.provider,
196
+ dev: {
197
+ watchFiles: config.dev?.watchFiles,
198
+ writeToDisk: config.dev?.writeToDisk ?? true,
199
+ progressBar: config.dev?.progressBar ?? true
200
+ },
201
+ environments: config.environments ?? {
202
+ lynx: {}
203
+ },
204
+ mode: config.mode,
205
+ output: {
206
+ assetPrefix: config.output?.assetPrefix,
207
+ charset: 'utf8',
208
+ cleanDistPath: config.output?.cleanDistPath,
209
+ copy: config.output?.copy,
210
+ cssModules: config.output?.cssModules,
211
+ dataUriLimit: config.output?.dataUriLimit ?? defaultDataUriLimit,
212
+ distPath: config.output?.distPath,
213
+ filenameHash: config.output?.filenameHash,
214
+ legalComments: config.output?.legalComments ?? 'none',
215
+ polyfill: 'off',
216
+ sourceMap: config.output?.sourceMap
217
+ },
218
+ source: {
219
+ alias: config.source?.alias,
220
+ assetsInclude: config.source?.assetsInclude,
221
+ decorators: config.source?.decorators,
222
+ define: config.source?.define,
223
+ entry: toRsbuildEntry(config.source?.entry),
224
+ exclude: config.source?.exclude,
225
+ include: config.source?.include,
226
+ transformImport: config.source?.transformImport,
227
+ tsconfigPath: config.source?.tsconfigPath
228
+ },
229
+ server: {
230
+ base: config.server?.base,
231
+ headers: config.server?.headers,
232
+ host: config.server?.host,
233
+ port: config.server?.port,
234
+ strictPort: config.server?.strictPort
235
+ },
236
+ plugins: config.plugins,
237
+ performance: {
238
+ chunkSplit: config.performance?.chunkSplit,
239
+ removeConsole: toRsbuildRemoveConsole(config),
240
+ printFileSize: config.performance?.printFileSize ?? true
241
+ },
242
+ tools: {
243
+ bundlerChain: config.tools?.bundlerChain,
244
+ cssExtract: config.tools?.cssExtract,
245
+ cssLoader: config.tools?.cssLoader,
246
+ htmlPlugin: false,
247
+ rspack: config.tools?.rspack,
248
+ swc: config.tools?.swc
249
+ }
250
+ };
251
+ }
252
+ function toRsbuildRemoveConsole(config) {
253
+ if (config.performance?.removeConsole === true) return [
254
+ 'log',
255
+ 'warn',
256
+ 'error',
257
+ 'info',
258
+ 'debug',
259
+ 'profile',
260
+ 'profileEnd'
261
+ ];
262
+ return config.performance?.removeConsole;
263
+ }
264
+ async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [] }) {
265
+ const config = applyDefaultRspeedyConfig(rspeedyConfig);
266
+ const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
267
+ (0, core_.createRsbuild)({
268
+ cwd,
269
+ loadEnv,
270
+ rsbuildConfig: toRsbuildConfig(config),
271
+ environment
272
+ }),
273
+ __webpack_require__.e("src_plugins_index_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/index.ts"))
274
+ ]);
275
+ await applyDefaultPlugins(rspeedy, config);
276
+ const inspectConfig = rspeedy.inspectConfig.bind(rspeedy);
277
+ return Object.assign(rspeedy, {
278
+ getRspeedyConfig: ()=>config,
279
+ async inspectConfig (options) {
280
+ const result = await inspectConfig(options);
281
+ const { inspectRspeedyConfig } = await Promise.all([
282
+ __webpack_require__.e("vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-b558be"),
283
+ __webpack_require__.e("src_plugins_inspect_plugin_ts")
284
+ ]).then(__webpack_require__.bind(__webpack_require__, "./src/plugins/inspect.plugin.ts"));
285
+ await inspectRspeedyConfig(rspeedyConfig, external_node_path_["default"].resolve(options.outputPath ?? rspeedy.context.distPath, '.rsbuild/rspeedy.config.js'), options.verbose ?? false);
286
+ return result;
287
+ }
288
+ });
289
+ }
48
290
  }
49
291
  };