bunchee 3.0.0-beta.10 → 3.0.0-beta.11
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/cli.js +38 -5
- package/dist/lib.js +4 -1
- package/package.json +6 -2
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
var path = require('path');
|
|
3
3
|
var arg = require('arg');
|
|
4
|
-
require('fs');
|
|
4
|
+
var fs = require('fs');
|
|
5
5
|
|
|
6
6
|
function exit(err) {
|
|
7
7
|
logger.error(err);
|
|
8
8
|
process.exit(1);
|
|
9
9
|
}
|
|
10
10
|
const formatDuration = (duration)=>duration >= 1000 ? `${duration / 1000}s` : `${duration}ms`;
|
|
11
|
+
function getPackageMeta(cwd) {
|
|
12
|
+
const pkgFilePath = path.resolve(cwd, 'package.json');
|
|
13
|
+
let targetPackageJson = {};
|
|
14
|
+
try {
|
|
15
|
+
targetPackageJson = JSON.parse(fs.readFileSync(pkgFilePath, {
|
|
16
|
+
encoding: 'utf-8'
|
|
17
|
+
}));
|
|
18
|
+
} catch (_) {}
|
|
19
|
+
return targetPackageJson;
|
|
20
|
+
}
|
|
11
21
|
const logger = {
|
|
12
22
|
log (arg) {
|
|
13
23
|
console.log(arg);
|
|
@@ -20,7 +30,7 @@ const logger = {
|
|
|
20
30
|
}
|
|
21
31
|
};
|
|
22
32
|
|
|
23
|
-
var version = "3.0.0-beta.
|
|
33
|
+
var version = "3.0.0-beta.11";
|
|
24
34
|
|
|
25
35
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
26
36
|
try {
|
|
@@ -71,6 +81,24 @@ Options:
|
|
|
71
81
|
function help() {
|
|
72
82
|
logger.log(helpMessage);
|
|
73
83
|
}
|
|
84
|
+
function lintPackage(cwd) {
|
|
85
|
+
return _lintPackage.apply(this, arguments);
|
|
86
|
+
}
|
|
87
|
+
function _lintPackage() {
|
|
88
|
+
_lintPackage = _asyncToGenerator(function*(cwd) {
|
|
89
|
+
const { publint } = yield import('publint');
|
|
90
|
+
const { printMessage } = yield import('publint/utils');
|
|
91
|
+
const messages = yield publint({
|
|
92
|
+
pkgDir: cwd,
|
|
93
|
+
level: 'error'
|
|
94
|
+
});
|
|
95
|
+
const pkg = getPackageMeta(cwd);
|
|
96
|
+
for (const message of messages){
|
|
97
|
+
console.log(printMessage(message, pkg));
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
return _lintPackage.apply(this, arguments);
|
|
101
|
+
}
|
|
74
102
|
function parseCliArgs(argv) {
|
|
75
103
|
let args;
|
|
76
104
|
args = arg({
|
|
@@ -144,7 +172,7 @@ function _run() {
|
|
|
144
172
|
return help();
|
|
145
173
|
}
|
|
146
174
|
const entry = source ? path.resolve(cwd, source) : '';
|
|
147
|
-
const
|
|
175
|
+
const bundle = require('./lib').bundle;
|
|
148
176
|
let timeStart = Date.now();
|
|
149
177
|
let timeEnd;
|
|
150
178
|
try {
|
|
@@ -158,9 +186,14 @@ function _run() {
|
|
|
158
186
|
throw err;
|
|
159
187
|
}
|
|
160
188
|
const duration = timeEnd - timeStart;
|
|
161
|
-
|
|
162
|
-
|
|
189
|
+
// watching mode
|
|
190
|
+
if (watch) {
|
|
191
|
+
logger.log(`🔍 Watching assets in ${cwd}...`);
|
|
192
|
+
return;
|
|
163
193
|
}
|
|
194
|
+
// build mode
|
|
195
|
+
logger.log(`✨ Finished in ${formatDuration(duration)}`);
|
|
196
|
+
yield lintPackage(cwd);
|
|
164
197
|
});
|
|
165
198
|
return _run.apply(this, arguments);
|
|
166
199
|
}
|
package/dist/lib.js
CHANGED
|
@@ -469,6 +469,7 @@ function assignDefault(options, name, defaultValue) {
|
|
|
469
469
|
}
|
|
470
470
|
// Map '.' -> './index.[ext]'
|
|
471
471
|
// Map './lite' -> './lite.[ext]'
|
|
472
|
+
// Return undefined if no match or if it's package.json exports
|
|
472
473
|
function getSourcePathFromExportPath(cwd, exportPath) {
|
|
473
474
|
const exts = [
|
|
474
475
|
'js',
|
|
@@ -509,7 +510,9 @@ function _bundle() {
|
|
|
509
510
|
const isSingleEntry = typeof packageExports === 'string';
|
|
510
511
|
const hasMultiEntries = packageExports && !isSingleEntry && Object.keys(packageExports).length > 0;
|
|
511
512
|
if (isSingleEntry) {
|
|
512
|
-
|
|
513
|
+
// Use specified string file path if possible, then fallback to the default behavior entry picking logic
|
|
514
|
+
// e.g. "exports": "./dist/index.js" -> use "./index.<ext>" as entry
|
|
515
|
+
entryPath = entryPath || getSourcePathFromExportPath(config.rootDir, '.') || '';
|
|
513
516
|
}
|
|
514
517
|
function buildEntryConfig(packageExports, dtsOnly) {
|
|
515
518
|
const configs = Object.keys(packageExports).map((entryExport)=>{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunchee",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.11",
|
|
4
4
|
"description": "zero config bundler for js/ts/jsx libraries",
|
|
5
5
|
"bin": {
|
|
6
6
|
"bunchee": "./dist/cli.js"
|
|
@@ -31,6 +31,9 @@
|
|
|
31
31
|
"dist",
|
|
32
32
|
"*.md"
|
|
33
33
|
],
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">= 16"
|
|
36
|
+
},
|
|
34
37
|
"author": "huozhi (github.com/huozhi)",
|
|
35
38
|
"repository": {
|
|
36
39
|
"type": "git",
|
|
@@ -43,6 +46,7 @@
|
|
|
43
46
|
"@rollup/plugin-node-resolve": "15.0.1",
|
|
44
47
|
"@swc/core": "1.3.35",
|
|
45
48
|
"arg": "5.0.2",
|
|
49
|
+
"publint": "0.1.11",
|
|
46
50
|
"rollup": "3.15.0",
|
|
47
51
|
"rollup-plugin-dts": "5.1.1",
|
|
48
52
|
"rollup-plugin-preserve-shebang": "1.0.1",
|
|
@@ -62,7 +66,7 @@
|
|
|
62
66
|
"@types/jest": "29.0.0",
|
|
63
67
|
"jest": "29.0.1",
|
|
64
68
|
"react": "18.2.0",
|
|
65
|
-
"tsx": "3.12.
|
|
69
|
+
"tsx": "3.12.6",
|
|
66
70
|
"typescript": "4.9.5"
|
|
67
71
|
},
|
|
68
72
|
"jest": {
|