@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.
@@ -23,7 +23,8 @@ export const __webpack_modules__ = {
23
23
  cwd,
24
24
  rspeedyConfig
25
25
  };
26
- if (buildOptions.envMode) options.loadEnv = {
26
+ if (buildOptions.noEnv) options.loadEnv = false;
27
+ else if (buildOptions.envMode) options.loadEnv = {
27
28
  mode: buildOptions.envMode
28
29
  };
29
30
  if (buildOptions.environment) options.environment = buildOptions.environment;
@@ -36,6 +37,248 @@ export const __webpack_modules__ = {
36
37
  if (shouldExit) (0, _exit_js__WEBPACK_IMPORTED_MODULE_1__.exit)();
37
38
  }
38
39
  },
40
+ "./src/config/loadConfig.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
41
+ __webpack_require__.d(__webpack_exports__, {
42
+ ME: ()=>loadConfig,
43
+ Mk: ()=>resolveConfigPath
44
+ });
45
+ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
46
+ var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:path");
47
+ var node_url__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("node:url");
48
+ var picocolors__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
49
+ var picocolors__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_5__);
50
+ var _lynx_js_rspeedy_register__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("@lynx-js/rspeedy/register");
51
+ var _debug_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/debug.ts");
52
+ const resolveConfigPath = (root, customConfig)=>{
53
+ if (customConfig) {
54
+ (0, _debug_js__WEBPACK_IMPORTED_MODULE_4__.fF)(`load custom config file ${customConfig} from ${root}`);
55
+ const customConfigPath = (0, node_path__WEBPACK_IMPORTED_MODULE_1__.isAbsolute)(customConfig) ? customConfig : (0, node_path__WEBPACK_IMPORTED_MODULE_1__.join)(root, customConfig);
56
+ if (node_fs__WEBPACK_IMPORTED_MODULE_0__["default"].existsSync(customConfigPath)) return customConfigPath;
57
+ throw new Error(`Cannot find config file: ${picocolors__WEBPACK_IMPORTED_MODULE_5___default().dim(customConfigPath)}`);
58
+ }
59
+ const CONFIG_FILES = [
60
+ 'lynx.config.ts',
61
+ 'lynx.config.js',
62
+ 'lynx.config.mts',
63
+ 'lynx.config.mjs'
64
+ ];
65
+ for (const file of CONFIG_FILES){
66
+ (0, _debug_js__WEBPACK_IMPORTED_MODULE_4__.fF)(`load default config file ${file} from ${root}`);
67
+ const configFile = (0, node_path__WEBPACK_IMPORTED_MODULE_1__.join)(root, file);
68
+ if (node_fs__WEBPACK_IMPORTED_MODULE_0__["default"].existsSync(configFile)) {
69
+ (0, _debug_js__WEBPACK_IMPORTED_MODULE_4__.fF)(`default config ${configFile} found`);
70
+ return configFile;
71
+ }
72
+ }
73
+ throw new Error([
74
+ `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]))}.`,
75
+ `Use custom config with ${picocolors__WEBPACK_IMPORTED_MODULE_5___default().green('`--config <config>`')} options.`
76
+ ].join(' '));
77
+ };
78
+ async function loadConfig(loadConfigOptions) {
79
+ let { configPath } = loadConfigOptions;
80
+ if (!configPath || !(0, node_path__WEBPACK_IMPORTED_MODULE_1__.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
81
+ const specifier = (0, node_url__WEBPACK_IMPORTED_MODULE_2__.pathToFileURL)(configPath).toString();
82
+ const unregister = shouldUseNativeImport(configPath) ? ()=>void 0 : (0, _lynx_js_rspeedy_register__WEBPACK_IMPORTED_MODULE_3__.register)();
83
+ try {
84
+ const [exports, { validate }] = await Promise.all([
85
+ import(`${specifier}?t=${Date.now()}`),
86
+ __webpack_require__.e("src_config_validate_ts").then(__webpack_require__.bind(__webpack_require__, "./src/config/validate.ts"))
87
+ ]);
88
+ const content = validate('default' in exports ? exports.default : exports, configPath);
89
+ return {
90
+ configPath,
91
+ content
92
+ };
93
+ } finally{
94
+ unregister();
95
+ }
96
+ }
97
+ function shouldUseNativeImport(configPath) {
98
+ return isJavaScriptPath(configPath) || hasNativeTSSupport();
99
+ }
100
+ function hasNativeTSSupport() {
101
+ if (process.features.typescript) return true;
102
+ if (false === process.features.typescript) return false;
103
+ const { NODE_OPTIONS } = process.env;
104
+ if (!NODE_OPTIONS) return false;
105
+ return NODE_OPTIONS.includes('--experimental-transform-types') || NODE_OPTIONS.includes('--experimental-strip-types');
106
+ }
107
+ function isJavaScriptPath(configPath) {
108
+ const ext = (0, node_path__WEBPACK_IMPORTED_MODULE_1__.extname)(configPath);
109
+ return [
110
+ '.js',
111
+ '.mjs',
112
+ '.cjs'
113
+ ].includes(ext);
114
+ }
115
+ },
116
+ "./src/create-rspeedy.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
117
+ __webpack_require__.d(__webpack_exports__, {
118
+ S: ()=>createRspeedy
119
+ });
120
+ var external_node_path_ = __webpack_require__("node:path");
121
+ var core_ = __webpack_require__("@rsbuild/core");
122
+ function applyDefaultRspeedyConfig(config) {
123
+ const ret = (0, core_.mergeRsbuildConfig)(config, {
124
+ output: {
125
+ filename: getFilename(config.output?.filename)
126
+ }
127
+ });
128
+ return ret;
129
+ }
130
+ const DEFAULT_FILENAME = '[name].[platform].bundle';
131
+ function getFilename(filename) {
132
+ if ('string' == typeof filename) return {
133
+ bundle: filename,
134
+ template: filename
135
+ };
136
+ const finalFilename = filename?.bundle ?? filename?.template ?? DEFAULT_FILENAME;
137
+ return {
138
+ bundle: finalFilename,
139
+ template: finalFilename
140
+ };
141
+ }
142
+ var debug = __webpack_require__("./src/debug.ts");
143
+ const DEFAULT_ENTRY = './src/index.js';
144
+ function toRsbuildEntry(entry) {
145
+ if (void 0 === entry) {
146
+ (0, debug.fF)(`Using default entry ${DEFAULT_ENTRY}`);
147
+ return {
148
+ main: DEFAULT_ENTRY
149
+ };
150
+ }
151
+ if (Array.isArray(entry) || 'string' == typeof entry) {
152
+ (0, debug.fF)(()=>`Using single entry ${[
153
+ ''
154
+ ].concat(entry).join('\n - ')}`);
155
+ return {
156
+ main: entry
157
+ };
158
+ }
159
+ return Object.fromEntries(Object.entries(entry).map(([key, value])=>{
160
+ if (Array.isArray(value) || 'string' == typeof value) {
161
+ (0, debug.NW)(`Using multiple entries - ${key}`, value);
162
+ return [
163
+ key,
164
+ {
165
+ import: value
166
+ }
167
+ ];
168
+ }
169
+ (0, debug.NW)(`Using multiple entries - ${key}`, value.import ?? DEFAULT_ENTRY);
170
+ if (void 0 === value.import) return [
171
+ key,
172
+ {
173
+ ...value,
174
+ import: DEFAULT_ENTRY
175
+ }
176
+ ];
177
+ return [
178
+ key,
179
+ value
180
+ ];
181
+ }));
182
+ }
183
+ const defaultDataUriLimit = 2048;
184
+ function toRsbuildConfig(config) {
185
+ return {
186
+ provider: config.provider,
187
+ dev: {
188
+ watchFiles: config.dev?.watchFiles,
189
+ writeToDisk: config.dev?.writeToDisk ?? true,
190
+ progressBar: config.dev?.progressBar ?? true
191
+ },
192
+ environments: config.environments ?? {
193
+ lynx: {}
194
+ },
195
+ mode: config.mode,
196
+ output: {
197
+ assetPrefix: config.output?.assetPrefix,
198
+ charset: 'utf8',
199
+ cleanDistPath: config.output?.cleanDistPath,
200
+ copy: config.output?.copy,
201
+ cssModules: config.output?.cssModules,
202
+ dataUriLimit: config.output?.dataUriLimit ?? defaultDataUriLimit,
203
+ distPath: config.output?.distPath,
204
+ filenameHash: config.output?.filenameHash,
205
+ legalComments: config.output?.legalComments ?? 'none',
206
+ polyfill: 'off',
207
+ sourceMap: config.output?.sourceMap
208
+ },
209
+ source: {
210
+ alias: config.source?.alias,
211
+ assetsInclude: config.source?.assetsInclude,
212
+ decorators: config.source?.decorators,
213
+ define: config.source?.define,
214
+ entry: toRsbuildEntry(config.source?.entry),
215
+ exclude: config.source?.exclude,
216
+ include: config.source?.include,
217
+ transformImport: config.source?.transformImport,
218
+ tsconfigPath: config.source?.tsconfigPath
219
+ },
220
+ server: {
221
+ base: config.server?.base,
222
+ headers: config.server?.headers,
223
+ host: config.server?.host,
224
+ port: config.server?.port,
225
+ strictPort: config.server?.strictPort
226
+ },
227
+ plugins: config.plugins,
228
+ performance: {
229
+ chunkSplit: config.performance?.chunkSplit,
230
+ removeConsole: toRsbuildRemoveConsole(config),
231
+ printFileSize: config.performance?.printFileSize ?? true
232
+ },
233
+ tools: {
234
+ bundlerChain: config.tools?.bundlerChain,
235
+ cssExtract: config.tools?.cssExtract,
236
+ cssLoader: config.tools?.cssLoader,
237
+ htmlPlugin: false,
238
+ rspack: config.tools?.rspack,
239
+ swc: config.tools?.swc
240
+ }
241
+ };
242
+ }
243
+ function toRsbuildRemoveConsole(config) {
244
+ if (config.performance?.removeConsole === true) return [
245
+ 'log',
246
+ 'warn',
247
+ 'error',
248
+ 'info',
249
+ 'debug',
250
+ 'profile',
251
+ 'profileEnd'
252
+ ];
253
+ return config.performance?.removeConsole;
254
+ }
255
+ async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [] }) {
256
+ const config = applyDefaultRspeedyConfig(rspeedyConfig);
257
+ const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
258
+ (0, core_.createRsbuild)({
259
+ cwd,
260
+ loadEnv,
261
+ rsbuildConfig: toRsbuildConfig(config),
262
+ environment
263
+ }),
264
+ __webpack_require__.e("src_plugins_index_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/index.ts"))
265
+ ]);
266
+ await applyDefaultPlugins(rspeedy, config);
267
+ const inspectConfig = rspeedy.inspectConfig.bind(rspeedy);
268
+ return Object.assign(rspeedy, {
269
+ getRspeedyConfig: ()=>config,
270
+ async inspectConfig (options) {
271
+ const result = await inspectConfig(options);
272
+ const { inspectRspeedyConfig } = await Promise.all([
273
+ __webpack_require__.e("vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-b558be"),
274
+ __webpack_require__.e("src_plugins_inspect_plugin_ts")
275
+ ]).then(__webpack_require__.bind(__webpack_require__, "./src/plugins/inspect.plugin.ts"));
276
+ await inspectRspeedyConfig(rspeedyConfig, external_node_path_["default"].resolve(options.outputPath ?? rspeedy.context.distPath, '.rsbuild/rspeedy.config.js'), options.verbose ?? false);
277
+ return result;
278
+ }
279
+ });
280
+ }
281
+ },
39
282
  "./src/utils/is-ci.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
