@rslib/core 0.0.2 → 0.0.4
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/bin/rslib.js
CHANGED
|
@@ -460,7 +460,7 @@ async function calcLongestCommonPath(absPaths) {
|
|
|
460
460
|
return lca;
|
|
461
461
|
}
|
|
462
462
|
const readPackageJson = (rootPath)=>{
|
|
463
|
-
const pkgJsonPath = external_node_path_namespaceObject["default"].
|
|
463
|
+
const pkgJsonPath = external_node_path_namespaceObject["default"].join(rootPath, './package.json');
|
|
464
464
|
if (!external_node_fs_namespaceObject["default"].existsSync(pkgJsonPath)) {
|
|
465
465
|
dist_logger.warn(`package.json does not exist in the ${rootPath} directory`);
|
|
466
466
|
return;
|
|
@@ -473,6 +473,25 @@ const readPackageJson = (rootPath)=>{
|
|
|
473
473
|
}
|
|
474
474
|
};
|
|
475
475
|
const isObject = (obj)=>Object.prototype.toString.call(obj) === '[object Object]';
|
|
476
|
+
function omitDeep(obj, keys) {
|
|
477
|
+
if (typeof obj === 'string' || typeof obj !== 'object' || obj === null) return obj;
|
|
478
|
+
if (Array.isArray(obj)) {
|
|
479
|
+
return obj.map((item)=>omitDeep(item, keys));
|
|
480
|
+
}
|
|
481
|
+
const clone = {};
|
|
482
|
+
for(const property in obj){
|
|
483
|
+
if (keys.includes(property)) {
|
|
484
|
+
continue;
|
|
485
|
+
}
|
|
486
|
+
const value = obj[property];
|
|
487
|
+
if (value && typeof value === 'object') {
|
|
488
|
+
clone[property] = omitDeep(value, keys);
|
|
489
|
+
} else {
|
|
490
|
+
clone[property] = value;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return clone;
|
|
494
|
+
}
|
|
476
495
|
|
|
477
496
|
|
|
478
497
|
;// CONCATENATED MODULE: ./src/utils/logger.ts
|
|
@@ -525,7 +544,7 @@ function prepareCli() {
|
|
|
525
544
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) {
|
|
526
545
|
console.log();
|
|
527
546
|
}
|
|
528
|
-
dist_logger.greet(` ${`Rslib v${"0.0.
|
|
547
|
+
dist_logger.greet(` ${`Rslib v${"0.0.4"}`}\n`);
|
|
529
548
|
}
|
|
530
549
|
|
|
531
550
|
;// CONCATENATED MODULE: external "../compiled/commander/index.js"
|
|
@@ -755,11 +774,10 @@ const resolveConfigPath = (root, customConfig)=>{
|
|
|
755
774
|
if (configFilePath) {
|
|
756
775
|
return configFilePath;
|
|
757
776
|
}
|
|
758
|
-
|
|
777
|
+
throw new Error(`${DEFAULT_CONFIG_NAME} not found in ${root}`);
|
|
759
778
|
};
|
|
760
|
-
async function loadConfig(
|
|
761
|
-
const
|
|
762
|
-
const configFilePath = resolveConfigPath(root, customConfig);
|
|
779
|
+
async function loadConfig({ cwd = process.cwd(), path, envMode }) {
|
|
780
|
+
const configFilePath = resolveConfigPath(cwd, path);
|
|
763
781
|
const { content } = await (0,core_namespaceObject.loadConfig)({
|
|
764
782
|
cwd: (0,external_node_path_namespaceObject.dirname)(configFilePath),
|
|
765
783
|
path: configFilePath,
|
|
@@ -767,6 +785,87 @@ async function loadConfig(customConfig, envMode) {
|
|
|
767
785
|
});
|
|
768
786
|
return content;
|
|
769
787
|
}
|
|
788
|
+
const composeExternalsWarnConfig = (format, ...externalsArray)=>{
|
|
789
|
+
if (format !== 'esm') {
|
|
790
|
+
return {};
|
|
791
|
+
}
|
|
792
|
+
const externals = [];
|
|
793
|
+
for (const e of externalsArray.filter(Boolean)){
|
|
794
|
+
if (Array.isArray(e)) {
|
|
795
|
+
externals.push(...e);
|
|
796
|
+
} else {
|
|
797
|
+
// @ts-ignore
|
|
798
|
+
externals.push(e);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
// Match logic is derived from https://github.com/webpack/webpack/blob/94aba382eccf3de1004d235045d4462918dfdbb7/lib/ExternalModuleFactoryPlugin.js#L166-L293.
|
|
802
|
+
const matchUserExternals = (externals, request, callback)=>{
|
|
803
|
+
if (typeof externals === 'string') {
|
|
804
|
+
if (externals === request) {
|
|
805
|
+
callback(true);
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
} else if (Array.isArray(externals)) {
|
|
809
|
+
let i = 0;
|
|
810
|
+
const next = ()=>{
|
|
811
|
+
let asyncFlag;
|
|
812
|
+
const handleExternalsAndCallback = (matched)=>{
|
|
813
|
+
if (!matched) {
|
|
814
|
+
if (asyncFlag) {
|
|
815
|
+
asyncFlag = false;
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
return next();
|
|
819
|
+
}
|
|
820
|
+
callback(matched);
|
|
821
|
+
};
|
|
822
|
+
do {
|
|
823
|
+
asyncFlag = true;
|
|
824
|
+
if (i >= externals.length) {
|
|
825
|
+
return callback();
|
|
826
|
+
}
|
|
827
|
+
matchUserExternals(externals[i++], request, handleExternalsAndCallback);
|
|
828
|
+
}while (!asyncFlag);
|
|
829
|
+
asyncFlag = false;
|
|
830
|
+
};
|
|
831
|
+
next();
|
|
832
|
+
return;
|
|
833
|
+
} else if (externals instanceof RegExp) {
|
|
834
|
+
if (externals.test(request)) {
|
|
835
|
+
callback(true);
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
} else if (typeof externals === 'function') {} else // TODO: Support function
|
|
839
|
+
if (typeof externals === 'object') {
|
|
840
|
+
if (Object.prototype.hasOwnProperty.call(externals, request)) {
|
|
841
|
+
callback(true);
|
|
842
|
+
return;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
callback();
|
|
846
|
+
};
|
|
847
|
+
return {
|
|
848
|
+
output: {
|
|
849
|
+
externals: [
|
|
850
|
+
({ request, dependencyType, contextInfo }, callback)=>{
|
|
851
|
+
let externalized = false;
|
|
852
|
+
const _callback = (matched)=>{
|
|
853
|
+
if (matched) {
|
|
854
|
+
externalized = true;
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
if (contextInfo.issuer && dependencyType === 'commonjs') {
|
|
858
|
+
matchUserExternals(externals, request, _callback);
|
|
859
|
+
if (externalized) {
|
|
860
|
+
dist_logger.warn(composeModuleImportWarn(request));
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
callback();
|
|
864
|
+
}
|
|
865
|
+
]
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
};
|
|
770
869
|
const composeAutoExternalConfig = (options)=>{
|
|
771
870
|
const { autoExternal, pkgJson, userExternals } = options;
|
|
772
871
|
if (!autoExternal) {
|
|
@@ -807,7 +906,7 @@ const composeAutoExternalConfig = (options)=>{
|
|
|
807
906
|
}
|
|
808
907
|
} : {};
|
|
809
908
|
};
|
|
810
|
-
async function
|
|
909
|
+
async function createConstantRsbuildConfig() {
|
|
811
910
|
return (0,core_namespaceObject.defineConfig)({
|
|
812
911
|
mode: 'production',
|
|
813
912
|
dev: {
|
|
@@ -825,13 +924,54 @@ async function createInternalRsbuildConfig() {
|
|
|
825
924
|
force: false
|
|
826
925
|
}
|
|
827
926
|
}
|
|
927
|
+
},
|
|
928
|
+
// TypeScript-specific behavior: if the extension is ".js" or ".jsx", try replacing it with ".ts" or ".tsx"
|
|
929
|
+
// see https://github.com/web-infra-dev/rslib/issues/41
|
|
930
|
+
resolve: {
|
|
931
|
+
extensionAlias: {
|
|
932
|
+
'.js': [
|
|
933
|
+
'.ts',
|
|
934
|
+
'.tsx',
|
|
935
|
+
'.js',
|
|
936
|
+
'.jsx'
|
|
937
|
+
],
|
|
938
|
+
'.jsx': [
|
|
939
|
+
'.tsx',
|
|
940
|
+
'.jsx'
|
|
941
|
+
],
|
|
942
|
+
'.mjs': [
|
|
943
|
+
'.mts',
|
|
944
|
+
'.mjs'
|
|
945
|
+
],
|
|
946
|
+
'.cjs': [
|
|
947
|
+
'.cts',
|
|
948
|
+
'.cjs'
|
|
949
|
+
]
|
|
950
|
+
}
|
|
828
951
|
}
|
|
829
952
|
}
|
|
830
953
|
},
|
|
831
954
|
output: {
|
|
832
955
|
filenameHash: false,
|
|
833
|
-
|
|
834
|
-
|
|
956
|
+
minify: {
|
|
957
|
+
js: true,
|
|
958
|
+
css: false,
|
|
959
|
+
jsOptions: {
|
|
960
|
+
minimizerOptions: {
|
|
961
|
+
mangle: false,
|
|
962
|
+
minify: false,
|
|
963
|
+
compress: {
|
|
964
|
+
defaults: false,
|
|
965
|
+
unused: true,
|
|
966
|
+
dead_code: true,
|
|
967
|
+
toplevel: true
|
|
968
|
+
},
|
|
969
|
+
format: {
|
|
970
|
+
comments: 'all'
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
},
|
|
835
975
|
distPath: {
|
|
836
976
|
js: './'
|
|
837
977
|
}
|
|
@@ -844,7 +984,6 @@ const composeFormatConfig = (format)=>{
|
|
|
844
984
|
return {
|
|
845
985
|
tools: {
|
|
846
986
|
rspack: {
|
|
847
|
-
externalsType: 'module-import',
|
|
848
987
|
output: {
|
|
849
988
|
module: true,
|
|
850
989
|
chunkFormat: 'module',
|
|
@@ -872,7 +1011,6 @@ const composeFormatConfig = (format)=>{
|
|
|
872
1011
|
return {
|
|
873
1012
|
tools: {
|
|
874
1013
|
rspack: {
|
|
875
|
-
externalsType: 'commonjs',
|
|
876
1014
|
output: {
|
|
877
1015
|
iife: false,
|
|
878
1016
|
chunkFormat: 'commonjs',
|
|
@@ -887,7 +1025,6 @@ const composeFormatConfig = (format)=>{
|
|
|
887
1025
|
return {
|
|
888
1026
|
tools: {
|
|
889
1027
|
rspack: {
|
|
890
|
-
externalsType: 'umd',
|
|
891
1028
|
output: {
|
|
892
1029
|
library: {
|
|
893
1030
|
type: 'umd'
|
|
@@ -900,9 +1037,39 @@ const composeFormatConfig = (format)=>{
|
|
|
900
1037
|
throw new Error(`Unsupported format: ${format}`);
|
|
901
1038
|
}
|
|
902
1039
|
};
|
|
903
|
-
const
|
|
1040
|
+
const composeModuleImportWarn = (request)=>{
|
|
1041
|
+
return `The externalized commonjs request ${index_js_namespaceObject["default"].green(`"${request}"`)} will use ${index_js_namespaceObject["default"].blue('"module"')} external type in ESM format. If you want to specify other external type, considering set the request and type with ${index_js_namespaceObject["default"].blue('"output.externals"')}.`;
|
|
1042
|
+
};
|
|
1043
|
+
const composeExternalsConfig = (format, externals)=>{
|
|
1044
|
+
// TODO: Define the internal externals config in Rsbuild's externals instead
|
|
1045
|
+
// Rspack's externals as they will not be merged from different fields. All externals
|
|
1046
|
+
// should to be unified and merged together in the future.
|
|
1047
|
+
const externalsTypeMap = {
|
|
1048
|
+
esm: 'module-import',
|
|
1049
|
+
cjs: 'commonjs',
|
|
1050
|
+
umd: 'umd'
|
|
1051
|
+
};
|
|
1052
|
+
switch(format){
|
|
1053
|
+
case 'esm':
|
|
1054
|
+
case 'cjs':
|
|
1055
|
+
case 'umd':
|
|
1056
|
+
return {
|
|
1057
|
+
output: externals ? {
|
|
1058
|
+
externals
|
|
1059
|
+
} : {},
|
|
1060
|
+
tools: {
|
|
1061
|
+
rspack: {
|
|
1062
|
+
externalsType: externalsTypeMap[format]
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
};
|
|
1066
|
+
default:
|
|
1067
|
+
throw new Error(`Unsupported format: ${format}`);
|
|
1068
|
+
}
|
|
1069
|
+
};
|
|
1070
|
+
const composeAutoExtensionConfig = (config, autoExtension, pkgJson)=>{
|
|
904
1071
|
const { jsExtension, dtsExtension } = getDefaultExtension({
|
|
905
|
-
format,
|
|
1072
|
+
format: config.format,
|
|
906
1073
|
pkgJson,
|
|
907
1074
|
autoExtension
|
|
908
1075
|
});
|
|
@@ -910,7 +1077,8 @@ const composeAutoExtensionConfig = (format, autoExtension, pkgJson)=>{
|
|
|
910
1077
|
config: {
|
|
911
1078
|
output: {
|
|
912
1079
|
filename: {
|
|
913
|
-
js: `[name]${jsExtension}
|
|
1080
|
+
js: `[name]${jsExtension}`,
|
|
1081
|
+
...config.output?.filename
|
|
914
1082
|
}
|
|
915
1083
|
}
|
|
916
1084
|
},
|
|
@@ -985,8 +1153,8 @@ const composeEntryConfig = async (entries, bundle, root)=>{
|
|
|
985
1153
|
for (const key of Object.keys(entries)){
|
|
986
1154
|
const entry = entries[key];
|
|
987
1155
|
// Entries in bundleless mode could be:
|
|
988
|
-
// 1. A string of glob pattern: { entry: {
|
|
989
|
-
// 2. An array of glob patterns: { entry: {
|
|
1156
|
+
// 1. A string of glob pattern: { entry: { index: 'src/*.ts' } }
|
|
1157
|
+
// 2. An array of glob patterns: { entry: { index: ['src/*.ts', 'src/*.tsx'] } }
|
|
990
1158
|
// Not supported for now: entry description object
|
|
991
1159
|
const entryFiles = Array.isArray(entry) ? entry : typeof entry === 'string' ? [
|
|
992
1160
|
entry
|
|
@@ -1028,8 +1196,16 @@ const composeBundleConfig = (jsExtension, bundle = true)=>{
|
|
|
1028
1196
|
// Prevent from externalizing entry modules here.
|
|
1029
1197
|
if (data.contextInfo.issuer) {
|
|
1030
1198
|
// Node.js ECMAScript module loader does no extension searching.
|
|
1031
|
-
//
|
|
1032
|
-
|
|
1199
|
+
// Add a file extension according to autoExtension config
|
|
1200
|
+
// when data.request is a relative path and do not have an extension.
|
|
1201
|
+
// If data.request already have an extension, we replace it with new extension
|
|
1202
|
+
// This may result in a change in semantics,
|
|
1203
|
+
// user should use copy to keep origin file or use another separate entry to deal this
|
|
1204
|
+
let request = data.request;
|
|
1205
|
+
if (request[0] === '.') {
|
|
1206
|
+
request = (0,external_node_path_namespaceObject.extname)(request) ? request.replace(/\.[^.]+$/, jsExtension) : `${request}${jsExtension}`;
|
|
1207
|
+
}
|
|
1208
|
+
return callback(null, request);
|
|
1033
1209
|
}
|
|
1034
1210
|
callback();
|
|
1035
1211
|
}
|
|
@@ -1100,48 +1276,65 @@ const composeTargetConfig = (target = 'web')=>{
|
|
|
1100
1276
|
throw new Error(`Unsupported platform: ${target}`);
|
|
1101
1277
|
}
|
|
1102
1278
|
};
|
|
1103
|
-
async function composeLibRsbuildConfig(
|
|
1104
|
-
const config = (0,core_namespaceObject.mergeRsbuildConfig)(rsbuildConfig, libConfig);
|
|
1279
|
+
async function composeLibRsbuildConfig(config, configPath) {
|
|
1105
1280
|
const rootPath = (0,external_node_path_namespaceObject.dirname)(configPath);
|
|
1106
1281
|
const pkgJson = readPackageJson(rootPath);
|
|
1107
1282
|
const { format, autoExtension = true, autoExternal = true } = config;
|
|
1108
1283
|
const formatConfig = composeFormatConfig(format);
|
|
1109
|
-
const
|
|
1284
|
+
const externalsConfig = composeExternalsConfig(format, config.output?.externals);
|
|
1285
|
+
const { config: autoExtensionConfig, jsExtension, dtsExtension } = composeAutoExtensionConfig(config, autoExtension, pkgJson);
|
|
1110
1286
|
const bundleConfig = composeBundleConfig(jsExtension, config.bundle);
|
|
1111
1287
|
const targetConfig = composeTargetConfig(config.output?.target);
|
|
1112
1288
|
const syntaxConfig = composeSyntaxConfig(config.output?.syntax, config.output?.target);
|
|
1113
1289
|
const autoExternalConfig = composeAutoExternalConfig({
|
|
1114
1290
|
autoExternal,
|
|
1115
1291
|
pkgJson,
|
|
1116
|
-
userExternals:
|
|
1292
|
+
userExternals: config.output?.externals
|
|
1117
1293
|
});
|
|
1118
1294
|
const entryConfig = await composeEntryConfig(config.source?.entry, config.bundle, (0,external_node_path_namespaceObject.dirname)(configPath));
|
|
1119
1295
|
const dtsConfig = await composeDtsConfig(config, dtsExtension);
|
|
1120
|
-
|
|
1296
|
+
const externalsWarnConfig = composeExternalsWarnConfig(format, autoExternalConfig?.output?.externals, externalsConfig?.output?.externals);
|
|
1297
|
+
return (0,core_namespaceObject.mergeRsbuildConfig)(formatConfig, // externalsWarnConfig should before other externals config
|
|
1298
|
+
externalsWarnConfig, externalsConfig, autoExternalConfig, autoExtensionConfig, syntaxConfig, bundleConfig, targetConfig, entryConfig, dtsConfig);
|
|
1121
1299
|
}
|
|
1122
1300
|
async function composeCreateRsbuildConfig(rslibConfig, path) {
|
|
1123
|
-
const
|
|
1301
|
+
const constantRsbuildConfig = await createConstantRsbuildConfig();
|
|
1124
1302
|
const configPath = path ?? rslibConfig._privateMeta?.configFilePath;
|
|
1125
1303
|
const { lib: libConfigsArray, ...sharedRsbuildConfig } = rslibConfig;
|
|
1126
1304
|
if (!libConfigsArray) {
|
|
1127
1305
|
throw new Error(`Expect lib field to be an array, but got ${libConfigsArray}.`);
|
|
1128
1306
|
}
|
|
1129
1307
|
const libConfigPromises = libConfigsArray.map(async (libConfig)=>{
|
|
1130
|
-
const
|
|
1131
|
-
const baseRsbuildConfig = (0,core_namespaceObject.mergeRsbuildConfig)(sharedRsbuildConfig, overrideRsbuildConfig);
|
|
1308
|
+
const userConfig = (0,core_namespaceObject.mergeRsbuildConfig)(sharedRsbuildConfig, libConfig);
|
|
1132
1309
|
// Merge the configuration of each environment based on the shared Rsbuild
|
|
1133
1310
|
// configuration and Lib configuration in the settings.
|
|
1134
|
-
const libRsbuildConfig = await composeLibRsbuildConfig(
|
|
1311
|
+
const libRsbuildConfig = await composeLibRsbuildConfig(userConfig, configPath);
|
|
1135
1312
|
// Reset certain fields because they will be completely overridden by the upcoming merge.
|
|
1136
1313
|
// We don't want to retain them in the final configuration.
|
|
1137
1314
|
// The reset process should occur after merging the library configuration.
|
|
1138
|
-
|
|
1139
|
-
|
|
1315
|
+
userConfig.source ??= {};
|
|
1316
|
+
userConfig.source.entry = {};
|
|
1317
|
+
// Already manually sort and merge the externals configuration.
|
|
1318
|
+
userConfig.output ??= {};
|
|
1319
|
+
delete userConfig.output.externals;
|
|
1140
1320
|
return {
|
|
1141
|
-
format: format,
|
|
1142
|
-
|
|
1143
|
-
//
|
|
1144
|
-
|
|
1321
|
+
format: libConfig.format,
|
|
1322
|
+
// The merge order represents the priority of the configuration
|
|
1323
|
+
// The priorities from high to low are as follows:
|
|
1324
|
+
// 1 - userConfig: users can configure any Rsbuild and Rspack config
|
|
1325
|
+
// 2 - libRsbuildConfig: the configuration that we compose from Rslib unique config and userConfig from 1
|
|
1326
|
+
// 3 - constantRsbuildConfig: the built-in best practice Rsbuild configuration we provide in Rslib
|
|
1327
|
+
// We should state in the document that the built-in configuration should not be changed optionally
|
|
1328
|
+
// In compose process of 2, we may read some config from 1, and reassemble the related config,
|
|
1329
|
+
// so before final mergeRsbuildConfig, we reset some specified fields
|
|
1330
|
+
config: (0,core_namespaceObject.mergeRsbuildConfig)(constantRsbuildConfig, libRsbuildConfig, omitDeep(userConfig, [
|
|
1331
|
+
'bundle',
|
|
1332
|
+
'format',
|
|
1333
|
+
'autoExtension',
|
|
1334
|
+
'autoExternal',
|
|
1335
|
+
'syntax',
|
|
1336
|
+
'dts'
|
|
1337
|
+
]))
|
|
1145
1338
|
};
|
|
1146
1339
|
});
|
|
1147
1340
|
const composedRsbuildConfig = await Promise.all(libConfigPromises);
|
|
@@ -1190,7 +1383,7 @@ const applyCommonOptions = (command)=>{
|
|
|
1190
1383
|
command.option('-c --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file');
|
|
1191
1384
|
};
|
|
1192
1385
|
function runCli() {
|
|
1193
|
-
commander_index_js_namespaceObject.program.name('rslib').usage('<command> [options]').version("0.0.
|
|
1386
|
+
commander_index_js_namespaceObject.program.name('rslib').usage('<command> [options]').version("0.0.4");
|
|
1194
1387
|
const buildCommand = commander_index_js_namespaceObject.program.command('build');
|
|
1195
1388
|
const inspectCommand = commander_index_js_namespaceObject.program.command('inspect');
|
|
1196
1389
|
[
|
|
@@ -1199,7 +1392,10 @@ function runCli() {
|
|
|
1199
1392
|
].forEach(applyCommonOptions);
|
|
1200
1393
|
buildCommand.option('-w --watch', 'turn on watch mode, watch for changes and rebuild').description('build the library for production').action(async (options)=>{
|
|
1201
1394
|
try {
|
|
1202
|
-
const rslibConfig = await loadConfig(
|
|
1395
|
+
const rslibConfig = await loadConfig({
|
|
1396
|
+
path: options.config,
|
|
1397
|
+
envMode: options.envMode
|
|
1398
|
+
});
|
|
1203
1399
|
await build(rslibConfig, options);
|
|
1204
1400
|
} catch (err) {
|
|
1205
1401
|
dist_logger.error('Failed to build.');
|
|
@@ -1210,7 +1406,10 @@ function runCli() {
|
|
|
1210
1406
|
inspectCommand.description('inspect the Rslib / Rsbuild / Rspack configs').option('--env <env>', 'specify env mode', 'development').option('--output <output>', 'specify inspect content output path', './').option('--verbose', 'show full function definitions in output').action(async (options)=>{
|
|
1211
1407
|
try {
|
|
1212
1408
|
// TODO: inspect should output Rslib's config
|
|
1213
|
-
const rslibConfig = await loadConfig(
|
|
1409
|
+
const rslibConfig = await loadConfig({
|
|
1410
|
+
path: options.config,
|
|
1411
|
+
envMode: options.envMode
|
|
1412
|
+
});
|
|
1214
1413
|
const rsbuildInstance = await initRsbuild(rslibConfig);
|
|
1215
1414
|
await rsbuildInstance.inspectConfig({
|
|
1216
1415
|
mode: options.mode,
|
|
@@ -1233,6 +1432,6 @@ function runCli() {
|
|
|
1233
1432
|
|
|
1234
1433
|
|
|
1235
1434
|
|
|
1236
|
-
const src_version = "0.0.
|
|
1435
|
+
const src_version = "0.0.4";
|
|
1237
1436
|
|
|
1238
1437
|
export { build, defineConfig, loadConfig, dist_logger as logger, prepareCli, runCli, src_version as version };
|
package/dist-types/config.d.ts
CHANGED
|
@@ -8,13 +8,18 @@ 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 declare function loadConfig(
|
|
11
|
+
export declare function loadConfig({ cwd, path, envMode, }: {
|
|
12
|
+
cwd?: string;
|
|
13
|
+
path?: string;
|
|
14
|
+
envMode?: string;
|
|
15
|
+
}): Promise<RslibConfig>;
|
|
12
16
|
export declare const composeAutoExternalConfig: (options: {
|
|
13
17
|
autoExternal: AutoExternal;
|
|
14
18
|
pkgJson?: PkgJson;
|
|
15
19
|
userExternals?: NonNullable<RsbuildConfig["output"]>["externals"];
|
|
16
20
|
}) => RsbuildConfig;
|
|
17
|
-
export declare function
|
|
21
|
+
export declare function createConstantRsbuildConfig(): Promise<RsbuildConfig>;
|
|
22
|
+
export declare const composeModuleImportWarn: (request: string) => string;
|
|
18
23
|
export declare function composeCreateRsbuildConfig(rslibConfig: RslibConfig, path?: string): Promise<{
|
|
19
24
|
format: Format;
|
|
20
25
|
config: RsbuildConfig;
|
|
@@ -8,4 +8,8 @@ export declare const nodeBuiltInModules: Array<string | RegExp>;
|
|
|
8
8
|
export declare function calcLongestCommonPath(absPaths: string[]): Promise<string | null>;
|
|
9
9
|
export declare const readPackageJson: (rootPath: string) => undefined | PkgJson;
|
|
10
10
|
export declare const isObject: (obj: unknown) => obj is Record<string, any>;
|
|
11
|
+
type OmitDeep<T, K extends string[]> = T extends (infer U)[] ? OmitDeep<U, K>[] : T extends Record<any, any> ? {
|
|
12
|
+
[P in keyof T as P extends K[number] ? never : P]: OmitDeep<T[P], K>;
|
|
13
|
+
} : T;
|
|
14
|
+
export declare function omitDeep<T extends object, K extends string[]>(obj: T, keys: K): OmitDeep<T, K>;
|
|
11
15
|
export { color };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "The Rspack-based library build tool.",
|
|
5
5
|
"homepage": "https://rslib.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
18
|
"types": "./dist-types/index.d.ts",
|
|
19
|
-
"default": "./dist/
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
20
|
},
|
|
21
21
|
"./package.json": "./package.json"
|
|
22
22
|
},
|
|
23
|
-
"main": "./dist/
|
|
23
|
+
"main": "./dist/index.js",
|
|
24
24
|
"types": "./dist-types/index.d.ts",
|
|
25
25
|
"bin": {
|
|
26
26
|
"rslib": "./bin/rslib.js"
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"compiled"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@rsbuild/core": "1.0.1-
|
|
36
|
-
"rsbuild-plugin-dts": "0.0.
|
|
35
|
+
"@rsbuild/core": "1.0.1-rc.0",
|
|
36
|
+
"rsbuild-plugin-dts": "0.0.4"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"fs-extra": "^11.2.0",
|
|
43
43
|
"memfs": "^4.11.1",
|
|
44
44
|
"picocolors": "1.0.1",
|
|
45
|
-
"prebundle": "1.
|
|
46
|
-
"rslib": "npm:@rslib/core@0.0.
|
|
45
|
+
"prebundle": "1.2.2",
|
|
46
|
+
"rslib": "npm:@rslib/core@0.0.3",
|
|
47
47
|
"rslog": "^1.2.2",
|
|
48
48
|
"typescript": "^5.5.4",
|
|
49
49
|
"@rslib/tsconfig": "0.0.1"
|