@rslib/core 0.5.4 → 0.5.5

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
@@ -89,7 +89,7 @@ function getAbsolutePath(base, filepath) {
89
89
  const readPackageJson = (rootPath)=>{
90
90
  const pkgJsonPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(rootPath, './package.json');
91
91
  if (!__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(pkgJsonPath)) {
92
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`package.json does not exist in the ${rootPath} directory`);
92
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`The \`package.json\` file does not exist in the ${rootPath} directory`);
93
93
  return;
94
94
  }
95
95
  try {
@@ -147,7 +147,31 @@ const windowsSlashRegex = /\\/g;
147
147
  function normalizeSlash(p) {
148
148
  return p.replace(windowsSlashRegex, '/');
149
149
  }
150
- if (process.env.DEBUG) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.level = 'verbose';
150
+ const isDebug = ()=>{
151
+ if (!process.env.DEBUG) return false;
152
+ const values = process.env.DEBUG.toLocaleLowerCase().split(',');
153
+ return [
154
+ 'rslib',
155
+ 'rs*',
156
+ 'rstack',
157
+ '*'
158
+ ].some((key)=>values.includes(key));
159
+ };
160
+ if (isDebug()) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.level = 'verbose';
161
+ function getTime() {
162
+ const now = new Date();
163
+ const hours = String(now.getHours()).padStart(2, '0');
164
+ const minutes = String(now.getMinutes()).padStart(2, '0');
165
+ const seconds = String(now.getSeconds()).padStart(2, '0');
166
+ return `${hours}:${minutes}:${seconds}`;
167
+ }
168
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.override({
169
+ debug: (message, ...args)=>{
170
+ if ('verbose' !== __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.level) return;
171
+ const time = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].gray(`${getTime()}`);
172
+ console.log(` ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green('rslib')} ${time} ${message}`, ...args);
173
+ }
174
+ });
151
175
  function initNodeEnv() {
152
176
  if (!process.env.NODE_ENV) {
153
177
  const command = process.argv[2] ?? '';
@@ -160,7 +184,7 @@ function prepareCli() {
160
184
  initNodeEnv();
161
185
  const { npm_execpath } = process.env;
162
186
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
163
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rslib v0.5.4\n`);
187
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rslib v0.5.5\n`);
164
188
  }
165
189
  const DEFAULT_CONFIG_NAME = 'rslib.config';
166
190
  const DEFAULT_CONFIG_EXTENSIONS = [
@@ -523,18 +547,20 @@ class EntryChunkPlugin {
523
547
  shebangInjectedAssets = new Set();
524
548
  enabledImportMetaUrlShim;
525
549
  contextToWatch = null;
526
- contextWatched = false;
527
550
  constructor({ enabledImportMetaUrlShim = true, contextToWatch }){
528
551
  this.enabledImportMetaUrlShim = enabledImportMetaUrlShim;
529
552
  this.contextToWatch = contextToWatch;
530
553
  }
531
554
  apply(compiler) {
532
- compiler.hooks.afterCompile.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
533
- if (this.contextWatched || null === this.contextToWatch) return;
534
- const contextDep = compilation.contextDependencies;
535
- contextDep.add(this.contextToWatch);
536
- this.contextWatched = true;
537
- });
555
+ compiler.hooks.afterCompile.tapPromise(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>new Promise((resolve)=>{
556
+ if (null === this.contextToWatch) {
557
+ resolve();
558
+ return;
559
+ }
560
+ const contextDep = compilation.contextDependencies;
561
+ if (!contextDep.has(this.contextToWatch)) contextDep.add(this.contextToWatch);
562
+ resolve();
563
+ }));
538
564
  compiler.hooks.make.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
539
565
  const entries = {};
540
566
  for (const [key, value] of compilation.entries){
@@ -669,7 +695,7 @@ const getDefaultExtension = (options)=>{
669
695
  dtsExtension
670
696
  };
671
697
  if (!pkgJson) {
672
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('autoExtension configuration will not be applied due to read package.json failed');
698
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('The `autoExtension` configuration will not be applied due to read package.json failed');
673
699
  return {
674
700
  jsExtension,
675
701
  dtsExtension
@@ -1462,7 +1488,7 @@ const composeExternalsWarnConfig = (format, ...externalsArray)=>{
1462
1488
  };
1463
1489
  if (contextInfo.issuer && 'commonjs' === dependencyType) {
1464
1490
  matchUserExternals(externals, request, _callback);
1465
- if (shouldWarn) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(composeModuleImportWarn(request));
1491
+ if (shouldWarn) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(composeModuleImportWarn(request, contextInfo.issuer));
1466
1492
  }
1467
1493
  callback();
1468
1494
  }
@@ -1477,7 +1503,7 @@ const composeAutoExternalConfig = (options)=>{
1477
1503
  const autoExternal = getAutoExternalDefaultValue(format, options.autoExternal);
1478
1504
  if (false === autoExternal) return {};
1479
1505
  if (!pkgJson) {
1480
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('autoExternal configuration will not be applied due to read package.json failed');
1506
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('The `autoExternal` configuration will not be applied due to read package.json failed');
1481
1507
  return {};
1482
1508
  }
1483
1509
  const userExternalKeys = userExternals && isObject(userExternals) ? Object.keys(userExternals) : [];
@@ -1852,7 +1878,7 @@ const composeShimsConfig = (format, shims)=>{
1852
1878
  enabledShims
1853
1879
  };
1854
1880
  };
1855
- const composeModuleImportWarn = (request)=>`The externalized commonjs request ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green(`"${request}"`)} will use ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].blue('"module"')} external type in ESM format. If you want to specify other external type, consider setting the request and type with ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].blue('"output.externals"')}.`;
1881
+ const composeModuleImportWarn = (request, issuer)=>`The externalized commonjs request ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green(`"${request}"`)} from ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].green(issuer)} will use ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].blue('"module"')} external type in ESM format. If you want to specify other external type, consider setting the request and type with ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].blue('"output.externals"')}.`;
1856
1882
  const composeExternalsConfig = (format, externals)=>{
1857
1883
  const externalsTypeMap = {
1858
1884
  esm: 'module-import',
@@ -2345,8 +2371,8 @@ const beforeRestart = async ({ filePath, clear = true } = {})=>{
2345
2371
  if (clear) clearConsole();
2346
2372
  if (filePath) {
2347
2373
  const filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filePath);
2348
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`Restart because ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].yellow(filename)} is changed.\n`);
2349
- } else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info('Restarting...\n');
2374
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`restart because ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js_ea7a20e9__["default"].yellow(filename)} is changed.\n`);
2375
+ } else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info('restarting...\n');
2350
2376
  for (const cleaner of cleaners)await cleaner();
2351
2377
  cleaners = [];
2352
2378
  };
@@ -2455,7 +2481,7 @@ const repeatableOption = (value, previous)=>(previous ?? []).concat([
2455
2481
  value
2456
2482
  ]);
2457
2483
  function runCli() {
2458
- __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.5.4");
2484
+ __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.5.5");
2459
2485
  const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('build');
2460
2486
  const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('inspect');
2461
2487
  const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('mf-dev');
@@ -2516,6 +2542,6 @@ function runCli() {
2516
2542
  });
2517
2543
  __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.parse();
2518
2544
  }
2519
- const src_rslib_entry_version = "0.5.4";
2545
+ const src_rslib_entry_version = "0.5.5";
2520
2546
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger;
2521
2547
  export { build, defineConfig, inspect, loadConfig, prepareCli, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_rslib_entry_version as version, __webpack_exports__logger as logger };
@@ -27,7 +27,7 @@ export declare function composeMinifyConfig(config: LibConfig): EnvironmentConfi
27
27
  export declare function composeBannerFooterConfig(banner: BannerAndFooter, footer: BannerAndFooter): EnvironmentConfig;
28
28
  export declare function composeDecoratorsConfig(compilerOptions?: Record<string, any>, version?: NonNullable<NonNullable<EnvironmentConfig['source']>['decorators']>['version']): EnvironmentConfig;
29
29
  export declare function createConstantRsbuildConfig(): Promise<EnvironmentConfig>;
30
- export declare const composeModuleImportWarn: (request: string) => string;
30
+ export declare const composeModuleImportWarn: (request: string, issuer: string) => string;
31
31
  export declare const appendEntryQuery: (entries: RsbuildConfigEntry) => RsbuildEntry;
32
32
  export declare const resolveEntryPath: (entries: RsbuildConfigEntry, root: string) => RsbuildEntry;
33
33
  export declare function composeCreateRsbuildConfig(rslibConfig: RslibConfig): Promise<RsbuildConfigWithLibInfo[]>;
@@ -1,4 +1,4 @@
1
- import type { EnvironmentConfig, RsbuildConfig, Rspack } from '@rsbuild/core';
1
+ import type { EnvironmentConfig, OutputConfig, RsbuildConfig, Rspack } from '@rsbuild/core';
2
2
  import type { GetAsyncFunctionFromUnion } from './utils';
3
3
  export type Format = 'esm' | 'cjs' | 'umd' | 'mf';
4
4
  export type FixedEcmaVersions = 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'es2023';
@@ -259,10 +259,38 @@ export interface LibConfig extends EnvironmentConfig {
259
259
  * @see {@link https://lib.rsbuild.dev/config/lib/out-base}
260
260
  */
261
261
  outBase?: string;
262
+ /**
263
+ * @inheritdoc
264
+ */
265
+ output?: RslibOutputConfig;
262
266
  }
263
267
  export type LibOnlyConfig = Omit<LibConfig, keyof EnvironmentConfig>;
268
+ interface RslibOutputConfig extends OutputConfig {
269
+ /**
270
+ * @override
271
+ * @default 'node'
272
+ */
273
+ target?: OutputConfig['target'];
274
+ /**
275
+ * @override
276
+ * @default false
277
+ */
278
+ filenameHash?: OutputConfig['filenameHash'];
279
+ /**
280
+ * @override
281
+ * When minify is not specified, Rslib will use a sane default for minify options.
282
+ * The default options will only perform dead code elimination and unused code elimination.
283
+ *
284
+ * @see {@link https://lib.rsbuild.dev/config/rsbuild/output#outputminify}
285
+ */
286
+ minify?: OutputConfig['minify'];
287
+ }
264
288
  export interface RslibConfig extends RsbuildConfig {
265
289
  lib: LibConfig[];
290
+ /**
291
+ * @inheritdoc
292
+ */
293
+ output?: RslibOutputConfig;
266
294
  }
267
295
  export type ConfigParams = {
268
296
  env: string;
@@ -272,3 +300,4 @@ export type ConfigParams = {
272
300
  export type RslibConfigSyncFn = (env: ConfigParams) => RslibConfig;
273
301
  export type RslibConfigAsyncFn = (env: ConfigParams) => Promise<RslibConfig>;
274
302
  export type RslibConfigExport = RslibConfig | RslibConfigSyncFn | RslibConfigAsyncFn;
303
+ export {};
@@ -1,5 +1,18 @@
1
+ /**
2
+ * Logging message case convention:
3
+ *
4
+ * Info, ready, success and debug messages:
5
+ * - Start with lowercase
6
+ * - Example: "info build started..."
7
+ *
8
+ * Errors and warnings:
9
+ * - Start with uppercase
10
+ * - Example: "error Failed to build"
11
+ *
12
+ * This convention helps distinguish between normal operations
13
+ * and important alerts that require attention.
14
+ */
1
15
  import { type Logger, logger } from '../../compiled/rslog';
2
16
  export declare const isDebug: () => boolean;
3
- export declare const debug: (message: string | (() => string)) => void;
4
17
  export { logger };
5
18
  export type { Logger };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslib/core",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "The Rsbuild-based library development tool.",
5
5
  "homepage": "https://lib.rsbuild.dev",
6
6
  "bugs": {
@@ -36,12 +36,12 @@
36
36
  "types.d.ts"
37
37
  ],
38
38
  "dependencies": {
39
- "@rsbuild/core": "~1.2.16",
39
+ "@rsbuild/core": "~1.2.19",
40
40
  "tinyglobby": "^0.2.12",
41
- "rsbuild-plugin-dts": "0.5.4"
41
+ "rsbuild-plugin-dts": "0.5.5"
42
42
  },
43
43
  "devDependencies": {
44
- "@module-federation/rsbuild-plugin": "^0.10.0",
44
+ "@module-federation/rsbuild-plugin": "^0.11.1",
45
45
  "@types/fs-extra": "^11.0.4",
46
46
  "chokidar": "^4.0.3",
47
47
  "commander": "^13.1.0",
@@ -50,7 +50,7 @@
50
50
  "picocolors": "1.1.1",
51
51
  "prebundle": "1.2.7",
52
52
  "rsbuild-plugin-publint": "^0.3.0",
53
- "rslib": "npm:@rslib/core@0.5.3",
53
+ "rslib": "npm:@rslib/core@0.5.4",
54
54
  "rslog": "^1.2.3",
55
55
  "tsconfck": "3.1.5",
56
56
  "typescript": "^5.8.2",