@rslib/core 0.15.1 → 0.16.1
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 +174 -94
- 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 +6 -6
- 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];
|
|
@@ -731,100 +732,82 @@ const RSPACK_TARGET_UNLISTED_MODERN_ECMA_VERSIONS = [
|
|
|
731
732
|
];
|
|
732
733
|
const ESX_TO_BROWSERSLIST = {
|
|
733
734
|
es5: {
|
|
734
|
-
chrome: '
|
|
735
|
-
edge: '12
|
|
736
|
-
firefox: '2
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
opera: '10.10.0',
|
|
741
|
-
safari: '3.1.0'
|
|
735
|
+
chrome: '13',
|
|
736
|
+
edge: '12',
|
|
737
|
+
firefox: '2',
|
|
738
|
+
ios: '6',
|
|
739
|
+
node: '0.6',
|
|
740
|
+
safari: '5.1'
|
|
742
741
|
},
|
|
743
|
-
es6
|
|
744
|
-
|
|
745
|
-
edge: '79.0.0',
|
|
746
|
-
firefox: '67.0.0',
|
|
747
|
-
ios: '13.0.0',
|
|
748
|
-
node: '13.2.0',
|
|
749
|
-
opera: '50.0.0',
|
|
750
|
-
safari: '13.0.0'
|
|
742
|
+
get es6 () {
|
|
743
|
+
return ESX_TO_BROWSERSLIST.es2015;
|
|
751
744
|
},
|
|
752
745
|
es2015: {
|
|
753
|
-
chrome: '
|
|
754
|
-
edge: '79
|
|
755
|
-
firefox: '
|
|
756
|
-
ios: '
|
|
757
|
-
node: '
|
|
758
|
-
|
|
759
|
-
safari: '13.0.0'
|
|
746
|
+
chrome: '51',
|
|
747
|
+
edge: '79',
|
|
748
|
+
firefox: '53',
|
|
749
|
+
ios: '16.3',
|
|
750
|
+
node: '6.5',
|
|
751
|
+
safari: '16.3'
|
|
760
752
|
},
|
|
761
753
|
es2016: {
|
|
762
|
-
chrome: '
|
|
763
|
-
edge: '79
|
|
764
|
-
firefox: '
|
|
765
|
-
ios: '
|
|
766
|
-
node: '
|
|
767
|
-
|
|
768
|
-
safari: '13.0.0'
|
|
754
|
+
chrome: '52',
|
|
755
|
+
edge: '79',
|
|
756
|
+
firefox: '53',
|
|
757
|
+
ios: '16.3',
|
|
758
|
+
node: '7',
|
|
759
|
+
safari: '16.3'
|
|
769
760
|
},
|
|
770
761
|
es2017: {
|
|
771
|
-
chrome: '
|
|
772
|
-
edge: '79
|
|
773
|
-
firefox: '
|
|
774
|
-
ios: '
|
|
775
|
-
node: '
|
|
776
|
-
|
|
777
|
-
safari: '13.0.0'
|
|
762
|
+
chrome: '55',
|
|
763
|
+
edge: '79',
|
|
764
|
+
firefox: '53',
|
|
765
|
+
ios: '16.3',
|
|
766
|
+
node: '7.6',
|
|
767
|
+
safari: '16.3'
|
|
778
768
|
},
|
|
779
769
|
es2018: {
|
|
780
|
-
chrome: '64
|
|
781
|
-
edge: '79
|
|
782
|
-
firefox: '78
|
|
783
|
-
ios: '16.
|
|
784
|
-
node: '
|
|
785
|
-
|
|
786
|
-
safari: '16.4.0'
|
|
770
|
+
chrome: '64',
|
|
771
|
+
edge: '79',
|
|
772
|
+
firefox: '78',
|
|
773
|
+
ios: '16.3',
|
|
774
|
+
node: '10',
|
|
775
|
+
safari: '16.3'
|
|
787
776
|
},
|
|
788
777
|
es2019: {
|
|
789
|
-
chrome: '66
|
|
790
|
-
edge: '79
|
|
791
|
-
firefox: '78
|
|
792
|
-
ios: '16.
|
|
793
|
-
node: '
|
|
794
|
-
|
|
795
|
-
safari: '16.4.0'
|
|
778
|
+
chrome: '66',
|
|
779
|
+
edge: '79',
|
|
780
|
+
firefox: '78',
|
|
781
|
+
ios: '16.3',
|
|
782
|
+
node: '10',
|
|
783
|
+
safari: '16.3'
|
|
796
784
|
},
|
|
797
785
|
es2020: {
|
|
798
|
-
chrome: '91
|
|
799
|
-
edge: '91
|
|
800
|
-
firefox: '80
|
|
801
|
-
ios: '16.
|
|
802
|
-
node: '16.
|
|
803
|
-
|
|
804
|
-
safari: '16.4.0'
|
|
786
|
+
chrome: '91',
|
|
787
|
+
edge: '91',
|
|
788
|
+
firefox: '80',
|
|
789
|
+
ios: '16.3',
|
|
790
|
+
node: '16.9',
|
|
791
|
+
safari: '16.3'
|
|
805
792
|
},
|
|
806
793
|
es2021: {
|
|
807
|
-
chrome: '91
|
|
808
|
-
edge: '91
|
|
809
|
-
firefox: '80
|
|
810
|
-
ios: '16.
|
|
811
|
-
node: '16.
|
|
812
|
-
|
|
813
|
-
safari: '16.4.0'
|
|
794
|
+
chrome: '91',
|
|
795
|
+
edge: '91',
|
|
796
|
+
firefox: '80',
|
|
797
|
+
ios: '16.3',
|
|
798
|
+
node: '16.9',
|
|
799
|
+
safari: '16.3'
|
|
814
800
|
},
|
|
815
801
|
es2022: {
|
|
816
|
-
chrome: '
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
802
|
+
chrome: '94',
|
|
803
|
+
edge: '94',
|
|
804
|
+
firefox: '93',
|
|
805
|
+
ios: '16.4',
|
|
806
|
+
node: '16.11',
|
|
807
|
+
safari: '16.4'
|
|
821
808
|
},
|
|
822
|
-
es2023
|
|
823
|
-
|
|
824
|
-
firefox: '93.0.0',
|
|
825
|
-
ios: '16.4.0',
|
|
826
|
-
node: '16.11.0',
|
|
827
|
-
safari: '16.4.0'
|
|
809
|
+
get es2023 () {
|
|
810
|
+
return ESX_TO_BROWSERSLIST.es2022;
|
|
828
811
|
},
|
|
829
812
|
es2024: calcEsnextBrowserslistByTarget,
|
|
830
813
|
esnext: calcEsnextBrowserslistByTarget
|
|
@@ -1366,7 +1349,7 @@ function isJSConfig(configFileName) {
|
|
|
1366
1349
|
async function loadTsconfig(root, tsconfigPath = 'tsconfig.json') {
|
|
1367
1350
|
const tsconfigFileName = await find(join(root, tsconfigPath), {
|
|
1368
1351
|
root,
|
|
1369
|
-
configName:
|
|
1352
|
+
configName: external_node_path_basename(tsconfigPath)
|
|
1370
1353
|
});
|
|
1371
1354
|
if (tsconfigFileName) {
|
|
1372
1355
|
const { tsconfig } = await parse_parse(tsconfigFileName);
|
|
@@ -1386,10 +1369,15 @@ const resolveConfigPath = (root, customConfig)=>{
|
|
|
1386
1369
|
}
|
|
1387
1370
|
const configFilePath = findConfig(join(root, DEFAULT_CONFIG_NAME));
|
|
1388
1371
|
if (configFilePath) return configFilePath;
|
|
1389
|
-
throw new Error(`${DEFAULT_CONFIG_NAME} not found in ${root}`);
|
|
1390
1372
|
};
|
|
1391
1373
|
async function loadConfig({ cwd = process.cwd(), path, envMode, loader }) {
|
|
1392
1374
|
const configFilePath = resolveConfigPath(cwd, path);
|
|
1375
|
+
if (!configFilePath) return {
|
|
1376
|
+
content: {
|
|
1377
|
+
lib: []
|
|
1378
|
+
},
|
|
1379
|
+
filePath: void 0
|
|
1380
|
+
};
|
|
1393
1381
|
const { content } = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.loadConfig)({
|
|
1394
1382
|
cwd: dirname(configFilePath),
|
|
1395
1383
|
path: configFilePath,
|
|
@@ -1673,7 +1661,7 @@ async function createConstantRsbuildConfig() {
|
|
|
1673
1661
|
}
|
|
1674
1662
|
});
|
|
1675
1663
|
}
|
|
1676
|
-
const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
1664
|
+
const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledShims })=>{
|
|
1677
1665
|
const jsParserOptions = {
|
|
1678
1666
|
cjs: {
|
|
1679
1667
|
requireResolve: false,
|
|
@@ -1693,7 +1681,8 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
|
1693
1681
|
};
|
|
1694
1682
|
const plugins = [
|
|
1695
1683
|
new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.experiments.RslibPlugin({
|
|
1696
|
-
interceptApiPlugin: true
|
|
1684
|
+
interceptApiPlugin: true,
|
|
1685
|
+
forceNodeShims: enabledShims.esm.__dirname || enabledShims.esm.__filename
|
|
1697
1686
|
})
|
|
1698
1687
|
];
|
|
1699
1688
|
switch(format){
|
|
@@ -2381,7 +2370,8 @@ async function composeLibRsbuildConfig(config, multiCompilerIndex, root, sharedP
|
|
|
2381
2370
|
format,
|
|
2382
2371
|
pkgJson: pkgJson,
|
|
2383
2372
|
bundle,
|
|
2384
|
-
umdName
|
|
2373
|
+
umdName,
|
|
2374
|
+
enabledShims
|
|
2385
2375
|
});
|
|
2386
2376
|
const externalHelpersConfig = composeExternalHelpersConfig(externalHelpers, pkgJson);
|
|
2387
2377
|
const userExternalsConfig = composeExternalsConfig(format, config.output?.externals);
|
|
@@ -3031,7 +3021,77 @@ const getEnvDir = (cwd, envDir)=>{
|
|
|
3031
3021
|
if (envDir) return node_path.isAbsolute(envDir) ? envDir : node_path.resolve(cwd, envDir);
|
|
3032
3022
|
return cwd;
|
|
3033
3023
|
};
|
|
3034
|
-
|
|
3024
|
+
const parseEntryOption = (entries)=>{
|
|
3025
|
+
if (!entries?.length) return;
|
|
3026
|
+
const entryList = [];
|
|
3027
|
+
for (const rawEntry of entries){
|
|
3028
|
+
const value = rawEntry?.trim();
|
|
3029
|
+
if (!value) continue;
|
|
3030
|
+
const equalIndex = value.indexOf('=');
|
|
3031
|
+
if (equalIndex > -1) {
|
|
3032
|
+
const name = value.slice(0, equalIndex).trim();
|
|
3033
|
+
const entryPath = value.slice(equalIndex + 1).trim();
|
|
3034
|
+
if (name && entryPath) {
|
|
3035
|
+
entryList.push({
|
|
3036
|
+
key: name,
|
|
3037
|
+
value: entryPath,
|
|
3038
|
+
explicit: true
|
|
3039
|
+
});
|
|
3040
|
+
continue;
|
|
3041
|
+
}
|
|
3042
|
+
}
|
|
3043
|
+
const basename = node_path.basename(value, node_path.extname(value));
|
|
3044
|
+
entryList.push({
|
|
3045
|
+
key: basename,
|
|
3046
|
+
value,
|
|
3047
|
+
explicit: false
|
|
3048
|
+
});
|
|
3049
|
+
}
|
|
3050
|
+
const keyCount = {};
|
|
3051
|
+
for (const { key, explicit } of entryList)if (!explicit) keyCount[key] = (keyCount[key] ?? 0) + 1;
|
|
3052
|
+
const keyIndex = {};
|
|
3053
|
+
const parsed = {};
|
|
3054
|
+
for (const { key, value, explicit } of entryList){
|
|
3055
|
+
const needsIndex = !explicit && (keyCount[key] ?? 0) > 1;
|
|
3056
|
+
const finalKey = needsIndex ? `${key}${keyIndex[key] ?? 0}` : key;
|
|
3057
|
+
if (needsIndex) keyIndex[key] = (keyIndex[key] ?? 0) + 1;
|
|
3058
|
+
parsed[finalKey] = value;
|
|
3059
|
+
}
|
|
3060
|
+
return Object.keys(parsed).length ? parsed : void 0;
|
|
3061
|
+
};
|
|
3062
|
+
const applyCliOptions = (config, options, root)=>{
|
|
3063
|
+
if (options.root) config.root = root;
|
|
3064
|
+
if (options.logLevel) config.logLevel = options.logLevel;
|
|
3065
|
+
for (const lib of config.lib){
|
|
3066
|
+
if (void 0 !== options.format) lib.format = options.format;
|
|
3067
|
+
if (void 0 !== options.bundle) lib.bundle = options.bundle;
|
|
3068
|
+
if (void 0 !== options.tsconfig) {
|
|
3069
|
+
lib.source ||= {};
|
|
3070
|
+
lib.source.tsconfigPath = options.tsconfig;
|
|
3071
|
+
}
|
|
3072
|
+
const entry = parseEntryOption(options.entry);
|
|
3073
|
+
if (void 0 !== entry) {
|
|
3074
|
+
lib.source ||= {};
|
|
3075
|
+
lib.source.entry = entry;
|
|
3076
|
+
}
|
|
3077
|
+
const syntax = options.syntax;
|
|
3078
|
+
if (void 0 !== syntax) lib.syntax = syntax;
|
|
3079
|
+
if (void 0 !== options.dts) lib.dts = options.dts;
|
|
3080
|
+
if (void 0 !== options.autoExtension) lib.autoExtension = options.autoExtension;
|
|
3081
|
+
if (void 0 !== options.autoExternal) lib.autoExternal = options.autoExternal;
|
|
3082
|
+
lib.output ??= {};
|
|
3083
|
+
if (void 0 !== options.target) lib.output.target = options.target;
|
|
3084
|
+
if (void 0 !== options.minify) lib.output.minify = options.minify;
|
|
3085
|
+
if (void 0 !== options.clean) lib.output.cleanDistPath = options.clean;
|
|
3086
|
+
const externals = options.externals?.filter(Boolean) ?? [];
|
|
3087
|
+
if (externals.length > 0) lib.output.externals = externals;
|
|
3088
|
+
if (options.distPath) lib.output.distPath = {
|
|
3089
|
+
...'object' == typeof lib.output.distPath ? lib.output.distPath : {},
|
|
3090
|
+
root: options.distPath
|
|
3091
|
+
};
|
|
3092
|
+
}
|
|
3093
|
+
};
|
|
3094
|
+
async function initConfig(options) {
|
|
3035
3095
|
const cwd = process.cwd();
|
|
3036
3096
|
const root = options.root ? getAbsolutePath(cwd, options.root) : cwd;
|
|
3037
3097
|
const envs = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.loadEnv)({
|
|
@@ -3045,20 +3105,30 @@ async function init(options) {
|
|
|
3045
3105
|
envMode: options.envMode,
|
|
3046
3106
|
loader: options.configLoader
|
|
3047
3107
|
});
|
|
3108
|
+
if (void 0 === configFilePath) {
|
|
3109
|
+
config.lib = [
|
|
3110
|
+
{}
|
|
3111
|
+
];
|
|
3112
|
+
logger.debug('No config file found. Falling back to CLI options for the default library.');
|
|
3113
|
+
}
|
|
3048
3114
|
config.source ||= {};
|
|
3049
3115
|
config.source.define = {
|
|
3050
3116
|
...envs.publicVars,
|
|
3051
3117
|
...config.source.define
|
|
3052
3118
|
};
|
|
3053
|
-
|
|
3054
|
-
|
|
3119
|
+
applyCliOptions(config, options, root);
|
|
3120
|
+
logger.debug('Rslib config used to generate Rsbuild environments:');
|
|
3121
|
+
logger.debug(`\n${node_util.inspect(config, {
|
|
3122
|
+
depth: null,
|
|
3123
|
+
colors: true
|
|
3124
|
+
})}`);
|
|
3055
3125
|
return {
|
|
3056
3126
|
config,
|
|
3057
3127
|
configFilePath,
|
|
3058
3128
|
watchFiles: [
|
|
3059
3129
|
configFilePath,
|
|
3060
3130
|
...envs.filePaths
|
|
3061
|
-
]
|
|
3131
|
+
].filter(Boolean)
|
|
3062
3132
|
};
|
|
3063
3133
|
}
|
|
3064
3134
|
async function inspect(config, options = {}) {
|
|
@@ -3128,15 +3198,25 @@ const applyCommonOptions = (cli)=>{
|
|
|
3128
3198
|
function runCli() {
|
|
3129
3199
|
const cli = dist('rslib');
|
|
3130
3200
|
cli.help();
|
|
3131
|
-
cli.version("0.
|
|
3201
|
+
cli.version("0.16.1");
|
|
3132
3202
|
applyCommonOptions(cli);
|
|
3133
3203
|
const buildCommand = cli.command('build', 'build the library for production');
|
|
3134
3204
|
const inspectCommand = cli.command('inspect', 'inspect the Rsbuild / Rspack configs of Rslib projects');
|
|
3135
3205
|
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').
|
|
3206
|
+
buildCommand.option('-w, --watch', 'turn on watch mode, watch for changes and rebuild').option('--entry <entry>', 'set entry file or pattern (repeatable)', {
|
|
3207
|
+
type: [
|
|
3208
|
+
String
|
|
3209
|
+
],
|
|
3210
|
+
default: []
|
|
3211
|
+
}).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)', {
|
|
3212
|
+
type: [
|
|
3213
|
+
String
|
|
3214
|
+
],
|
|
3215
|
+
default: []
|
|
3216
|
+
}).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
3217
|
try {
|
|
3138
3218
|
const cliBuild = async ()=>{
|
|
3139
|
-
const { config, watchFiles } = await
|
|
3219
|
+
const { config, watchFiles } = await initConfig(options);
|
|
3140
3220
|
await build(config, options);
|
|
3141
3221
|
if (options.watch) watchFilesForRestart(watchFiles, async ()=>{
|
|
3142
3222
|
await cliBuild();
|
|
@@ -3154,7 +3234,7 @@ function runCli() {
|
|
|
3154
3234
|
default: '.rsbuild'
|
|
3155
3235
|
}).option('--verbose', 'show full function definitions in output').action(async (options)=>{
|
|
3156
3236
|
try {
|
|
3157
|
-
const { config } = await
|
|
3237
|
+
const { config } = await initConfig(options);
|
|
3158
3238
|
await inspect(config, {
|
|
3159
3239
|
lib: options.lib,
|
|
3160
3240
|
mode: options.mode,
|
|
@@ -3170,7 +3250,7 @@ function runCli() {
|
|
|
3170
3250
|
mfDevCommand.action(async (options)=>{
|
|
3171
3251
|
try {
|
|
3172
3252
|
const cliMfDev = async ()=>{
|
|
3173
|
-
const { config, watchFiles } = await
|
|
3253
|
+
const { config, watchFiles } = await initConfig(options);
|
|
3174
3254
|
await startMFDevServer(config, {
|
|
3175
3255
|
lib: options.lib
|
|
3176
3256
|
});
|
|
@@ -3211,8 +3291,8 @@ function prepareCli() {
|
|
|
3211
3291
|
setupLogLevel();
|
|
3212
3292
|
const { npm_execpath } = process.env;
|
|
3213
3293
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) logger.log();
|
|
3214
|
-
logger.greet(` Rslib v0.
|
|
3294
|
+
logger.greet(` Rslib v0.16.1\n`);
|
|
3215
3295
|
}
|
|
3216
|
-
const src_version = "0.
|
|
3296
|
+
const src_version = "0.16.1";
|
|
3217
3297
|
var __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack;
|
|
3218
3298
|
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.1",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://rslib.rs",
|
|
6
6
|
"bugs": {
|
|
@@ -36,11 +36,11 @@
|
|
|
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.1",
|
|
40
|
+
"rsbuild-plugin-dts": "0.16.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@module-federation/rsbuild-plugin": "^0.
|
|
43
|
+
"@module-federation/rsbuild-plugin": "^0.21.1",
|
|
44
44
|
"@types/fs-extra": "^11.0.4",
|
|
45
45
|
"cac": "^6.7.14",
|
|
46
46
|
"chokidar": "^4.0.3",
|
|
@@ -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.
|
|
54
|
-
"rslog": "^1.
|
|
53
|
+
"rslib": "npm:@rslib/core@0.16.0",
|
|
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