@rslib/core 0.0.1 → 0.0.3
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 +1 -1
- package/dist/{main.js → index.js} +42 -74
- package/dist-types/config.d.ts +5 -1
- package/dist-types/utils/extension.d.ts +1 -1
- package/package.json +6 -6
package/bin/rslib.js
CHANGED
|
@@ -39,44 +39,20 @@ return module.exports;
|
|
|
39
39
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
/************************************************************************/
|
|
43
|
-
// webpack/runtime/define_property_getters
|
|
44
|
-
!function() {
|
|
45
|
-
__webpack_require__.d = function(exports, definition) {
|
|
46
|
-
for(var key in definition) {
|
|
47
|
-
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
48
|
-
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}();
|
|
53
|
-
// webpack/runtime/has_own_property
|
|
54
|
-
!function() {
|
|
55
|
-
__webpack_require__.o = function (obj, prop) {
|
|
56
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
}();
|
|
60
42
|
/************************************************************************/
|
|
61
43
|
|
|
62
44
|
;// CONCATENATED MODULE: external "process"
|
|
63
45
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
var external_process_namespaceObject = __WEBPACK_EXTERNAL_MODULE_process__;
|
|
67
|
-
|
|
46
|
+
var external_process_namespaceObject = __WEBPACK_EXTERNAL_MODULE_process__;
|
|
47
|
+
|
|
68
48
|
;// CONCATENATED MODULE: external "os"
|
|
69
49
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var external_os_namespaceObject = __WEBPACK_EXTERNAL_MODULE_os__;
|
|
73
|
-
|
|
50
|
+
var external_os_namespaceObject = __WEBPACK_EXTERNAL_MODULE_os__;
|
|
51
|
+
|
|
74
52
|
;// CONCATENATED MODULE: external "tty"
|
|
75
53
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
var external_tty_namespaceObject = __WEBPACK_EXTERNAL_MODULE_tty__;
|
|
79
|
-
|
|
54
|
+
var external_tty_namespaceObject = __WEBPACK_EXTERNAL_MODULE_tty__;
|
|
55
|
+
|
|
80
56
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/rslog@1.2.2/node_modules/rslog/dist/index.mjs
|
|
81
57
|
// node_modules/.pnpm/supports-color@9.4.0/node_modules/supports-color/index.js
|
|
82
58
|
|
|
@@ -374,28 +350,20 @@ var dist_logger = createLogger();
|
|
|
374
350
|
|
|
375
351
|
;// CONCATENATED MODULE: external "node:fs"
|
|
376
352
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
var external_node_fs_namespaceObject = __WEBPACK_EXTERNAL_MODULE_node_fs__;
|
|
380
|
-
|
|
353
|
+
var external_node_fs_namespaceObject = __WEBPACK_EXTERNAL_MODULE_node_fs__;
|
|
354
|
+
|
|
381
355
|
;// CONCATENATED MODULE: external "node:fs/promises"
|
|
382
356
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
var promises_namespaceObject = __WEBPACK_EXTERNAL_MODULE_node_fs_promises__;
|
|
386
|
-
|
|
357
|
+
var promises_namespaceObject = __WEBPACK_EXTERNAL_MODULE_node_fs_promises__;
|
|
358
|
+
|
|
387
359
|
;// CONCATENATED MODULE: external "node:path"
|
|
388
360
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
var external_node_path_namespaceObject = __WEBPACK_EXTERNAL_MODULE_node_path__;
|
|
392
|
-
|
|
361
|
+
var external_node_path_namespaceObject = __WEBPACK_EXTERNAL_MODULE_node_path__;
|
|
362
|
+
|
|
393
363
|
;// CONCATENATED MODULE: external "../compiled/picocolors/index.js"
|
|
394
364
|
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
var index_js_namespaceObject = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__;
|
|
398
|
-
|
|
365
|
+
var index_js_namespaceObject = __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__;
|
|
366
|
+
|
|
399
367
|
;// CONCATENATED MODULE: ./src/utils/helper.ts
|
|
400
368
|
|
|
401
369
|
|
|
@@ -492,7 +460,7 @@ async function calcLongestCommonPath(absPaths) {
|
|
|
492
460
|
return lca;
|
|
493
461
|
}
|
|
494
462
|
const readPackageJson = (rootPath)=>{
|
|
495
|
-
const pkgJsonPath = external_node_path_namespaceObject["default"].
|
|
463
|
+
const pkgJsonPath = external_node_path_namespaceObject["default"].join(rootPath, './package.json');
|
|
496
464
|
if (!external_node_fs_namespaceObject["default"].existsSync(pkgJsonPath)) {
|
|
497
465
|
dist_logger.warn(`package.json does not exist in the ${rootPath} directory`);
|
|
498
466
|
return;
|
|
@@ -557,27 +525,21 @@ function prepareCli() {
|
|
|
557
525
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) {
|
|
558
526
|
console.log();
|
|
559
527
|
}
|
|
560
|
-
dist_logger.greet(` ${`Rslib v${"0.0.
|
|
528
|
+
dist_logger.greet(` ${`Rslib v${"0.0.3"}`}\n`);
|
|
561
529
|
}
|
|
562
530
|
|
|
563
531
|
;// CONCATENATED MODULE: external "../compiled/commander/index.js"
|
|
564
532
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
var commander_index_js_namespaceObject = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__;
|
|
568
|
-
|
|
533
|
+
var commander_index_js_namespaceObject = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__;
|
|
534
|
+
|
|
569
535
|
;// CONCATENATED MODULE: external "@rsbuild/core"
|
|
570
536
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
var core_namespaceObject = __WEBPACK_EXTERNAL_MODULE__rsbuild_core__;
|
|
574
|
-
|
|
537
|
+
var core_namespaceObject = __WEBPACK_EXTERNAL_MODULE__rsbuild_core__;
|
|
538
|
+
|
|
575
539
|
;// CONCATENATED MODULE: external "../compiled/fast-glob/index.js"
|
|
576
540
|
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
var fast_glob_index_js_namespaceObject = __WEBPACK_EXTERNAL_MODULE__compiled_fast_glob_index_js__;
|
|
580
|
-
|
|
541
|
+
var fast_glob_index_js_namespaceObject = __WEBPACK_EXTERNAL_MODULE__compiled_fast_glob_index_js__;
|
|
542
|
+
|
|
581
543
|
;// CONCATENATED MODULE: ./src/constant.ts
|
|
582
544
|
const DEFAULT_CONFIG_NAME = 'rslib.config';
|
|
583
545
|
const DEFAULT_EXTENSIONS = [
|
|
@@ -793,11 +755,10 @@ const resolveConfigPath = (root, customConfig)=>{
|
|
|
793
755
|
if (configFilePath) {
|
|
794
756
|
return configFilePath;
|
|
795
757
|
}
|
|
796
|
-
|
|
758
|
+
throw new Error(`${DEFAULT_CONFIG_NAME} not found in ${root}`);
|
|
797
759
|
};
|
|
798
|
-
async function loadConfig(
|
|
799
|
-
const
|
|
800
|
-
const configFilePath = resolveConfigPath(root, customConfig);
|
|
760
|
+
async function loadConfig({ cwd = process.cwd(), path, envMode }) {
|
|
761
|
+
const configFilePath = resolveConfigPath(cwd, path);
|
|
801
762
|
const { content } = await (0,core_namespaceObject.loadConfig)({
|
|
802
763
|
cwd: (0,external_node_path_namespaceObject.dirname)(configFilePath),
|
|
803
764
|
path: configFilePath,
|
|
@@ -938,9 +899,9 @@ const composeFormatConfig = (format)=>{
|
|
|
938
899
|
throw new Error(`Unsupported format: ${format}`);
|
|
939
900
|
}
|
|
940
901
|
};
|
|
941
|
-
const composeAutoExtensionConfig = (
|
|
902
|
+
const composeAutoExtensionConfig = (config, autoExtension, pkgJson)=>{
|
|
942
903
|
const { jsExtension, dtsExtension } = getDefaultExtension({
|
|
943
|
-
format,
|
|
904
|
+
format: config.format,
|
|
944
905
|
pkgJson,
|
|
945
906
|
autoExtension
|
|
946
907
|
});
|
|
@@ -948,7 +909,8 @@ const composeAutoExtensionConfig = (format, autoExtension, pkgJson)=>{
|
|
|
948
909
|
config: {
|
|
949
910
|
output: {
|
|
950
911
|
filename: {
|
|
951
|
-
js: `[name]${jsExtension}
|
|
912
|
+
js: `[name]${jsExtension}`,
|
|
913
|
+
...config.output?.filename
|
|
952
914
|
}
|
|
953
915
|
}
|
|
954
916
|
},
|
|
@@ -1023,8 +985,8 @@ const composeEntryConfig = async (entries, bundle, root)=>{
|
|
|
1023
985
|
for (const key of Object.keys(entries)){
|
|
1024
986
|
const entry = entries[key];
|
|
1025
987
|
// Entries in bundleless mode could be:
|
|
1026
|
-
// 1. A string of glob pattern: { entry: {
|
|
1027
|
-
// 2. An array of glob patterns: { entry: {
|
|
988
|
+
// 1. A string of glob pattern: { entry: { index: 'src/*.ts' } }
|
|
989
|
+
// 2. An array of glob patterns: { entry: { index: ['src/*.ts', 'src/*.tsx'] } }
|
|
1028
990
|
// Not supported for now: entry description object
|
|
1029
991
|
const entryFiles = Array.isArray(entry) ? entry : typeof entry === 'string' ? [
|
|
1030
992
|
entry
|
|
@@ -1144,7 +1106,7 @@ async function composeLibRsbuildConfig(libConfig, rsbuildConfig, configPath) {
|
|
|
1144
1106
|
const pkgJson = readPackageJson(rootPath);
|
|
1145
1107
|
const { format, autoExtension = true, autoExternal = true } = config;
|
|
1146
1108
|
const formatConfig = composeFormatConfig(format);
|
|
1147
|
-
const { config: autoExtensionConfig, jsExtension, dtsExtension } = composeAutoExtensionConfig(
|
|
1109
|
+
const { config: autoExtensionConfig, jsExtension, dtsExtension } = composeAutoExtensionConfig(config, autoExtension, pkgJson);
|
|
1148
1110
|
const bundleConfig = composeBundleConfig(jsExtension, config.bundle);
|
|
1149
1111
|
const targetConfig = composeTargetConfig(config.output?.target);
|
|
1150
1112
|
const syntaxConfig = composeSyntaxConfig(config.output?.syntax, config.output?.target);
|
|
@@ -1228,7 +1190,7 @@ const applyCommonOptions = (command)=>{
|
|
|
1228
1190
|
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');
|
|
1229
1191
|
};
|
|
1230
1192
|
function runCli() {
|
|
1231
|
-
commander_index_js_namespaceObject.program.name('rslib').usage('<command> [options]').version("0.0.
|
|
1193
|
+
commander_index_js_namespaceObject.program.name('rslib').usage('<command> [options]').version("0.0.3");
|
|
1232
1194
|
const buildCommand = commander_index_js_namespaceObject.program.command('build');
|
|
1233
1195
|
const inspectCommand = commander_index_js_namespaceObject.program.command('inspect');
|
|
1234
1196
|
[
|
|
@@ -1237,7 +1199,10 @@ function runCli() {
|
|
|
1237
1199
|
].forEach(applyCommonOptions);
|
|
1238
1200
|
buildCommand.option('-w --watch', 'turn on watch mode, watch for changes and rebuild').description('build the library for production').action(async (options)=>{
|
|
1239
1201
|
try {
|
|
1240
|
-
const rslibConfig = await loadConfig(
|
|
1202
|
+
const rslibConfig = await loadConfig({
|
|
1203
|
+
path: options.config,
|
|
1204
|
+
envMode: options.envMode
|
|
1205
|
+
});
|
|
1241
1206
|
await build(rslibConfig, options);
|
|
1242
1207
|
} catch (err) {
|
|
1243
1208
|
dist_logger.error('Failed to build.');
|
|
@@ -1248,7 +1213,10 @@ function runCli() {
|
|
|
1248
1213
|
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)=>{
|
|
1249
1214
|
try {
|
|
1250
1215
|
// TODO: inspect should output Rslib's config
|
|
1251
|
-
const rslibConfig = await loadConfig(
|
|
1216
|
+
const rslibConfig = await loadConfig({
|
|
1217
|
+
path: options.config,
|
|
1218
|
+
envMode: options.envMode
|
|
1219
|
+
});
|
|
1252
1220
|
const rsbuildInstance = await initRsbuild(rslibConfig);
|
|
1253
1221
|
await rsbuildInstance.inspectConfig({
|
|
1254
1222
|
mode: options.mode,
|
|
@@ -1271,6 +1239,6 @@ function runCli() {
|
|
|
1271
1239
|
|
|
1272
1240
|
|
|
1273
1241
|
|
|
1274
|
-
const src_version = "0.0.
|
|
1242
|
+
const src_version = "0.0.3";
|
|
1275
1243
|
|
|
1276
1244
|
export { build, defineConfig, loadConfig, dist_logger as logger, prepareCli, runCli, src_version as version };
|
package/dist-types/config.d.ts
CHANGED
|
@@ -8,7 +8,11 @@ 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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
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-beta.
|
|
36
|
-
"rsbuild-plugin-dts": "0.0.
|
|
35
|
+
"@rsbuild/core": "1.0.1-beta.16",
|
|
36
|
+
"rsbuild-plugin-dts": "0.0.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"memfs": "^4.11.1",
|
|
44
44
|
"picocolors": "1.0.1",
|
|
45
45
|
"prebundle": "1.1.0",
|
|
46
|
-
"rslib": "npm:@rslib/core@0.0.
|
|
46
|
+
"rslib": "npm:@rslib/core@0.0.2",
|
|
47
47
|
"rslog": "^1.2.2",
|
|
48
48
|
"typescript": "^5.5.4",
|
|
49
49
|
"@rslib/tsconfig": "0.0.1"
|