@rslib/core 0.13.3 → 0.14.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 +28 -9
- package/dist-types/cli/commands.d.ts +2 -1
- package/dist-types/config.d.ts +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ const DEFAULT_CONFIG_EXTENSIONS = [
|
|
|
18
18
|
'.cts'
|
|
19
19
|
];
|
|
20
20
|
const SWC_HELPERS = '@swc/helpers';
|
|
21
|
+
const SHEBANG_PREFIX = '#!';
|
|
21
22
|
const SHEBANG_REGEX = /#!.*[\s\n\r]*$/;
|
|
22
23
|
const REACT_DIRECTIVE_REGEX = /^['"]use (client|server)['"](;?)[\s\n\r]*$/;
|
|
23
24
|
const DTS_EXTENSIONS = [
|
|
@@ -394,7 +395,7 @@ class EntryChunkPlugin {
|
|
|
394
395
|
const content = compiler.inputFileSystem.readFileSync(filename, {
|
|
395
396
|
encoding: 'utf-8'
|
|
396
397
|
});
|
|
397
|
-
if (content.startsWith(
|
|
398
|
+
if (content.startsWith(SHEBANG_PREFIX)) {
|
|
398
399
|
const shebangMatch = matchFirstLine(content, SHEBANG_REGEX);
|
|
399
400
|
if (shebangMatch) this.shebangEntries[name] = shebangMatch;
|
|
400
401
|
}
|
|
@@ -509,6 +510,7 @@ const isDebug = ()=>{
|
|
|
509
510
|
const values = process.env.DEBUG.toLocaleLowerCase().split(',');
|
|
510
511
|
return [
|
|
511
512
|
'rslib',
|
|
513
|
+
'rsbuild',
|
|
512
514
|
'rs*',
|
|
513
515
|
'rstack',
|
|
514
516
|
'*'
|
|
@@ -2379,7 +2381,8 @@ async function composeLibRsbuildConfig(config, multiCompilerIndex, root, sharedP
|
|
|
2379
2381
|
}
|
|
2380
2382
|
async function composeCreateRsbuildConfig(rslibConfig) {
|
|
2381
2383
|
const constantRsbuildConfig = await createConstantRsbuildConfig();
|
|
2382
|
-
const { lib: libConfigsArray, mode: _mode, root, plugins: sharedPlugins, dev: _dev, server: _server, ...sharedRsbuildConfig } = rslibConfig;
|
|
2384
|
+
const { lib: libConfigsArray, mode: _mode, root, plugins: sharedPlugins, dev: _dev, server: _server, logLevel, ...sharedRsbuildConfig } = rslibConfig;
|
|
2385
|
+
if (logLevel && !isDebug()) logger.level = logLevel;
|
|
2383
2386
|
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))}.`);
|
|
2384
2387
|
const libConfigPromises = libConfigsArray.map(async (libConfig, index)=>{
|
|
2385
2388
|
const userConfig = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(sharedRsbuildConfig, libConfig);
|
|
@@ -2496,6 +2499,7 @@ async function build(config, options = {}) {
|
|
|
2496
2499
|
plugins: config.plugins,
|
|
2497
2500
|
dev: config.dev,
|
|
2498
2501
|
server: config.server,
|
|
2502
|
+
logLevel: isDebug() ? 'info' : config.logLevel,
|
|
2499
2503
|
environments: pruneEnvironments(environments, options.lib)
|
|
2500
2504
|
}
|
|
2501
2505
|
});
|
|
@@ -3015,6 +3019,7 @@ async function init(options) {
|
|
|
3015
3019
|
...config.source.define
|
|
3016
3020
|
};
|
|
3017
3021
|
if (options.root) config.root = root;
|
|
3022
|
+
if (options.logLevel) config.logLevel = options.logLevel;
|
|
3018
3023
|
return {
|
|
3019
3024
|
config,
|
|
3020
3025
|
configFilePath,
|
|
@@ -3034,6 +3039,7 @@ async function inspect(config, options = {}) {
|
|
|
3034
3039
|
plugins: config.plugins,
|
|
3035
3040
|
dev: config.dev,
|
|
3036
3041
|
server: config.server,
|
|
3042
|
+
logLevel: isDebug() ? 'info' : config.logLevel,
|
|
3037
3043
|
environments: pruneEnvironments(environments, options.lib)
|
|
3038
3044
|
}
|
|
3039
3045
|
});
|
|
@@ -3066,6 +3072,7 @@ async function initMFRsbuild(config, options = {}) {
|
|
|
3066
3072
|
plugins: config.plugins,
|
|
3067
3073
|
dev: config.dev,
|
|
3068
3074
|
server: config.server,
|
|
3075
|
+
logLevel: isDebug() ? 'info' : config.logLevel,
|
|
3069
3076
|
environments: selectedEnvironments
|
|
3070
3077
|
}
|
|
3071
3078
|
});
|
|
@@ -3074,9 +3081,9 @@ async function initMFRsbuild(config, options = {}) {
|
|
|
3074
3081
|
return rsbuildInstance;
|
|
3075
3082
|
}
|
|
3076
3083
|
const applyCommonOptions = (cli)=>{
|
|
3077
|
-
cli.option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('-r, --root <root>', 'specify the project root directory, can be an absolute path or a path relative to cwd').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--config-loader <loader>', 'Set the config file loader (jiti | native)', {
|
|
3078
|
-
default: '
|
|
3079
|
-
}).option('--env-dir <dir>', 'specify the directory to load `.env` files').option('--lib <id>', 'specify the library (repeatable, e.g. --lib esm --lib cjs)', {
|
|
3084
|
+
cli.option('-c, --config <config>', 'specify the configuration file, can be a relative or absolute path').option('-r, --root <root>', 'specify the project root directory, can be an absolute path or a path relative to cwd').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file').option('--config-loader <loader>', 'Set the config file loader (auto | jiti | native)', {
|
|
3085
|
+
default: 'auto'
|
|
3086
|
+
}).option('--env-dir <dir>', 'specify the directory to load `.env` files').option('--log-level <level>', 'set the log level (info | warn | error | silent)').option('--lib <id>', 'specify the library (repeatable, e.g. --lib esm --lib cjs)', {
|
|
3080
3087
|
type: [
|
|
3081
3088
|
String
|
|
3082
3089
|
],
|
|
@@ -3086,7 +3093,7 @@ const applyCommonOptions = (cli)=>{
|
|
|
3086
3093
|
function runCli() {
|
|
3087
3094
|
const cli = dist('rslib');
|
|
3088
3095
|
cli.help();
|
|
3089
|
-
cli.version("0.
|
|
3096
|
+
cli.version("0.14.0");
|
|
3090
3097
|
applyCommonOptions(cli);
|
|
3091
3098
|
const buildCommand = cli.command('build', 'build the library for production');
|
|
3092
3099
|
const inspectCommand = cli.command('inspect', 'inspect the Rsbuild / Rspack configs of Rslib projects');
|
|
@@ -3153,12 +3160,24 @@ function initNodeEnv() {
|
|
|
3153
3160
|
].includes(command) ? 'production' : 'development';
|
|
3154
3161
|
}
|
|
3155
3162
|
}
|
|
3163
|
+
function setupLogLevel() {
|
|
3164
|
+
const logLevelIndex = process.argv.findIndex((item)=>'--log-level' === item || '--logLevel' === item);
|
|
3165
|
+
if (-1 !== logLevelIndex) {
|
|
3166
|
+
const level = process.argv[logLevelIndex + 1];
|
|
3167
|
+
if (level && [
|
|
3168
|
+
'warn',
|
|
3169
|
+
'error',
|
|
3170
|
+
'silent'
|
|
3171
|
+
].includes(level) && !isDebug()) logger.level = level;
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3156
3174
|
function prepareCli() {
|
|
3157
3175
|
initNodeEnv();
|
|
3176
|
+
setupLogLevel();
|
|
3158
3177
|
const { npm_execpath } = process.env;
|
|
3159
|
-
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun'))
|
|
3160
|
-
logger.greet(` Rslib v0.
|
|
3178
|
+
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) logger.log();
|
|
3179
|
+
logger.greet(` Rslib v0.14.0\n`);
|
|
3161
3180
|
}
|
|
3162
|
-
const src_version = "0.
|
|
3181
|
+
const src_version = "0.14.0";
|
|
3163
3182
|
var __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack;
|
|
3164
3183
|
export { build, defineConfig, inspect, loadConfig, logger, prepareCli, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ as rsbuild, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_version as version, __webpack_exports__rspack as rspack };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RsbuildMode } from '@rsbuild/core';
|
|
1
|
+
import type { LogLevel, RsbuildMode } from '@rsbuild/core';
|
|
2
2
|
import type { ConfigLoader } from '../config';
|
|
3
3
|
export type CommonOptions = {
|
|
4
4
|
root?: string;
|
|
@@ -7,6 +7,7 @@ export type CommonOptions = {
|
|
|
7
7
|
envMode?: string;
|
|
8
8
|
lib?: string[];
|
|
9
9
|
configLoader?: ConfigLoader;
|
|
10
|
+
logLevel?: LogLevel;
|
|
10
11
|
};
|
|
11
12
|
export type BuildOptions = CommonOptions & {
|
|
12
13
|
watch?: boolean;
|
package/dist-types/config.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare function defineConfig(config: RslibConfig): RslibConfig;
|
|
|
8
8
|
export declare function defineConfig(config: RslibConfigSyncFn): RslibConfigSyncFn;
|
|
9
9
|
export declare function defineConfig(config: RslibConfigAsyncFn): RslibConfigAsyncFn;
|
|
10
10
|
export declare function defineConfig(config: RslibConfigExport): RslibConfigExport;
|
|
11
|
-
export type ConfigLoader = 'jiti' | 'native';
|
|
11
|
+
export type ConfigLoader = 'auto' | 'jiti' | 'native';
|
|
12
12
|
export declare function loadConfig({ cwd, path, envMode, loader, }: {
|
|
13
13
|
cwd?: string;
|
|
14
14
|
path?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://rslib.rs",
|
|
6
6
|
"bugs": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"types.d.ts"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@rsbuild/core": "~1.5.
|
|
40
|
-
"rsbuild-plugin-dts": "0.
|
|
39
|
+
"@rsbuild/core": "~1.5.11",
|
|
40
|
+
"rsbuild-plugin-dts": "0.14.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@module-federation/rsbuild-plugin": "^0.19.1",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"cac": "^6.7.14",
|
|
46
46
|
"chokidar": "^4.0.3",
|
|
47
47
|
"fs-extra": "^11.3.2",
|
|
48
|
-
"memfs": "^4.
|
|
48
|
+
"memfs": "^4.43.0",
|
|
49
49
|
"path-serializer": "0.5.1",
|
|
50
50
|
"picocolors": "1.1.1",
|
|
51
51
|
"prebundle": "1.4.2",
|
|
52
52
|
"rsbuild-plugin-publint": "^0.3.3",
|
|
53
|
-
"rslib": "npm:@rslib/core@0.13.
|
|
53
|
+
"rslib": "npm:@rslib/core@0.13.3",
|
|
54
54
|
"rslog": "^1.2.11",
|
|
55
55
|
"tinyglobby": "0.2.14",
|
|
56
56
|
"tsconfck": "3.1.6",
|