@rslib/core 0.15.1 → 0.16.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/compiled/rslog/index.js +17 -6
- package/compiled/rslog/package.json +1 -1
- package/dist/index.js +170 -75
- package/dist-types/cli/commands.d.ts +14 -0
- package/dist-types/cli/initConfig.d.ts +9 -0
- package/dist-types/config.d.ts +1 -1
- package/dist-types/utils/syntax.d.ts +1 -4
- package/package.json +5 -5
- package/dist-types/cli/init.d.ts +0 -7
package/compiled/rslog/index.js
CHANGED
|
@@ -100,6 +100,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
100
100
|
if ('truecolor' === env.COLORTERM) return 3;
|
|
101
101
|
if ('xterm-kitty' === env.TERM) return 3;
|
|
102
102
|
if ('xterm-ghostty' === env.TERM) return 3;
|
|
103
|
+
if ('wezterm' === env.TERM) return 3;
|
|
103
104
|
if ('TERM_PROGRAM' in env) {
|
|
104
105
|
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
105
106
|
switch(env.TERM_PROGRAM){
|
|
@@ -234,6 +235,14 @@ let LOG_TYPES = {
|
|
|
234
235
|
color: magenta
|
|
235
236
|
}
|
|
236
237
|
};
|
|
238
|
+
const normalizeErrorMessage = (err)=>{
|
|
239
|
+
if (err.stack) {
|
|
240
|
+
let [name, ...rest] = err.stack.split('\n');
|
|
241
|
+
if (name.startsWith('Error: ')) name = name.slice(7);
|
|
242
|
+
return `${name}\n${gray(rest.join('\n'))}`;
|
|
243
|
+
}
|
|
244
|
+
return err.message;
|
|
245
|
+
};
|
|
237
246
|
let createLogger = (options = {})=>{
|
|
238
247
|
let maxLevel = options.level || 'info';
|
|
239
248
|
let log = (type, message, ...args)=>{
|
|
@@ -246,12 +255,14 @@ let createLogger = (options = {})=>{
|
|
|
246
255
|
label = (logType.label || '').padEnd(7);
|
|
247
256
|
label = bold(logType.color ? logType.color(label) : label);
|
|
248
257
|
}
|
|
249
|
-
if (message instanceof Error)
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
258
|
+
if (message instanceof Error) {
|
|
259
|
+
text += normalizeErrorMessage(message);
|
|
260
|
+
const { cause } = message;
|
|
261
|
+
if (cause) {
|
|
262
|
+
text += yellow('\n [cause]: ');
|
|
263
|
+
text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause);
|
|
264
|
+
}
|
|
265
|
+
} else if ('error' === logType.level && 'string' == typeof message) {
|
|
255
266
|
let lines = message.split('\n');
|
|
256
267
|
text = lines.map((line)=>isErrorStackMessage(line) ? gray(line) : line).join('\n');
|
|
257
268
|
} else text = `${message}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"rslog","version":"1.
|
|
1
|
+
{"name":"rslog","version":"1.3.0","license":"MIT","types":"index.d.ts","type":"commonjs"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import node_fs, { chmodSync, promises } from "node:fs";
|
|
2
|
-
import node_path, { basename, dirname, extname, isAbsolute, join } from "node:path";
|
|
2
|
+
import node_path, { basename as external_node_path_basename, dirname, extname, isAbsolute, join } from "node:path";
|
|
3
3
|
import { glob } from "../compiled/tinyglobby/index.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import picocolors from "../compiled/picocolors/index.js";
|
|
@@ -7,6 +7,7 @@ import { logger } from "../compiled/rslog/index.js";
|
|
|
7
7
|
import node_fs_promises from "node:fs/promises";
|
|
8
8
|
import { createRequire as external_module_createRequire } from "module";
|
|
9
9
|
import { EventEmitter } from "events";
|
|
10
|
+
import node_util from "node:util";
|
|
10
11
|
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
|
|
11
12
|
const DEFAULT_CONFIG_NAME = 'rslib.config';
|
|
12
13
|
const DEFAULT_CONFIG_EXTENSIONS = [
|
|
@@ -406,9 +407,9 @@ class EntryChunkPlugin {
|
|
|
406
407
|
compilation.hooks.chunkAsset.tap(EntryChunkPlugin_PLUGIN_NAME, (chunk, filename)=>{
|
|
407
408
|
const isJs = JS_EXTENSIONS_PATTERN.test(filename);
|
|
408
409
|
if (!isJs) return;
|
|
410
|
+
this.shimsInjectedAssets.add(filename);
|
|
409
411
|
const name = chunk.name;
|
|
410
412
|
if (!name) return;
|
|
411
|
-
this.shimsInjectedAssets.add(filename);
|
|
412
413
|
const shebangEntry = this.shebangEntries[name];
|
|
413
414
|
if (shebangEntry) this.shebangEntries[filename] = shebangEntry;
|
|
414
415
|
const reactDirective = this.reactDirectives[name];
|
|
@@ -741,90 +742,84 @@ const ESX_TO_BROWSERSLIST = {
|
|
|
741
742
|
safari: '3.1.0'
|
|
742
743
|
},
|
|
743
744
|
es6: {
|
|
744
|
-
chrome: '
|
|
745
|
-
edge: '
|
|
746
|
-
firefox: '
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
safari: '13.0.0'
|
|
745
|
+
chrome: '51.0.0',
|
|
746
|
+
edge: '15.0.0',
|
|
747
|
+
firefox: '54.0.0',
|
|
748
|
+
safari: '10.0.0',
|
|
749
|
+
opera: '38.0.0',
|
|
750
|
+
samsung: '5.0.0'
|
|
751
751
|
},
|
|
752
752
|
es2015: {
|
|
753
|
-
chrome: '
|
|
754
|
-
edge: '
|
|
755
|
-
firefox: '
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
safari: '13.0.0'
|
|
753
|
+
chrome: '51.0.0',
|
|
754
|
+
edge: '15.0.0',
|
|
755
|
+
firefox: '54.0.0',
|
|
756
|
+
safari: '10.0.0',
|
|
757
|
+
opera: '38.0.0',
|
|
758
|
+
samsung: '5.0.0'
|
|
760
759
|
},
|
|
761
760
|
es2016: {
|
|
762
|
-
chrome: '
|
|
763
|
-
edge: '
|
|
764
|
-
firefox: '
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
safari: '13.0.0'
|
|
761
|
+
chrome: '52.0.0',
|
|
762
|
+
edge: '15.0.0',
|
|
763
|
+
firefox: '54.0.0',
|
|
764
|
+
safari: '10.3.0',
|
|
765
|
+
opera: '39.0.0',
|
|
766
|
+
samsung: '6.2.0'
|
|
769
767
|
},
|
|
770
768
|
es2017: {
|
|
771
|
-
chrome: '
|
|
772
|
-
edge: '
|
|
773
|
-
firefox: '
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
safari: '13.0.0'
|
|
769
|
+
chrome: '57.0.0',
|
|
770
|
+
edge: '15.0.0',
|
|
771
|
+
firefox: '54.0.0',
|
|
772
|
+
safari: '11.0.0',
|
|
773
|
+
opera: '44.0.0',
|
|
774
|
+
samsung: '6.2.0'
|
|
778
775
|
},
|
|
779
776
|
es2018: {
|
|
780
777
|
chrome: '64.0.0',
|
|
781
778
|
edge: '79.0.0',
|
|
782
779
|
firefox: '78.0.0',
|
|
783
|
-
|
|
784
|
-
node: '13.2.0',
|
|
780
|
+
safari: '16.4.0',
|
|
785
781
|
opera: '51.0.0',
|
|
786
|
-
|
|
782
|
+
samsung: '8.2.0'
|
|
787
783
|
},
|
|
788
784
|
es2019: {
|
|
789
|
-
chrome: '
|
|
785
|
+
chrome: '73.0.0',
|
|
790
786
|
edge: '79.0.0',
|
|
791
787
|
firefox: '78.0.0',
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
safari: '16.4.0'
|
|
788
|
+
safari: '17.0.0',
|
|
789
|
+
opera: '60.0.0',
|
|
790
|
+
samsung: '11.1.0'
|
|
796
791
|
},
|
|
797
792
|
es2020: {
|
|
798
|
-
chrome: '
|
|
799
|
-
edge: '
|
|
793
|
+
chrome: '80.0.0',
|
|
794
|
+
edge: '80.0.0',
|
|
800
795
|
firefox: '80.0.0',
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
safari: '16.4.0'
|
|
796
|
+
safari: '17.0.0',
|
|
797
|
+
opera: '67.0.0',
|
|
798
|
+
samsung: '13.0.0'
|
|
805
799
|
},
|
|
806
800
|
es2021: {
|
|
807
|
-
chrome: '
|
|
808
|
-
edge: '
|
|
801
|
+
chrome: '85.0.0',
|
|
802
|
+
edge: '85.0.0',
|
|
809
803
|
firefox: '80.0.0',
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
safari: '16.4.0'
|
|
804
|
+
safari: '17.0.0',
|
|
805
|
+
opera: '71.0.0',
|
|
806
|
+
samsung: '14.0.0'
|
|
814
807
|
},
|
|
815
808
|
es2022: {
|
|
816
|
-
chrome: '
|
|
809
|
+
chrome: '94.0.0',
|
|
810
|
+
edge: '94.0.0',
|
|
817
811
|
firefox: '93.0.0',
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
812
|
+
safari: '17.0.0',
|
|
813
|
+
opera: '80.0.0',
|
|
814
|
+
samsung: '17.0.0'
|
|
821
815
|
},
|
|
822
816
|
es2023: {
|
|
823
|
-
chrome: '
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
817
|
+
chrome: '110.0.0',
|
|
818
|
+
edge: '110.0.0',
|
|
819
|
+
firefox: '115.0.0',
|
|
820
|
+
safari: '17.0.0',
|
|
821
|
+
opera: '96.0.0',
|
|
822
|
+
samsung: '21.0.0'
|
|
828
823
|
},
|
|
829
824
|
es2024: calcEsnextBrowserslistByTarget,
|
|
830
825
|
esnext: calcEsnextBrowserslistByTarget
|
|
@@ -1366,7 +1361,7 @@ function isJSConfig(configFileName) {
|
|
|
1366
1361
|
async function loadTsconfig(root, tsconfigPath = 'tsconfig.json') {
|
|
1367
1362
|
const tsconfigFileName = await find(join(root, tsconfigPath), {
|
|
1368
1363
|
root,
|
|
1369
|
-
configName:
|
|
1364
|
+
configName: external_node_path_basename(tsconfigPath)
|
|
1370
1365
|
});
|
|
1371
1366
|
if (tsconfigFileName) {
|
|
1372
1367
|
const { tsconfig } = await parse_parse(tsconfigFileName);
|
|
@@ -1386,10 +1381,15 @@ const resolveConfigPath = (root, customConfig)=>{
|
|
|
1386
1381
|
}
|
|
1387
1382
|
const configFilePath = findConfig(join(root, DEFAULT_CONFIG_NAME));
|
|
1388
1383
|
if (configFilePath) return configFilePath;
|
|
1389
|
-
throw new Error(`${DEFAULT_CONFIG_NAME} not found in ${root}`);
|
|
1390
1384
|
};
|
|
1391
1385
|
async function loadConfig({ cwd = process.cwd(), path, envMode, loader }) {
|
|
1392
1386
|
const configFilePath = resolveConfigPath(cwd, path);
|
|
1387
|
+
if (!configFilePath) return {
|
|
1388
|
+
content: {
|
|
1389
|
+
lib: []
|
|
1390
|
+
},
|
|
1391
|
+
filePath: void 0
|
|
1392
|
+
};
|
|
1393
1393
|
const { content } = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.loadConfig)({
|
|
1394
1394
|
cwd: dirname(configFilePath),
|
|
1395
1395
|
path: configFilePath,
|
|
@@ -1673,7 +1673,7 @@ async function createConstantRsbuildConfig() {
|
|
|
1673
1673
|
}
|
|
1674
1674
|
});
|
|
1675
1675
|
}
|
|
1676
|
-
const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
1676
|
+
const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledShims })=>{
|
|
1677
1677
|
const jsParserOptions = {
|
|
1678
1678
|
cjs: {
|
|
1679
1679
|
requireResolve: false,
|
|
@@ -1693,7 +1693,8 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1693
1693
|
};
|
|
1694
1694
|
const plugins = [
|
|
1695
1695
|
new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.experiments.RslibPlugin({
|
|
1696
|
-
interceptApiPlugin: true
|
|
1696
|
+
interceptApiPlugin: true,
|
|
1697
|
+
forceNodeShims: enabledShims.esm.__dirname || enabledShims.esm.__filename
|
|
1697
1698
|
})
|
|
1698
1699
|
];
|
|
1699
1700
|
switch(format){
|
|
@@ -2381,7 +2382,8 @@ async function composeLibRsbuildConfig(config, multiCompilerIndex, root, sharedP
|
|
|
2381
2382
|
format,
|
|
2382
2383
|
pkgJson: pkgJson,
|
|
2383
2384
|
bundle,
|
|
2384
|
-
umdName
|
|
2385
|
+
umdName,
|
|
2386
|
+
enabledShims
|
|
2385
2387
|
});
|
|
2386
2388
|
const externalHelpersConfig = composeExternalHelpersConfig(externalHelpers, pkgJson);
|
|
2387
2389
|
const userExternalsConfig = composeExternalsConfig(format, config.output?.externals);
|
|
@@ -2423,6 +2425,9 @@ async function composeCreateRsbuildConfig(rslibConfig) {
|
|
|
2423
2425
|
userConfig.source.entry = {};
|
|
2424
2426
|
userConfig.output ??= {};
|
|
2425
2427
|
delete userConfig.output.externals;
|
|
2428
|
+
if (userConfig.output.distPath && 'string' == typeof userConfig.output.distPath) userConfig.output.distPath = {
|
|
2429
|
+
root: userConfig.output.distPath
|
|
2430
|
+
};
|
|
2426
2431
|
const config = {
|
|
2427
2432
|
format: libConfig.format ?? 'esm',
|
|
2428
2433
|
config: (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(constantRsbuildConfig, libRsbuildConfig, omit(userConfig, {
|
|
@@ -3031,7 +3036,77 @@ const getEnvDir = (cwd, envDir)=>{
|
|
|
3031
3036
|
if (envDir) return node_path.isAbsolute(envDir) ? envDir : node_path.resolve(cwd, envDir);
|
|
3032
3037
|
return cwd;
|
|
3033
3038
|
};
|
|
3034
|
-
|
|
3039
|
+
const parseEntryOption = (entries)=>{
|
|
3040
|
+
if (!entries?.length) return;
|
|
3041
|
+
const entryList = [];
|
|
3042
|
+
for (const rawEntry of entries){
|
|
3043
|
+
const value = rawEntry?.trim();
|
|
3044
|
+
if (!value) continue;
|
|
3045
|
+
const equalIndex = value.indexOf('=');
|
|
3046
|
+
if (equalIndex > -1) {
|
|
3047
|
+
const name = value.slice(0, equalIndex).trim();
|
|
3048
|
+
const entryPath = value.slice(equalIndex + 1).trim();
|
|
3049
|
+
if (name && entryPath) {
|
|
3050
|
+
entryList.push({
|
|
3051
|
+
key: name,
|
|
3052
|
+
value: entryPath,
|
|
3053
|
+
explicit: true
|
|
3054
|
+
});
|
|
3055
|
+
continue;
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
3058
|
+
const basename = node_path.basename(value, node_path.extname(value));
|
|
3059
|
+
entryList.push({
|
|
3060
|
+
key: basename,
|
|
3061
|
+
value,
|
|
3062
|
+
explicit: false
|
|
3063
|
+
});
|
|
3064
|
+
}
|
|
3065
|
+
const keyCount = {};
|
|
3066
|
+
for (const { key, explicit } of entryList)if (!explicit) keyCount[key] = (keyCount[key] ?? 0) + 1;
|
|
3067
|
+
const keyIndex = {};
|
|
3068
|
+
const parsed = {};
|
|
3069
|
+
for (const { key, value, explicit } of entryList){
|
|
3070
|
+
const needsIndex = !explicit && (keyCount[key] ?? 0) > 1;
|
|
3071
|
+
const finalKey = needsIndex ? `${key}${keyIndex[key] ?? 0}` : key;
|
|
3072
|
+
if (needsIndex) keyIndex[key] = (keyIndex[key] ?? 0) + 1;
|
|
3073
|
+
parsed[finalKey] = value;
|
|
3074
|
+
}
|
|
3075
|
+
return Object.keys(parsed).length ? parsed : void 0;
|
|
3076
|
+
};
|
|
3077
|
+
const applyCliOptions = (config, options, root)=>{
|
|
3078
|
+
if (options.root) config.root = root;
|
|
3079
|
+
if (options.logLevel) config.logLevel = options.logLevel;
|
|
3080
|
+
for (const lib of config.lib){
|
|
3081
|
+
if (void 0 !== options.format) lib.format = options.format;
|
|
3082
|
+
if (void 0 !== options.bundle) lib.bundle = options.bundle;
|
|
3083
|
+
if (void 0 !== options.tsconfig) {
|
|
3084
|
+
lib.source ||= {};
|
|
3085
|
+
lib.source.tsconfigPath = options.tsconfig;
|
|
3086
|
+
}
|
|
3087
|
+
const entry = parseEntryOption(options.entry);
|
|
3088
|
+
if (void 0 !== entry) {
|
|
3089
|
+
lib.source ||= {};
|
|
3090
|
+
lib.source.entry = entry;
|
|
3091
|
+
}
|
|
3092
|
+
const syntax = options.syntax;
|
|
3093
|
+
if (void 0 !== syntax) lib.syntax = syntax;
|
|
3094
|
+
if (void 0 !== options.dts) lib.dts = options.dts;
|
|
3095
|
+
if (void 0 !== options.autoExtension) lib.autoExtension = options.autoExtension;
|
|
3096
|
+
if (void 0 !== options.autoExternal) lib.autoExternal = options.autoExternal;
|
|
3097
|
+
lib.output ??= {};
|
|
3098
|
+
if (void 0 !== options.target) lib.output.target = options.target;
|
|
3099
|
+
if (void 0 !== options.minify) lib.output.minify = options.minify;
|
|
3100
|
+
if (void 0 !== options.clean) lib.output.cleanDistPath = options.clean;
|
|
3101
|
+
const externals = options.externals?.filter(Boolean) ?? [];
|
|
3102
|
+
if (externals.length > 0) lib.output.externals = externals;
|
|
3103
|
+
if (options.distPath) lib.output.distPath = {
|
|
3104
|
+
...'object' == typeof lib.output.distPath ? lib.output.distPath : {},
|
|
3105
|
+
root: options.distPath
|
|
3106
|
+
};
|
|
3107
|
+
}
|
|
3108
|
+
};
|
|
3109
|
+
async function initConfig(options) {
|
|
3035
3110
|
const cwd = process.cwd();
|
|
3036
3111
|
const root = options.root ? getAbsolutePath(cwd, options.root) : cwd;
|
|
3037
3112
|
const envs = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.loadEnv)({
|
|
@@ -3045,20 +3120,30 @@ async function init(options) {
|
|
|
3045
3120
|
envMode: options.envMode,
|
|
3046
3121
|
loader: options.configLoader
|
|
3047
3122
|
});
|
|
3123
|
+
if (void 0 === configFilePath) {
|
|
3124
|
+
config.lib = [
|
|
3125
|
+
{}
|
|
3126
|
+
];
|
|
3127
|
+
logger.debug('No config file found. Falling back to CLI options for the default library.');
|
|
3128
|
+
}
|
|
3048
3129
|
config.source ||= {};
|
|
3049
3130
|
config.source.define = {
|
|
3050
3131
|
...envs.publicVars,
|
|
3051
3132
|
...config.source.define
|
|
3052
3133
|
};
|
|
3053
|
-
|
|
3054
|
-
|
|
3134
|
+
applyCliOptions(config, options, root);
|
|
3135
|
+
logger.debug('Rslib config used to generate Rsbuild environments:');
|
|
3136
|
+
logger.debug(`\n${node_util.inspect(config, {
|
|
3137
|
+
depth: null,
|
|
3138
|
+
colors: true
|
|
3139
|
+
})}`);
|
|
3055
3140
|
return {
|
|
3056
3141
|
config,
|
|
3057
3142
|
configFilePath,
|
|
3058
3143
|
watchFiles: [
|
|
3059
3144
|
configFilePath,
|
|
3060
3145
|
...envs.filePaths
|
|
3061
|
-
]
|
|
3146
|
+
].filter(Boolean)
|
|
3062
3147
|
};
|
|
3063
3148
|
}
|
|
3064
3149
|
async function inspect(config, options = {}) {
|
|
@@ -3128,15 +3213,25 @@ const applyCommonOptions = (cli)=>{
|
|
|
3128
3213
|
function runCli() {
|
|
3129
3214
|
const cli = dist('rslib');
|
|
3130
3215
|
cli.help();
|
|
3131
|
-
cli.version("0.
|
|
3216
|
+
cli.version("0.16.0");
|
|
3132
3217
|
applyCommonOptions(cli);
|
|
3133
3218
|
const buildCommand = cli.command('build', 'build the library for production');
|
|
3134
3219
|
const inspectCommand = cli.command('inspect', 'inspect the Rsbuild / Rspack configs of Rslib projects');
|
|
3135
3220
|
const mfDevCommand = cli.command('mf-dev', 'start Rsbuild dev server of Module Federation format');
|
|
3136
|
-
buildCommand.option('-w, --watch', 'turn on watch mode, watch for changes and rebuild').
|
|
3221
|
+
buildCommand.option('-w, --watch', 'turn on watch mode, watch for changes and rebuild').option('--entry <entry>', 'set entry file or pattern (repeatable)', {
|
|
3222
|
+
type: [
|
|
3223
|
+
String
|
|
3224
|
+
],
|
|
3225
|
+
default: []
|
|
3226
|
+
}).option('--dist-path <dir>', 'set output directory').option('--bundle', 'enable bundle mode (use --no-bundle to disable)').option('--format <format>', 'specify the output format (esm | cjs | umd | mf | iife)').option('--syntax <syntax>', 'set build syntax target (repeatable)').option('--target <target>', 'set runtime target (web | node)').option('--dts', 'emit declaration files (use --no-dts to disable)').option('--externals <pkg>', 'add package to externals (repeatable)', {
|
|
3227
|
+
type: [
|
|
3228
|
+
String
|
|
3229
|
+
],
|
|
3230
|
+
default: []
|
|
3231
|
+
}).option('--minify', 'minify output (use --no-minify to disable)').option('--clean', 'clean output directory before build (use --no-clean to disable)').option('--auto-extension', 'control automatic extension redirect (use --no-auto-extension to disable)').option('--auto-external', 'control automatic dependency externalization (use --no-auto-external to disable)').option('--tsconfig <path>', 'use specific tsconfig (relative to project root)').action(async (options)=>{
|
|
3137
3232
|
try {
|
|
3138
3233
|
const cliBuild = async ()=>{
|
|
3139
|
-
const { config, watchFiles } = await
|
|
3234
|
+
const { config, watchFiles } = await initConfig(options);
|
|
3140
3235
|
await build(config, options);
|
|
3141
3236
|
if (options.watch) watchFilesForRestart(watchFiles, async ()=>{
|
|
3142
3237
|
await cliBuild();
|
|
@@ -3154,7 +3249,7 @@ function runCli() {
|
|
|
3154
3249
|
default: '.rsbuild'
|
|
3155
3250
|
}).option('--verbose', 'show full function definitions in output').action(async (options)=>{
|
|
3156
3251
|
try {
|
|
3157
|
-
const { config } = await
|
|
3252
|
+
const { config } = await initConfig(options);
|
|
3158
3253
|
await inspect(config, {
|
|
3159
3254
|
lib: options.lib,
|
|
3160
3255
|
mode: options.mode,
|
|
@@ -3170,7 +3265,7 @@ function runCli() {
|
|
|
3170
3265
|
mfDevCommand.action(async (options)=>{
|
|
3171
3266
|
try {
|
|
3172
3267
|
const cliMfDev = async ()=>{
|
|
3173
|
-
const { config, watchFiles } = await
|
|
3268
|
+
const { config, watchFiles } = await initConfig(options);
|
|
3174
3269
|
await startMFDevServer(config, {
|
|
3175
3270
|
lib: options.lib
|
|
3176
3271
|
});
|
|
@@ -3211,8 +3306,8 @@ function prepareCli() {
|
|
|
3211
3306
|
setupLogLevel();
|
|
3212
3307
|
const { npm_execpath } = process.env;
|
|
3213
3308
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) logger.log();
|
|
3214
|
-
logger.greet(` Rslib v0.
|
|
3309
|
+
logger.greet(` Rslib v0.16.0\n`);
|
|
3215
3310
|
}
|
|
3216
|
-
const src_version = "0.
|
|
3311
|
+
const src_version = "0.16.0";
|
|
3217
3312
|
var __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack;
|
|
3218
3313
|
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,5 +1,6 @@
|
|
|
1
1
|
import type { LogLevel, RsbuildMode } from '@rsbuild/core';
|
|
2
2
|
import type { ConfigLoader } from '../config';
|
|
3
|
+
import type { Format, Syntax } from '../types/config';
|
|
3
4
|
export type CommonOptions = {
|
|
4
5
|
root?: string;
|
|
5
6
|
config?: string;
|
|
@@ -11,6 +12,19 @@ export type CommonOptions = {
|
|
|
11
12
|
};
|
|
12
13
|
export type BuildOptions = CommonOptions & {
|
|
13
14
|
watch?: boolean;
|
|
15
|
+
format?: Format;
|
|
16
|
+
entry?: string[];
|
|
17
|
+
distPath?: string;
|
|
18
|
+
bundle?: boolean;
|
|
19
|
+
syntax?: Syntax;
|
|
20
|
+
target?: string;
|
|
21
|
+
dts?: boolean;
|
|
22
|
+
externals?: string[];
|
|
23
|
+
minify?: boolean;
|
|
24
|
+
clean?: boolean;
|
|
25
|
+
autoExtension?: boolean;
|
|
26
|
+
autoExternal?: boolean;
|
|
27
|
+
tsconfig?: string;
|
|
14
28
|
};
|
|
15
29
|
export type InspectOptions = CommonOptions & {
|
|
16
30
|
mode?: RsbuildMode;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RslibConfig } from '../types';
|
|
2
|
+
import type { BuildOptions, CommonOptions } from './commands';
|
|
3
|
+
export declare const parseEntryOption: (entries?: string[]) => Record<string, string> | undefined;
|
|
4
|
+
export declare const applyCliOptions: (config: RslibConfig, options: BuildOptions, root: string) => void;
|
|
5
|
+
export declare function initConfig(options: CommonOptions): Promise<{
|
|
6
|
+
config: RslibConfig;
|
|
7
|
+
configFilePath?: string;
|
|
8
|
+
watchFiles: string[];
|
|
9
|
+
}>;
|
package/dist-types/config.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare function loadConfig({ cwd, path, envMode, loader, }: {
|
|
|
16
16
|
loader?: ConfigLoader;
|
|
17
17
|
}): Promise<{
|
|
18
18
|
content: RslibConfig;
|
|
19
|
-
filePath
|
|
19
|
+
filePath?: string;
|
|
20
20
|
}>;
|
|
21
21
|
export declare const composeAutoExternalConfig: (options: {
|
|
22
22
|
bundle: boolean;
|
|
@@ -2,11 +2,8 @@ import type { EnvironmentConfig, Rspack } from '@rsbuild/core';
|
|
|
2
2
|
import type { FixedEcmaVersions, LatestEcmaVersions, RsbuildConfigOutputTarget, Syntax } from '../types/config';
|
|
3
3
|
export declare const LATEST_TARGET_VERSIONS: Record<NonNullable<RsbuildConfigOutputTarget>, string[]>;
|
|
4
4
|
/**
|
|
5
|
-
* The esX to browserslist mapping is transformed from
|
|
6
|
-
* https://github.com/evanw/esbuild/blob/main/internal/compat/js_table.go
|
|
7
|
-
* It does not completely align with the browserslist query of Rsbuild now:
|
|
5
|
+
* The esX to browserslist mapping is transformed from
|
|
8
6
|
* https://github.com/rspack-contrib/browserslist-to-es-version
|
|
9
|
-
* TODO: align with Rsbuild, we may should align with SWC
|
|
10
7
|
*/
|
|
11
8
|
export declare const ESX_TO_BROWSERSLIST: Record<FixedEcmaVersions, Record<string, string>> & Record<LatestEcmaVersions, (target: RsbuildConfigOutputTarget) => string[]>;
|
|
12
9
|
export declare function transformSyntaxToRspackTarget(syntax: Syntax): Rspack.Configuration['target'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.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": "
|
|
40
|
-
"rsbuild-plugin-dts": "0.
|
|
39
|
+
"@rsbuild/core": "1.6.0-beta.0",
|
|
40
|
+
"rsbuild-plugin-dts": "0.16.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@module-federation/rsbuild-plugin": "^0.20.0",
|
|
@@ -50,8 +50,8 @@
|
|
|
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.15.
|
|
54
|
-
"rslog": "^1.
|
|
53
|
+
"rslib": "npm:@rslib/core@0.15.1",
|
|
54
|
+
"rslog": "^1.3.0",
|
|
55
55
|
"tinyglobby": "0.2.14",
|
|
56
56
|
"tsconfck": "3.1.6",
|
|
57
57
|
"typescript": "^5.9.3",
|
package/dist-types/cli/init.d.ts
DELETED