40
283
  __webpack_require__.d(__webpack_exports__, {
41
284
  y: ()=>isCI
@@ -9,31 +9,19 @@ 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"');
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"');
13
13
  }
14
14
  function apply(program) {
15
15
  const cwd = process.cwd();
16
16
  program.name('rspeedy').usage('<command> [options]').version(_version_js__WEBPACK_IMPORTED_MODULE_0__.version).option('--unmanaged', 'Force to use the unmanaged version of Rspeedy, instead of the locally installed.').showHelpAfterError(true).showSuggestionAfterError(true).exitOverride();
17
17
  const buildCommand = program.command('build');
18
- buildCommand.description('Build the project in production mode').option('--environment <name...>', 'specify the name of environment to build').action((buildOptions)=>Promise.all([
19
- __webpack_require__.e("src_config_loadConfig_ts-src_create-rspeedy_ts"),
20
- __webpack_require__.e("src_cli_build_ts")
21
- ]).then(__webpack_require__.bind(__webpack_require__, "./src/cli/build.ts")).then(({ build })=>build.call(buildCommand, cwd, buildOptions)));
18
+ buildCommand.description('Build the project in production mode').option('--environment <name...>', 'specify the name of environment to build').action((buildOptions)=>__webpack_require__.e("src_cli_build_ts").then(__webpack_require__.bind(__webpack_require__, "./src/cli/build.ts")).then(({ build })=>build.call(buildCommand, cwd, buildOptions)));
22
19
  const devCommand = program.command('dev');
23
- 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)=>Promise.all([
24
- __webpack_require__.e("src_config_loadConfig_ts-src_create-rspeedy_ts"),
25
- __webpack_require__.e("src_cli_dev_ts")
26
- ]).then(__webpack_require__.bind(__webpack_require__, "./src/cli/dev.ts")).then(({ dev })=>dev.call(devCommand, cwd, devOptions)));
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)));
27
21
  const inspectCommand = program.command('inspect');
