@rslib/core 0.20.0 → 0.20.2

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/dist/index.js CHANGED
@@ -1,15 +1,286 @@
1
- import { logger } from "../compiled/rslog/index.js";
2
- import picocolors from "../compiled/picocolors/index.js";
1
+ import node_util from "node:util";
2
+ import node_process from "node:process";
3
+ import node_os from "node:os";
4
+ import node_tty from "node:tty";
3
5
  import node_path, { basename as external_node_path_basename, dirname, extname, isAbsolute, join } from "node:path";
4
6
  import node_fs, { promises as external_node_fs_promises } from "node:fs";
5
7
  import promises from "node:fs/promises";
6
- import node_util from "node:util";
7
8
  import * as __rspack_external__rsbuild_core_1b356efc from "@rsbuild/core";
8
9
  import { createRsbuild, defineConfig, loadConfig, loadEnv, mergeRsbuildConfig, rspack } from "@rsbuild/core";
9
- import { glob } from "../compiled/tinyglobby/index.js";
10
10
  import { createRequire } from "node:module";
11
11
  import { createRequire as external_module_createRequire } from "module";
12
12
  import { getUndoPath, ABSOLUTE_PUBLIC_PATH, isCssFile, DTS_EXTENSIONS_PATTERN, SWC_HELPERS, AUTO_PUBLIC_PATH, CSS_EXTENSIONS_PATTERN, JS_EXTENSIONS_PATTERN, isCssGlobalFile, SINGLE_DOT_PATH_SEGMENT, BASE_URI, isCssModulesFile } from "./108.js";
