@rslib/core 0.5.4 → 0.6.0
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 +38 -16
- package/dist-types/config.d.ts +1 -1
- package/dist-types/types/config.d.ts +30 -1
- package/dist-types/utils/logger.d.ts +14 -1
- package/package.json +5 -5
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
|
-
|
|
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.
|
|
187
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rslib v0.6.0\n`);
|
|
164
188
|
}
|
|
165
189
|
const DEFAULT_CONFIG_NAME = 'rslib.config';
|
|
166
190
|
const DEFAULT_CONFIG_EXTENSIONS = [
|
|
@@ -523,17 +547,15 @@ 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
555
|
compiler.hooks.afterCompile.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
|
|
533
|
-
if (
|
|
556
|
+
if (null === this.contextToWatch) return;
|
|
534
557
|
const contextDep = compilation.contextDependencies;
|
|
535
|
-
contextDep.add(this.contextToWatch);
|
|
536
|
-
this.contextWatched = true;
|
|
558
|
+
if (!contextDep.has(this.contextToWatch)) contextDep.add(this.contextToWatch);
|
|
537
559
|
});
|
|
538
560
|
compiler.hooks.make.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
|
|
539
561
|
const entries = {};
|
|
@@ -669,7 +691,7 @@ const getDefaultExtension = (options)=>{
|
|
|
669
691
|
dtsExtension
|
|
670
692
|
};
|
|
671
693
|
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');
|
|
694
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('The `autoExtension` configuration will not be applied due to read package.json failed');
|
|
673
695
|
return {
|
|
674
696
|
jsExtension,
|
|
675
697
|
dtsExtension
|
|
@@ -1462,7 +1484,7 @@ const composeExternalsWarnConfig = (format, ...externalsArray)=>{
|
|
|
1462
1484
|
};
|
|
1463
1485
|
if (contextInfo.issuer && 'commonjs' === dependencyType) {
|
|
1464
1486
|
matchUserExternals(externals, request, _callback);
|
|
1465
|
-
if (shouldWarn) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(composeModuleImportWarn(request));
|
|
1487
|
+
if (shouldWarn) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(composeModuleImportWarn(request, contextInfo.issuer));
|
|
1466
1488
|
}
|
|
1467
1489
|
callback();
|
|
1468
1490
|
}
|
|
@@ -1477,7 +1499,7 @@ const composeAutoExternalConfig = (options)=>{
|
|
|
1477
1499
|
const autoExternal = getAutoExternalDefaultValue(format, options.autoExternal);
|
|
1478
1500
|
if (false === autoExternal) return {};
|
|
1479
1501
|
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');
|
|
1502
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn('The `autoExternal` configuration will not be applied due to read package.json failed');
|
|
1481
1503
|
return {};
|
|
1482
1504
|
}
|
|
1483
1505
|
const userExternalKeys = userExternals && isObject(userExternals) ? Object.keys(userExternals) : [];
|
|
@@ -1720,7 +1742,7 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1720
1742
|
iife: false,
|
|
1721
1743
|
chunkFormat: 'commonjs',
|
|
1722
1744
|
library: {
|
|
1723
|
-
type: 'commonjs'
|
|
1745
|
+
type: 'commonjs-static'
|
|
1724
1746
|
},
|
|
1725
1747
|
chunkLoading: 'require',
|
|
1726
1748
|
workerChunkLoading: 'async-node',
|
|
@@ -1852,7 +1874,7 @@ const composeShimsConfig = (format, shims)=>{
|
|
|
1852
1874
|
enabledShims
|
|
1853
1875
|
};
|
|
1854
1876
|
};
|
|
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"')}.`;
|
|
1877
|
+
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
1878
|
const composeExternalsConfig = (format, externals)=>{
|
|
1857
1879
|
const externalsTypeMap = {
|
|
1858
1880
|
esm: 'module-import',
|
|
@@ -2345,8 +2367,8 @@ const beforeRestart = async ({ filePath, clear = true } = {})=>{
|
|
|
2345
2367
|
if (clear) clearConsole();
|
|
2346
2368
|
if (filePath) {
|
|
2347
2369
|
const filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filePath);
|
|
2348
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info(`
|
|
2349
|
-
} else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info('
|
|
2370
|
+
__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`);
|
|
2371
|
+
} else __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.info('restarting...\n');
|
|
2350
2372
|
for (const cleaner of cleaners)await cleaner();
|
|
2351
2373
|
cleaners = [];
|
|
2352
2374
|
};
|
|
@@ -2455,7 +2477,7 @@ const repeatableOption = (value, previous)=>(previous ?? []).concat([
|
|
|
2455
2477
|
value
|
|
2456
2478
|
]);
|
|
2457
2479
|
function runCli() {
|
|
2458
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.
|
|
2480
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.6.0");
|
|
2459
2481
|
const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('build');
|
|
2460
2482
|
const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('inspect');
|
|
2461
2483
|
const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('mf-dev');
|
|
@@ -2516,6 +2538,6 @@ function runCli() {
|
|
|
2516
2538
|
});
|
|
2517
2539
|
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.parse();
|
|
2518
2540
|
}
|
|
2519
|
-
const src_rslib_entry_version = "0.
|
|
2541
|
+
const src_rslib_entry_version = "0.6.0";
|
|
2520
2542
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger;
|
|
2521
2543
|
export { build, defineConfig, inspect, loadConfig, prepareCli, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_rslib_entry_version as version, __webpack_exports__logger as logger };
|
package/dist-types/config.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.6.0",
|
|
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": "
|
|
39
|
+
"@rsbuild/core": "1.3.0-beta.3",
|
|
40
40
|
"tinyglobby": "^0.2.12",
|
|
41
|
-
"rsbuild-plugin-dts": "0.
|
|
41
|
+
"rsbuild-plugin-dts": "0.6.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@module-federation/rsbuild-plugin": "^0.
|
|
44
|
+
"@module-federation/rsbuild-plugin": "^0.11.2",
|
|
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.
|
|
53
|
+
"rslib": "npm:@rslib/core@0.5.5",
|
|
54
54
|
"rslog": "^1.2.3",
|
|
55
55
|
"tsconfck": "3.1.5",
|
|
56
56
|
"typescript": "^5.8.2",
|