28
- inspectCommand.description('View the Rsbuild config and Rspack config of the project.').option('--mode <mode>', 'specify the mode of Rsbuild', 'development').option('--output <output>', 'specify inspect content output path').option('--verbose', 'show full function definitions in output').action((inspectOptions)=>Promise.all([
29
- __webpack_require__.e("src_config_loadConfig_ts-src_create-rspeedy_ts"),
30
- __webpack_require__.e("src_cli_inspect_ts")
31
- ]).then(__webpack_require__.bind(__webpack_require__, "./src/cli/inspect.ts")).then(({ inspect })=>inspect.call(inspectCommand, cwd, inspectOptions)));
22
+ inspectCommand.description('View the Rsbuild config and Rspack config of the project.').option('--mode <mode>', 'specify the mode of Rsbuild', 'development').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)));
32
23
  const previewCommand = program.command('preview');
33
- previewCommand.description('Preview the production build outputs locally.').option('--base <base>', 'specify the base path of the server').action((previewOptions)=>Promise.all([
34
- __webpack_require__.e("src_config_loadConfig_ts-src_create-rspeedy_ts"),
35
- __webpack_require__.e("src_cli_preview_ts")
36
- ]).then(__webpack_require__.bind(__webpack_require__, "./src/cli/preview.ts")).then(({ preview })=>preview.call(previewCommand, cwd, previewOptions)));
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)));
37
25
  const commonCommands = [
38
26
  devCommand,
39
27
  buildCommand,
@@ -52,7 +40,7 @@ export const __webpack_modules__ = {
52
40
  });