13
+ function checkNodeVersion() {
14
+ const { versions } = process;
15
+ if ("styleText" in node_util || !versions.node || versions.bun || versions.deno) return;
16
+ throw new Error(`Unsupported Node.js version: "${process.versions.node || 'unknown'}". Expected Node.js >= 20.`);
17
+ }
18
+ checkNodeVersion();
19
+ const createStyler = (style)=>(text)=>node_util.styleText(style, String(text));
20
+ const color = {
21
+ dim: createStyler('dim'),
22
+ red: createStyler('red'),
23
+ bold: createStyler('bold'),
24
+ blue: createStyler('blue'),
25
+ cyan: createStyler('cyan'),
26
+ gray: createStyler('gray'),
27
+ black: createStyler('black'),
28
+ green: createStyler('green'),
29
+ white: createStyler('white'),
30
+ reset: createStyler('reset'),
31
+ yellow: createStyler('yellow'),
32
+ magenta: createStyler('magenta'),
33
+ underline: createStyler('underline'),
34
+ strikethrough: createStyler('strikethrough')
35
+ };
36
+ function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : node_process.argv) {
37
+ const prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--';
38
+ const position = argv.indexOf(prefix + flag);
39
+ const terminatorPosition = argv.indexOf('--');
40
+ return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
41
+ }
42
+ const { env: dist_env } = node_process;
43
+ let flagForceColor;
44
+ if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) flagForceColor = 0;
45
+ else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) flagForceColor = 1;
46
+ function envForceColor() {
47
+ if (!('FORCE_COLOR' in dist_env)) return;
48
+ if ('true' === dist_env.FORCE_COLOR) return 1;
49
+ if ('false' === dist_env.FORCE_COLOR) return 0;
50
+ if (0 === dist_env.FORCE_COLOR.length) return 1;
51
+ const level = Math.min(Number.parseInt(dist_env.FORCE_COLOR, 10), 3);
52
+ if (![
53
+ 0,
54
+ 1,
55
+ 2,
56
+ 3
57
+ ].includes(level)) return;
58
+ return level;
59
+ }
60
+ function translateLevel(level) {
61
+ if (0 === level) return false;
62
+ return {
63
+ level,
64
+ hasBasic: true,
65
+ has256: level >= 2,
66
+ has16m: level >= 3
67
+ };
68
+ }
69
+ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
70
+ const noFlagForceColor = envForceColor();
71
+ if (void 0 !== noFlagForceColor) flagForceColor = noFlagForceColor;
72
+ const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
73
+ if (0 === forceColor) return 0;
74
+ if (sniffFlags) {
75
+ if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) return 3;
76
+ if (hasFlag('color=256')) return 2;
77
+ }
78
+ if ('TF_BUILD' in dist_env && 'AGENT_NAME' in dist_env) return 1;
79
+ if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
80
+ const min = forceColor || 0;
81
+ if ('dumb' === dist_env.TERM) return min;
82
+ if ('win32' === node_process.platform) {
83
+ const osRelease = node_os.release().split('.');
84
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
85
+ return 1;
86
+ }
87
+ if ('CI' in dist_env) {
88
+ if ([
89
+ 'GITHUB_ACTIONS',
90
+ 'GITEA_ACTIONS',
91
+ 'CIRCLECI'
92
+ ].some((key)=>key in dist_env)) return 3;
93
+ if ([
94
+ 'TRAVIS',
95
+ 'APPVEYOR',
96
+ 'GITLAB_CI',
97
+ 'BUILDKITE',
98
+ 'DRONE'
99
+ ].some((sign)=>sign in dist_env) || 'codeship' === dist_env.CI_NAME) return 1;
100
+ return min;
101
+ }
102
+ if ('TEAMCITY_VERSION' in dist_env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(dist_env.TEAMCITY_VERSION) ? 1 : 0;
103
+ if ('truecolor' === dist_env.COLORTERM) return 3;
104
+ if ('xterm-kitty' === dist_env.TERM) return 3;
105
+ if ('xterm-ghostty' === dist_env.TERM) return 3;
106
+ if ('wezterm' === dist_env.TERM) return 3;
107
+ if ('TERM_PROGRAM' in dist_env) {
108
+ const version = Number.parseInt((dist_env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
109
+ switch(dist_env.TERM_PROGRAM){
110
+ case 'iTerm.app':
111
+ return version >= 3 ? 3 : 2;
112
+ case 'Apple_Terminal':
113
+ return 2;
114
+ }
115
+ }
116
+ if (/-256(color)?$/i.test(dist_env.TERM)) return 2;
117
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(dist_env.TERM)) return 1;
118
+ if ('COLORTERM' in dist_env) return 1;
119
+ return min;
120
+ }
121
+ function createSupportsColor(stream, options = {}) {
122
+ const level = _supportsColor(stream, {
123
+ streamIsTTY: stream && stream.isTTY,
124
+ ...options
125
+ });
126
+ return translateLevel(level);
127
+ }
128
+ const supportsColor = {
129
+ stdout: createSupportsColor({
130
+ isTTY: node_tty.isatty(1)
131
+ }),
132
+ stderr: createSupportsColor({
133
+ isTTY: node_tty.isatty(2)
134
+ })
135
+ };
136
+ const supports_color = supportsColor;
137
+ const colorLevel = supports_color.stdout ? supports_color.stdout.level : 0;
138
+ let errorStackRegExp = /at [^\r\n]{0,200}:\d+:\d+[\s\)]*$/;
139
+ let anonymousErrorStackRegExp = /at [^\r\n]{0,200}\(<anonymous>\)$/;
140
+ let indexErrorStackRegExp = /at [^\r\n]{0,200}\(index\s\d+\)$/;
141
+ let isErrorStackMessage = (message)=>errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message) || indexErrorStackRegExp.test(message);
142
+ let startColor = [
143
+ 189,
144
+ 255,
145
+ 243
146
+ ];
147
+ let endColor = [
148
+ 74,
149
+ 194,
150
+ 154
151
+ ];
152
+ let isWord = (char)=>!/[\s\n]/.test(char);
153
+ let gradient = (message)=>{
154
+ if (colorLevel < 3) return 2 === colorLevel ? color.cyan(message) : message;
155
+ let chars = [
156
+ ...message
157
+ ];
158
+ let steps = chars.filter(isWord).length;
159
+ let r = startColor[0];
160
+ let g = startColor[1];
161
+ let b = startColor[2];
162
+ let rStep = (endColor[0] - r) / steps;
163
+ let gStep = (endColor[1] - g) / steps;
164
+ let bStep = (endColor[2] - b) / steps;
165
+ let output = '';
166
+ for (let char of chars){
167
+ if (isWord(char)) {
168
+ r += rStep;
169
+ g += gStep;
170
+ b += bStep;
171
+ }
172
+ output += `\x1b[38;2;${Math.round(r)};${Math.round(g)};${Math.round(b)}m${char}\x1b[39m`;
173
+ }
174
+ return color.bold(output);
175
+ };
176
+ let LOG_LEVEL = {
177
+ silent: -1,
178
+ error: 0,
179
+ warn: 1,
180
+ info: 2,
181
+ log: 2,
182
+ verbose: 3
183
+ };
184
+ let LOG_TYPES = {
185
+ error: {
186
+ label: 'error',
187
+ level: 'error',
188
+ color: color.red
189
+ },
190
+ warn: {
191
+ label: 'warn',
192
+ level: 'warn',
193
+ color: color.yellow
194
+ },
195
+ info: {
196
+ label: 'info',
197
+ level: 'info',
198
+ color: color.cyan
199
+ },
200
+ start: {
201
+ label: 'start',
202
+ level: 'info',
203
+ color: color.cyan
204
+ },
205
+ ready: {
206
+ label: 'ready',
207
+ level: 'info',
208
+ color: color.green
209
+ },
210
+ success: {
211
+ label: 'success',
212
+ level: 'info',
213
+ color: color.green
214
+ },
215
+ log: {
216
+ level: 'info'
217
+ },
218
+ debug: {
219
+ label: 'debug',
220
+ level: 'verbose',
221
+ color: color.magenta
222
+ }
223
+ };
224
+ const normalizeErrorMessage = (err)=>{
225
+ if (err.stack) {
226
+ let [name, ...rest] = err.stack.split('\n');
227
+ if (name.startsWith('Error: ')) name = name.slice(7);
228
+ return `${name}\n${color.gray(rest.join('\n'))}`;
229
+ }
230
+ return err.message;
231
+ };
232
+ let createLogger = (options = {})=>{
233
+ const { level = 'info', prefix, console: console1 = globalThis.console } = options;
234
+ let maxLevel = level;
235
+ let log = (type, message, ...args)=>{
236
+ let logType = LOG_TYPES[type];
237
+ const { level } = logType;
238
+ if (LOG_LEVEL[level] > LOG_LEVEL[maxLevel]) return;
239
+ if (null == message) return console1.log();
240
+ let label = '';
241
+ let text = '';
242
+ if ('label' in logType) {
243
+ label = (logType.label || '').padEnd(7);
244
+ label = color.bold(logType.color ? logType.color(label) : label);
245
+ }
246
+ if (message instanceof Error) {
247
+ text += normalizeErrorMessage(message);
248
+ const { cause } = message;
249
+ if (cause) {
250
+ text += color.yellow('\n [cause]: ');
251
+ text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause);
252
+ }
253
+ } else if ('error' === level && 'string' == typeof message) {
254
+ let lines = message.split('\n');
255
+ text = lines.map((line)=>isErrorStackMessage(line) ? color.gray(line) : line).join('\n');
256
+ } else text = `${message}`;
257
+ if (prefix) text = `${prefix} ${text}`;
258
+ const method = 'error' === level || 'warn' === level ? level : 'log';
259
+ console1[method](label.length ? `${label} ${text}` : text, ...args);
260
+ };
261
+ let logger = {
262
+ greet: (message)=>log('log', gradient(message))
263
+ };
264
+ Object.keys(LOG_TYPES).forEach((key)=>{
265
+ logger[key] = (...args)=>log(key, ...args);
266
+ });
267
+ Object.defineProperty(logger, 'level', {
268
+ get: ()=>maxLevel,
269
+ set (val) {
270
+ maxLevel = val;
271
+ }
272
+ });
273
+ Object.defineProperty(logger, 'options', {
274
+ get: ()=>({
275
+ ...options
276
+ })
277
+ });
278
+ logger.override = (customLogger)=>{
279
+ Object.assign(logger, customLogger);
280
+ };
281
+ return logger;
282
+ };
283
+ let src_logger = createLogger();
13
284
  const isDebugKey = (keys)=>{
14
285
  if (!process.env.DEBUG) return false;
15
286
  const values = process.env.DEBUG.toLocaleLowerCase().split(',');
@@ -22,7 +293,7 @@ const isDebug = ()=>isDebugKey([
22
293
  'rstack',
23
294
  '*'
24
295
  ]);
25
- if (isDebug()) logger.level = 'verbose';
296
+ if (isDebug()) src_logger.level = 'verbose';
26
297
  function getTime() {
27
298
  const now = new Date();
28
299
  const hours = String(now.getHours()).padStart(2, '0');
@@ -30,11 +301,11 @@ function getTime() {
30
301
  const seconds = String(now.getSeconds()).padStart(2, '0');
31
302
  return `${hours}:${minutes}:${seconds}`;
32
303
  }
33
- logger.override({
304
+ src_logger.override({
34
305
  debug: (message, ...args)=>{
35
- if ('verbose' !== logger.level) return;
36
- const time = picocolors.gray(getTime());
37
- console.log(` ${picocolors.green('rslib')} ${time} ${message}`, ...args);
306
+ if ('verbose' !== src_logger.level) return;
307
+ const time = color.gray(getTime());
308
+ console.log(` ${color.green('rslib')} ${time} ${message}`, ...args);
38
309
  }
39
310
  });
40
311
  function toArr(any) {
@@ -664,11 +935,11 @@ function ensureAbsolutePath(base, filepath) {
664
935
  }
665
936
  const readPackageJson = (rootPath)=>{
666
937
  const pkgJsonPath = node_path.join(rootPath, './package.json');
667
- if (!node_fs.existsSync(pkgJsonPath)) return void logger.warn(`The \`package.json\` file does not exist in the ${rootPath} directory`);
938
+ if (!node_fs.existsSync(pkgJsonPath)) return void src_logger.warn(`The \`package.json\` file does not exist in the ${rootPath} directory`);
668
939
  try {
669
940
  return JSON.parse(node_fs.readFileSync(pkgJsonPath, 'utf8'));
670
- } catch (_err) {
671
- logger.warn(`Failed to parse ${pkgJsonPath}, it might not be valid JSON`);
941
+ } catch {
942
+ src_logger.warn(`Failed to parse ${pkgJsonPath}, it might not be valid JSON`);
672
943
  return;
673
944
  }
674
945
  };
@@ -700,7 +971,7 @@ function checkMFPlugin(config, sharedPlugins) {
700
971
  ...config.plugins || []
701
972
  ]);
702
973
  if (!added) {
703
- logger.warn(`${picocolors.green('format: "mf"')} should be used with ${picocolors.blue('@module-federation/rsbuild-plugin')}", consider installing and adding it to plugins. Check the documentation (https://module-federation.io/guide/basic/rsbuild.html#rslib-module) to get started with "mf" output.`);
974
+ src_logger.warn(`${color.green('format: "mf"')} should be used with ${color.blue('@module-federation/rsbuild-plugin')}", consider installing and adding it to plugins. Check the documentation (https://module-federation.io/guide/basic/rsbuild.html#rslib-module) to get started with "mf" output.`);
704
975
  process.exit(1);
705
976
  }
706
977
  return added;
@@ -714,7 +985,9 @@ function debounce(func, wait) {
714
985
  }, wait);
715
986
  };
716
987
  }
717
- const isTTY = (type = 'stdout')=>('stdin' === type ? process.stdin.isTTY : process.stdout.isTTY) && !process.env.CI;
988
+ function isTTY(type = 'stdout') {
989
+ return ('stdin' === type ? process.stdin.isTTY : process.stdout.isTTY) && !process.env.CI;
990
+ }
718
991
  const isIntermediateOutputFormat = (format)=>'cjs' === format || 'esm' === format;
719
992
  const windowsSlashRegex = /\\/g;
720
993
  function normalizeSlash(p) {
@@ -735,15 +1008,15 @@ const setNodeEnv = (env)=>{
735
1008
  };
736
1009
  function getWatchFilesForRestart(rslib) {
737
1010
  const meta = rslib.getRslibConfig()._privateMeta;
738
- if (!meta) return;
1011
+ if (!meta) return [];
739
1012
  return [
740
1013
  meta.configFilePath,
741
1014
  ...meta.envFilePaths || []
742
1015
  ].filter(Boolean);
743
1016
  }
744
1017
  async function watchFilesForRestart(files, restart) {
745
- if (!files || !files.length) return;
746
- const chokidar = await import("../compiled/chokidar/index.js");
1018
+ if (!files.length) return;
1019
+ const { default: chokidar } = await import("./chokidar.js");
747
1020
  const watcher = chokidar.watch(files, {
748
1021
  ignoreInitial: true,
749
1022
  ignorePermissionErrors: true
@@ -770,8 +1043,8 @@ const beforeRestart = async ({ filePath, clear = true } = {})=>{
770
1043
  if (clear) clearConsole();
771
1044
  if (filePath) {
772
1045
  const filename = node_path.basename(filePath);
773
- logger.info(`restarting as ${picocolors.yellow(filename)} is changed\n`);
774
- } else logger.info('restarting...\n');
1046
+ src_logger.info(`restarting as ${color.yellow(filename)} is changed\n`);
1047
+ } else src_logger.info('restarting...\n');
775
1048
  for (const cleaner of cleaners)await cleaner();
776
1049
  cleaners = [];
777
1050
  };
@@ -927,7 +1200,7 @@ class LibCssExtractPlugin {
927
1200
  apply(compiler) {
928
1201
  compiler.hooks.make.tap(LibCssExtractPlugin_pluginName, (compilation)=>{
929
1202
  compilation.hooks.processAssets.tap(LibCssExtractPlugin_pluginName, (assets)=>{
930
- const chunkAsset = Object.keys(assets).filter((name)=>/\.css/.test(name));
1203
+ const chunkAsset = Object.keys(assets).filter((name)=>name.includes('.css'));
931
1204
  for (const name of chunkAsset)compilation.updateAsset(name, (old)=>{
932
1205
  const oldSource = old.source().toString();
933
1206
  const replaceSource = new rspack.sources.ReplaceSource(old);
@@ -952,7 +1225,7 @@ class LibCssExtractPlugin {
952
1225
  const cssConfig_require = createRequire(import.meta.url);
953
1226
  const RSLIB_CSS_ENTRY_FLAG = '__rslib_css__';
954
1227
  async function cssExternalHandler(request, callback, jsExtension, auto, styleRedirectPath, styleRedirectExtension, redirectedPath, issuer) {
955
- if (/compiled\/css-loader\//.test(request)) return void callback();
1228
+ if (request.includes('compiled/css-loader/')) return void callback();
956
1229
  let resolvedRequest = request;
957
1230
  if (styleRedirectPath) {
958
1231
  if (void 0 === redirectedPath) return false;
@@ -971,16 +1244,22 @@ async function cssExternalHandler(request, callback, jsExtension, auto, styleRed
971
1244
  callback(void 0, resolvedRequest);
972
1245
  }
973
1246
  const cssConfig_PLUGIN_NAME = 'rsbuild:lib-css';
1247
+ const isPreprocessorRule = (preprocessRuleId, toMatchRuleId)=>{
1248
+ if (preprocessRuleId === toMatchRuleId) return true;
1249
+ if (new RegExp(`^${preprocessRuleId}-\\d+$`).test(toMatchRuleId)) return true;
1250
+ return false;
1251
+ };
974
1252
  const pluginLibCss = (rootDir, auto, banner, footer)=>({
975
1253
  name: cssConfig_PLUGIN_NAME,
976
1254
  setup (api) {
977
1255
  api.processAssets({
978
1256
  stage: 'additional'
979
1257
  }, ({ assets, compilation })=>{
980
- for (const key of Object.keys(assets))if (key.match(RSLIB_CSS_ENTRY_FLAG)) compilation.deleteAsset(key);
1258
+ for (const key of Object.keys(assets))if (RegExp(RSLIB_CSS_ENTRY_FLAG).exec(key)) compilation.deleteAsset(key);
981
1259
  });
982
1260
  api.modifyBundlerChain((config, { CHAIN_ID })=>{
983
1261
  let isUsingCssExtract = false;
1262
+ const ruleIds = Object.keys(config.module.rules.entries());
984
1263
  for (const [ruleId, oneOfId] of [
985
1264
  [
986
1265
  CHAIN_ID.RULE.CSS,
@@ -999,17 +1278,22 @@ const pluginLibCss = (rootDir, auto, banner, footer)=>({
999
1278
  'stylus'
1000
1279
  ]
1001
1280
  ]){
1002
- if (!config.module.rules.has(ruleId)) continue;
1003
- const mainRule = config.module.rule(ruleId).oneOfs.get(oneOfId);
1004
- if (mainRule) {
1005
- if (mainRule.uses.has(CHAIN_ID.USE.MINI_CSS_EXTRACT)) {
1006
- isUsingCssExtract = true;
1007
- mainRule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader(cssConfig_require.resolve('./libCssExtractLoader.js')).options({
1008
- rootDir,
1009
- auto,
1010
- banner,
1011
- footer
1012
- });
1281
+ const matchedRuleIds = ruleId === CHAIN_ID.RULE.CSS ? [
1282
+ ruleId
1283
+ ] : ruleIds.filter((currentRuleId)=>isPreprocessorRule(ruleId, currentRuleId));
1284
+ for (const matchedRuleId of matchedRuleIds){
1285
+ if (!config.module.rules.has(matchedRuleId)) continue;
1286
+ const mainRule = config.module.rule(matchedRuleId).oneOfs.get(oneOfId);
1287
+ if (mainRule) {
1288
+ if (mainRule.uses.has(CHAIN_ID.USE.MINI_CSS_EXTRACT)) {
1289
+ isUsingCssExtract = true;
1290
+ mainRule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader(cssConfig_require.resolve('./libCssExtractLoader.js')).options({
1291
+ rootDir,
1292
+ auto,
1293
+ banner,
1294
+ footer
1295
+ });
1296
+ }
1013
1297
  }
1014
1298
  }
1015
1299
  }
@@ -1021,7 +1305,7 @@ const pluginLibCss = (rootDir, auto, banner, footer)=>({
1021
1305
  });
1022
1306
  }
1023
1307
  });
1024
- const composeCssConfig = (rootDir, auto, bundle = true, banner, footer)=>{
1308
+ function composeCssConfig(rootDir, auto, bundle = true, banner, footer) {
1025
1309
  if (bundle || null === rootDir) return {};
1026
1310
  return {
1027
1311
  plugins: [
@@ -1033,7 +1317,7 @@ const composeCssConfig = (rootDir, auto, bundle = true, banner, footer)=>{
1033
1317
  }
1034
1318
  }
1035
1319
  };
1036
- };
1320
+ }
1037
1321
  const EntryChunkPlugin_PLUGIN_NAME = 'rsbuild:lib-entry-chunk';
1038
1322
  const IMPORT_META_URL_SHIM = `const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
1039
1323
  return typeof document === 'undefined'
@@ -1139,7 +1423,7 @@ const getDefaultExtension = (options)=>{
1139
1423
  dtsExtension
1140
1424
  };
1141
1425
  if (!pkgJson) {
1142
- logger.warn('The `autoExtension` configuration will not be applied due to read package.json failed');
1426
+ src_logger.warn('The `autoExtension` configuration will not be applied due to read package.json failed');
1143
1427
  return {
1144
1428
  jsExtension,
1145
1429
  dtsExtension
@@ -1876,7 +2160,7 @@ const composeExternalsWarnConfig = (format, ...externalsArray)=>{
1876
2160
  };
1877
2161
  if (contextInfo.issuer && 'commonjs' === dependencyType) {
1878
2162
  matchUserExternals(externals, request, _callback);
1879
- if (shouldWarn) logger.warn(composeModuleImportWarn(request, contextInfo.issuer));
2163
+ if (shouldWarn) src_logger.warn(composeModuleImportWarn(request, contextInfo.issuer));
1880
2164
  }
1881
2165
  callback();
1882
2166
  }
@@ -1891,7 +2175,7 @@ const composeAutoExternalConfig = (options)=>{
1891
2175
  const autoExternal = getAutoExternalDefaultValue(format, options.autoExternal);
1892
2176
  if (false === autoExternal) return {};
1893
2177
  if (!pkgJson) {
1894
- logger.warn('The `autoExternal` configuration will not be applied due to read package.json failed');
2178
+ src_logger.warn('The `autoExternal` configuration will not be applied due to read package.json failed');
1895
2179
  return {};
1896
2180
  }
1897
2181
  const userExternalKeys = userExternals && isObject(userExternals) ? Object.keys(userExternals) : [];
@@ -2017,9 +2301,9 @@ function composePrintFileSizeConfig(bundle, target) {
2017
2301
  performance: {
2018
2302
  printFileSize: {
2019
2303
  total: ({ environmentName, distPath, assets, totalSize, totalGzipSize })=>{
2020
- let log = `${picocolors.yellow(assets.length)} files generated in ${picocolors.cyan(distPath)}, ${picocolors.magenta('total:')} ${(totalSize / 1000).toFixed(1)} kB`;
2021
- if ('web' === target) log += ` ${picocolors.green(`(${(totalGzipSize / 1000).toFixed(1)} kB gzipped)`)}`;
2022
- log += ` ${picocolors.dim(`(${environmentName})`)}`;
2304
+ let log = `${color.yellow(assets.length)} files generated in ${color.cyan(distPath)}, ${color.magenta('total:')} ${(totalSize / 1000).toFixed(1)} kB`;
2305
+ if ('web' === target) log += ` ${color.green(`(${(totalGzipSize / 1000).toFixed(1)} kB gzipped)`)}`;
2306
+ log += ` ${color.dim(`(${environmentName})`)}`;
2023
2307
  return log;
2024
2308
  },
2025
2309
  detail: false
@@ -2077,7 +2361,7 @@ async function createConstantRsbuildConfig() {
2077
2361
  }
2078
2362
  });
2079
2363
  }
2080
- const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledShims })=>{
2364
+ const composeFormatConfig = ({ format, target, bundle = true, umdName, pkgJson, enabledShims, multiCompilerIndex, sourceEntry })=>{
2081
2365
  const jsParserOptions = {
2082
2366
  cjs: {
2083
2367
  requireResolve: false,
@@ -2098,7 +2382,8 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledS
2098
2382
  const plugins = [
2099
2383
  new rspack.experiments.RslibPlugin({
2100
2384
  interceptApiPlugin: true,
2101
- forceNodeShims: enabledShims.esm.__dirname || enabledShims.esm.__filename
2385
+ forceNodeShims: enabledShims.esm.__dirname || enabledShims.esm.__filename,
2386
+ externalEsmNodeBuiltin: 'esm' === format && 'node' === target
2102
2387
  })
2103
2388
  ].filter(Boolean);
2104
2389
  switch(format){
@@ -2121,9 +2406,11 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledS
2121
2406
  optimization: {
2122
2407
  concatenateModules: false,
2123
2408
  sideEffects: true,
2124
- runtimeChunk: {
2125
- name: 'rslib-runtime'
2126
- },
2409
+ runtimeChunk: getRuntimeChunkConfig({
2410
+ bundle,
2411
+ multiCompilerIndex,
2412
+ sourceEntry
2413
+ }),
2127
2414
  avoidEntryIife: true,
2128
2415
  splitChunks: {
2129
2416
  chunks: 'async'
@@ -2306,13 +2593,24 @@ const BundlePlugin = ()=>({
2306
2593
  order: 'post',
2307
2594
  handler: ({ bundlerConfig })=>{
2308
2595
  if (bundlerConfig?.module?.parser?.javascript?.jsx === true) {
2309
- logger.error('Bundle mode does not support preserving JSX syntax. Set "bundle" to "false" or change the JSX runtime to `automatic` or `classic`. Check out ' + picocolors.green('https://rslib.rs/guide/solution/react#jsx-transform') + ' for more details.');
2596
+ src_logger.error('Bundle mode does not support preserving JSX syntax. Set "bundle" to "false" or change the JSX runtime to `automatic` or `classic`. Check out ' + color.green('https://rslib.rs/guide/solution/react#jsx-transform') + ' for more details.');
2310
2597
  process.exit(1);
2311
2598
  }
2312
2599
  }
2313
2600
  });
2314
2601
  }
2315
2602
  });
2603
+ const RSLIB_RUNTIME_CHUNK_NAME = 'rslib-runtime';
2604
+ const getMultiCompilerRuntimeChunkName = (multiCompilerIndex)=>'number' == typeof multiCompilerIndex ? `${multiCompilerIndex}~${RSLIB_RUNTIME_CHUNK_NAME}` : RSLIB_RUNTIME_CHUNK_NAME;
2605
+ const getRuntimeChunkConfig = ({ bundle, multiCompilerIndex, sourceEntry })=>{
2606
+ if (!bundle) return {
2607
+ name: RSLIB_RUNTIME_CHUNK_NAME
2608
+ };
2609
+ if (!sourceEntry || Object.keys(sourceEntry).length <= 1) return;
2610
+ return {
2611
+ name: getMultiCompilerRuntimeChunkName(multiCompilerIndex)
2612
+ };
2613
+ };
2316
2614
  const composeBundleConfig = (bundle)=>{
2317
2615
  if (bundle) return {
2318
2616
  rsbuildConfig: {
@@ -2395,7 +2693,7 @@ const composeShimsConfig = (format, shims)=>{
2395
2693
  enabledShims
2396
2694
  };
2397
2695
  };
2398
- const composeModuleImportWarn = (request, issuer)=>`The externalized commonjs request ${picocolors.green(`"${request}"`)} from ${picocolors.green(issuer)} will use ${picocolors.blue('"module"')} external type in ESM format. If you want to specify other external type, consider setting the request and type with ${picocolors.blue('"output.externals"')}.`;
2696
+ const composeModuleImportWarn = (request, issuer)=>`The externalized commonjs request ${color.green(`"${request}"`)} from ${color.green(issuer)} will use ${color.blue('"module"')} external type in ESM format. If you want to specify other external type, consider setting the request and type with ${color.blue('"output.externals"')}.`;
2399
2697
  const composeExternalsConfig = (format, externals)=>{
2400
2698
  const externalsTypeMap = {
2401
2699
  esm: 'module-import',
@@ -2535,20 +2833,20 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
2535
2833
  index: 'src/**'
2536
2834
  };
2537
2835
  }
2538
- if ('object' != typeof entries) throw new Error(`The ${picocolors.cyan('source.entry')} configuration should be an object, but received ${typeof entries}: ${picocolors.cyan(entries)}. Checkout ${picocolors.green('https://rslib.rs/config/rsbuild/source#sourceentry')} for more details.`);
2836
+ if ('object' != typeof entries) throw new Error(`The ${color.cyan('source.entry')} configuration should be an object, but received ${typeof entries}: ${color.cyan(entries)}. Checkout ${color.green('https://rslib.rs/config/rsbuild/source#sourceentry')} for more details.`);
2539
2837
  if (false !== bundle) {
2540
2838
  const entryErrorReasons = [];
2541
2839
  traverseEntryQuery(entries, (entry)=>{
2542
2840
  const entryAbsPath = node_path.isAbsolute(entry) ? entry : node_path.resolve(root, entry);
2543
2841
  const isDirLike = '' === node_path.extname(entryAbsPath);
2544
- const dirError = `Glob pattern ${picocolors.cyan(`"${entry}"`)} is not supported when "bundle" is "true", considering "bundle" to "false" to use bundleless mode, or specify a file entry to bundle. See ${picocolors.green('https://rslib.rs/guide/basic/output-structure')} for more details.`;
2842
+ const dirError = `Glob pattern ${color.cyan(`"${entry}"`)} is not supported when "bundle" is "true", considering "bundle" to "false" to use bundleless mode, or specify a file entry to bundle. See ${color.green('https://rslib.rs/guide/basic/output-structure')} for more details.`;
2545
2843
  if (node_fs.existsSync(entryAbsPath)) {
2546
2844
  const stats = node_fs.statSync(entryAbsPath);
2547
2845
  if (!stats.isFile()) entryErrorReasons.push(dirError);
2548
2846
  } else {
2549
2847
  const isGlobLike = entry.startsWith('!') || /[*?[{\]}]/.test(entry);
2550
2848
  if (isDirLike || isGlobLike) entryErrorReasons.push(dirError);
2551
- else entryErrorReasons.push(`Can't resolve the entry ${picocolors.cyan(`"${entry}"`)} at the location ${picocolors.cyan(entryAbsPath)}. Please ensure that the file exists.`);
2849
+ else entryErrorReasons.push(`Can't resolve the entry ${color.cyan(`"${entry}"`)} at the location ${color.cyan(entryAbsPath)}. Please ensure that the file exists.`);
2552
2850
  }
2553
2851
  return entry;
2554
2852
  });
@@ -2575,6 +2873,7 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
2575
2873
  entry
2576
2874
  ] : null;
2577
2875
  if (!entryFiles) throw new Error('Entry can only be a string or an array of strings for now');
2876
+ const { glob } = await import("./tinyglobby.js");
2578
2877
  const globEntryFiles = await glob(entryFiles, {
2579
2878
  cwd: root,
2580
2879
  absolute: true,
@@ -2586,7 +2885,7 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
2586
2885
  });
2587
2886
  const resolvedEntryFiles = globEntryFiles.filter((i)=>!DTS_EXTENSIONS_PATTERN.test(i));
2588
2887
  if (0 === resolvedEntryFiles.length) {
2589
- const error = new Error(`No entry files matching ${entryFiles.map((file)=>picocolors.cyan(file)).join(', ')}. Please ensure the entry pattern in ${picocolors.cyan('source.entry')} is correct and points to valid source files.`);
2888
+ const error = new Error(`No entry files matching ${entryFiles.map((file)=>color.cyan(file)).join(', ')}. Please ensure the entry pattern in ${color.cyan('source.entry')} is correct and points to valid source files.`);
2590
2889
  error.stack = '';
2591
2890
  throw error;
2592
2891
  }
@@ -2599,7 +2898,7 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
2599
2898
  }
2600
2899
  for (const file of resolvedEntryFiles){
2601
2900
  const entryName = getEntryName(file);
2602
- if (resolvedEntries[entryName]) tryResolveOutBase && logger.warn(`Duplicate entry ${picocolors.cyan(entryName)} from ${picocolors.cyan(node_path.relative(root, file))} and ${picocolors.cyan(node_path.relative(root, resolvedEntries[entryName]))}, which may lead to the incorrect output, please rename the file.`);
2901
+ if (resolvedEntries[entryName]) tryResolveOutBase && src_logger.warn(`Duplicate entry ${color.cyan(entryName)} from ${color.cyan(node_path.relative(root, file))} and ${color.cyan(node_path.relative(root, resolvedEntries[entryName]))}, which may lead to the incorrect output, please rename the file.`);
2603
2902
  resolvedEntries[entryName] = file;
2604
2903
  }
2605
2904
  }
@@ -2674,8 +2973,8 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
2674
2973
  path: void 0,
2675
2974
  isResolved: true
2676
2975
  };
2677
- } catch (_e) {
2678
- logger.debug(`Failed to resolve module ${picocolors.green(`"${request}"`)} from ${picocolors.green(issuer)}. If it's an npm package, consider adding it to dependencies or peerDependencies in package.json to make it externalized.`);
2976
+ } catch {
2977
+ src_logger.debug(`Failed to resolve module ${color.green(`"${request}"`)} from ${color.green(issuer)}. If it's an npm package, consider adding it to dependencies or peerDependencies in package.json to make it externalized.`);
2679
2978
  return {
2680
2979
  path: request,
2681
2980
  isResolved: false
@@ -2772,7 +3071,7 @@ const composeTargetConfig = (userTarget, format)=>{
2772
3071
  }
2773
3072
  },
2774
3073
  target: 'node',
2775
- externalsConfig: {
3074
+ externalsConfig: 'esm' === format ? {} : {
2776
3075
  output: {
2777
3076
  externals: nodeBuiltInModules
2778
3077
  }
@@ -2798,7 +3097,7 @@ const composeExternalHelpersConfig = (externalHelpers, pkgJson)=>{
2798
3097
  ...Object.keys(pkgJson?.devDependencies ?? [])
2799
3098
  ];
2800
3099
  if (!deps.includes(SWC_HELPERS)) {
2801
- logger.error(`${picocolors.green('externalHelpers')} is enabled, but the ${picocolors.blue(SWC_HELPERS)} dependency declaration was not found in package.json.`);
3100
+ src_logger.error(`${color.green('externalHelpers')} is enabled, but the ${color.blue(SWC_HELPERS)} dependency declaration was not found in package.json.`);
2802
3101
  process.exit(1);
2803
3102
  }
2804
3103
  defaultConfig = Object.assign(defaultConfig, {
@@ -2818,19 +3117,22 @@ async function composeLibRsbuildConfig(config, multiCompilerIndex, root = proces
2818
3117
  const { format = 'esm', shims, bundle = true, banner = {}, footer = {}, autoExtension = true, autoExternal, externalHelpers = false, redirect = {}, umdName } = config;
2819
3118
  const { rsbuildConfig: bundleConfig } = composeBundleConfig(bundle);
2820
3119
  const { rsbuildConfig: shimsConfig, enabledShims } = composeShimsConfig(format, shims);
3120
+ const { config: targetConfig, externalsConfig: targetExternalsConfig, target } = composeTargetConfig(config.output?.target, format);
2821
3121
  const formatConfig = composeFormatConfig({
2822
3122
  format,
3123
+ target,
2823
3124
  pkgJson: pkgJson,
2824
3125
  bundle,
2825
3126
  umdName,
2826
- enabledShims
3127
+ enabledShims,
3128
+ multiCompilerIndex,
3129
+ sourceEntry: config.source?.entry
2827
3130
  });
2828
3131
  const externalHelpersConfig = composeExternalHelpersConfig(externalHelpers, pkgJson);
2829
3132
  const userExternalsConfig = composeExternalsConfig(format, config.output?.externals);
2830
3133
  const { config: outputFilenameConfig, jsExtension, dtsExtension } = composeOutputFilenameConfig(config, format, autoExtension, multiCompilerIndex, pkgJson);
2831
3134
  const { entryConfig, outBase } = await composeEntryConfig(config.source?.entry, config.bundle, root, cssModulesAuto, config.outBase);
2832
3135
  const { config: bundlelessExternalConfig } = composeBundlelessExternalConfig(jsExtension, redirect, cssModulesAuto, bundle, outBase);
2833
- const { config: targetConfig, externalsConfig: targetExternalsConfig, target } = composeTargetConfig(config.output?.target, format);
2834
3136
  const syntaxConfig = composeSyntaxConfig(target, config?.syntax);
2835
3137
  const autoExternalConfig = composeAutoExternalConfig({
2836
3138
  bundle,
@@ -2856,8 +3158,8 @@ async function composeLibRsbuildConfig(config, multiCompilerIndex, root = proces
2856
3158
  async function composeCreateRsbuildConfig(rslibConfig) {
2857
3159
  const constantRsbuildConfig = await createConstantRsbuildConfig();
2858
3160
  const { lib: libConfigsArray, mode: _mode, root, plugins: sharedPlugins, dev: _dev, server: _server, logLevel, ...sharedRsbuildConfig } = rslibConfig;
2859
- if (logLevel && !isDebug()) logger.level = logLevel;
2860
- if (!Array.isArray(libConfigsArray) || 0 === libConfigsArray.length) throw new Error(`Expect "lib" field to be a non-empty array, but got: ${picocolors.cyan(JSON.stringify(libConfigsArray))}.`);
3161
+ if (logLevel && !isDebug()) src_logger.level = logLevel;
3162
+ if (!Array.isArray(libConfigsArray) || 0 === libConfigsArray.length) throw new Error(`Expect "lib" field to be a non-empty array, but got: ${color.cyan(JSON.stringify(libConfigsArray))}.`);
2861
3163
  const libConfigPromises = libConfigsArray.map(async (libConfig, index)=>{
2862
3164
  const userConfig = mergeRsbuildConfig(sharedRsbuildConfig, libConfig);
2863
3165
  const libRsbuildConfig = await composeLibRsbuildConfig(userConfig, libConfigsArray.length > 1 ? index : null, root, sharedPlugins);
@@ -2904,7 +3206,7 @@ async function composeRsbuildEnvironments(rslibConfig) {
2904
3206
  const nextDefaultId = (format, index)=>`${format}${1 === formatCount[format] && 0 === index ? '' : index}`;
2905
3207
  let index = 0;
2906
3208
  let candidateId = nextDefaultId(format, index);
2907
- while(-1 !== usedIds.indexOf(candidateId))candidateId = nextDefaultId(format, ++index);
3209
+ while(usedIds.includes(candidateId))candidateId = nextDefaultId(format, ++index);
2908
3210
  usedIds.push(candidateId);
2909
3211
  return candidateId;
2910
3212
  };
@@ -3013,7 +3315,7 @@ async function createRslib(options = {}) {
3013
3315
  name: 'rslib:on-after-build',
3014
3316
  setup (api) {
3015
3317
  api.onAfterBuild(({ isFirstCompile, stats })=>{
3016
- if (isFirstCompile) stats?.hasErrors() ? logger.error('build completed with errors, watching for changes...') : logger.success('build completed, watching for changes...');
3318
+ if (isFirstCompile) stats?.hasErrors() ? src_logger.error('build completed with errors, watching for changes...') : src_logger.success('build completed, watching for changes...');
3017
3319
  });
3018
3320
  }
3019
3321
  });
@@ -3079,7 +3381,7 @@ const resolveConfigPath = (root, customConfig)=>{
3079
3381
  if (customConfig) {
3080
3382
  const customConfigPath = isAbsolute(customConfig) ? customConfig : join(root, customConfig);
3081
3383
  if (node_fs.existsSync(customConfigPath)) return customConfigPath;
3082
- const error = new Error(`${picocolors.dim('[rslib:loadConfig]')} Cannot find config file: ${picocolors.dim(customConfigPath)}`);
3384
+ const error = new Error(`${color.dim('[rslib:loadConfig]')} Cannot find config file: ${color.dim(customConfigPath)}`);
3083
3385
  error.stack = '';
3084
3386
  throw error;
3085
3387
  }
@@ -3100,7 +3402,7 @@ const resolveConfigPath = (root, customConfig)=>{
3100
3402
  async function loadConfig_loadConfig({ cwd = process.cwd(), path, envMode, meta, loader }) {
3101
3403
  const configFilePath = resolveConfigPath(cwd, path);
3102
3404
  if (!configFilePath) {
3103
- logger.debug('no config file found.');
3405
+ src_logger.debug('no config file found.');
3104
3406
  return {
3105
3407
  content: {},
3106
3408
  filePath: null
@@ -3203,7 +3505,7 @@ const init_loadConfig = async (options, root)=>{
3203
3505
  config.lib = [
3204
3506
  {}
3205
3507
  ];
3206
- logger.debug('Falling back to CLI options for the default library.');
3508
+ src_logger.debug('Falling back to CLI options for the default library.');
3207
3509
  }
3208
3510
  applyCliOptions(config, options, root);
3209
3511
  return config;
@@ -3234,9 +3536,9 @@ const applyCommonOptions = (cli)=>{
3234
3536
  };
3235
3537
  function setupCommands() {
3236
3538
  const cli = cac('rslib');
3237
- cli.version("0.20.0");
3539
+ cli.version("0.20.2");
3238
3540
  applyCommonOptions(cli);
3239
- const buildDescription = `build the library for production ${picocolors.dim('(default if no command is given)')}`;
3541
+ const buildDescription = `build the library for production ${color.dim('(default if no command is given)')}`;
3240
3542
  const buildCommand = cli.command('', buildDescription).alias('build');
3241
3543
  const inspectCommand = cli.command('inspect', 'inspect the Rsbuild / Rspack configs of Rslib projects');
3242
3544
  const mfDevCommand = cli.command('mf-dev', 'start Rsbuild dev server of Module Federation format');
@@ -3264,9 +3566,9 @@ function setupCommands() {
3264
3566
  await cliBuild();
3265
3567
  } catch (err) {
3266
3568
  const isRspackError = err instanceof Error && err.message === RSPACK_BUILD_ERROR;
3267
- if (!isRspackError) logger.error('Failed to build.');
3268
- if (err instanceof AggregateError) for (const error of err.errors)logger.error(error);
3269
- else logger.error(err);
3569
+ if (!isRspackError) src_logger.error('Failed to build.');
3570
+ if (err instanceof AggregateError) for (const error of err.errors)src_logger.error(error);
3571
+ else src_logger.error(err);
3270
3572
  process.exit(1);
3271
3573
  }
3272
3574
  });
@@ -3283,8 +3585,8 @@ function setupCommands() {
3283
3585
  writeToDisk: true
3284
3586
  });
3285
3587
  } catch (err) {
3286
- logger.error('Failed to inspect config.');
3287
- logger.error(err);
3588
+ src_logger.error('Failed to inspect config.');
3589
+ src_logger.error(err);
3288
3590
  process.exit(1);
3289
3591
  }
3290
3592
  });
@@ -3301,27 +3603,27 @@ function setupCommands() {
3301
3603
  };
3302
3604
  await cliMfDev();
3303
3605
  } catch (err) {
3304
- logger.error('Failed to start mf-dev.');
3305
- logger.error(err);
3606
+ src_logger.error('Failed to start mf-dev.');
3607
+ src_logger.error(err);
3306
3608
  process.exit(1);
3307
3609
  }
3308
3610
  });
3309
3611
  cli.help((sections)=>{
3310
3612
  sections.shift();
3311
3613
  for (const section of sections){
3312
- if ('Usage' === section.title) section.body = section.body.replace('$ rslib', picocolors.yellow('$ rslib [command] [options]'));
3614
+ if ('Usage' === section.title) section.body = section.body.replace('$ rslib', color.yellow('$ rslib [command] [options]'));
3313
3615
  if ('Commands' === section.title) section.body = section.body.replace(` ${buildDescription}`, `build ${buildDescription}`);
3314
3616
  if (section.title?.startsWith('For more info')) {
3315
- section.title = picocolors.dim(' For details on a sub-command, run');
3316
- section.body = picocolors.dim(' $ rslib <command> -h');
3317
- } else section.title = picocolors.cyan(section.title);
3617
+ section.title = color.dim(' For details on a sub-command, run');
3618
+ section.body = color.dim(' $ rslib <command> -h');
3619
+ } else if (section.title) section.title = color.cyan(section.title);
3318
3620
  }
3319
3621
  });
3320
3622
  cli.parse();
3321
3623
  }
3322
3624
  function initNodeEnv() {
3323
3625
  if (!process.env.NODE_ENV) {
3324
- const command = process.argv[2] ?? '';
3626
+ const command = process.argv[2] ?? 'build';
3325
3627
  process.env.NODE_ENV = [
3326
3628
  'build',
3327
3629
  'inspect'
@@ -3334,7 +3636,7 @@ function showGreeting() {
3334
3636
  const isBun = npm_execpath?.includes('.bun');
3335
3637
  const isNodeRun = Boolean(NODE_RUN_SCRIPT_NAME);
3336
3638
  const prefix = isNpx || isBun || isNodeRun ? '\n' : '';
3337
- logger.greet(`${prefix}Rslib v0.20.0\n`);
3639
+ src_logger.greet(`${prefix}Rslib v0.20.2\n`);
3338
3640
  }
3339
3641
  function setupLogLevel() {
3340
3642
  const logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
@@ -3344,7 +3646,7 @@ function setupLogLevel() {
3344
3646
  'warn',
3345
3647
  'error',
3346
3648
  'silent'
3347
- ].includes(level) && !isDebug()) logger.level = level;
3649
+ ].includes(level) && !isDebug()) src_logger.level = level;
3348
3650
  }
3349
3651
  }
3350
3652
  function runCLI() {
@@ -3355,8 +3657,8 @@ function runCLI() {
3355
3657
  try {
3356
3658
  setupCommands();
3357
3659
  } catch (err) {
3358
- logger.error('Failed to start Rslib CLI.');
3359
- logger.error(err);
3660
+ src_logger.error('Failed to start Rslib CLI.');
3661
+ src_logger.error(err);
3360
3662
  process.exit(1);
3361
3663
  }
3362
3664
  }
@@ -3388,6 +3690,6 @@ function mergeRslibConfig(...originalConfigs) {
3388
3690
  if (void 0 !== mergedLib) mergedConfig.lib = mergedLib;
3389
3691
  return mergedConfig;
3390
3692
  }
3391
- const src_version = "0.20.0";
3693
+ const src_version = "0.20.2";
3392
3694
  var rspack_0 = __rspack_external__rsbuild_core_1b356efc.rspack;
3393
3695
  export { __rspack_external__rsbuild_core_1b356efc as rsbuild, createRslib, loadConfig_defineConfig as defineConfig, loadConfig_loadConfig as loadConfig, loadEnv, mergeRslibConfig, rspack_0 as rspack, runCLI, src_version as version };