53
41
  var core_ = __webpack_require__("@rsbuild/core");
54
42
  var package_namespaceObject = {
55
- i8: "0.9.1"
43
+ i8: "0.9.3"
56
44
  };
57
45
  const version = package_namespaceObject.i8;
58
46
  const rspackVersion = core_.rspack.rspackVersion;
@@ -47,7 +47,8 @@ export const __webpack_modules__ = {
47
47
  cwd,
48
48
  rspeedyConfig
49
49
  };
50
- if (devOptions.envMode) options.loadEnv = {
50
+ if (devOptions.noEnv) options.loadEnv = false;
51
+ else if (devOptions.envMode) options.loadEnv = {
51
52
  mode: devOptions.envMode
52
53
  };
53
54
  if (devOptions.environment) options.environment = devOptions.environment;
@@ -83,5 +84,247 @@ export const __webpack_modules__ = {
83
84
  }, wait);
84
85
  };
85
86
  }
87
+ },
88
+ "./src/config/loadConfig.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
89
+ __webpack_require__.d(__webpack_exports__, {
90
+ ME: ()=>loadConfig,
91
+ Mk: ()=>resolveConfigPath
92
+ });
93
+ var node_fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:fs");
94
+ var node_path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:path");
95
+ var node_url__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("node:url");
96
+ var picocolors__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("../../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
97
+ var picocolors__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_5__);
98
+ var _lynx_js_rspeedy_register__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("@lynx-js/rspeedy/register");
99
+ var _debug_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./src/debug.ts");
100
+ const resolveConfigPath = (root, customConfig)=>{
101
+ if (customConfig) {
102
+ (0, _debug_js__WEBPACK_IMPORTED_MODULE_4__.fF)(`load custom config file ${customConfig} from ${root}`);
103
+ const customConfigPath = (0, node_path__WEBPACK_IMPORTED_MODULE_1__.isAbsolute)(customConfig) ? customConfig : (0, node_path__WEBPACK_IMPORTED_MODULE_1__.join)(root, customConfig);
104
+ if (node_fs__WEBPACK_IMPORTED_MODULE_0__["default"].existsSync(customConfigPath)) return customConfigPath;
105
+ throw new Error(`Cannot find config file: ${picocolors__WEBPACK_IMPORTED_MODULE_5___default().dim(customConfigPath)}`);
106
+ }
107
+ const CONFIG_FILES = [
108
+ 'lynx.config.ts',
109
+ 'lynx.config.js',
110
+ 'lynx.config.mts',
111
+ 'lynx.config.mjs'
112
+ ];
113
+ for (const file of CONFIG_FILES){
114
+ (0, _debug_js__WEBPACK_IMPORTED_MODULE_4__.fF)(`load default config file ${file} from ${root}`);
115
+ const configFile = (0, node_path__WEBPACK_IMPORTED_MODULE_1__.join)(root, file);
116
+ if (node_fs__WEBPACK_IMPORTED_MODULE_0__["default"].existsSync(configFile)) {
117
+ (0, _debug_js__WEBPACK_IMPORTED_MODULE_4__.fF)(`default config ${configFile} found`);
118
+ return configFile;
119
+ }
120
+ }
121
+ throw new Error([
122
+ `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]))}.`,
123
+ `Use custom config with ${picocolors__WEBPACK_IMPORTED_MODULE_5___default().green('`--config <config>`')} options.`
124
+ ].join(' '));
125
+ };
126
+ async function loadConfig(loadConfigOptions) {
127
+ let { configPath } = loadConfigOptions;
128
+ if (!configPath || !(0, node_path__WEBPACK_IMPORTED_MODULE_1__.isAbsolute)(configPath)) configPath = resolveConfigPath(loadConfigOptions.cwd ?? process.cwd(), configPath);
129
+ const specifier = (0, node_url__WEBPACK_IMPORTED_MODULE_2__.pathToFileURL)(configPath).toString();
130
+ const unregister = shouldUseNativeImport(configPath) ? ()=>void 0 : (0, _lynx_js_rspeedy_register__WEBPACK_IMPORTED_MODULE_3__.register)();
131
+ try {
132
+ const [exports, { validate }] = await Promise.all([
133
+ import(`${specifier}?t=${Date.now()}`),
134
+ __webpack_require__.e("src_config_validate_ts").then(__webpack_require__.bind(__webpack_require__, "./src/config/validate.ts"))
135
+ ]);
136
+ const content = validate('default' in exports ? exports.default : exports, configPath);
137
+ return {
138
+ configPath,
139
+ content
140
+ };
141
+ } finally{
142
+ unregister();
143
+ }
144
+ }
145
+ function shouldUseNativeImport(configPath) {
146
+ return isJavaScriptPath(configPath) || hasNativeTSSupport();
147
+ }
148
+ function hasNativeTSSupport() {
149
+ if (process.features.typescript) return true;
150
+ if (false === process.features.typescript) return false;
151
+ const { NODE_OPTIONS } = process.env;
152
+ if (!NODE_OPTIONS) return false;
153
+ return NODE_OPTIONS.includes('--experimental-transform-types') || NODE_OPTIONS.includes('--experimental-strip-types');
154
+ }
155
+ function isJavaScriptPath(configPath) {
156
+ const ext = (0, node_path__WEBPACK_IMPORTED_MODULE_1__.extname)(configPath);
157
+ return [
158
+ '.js',
159
+ '.mjs',
160
+ '.cjs'
161
+ ].includes(ext);
162
+ }
163
+ },
164
+ "./src/create-rspeedy.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
165
+ __webpack_require__.d(__webpack_exports__, {
166
+ S: ()=>createRspeedy
167
+ });
168
+ var external_node_path_ = __webpack_require__("node:path");
169
+ var core_ = __webpack_require__("@rsbuild/core");
170
+ function applyDefaultRspeedyConfig(config) {
171
+ const ret = (0, core_.mergeRsbuildConfig)(config, {
172
+ output: {
173
+ filename: getFilename(config.output?.filename)
174
+ }
175
+ });
176
+ return ret;
177
+ }
178
+ const DEFAULT_FILENAME = '[name].[platform].bundle';
179
+ function getFilename(filename) {
180
+ if ('string' == typeof filename) return {
181
+ bundle: filename,
182
+ template: filename
183
+ };
184
+ const finalFilename = filename?.bundle ?? filename?.template ?? DEFAULT_FILENAME;
185
+ return {
186
+ bundle: finalFilename,
187
+ template: finalFilename
188
+ };
189
+ }
190
+ var debug = __webpack_require__("./src/debug.ts");
191
+ const DEFAULT_ENTRY = './src/index.js';
192
+ function toRsbuildEntry(entry) {
193
+ if (void 0 === entry) {
194
+ (0, debug.fF)(`Using default entry ${DEFAULT_ENTRY}`);
195
+ return {
196
+ main: DEFAULT_ENTRY
197
+ };
198
+ }
199
+ if (Array.isArray(entry) || 'string' == typeof entry) {
200
+ (0, debug.fF)(()=>`Using single entry ${[
201
+ ''
202
+ ].concat(entry).join('\n - ')}`);
203
+ return {
204
+ main: entry
205
+ };
206
+ }
207
+ return Object.fromEntries(Object.entries(entry).map(([key, value])=>{
208
+ if (Array.isArray(value) || 'string' == typeof value) {
209
+ (0, debug.NW)(`Using multiple entries - ${key}`, value);
210
+ return [
211
+ key,
212
+ {
213
+ import: value
214
+ }
215
+ ];
216
+ }
217
+ (0, debug.NW)(`Using multiple entries - ${key}`, value.import ?? DEFAULT_ENTRY);
218
+ if (void 0 === value.import) return [
219
+ key,
220
+ {
221
+ ...value,
222
+ import: DEFAULT_ENTRY
223
+ }
224
+ ];
225
+ return [
226
+ key,
227
+ value
228
+ ];
229
+ }));
230
+ }
231
+ const defaultDataUriLimit = 2048;
232
+ function toRsbuildConfig(config) {
233
+ return {
234
+ provider: config.provider,
235
+ dev: {
236
+ watchFiles: config.dev?.watchFiles,
237
+ writeToDisk: config.dev?.writeToDisk ?? true,
238
+ progressBar: config.dev?.progressBar ?? true
239
+ },
240
+ environments: config.environments ?? {
241
+ lynx: {}
242
+ },
243
+ mode: config.mode,
244
+ output: {
245
+ assetPrefix: config.output?.assetPrefix,
246
+ charset: 'utf8',
247
+ cleanDistPath: config.output?.cleanDistPath,
248
+ copy: config.output?.copy,
249
+ cssModules: config.output?.cssModules,
250
+ dataUriLimit: config.output?.dataUriLimit ?? defaultDataUriLimit,
251
+ distPath: config.output?.distPath,
252
+ filenameHash: config.output?.filenameHash,
253
+ legalComments: config.output?.legalComments ?? 'none',
254
+ polyfill: 'off',
255
+ sourceMap: config.output?.sourceMap
256
+ },
257
+ source: {
258
+ alias: config.source?.alias,
259
+ assetsInclude: config.source?.assetsInclude,
260
+ decorators: config.source?.decorators,
261
+ define: config.source?.define,
262
+ entry: toRsbuildEntry(config.source?.entry),
263
+ exclude: config.source?.exclude,
264
+ include: config.source?.include,
265
+ transformImport: config.source?.transformImport,
266
+ tsconfigPath: config.source?.tsconfigPath
267
+ },
268
+ server: {
269
+ base: config.server?.base,
270
+ headers: config.server?.headers,
271
+ host: config.server?.host,
272
+ port: config.server?.port,
273
+ strictPort: config.server?.strictPort
274
+ },
275
+ plugins: config.plugins,
276
+ performance: {
277
+ chunkSplit: config.performance?.chunkSplit,
278
+ removeConsole: toRsbuildRemoveConsole(config),
279
+ printFileSize: config.performance?.printFileSize ?? true
280
+ },
281
+ tools: {
282
+ bundlerChain: config.tools?.bundlerChain,
283
+ cssExtract: config.tools?.cssExtract,
284
+ cssLoader: config.tools?.cssLoader,
285
+ htmlPlugin: false,
286
+ rspack: config.tools?.rspack,
287
+ swc: config.tools?.swc
288
+ }
289
+ };
290
+ }
291
+ function toRsbuildRemoveConsole(config) {
292
+ if (config.performance?.removeConsole === true) return [
293
+ 'log',
294
+ 'warn',
295
+ 'error',
296
+ 'info',
297
+ 'debug',
298
+ 'profile',
299
+ 'profileEnd'
300
+ ];
301
+ return config.performance?.removeConsole;
302
+ }
303
+ async function createRspeedy({ cwd = process.cwd(), rspeedyConfig = {}, loadEnv = true, environment = [] }) {
304
+ const config = applyDefaultRspeedyConfig(rspeedyConfig);
305
+ const [rspeedy, { applyDefaultPlugins }] = await Promise.all([
306
+ (0, core_.createRsbuild)({
307
+ cwd,
308
+ loadEnv,
309
+ rsbuildConfig: toRsbuildConfig(config),
310
+ environment
311
+ }),
312
+ __webpack_require__.e("src_plugins_index_ts").then(__webpack_require__.bind(__webpack_require__, "./src/plugins/index.ts"))
313
+ ]);
314
+ await applyDefaultPlugins(rspeedy, config);
315
+ const inspectConfig = rspeedy.inspectConfig.bind(rspeedy);
316
+ return Object.assign(rspeedy, {
317
+ getRspeedyConfig: ()=>config,
318
+ async inspectConfig (options) {
319
+ const result = await inspectConfig(options);
320
+ const { inspectRspeedyConfig } = await Promise.all([
321
+ __webpack_require__.e("vendors-node_modules_pnpm_javascript-stringify_2_1_0_node_modules_javascript-stringify_dist_i-b558be"),
322
+ __webpack_require__.e("src_plugins_inspect_plugin_ts")
323
+ ]).then(__webpack_require__.bind(__webpack_require__, "./src/plugins/inspect.plugin.ts"));
324
+ await inspectRspeedyConfig(rspeedyConfig, external_node_path_["default"].resolve(options.outputPath ?? rspeedy.context.distPath, '.rsbuild/rspeedy.config.js'), options.verbose ?? false);
325
+ return result;
326
+ }
327
+ });
328
+ }
86
329
  }
87
330
  };