bunchee 6.3.1 → 6.3.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/README.md +73 -73
- package/dist/bin/cli.js +30 -19
- package/dist/index.d.ts +1 -0
- package/dist/index.js +43 -17
- package/package.json +7 -29
package/README.md
CHANGED
|
@@ -41,12 +41,12 @@ Add the exports in `package.json`.
|
|
|
41
41
|
|
|
42
42
|
```json5
|
|
43
43
|
{
|
|
44
|
-
name:
|
|
45
|
-
type:
|
|
46
|
-
main:
|
|
47
|
-
scripts: {
|
|
48
|
-
build:
|
|
49
|
-
}
|
|
44
|
+
"name": "coffee",
|
|
45
|
+
"type": "module",
|
|
46
|
+
"main": "./dist/index.js",
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "bunchee"
|
|
49
|
+
}
|
|
50
50
|
}
|
|
51
51
|
```
|
|
52
52
|
|
|
@@ -73,23 +73,23 @@ Here's a example of entry files and exports configuration:
|
|
|
73
73
|
|
|
74
74
|
```json5
|
|
75
75
|
{
|
|
76
|
-
name:
|
|
77
|
-
scripts: {
|
|
78
|
-
build:
|
|
76
|
+
"name": "coffee",
|
|
77
|
+
"scripts": {
|
|
78
|
+
"build: "bunchee",
|
|
79
79
|
},
|
|
80
|
-
type:
|
|
81
|
-
exports: {
|
|
80
|
+
"type": "module",
|
|
81
|
+
"exports": {
|
|
82
82
|
// entry: ./src/index.ts
|
|
83
|
-
|
|
84
|
-
import:
|
|
85
|
-
require:
|
|
83
|
+
".": {
|
|
84
|
+
"import": "./dist/index.js",
|
|
85
|
+
"require": "./dist/index.cjs",
|
|
86
86
|
},
|
|
87
87
|
|
|
88
88
|
// entry: ./src/lite.ts
|
|
89
|
-
|
|
89
|
+
"./lite": "./dist/lite.js",
|
|
90
90
|
|
|
91
91
|
// entry: ./src/react/index.ts
|
|
92
|
-
|
|
92
|
+
"./react": "./dist/react.js",
|
|
93
93
|
},
|
|
94
94
|
}
|
|
95
95
|
```
|
|
@@ -124,15 +124,15 @@ The `dependencies` and `peerDependencies` will be marked as externalized and won
|
|
|
124
124
|
```json5
|
|
125
125
|
{
|
|
126
126
|
// Externalized
|
|
127
|
-
dependencies: {
|
|
127
|
+
"dependencies": {
|
|
128
128
|
/* ... */
|
|
129
129
|
},
|
|
130
|
-
peerDependencies: {
|
|
130
|
+
"peerDependencies": {
|
|
131
131
|
/* ... */
|
|
132
132
|
},
|
|
133
133
|
|
|
134
134
|
// Bundled
|
|
135
|
-
devDependencies: {
|
|
135
|
+
"devDependencies": {
|
|
136
136
|
/* ... */
|
|
137
137
|
},
|
|
138
138
|
}
|
|
@@ -146,10 +146,10 @@ For instance:
|
|
|
146
146
|
|
|
147
147
|
```json5
|
|
148
148
|
{
|
|
149
|
-
exports: {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
import:
|
|
149
|
+
"exports": {
|
|
150
|
+
"react-server": "./dist/react-server.mjs",
|
|
151
|
+
"edge-light": "./dist/edge-light.mjs",
|
|
152
|
+
"import": "./dist/index.mjs",
|
|
153
153
|
},
|
|
154
154
|
}
|
|
155
155
|
```
|
|
@@ -161,8 +161,8 @@ For instance:
|
|
|
161
161
|
```json5
|
|
162
162
|
// package.json
|
|
163
163
|
{
|
|
164
|
-
imports: {
|
|
165
|
-
|
|
164
|
+
"imports": {
|
|
165
|
+
"#util": "./src/utils.ts",
|
|
166
166
|
},
|
|
167
167
|
}
|
|
168
168
|
```
|
|
@@ -183,7 +183,7 @@ This will match the `bin` field in package.json as:
|
|
|
183
183
|
|
|
184
184
|
```json5
|
|
185
185
|
{
|
|
186
|
-
bin:
|
|
186
|
+
"bin": "./dist/bin.js",
|
|
187
187
|
}
|
|
188
188
|
```
|
|
189
189
|
|
|
@@ -204,9 +204,9 @@ This will match the `bin` field in package.json as:
|
|
|
204
204
|
|
|
205
205
|
```json5
|
|
206
206
|
{
|
|
207
|
-
bin: {
|
|
208
|
-
foo:
|
|
209
|
-
bar:
|
|
207
|
+
"bin": {
|
|
208
|
+
"foo": "./dist/bin/a.js",
|
|
209
|
+
"bar": "./dist/bin/b.js",
|
|
210
210
|
},
|
|
211
211
|
}
|
|
212
212
|
```
|
|
@@ -338,14 +338,14 @@ Then use use the [exports field in package.json](https://nodejs.org/api/packages
|
|
|
338
338
|
|
|
339
339
|
```json5
|
|
340
340
|
{
|
|
341
|
-
files: [
|
|
342
|
-
type:
|
|
343
|
-
exports: {
|
|
344
|
-
|
|
345
|
-
|
|
341
|
+
"files": ["dist"],
|
|
342
|
+
"type": "module",
|
|
343
|
+
"exports": {
|
|
344
|
+
".": "./dist/es/index.js",
|
|
345
|
+
"./react": "./dist/es/react.js",
|
|
346
346
|
},
|
|
347
|
-
scripts: {
|
|
348
|
-
build:
|
|
347
|
+
"scripts": {
|
|
348
|
+
"build": "bunchee",
|
|
349
349
|
},
|
|
350
350
|
}
|
|
351
351
|
```
|
|
@@ -355,25 +355,25 @@ Then use use the [exports field in package.json](https://nodejs.org/api/packages
|
|
|
355
355
|
<details>
|
|
356
356
|
<summary>TypeScript</summary>
|
|
357
357
|
|
|
358
|
-
If you're
|
|
358
|
+
If you're building a TypeScript library, separate the types from the main entry file and specify the types path in package.json. Types exports need to stay on the top of each export with `types` condition, and you can use `default` condition for the JS bundle file.
|
|
359
359
|
|
|
360
360
|
```json5
|
|
361
361
|
{
|
|
362
|
-
files: [
|
|
363
|
-
type:
|
|
364
|
-
main:
|
|
365
|
-
exports: {
|
|
366
|
-
|
|
367
|
-
types:
|
|
368
|
-
default:
|
|
362
|
+
"files": ["dist"],
|
|
363
|
+
"type": "module",
|
|
364
|
+
"main": "./dist/index.js",
|
|
365
|
+
"exports": {
|
|
366
|
+
".": {
|
|
367
|
+
"types": "./dist/index.d.ts",
|
|
368
|
+
"default": "./dist/index.js",
|
|
369
369
|
},
|
|
370
|
-
|
|
371
|
-
types:
|
|
372
|
-
default:
|
|
370
|
+
"./react": {
|
|
371
|
+
"types": "./dist/react/index.d.ts",
|
|
372
|
+
"default": "./dist/react/index.js",
|
|
373
373
|
},
|
|
374
374
|
},
|
|
375
|
-
scripts: {
|
|
376
|
-
build:
|
|
375
|
+
"scripts": {
|
|
376
|
+
"build": "bunchee",
|
|
377
377
|
},
|
|
378
378
|
}
|
|
379
379
|
```
|
|
@@ -388,23 +388,23 @@ _NOTE_: When you're using `.mjs` or `.cjs` extensions with TypeScript and modern
|
|
|
388
388
|
|
|
389
389
|
```json5
|
|
390
390
|
{
|
|
391
|
-
files: [
|
|
392
|
-
type:
|
|
393
|
-
main:
|
|
394
|
-
module:
|
|
395
|
-
types:
|
|
396
|
-
exports: {
|
|
397
|
-
import: {
|
|
398
|
-
types:
|
|
399
|
-
default:
|
|
391
|
+
"files": ["dist"],
|
|
392
|
+
"type": "module",
|
|
393
|
+
"main": "./dist/index.js",
|
|
394
|
+
"module": "./dist/index.js",
|
|
395
|
+
"types": "./dist/index.d.ts",
|
|
396
|
+
"exports": {
|
|
397
|
+
"import": {
|
|
398
|
+
"types": "./dist/index.d.ts",
|
|
399
|
+
"default": "./dist/index.js",
|
|
400
400
|
},
|
|
401
|
-
require: {
|
|
402
|
-
types:
|
|
403
|
-
default:
|
|
401
|
+
"require": {
|
|
402
|
+
"types": "./dist/index.d.cts",
|
|
403
|
+
"default": "./dist/index.cjs",
|
|
404
404
|
},
|
|
405
405
|
},
|
|
406
|
-
scripts: {
|
|
407
|
-
build:
|
|
406
|
+
"scripts": {
|
|
407
|
+
"build": "bunchee",
|
|
408
408
|
},
|
|
409
409
|
}
|
|
410
410
|
```
|
|
@@ -450,9 +450,9 @@ This will match the export name `"react-server"` and `"edge-light"` then use the
|
|
|
450
450
|
|
|
451
451
|
```json5
|
|
452
452
|
{
|
|
453
|
-
exports: {
|
|
454
|
-
development: './dist/index.development.js',
|
|
455
|
-
production: './dist/index.production.js',
|
|
453
|
+
"exports": {
|
|
454
|
+
"development": './dist/index.development.js',
|
|
455
|
+
"production": './dist/index.production.js',
|
|
456
456
|
},
|
|
457
457
|
}
|
|
458
458
|
```
|
|
@@ -499,8 +499,8 @@ hello world
|
|
|
499
499
|
|
|
500
500
|
output
|
|
501
501
|
|
|
502
|
-
```
|
|
503
|
-
export default
|
|
502
|
+
```js
|
|
503
|
+
export default 'hello world'
|
|
504
504
|
```
|
|
505
505
|
|
|
506
506
|
### Node.js API
|
|
@@ -538,11 +538,11 @@ For example:
|
|
|
538
538
|
|
|
539
539
|
```json5
|
|
540
540
|
{
|
|
541
|
-
browserslist: [
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
541
|
+
"browserslist": [
|
|
542
|
+
"last 1 version",
|
|
543
|
+
"> 1%",
|
|
544
|
+
"maintained node versions",
|
|
545
|
+
"not dead",
|
|
546
546
|
],
|
|
547
547
|
}
|
|
548
548
|
```
|
package/dist/bin/cli.js
CHANGED
|
@@ -9,7 +9,7 @@ var require$$0 = require('tty');
|
|
|
9
9
|
var picomatch = require('picomatch');
|
|
10
10
|
var index_js = require('../index.js');
|
|
11
11
|
require('module');
|
|
12
|
-
var
|
|
12
|
+
var fastGlob = require('fast-glob');
|
|
13
13
|
var prettyBytes = require('pretty-bytes');
|
|
14
14
|
|
|
15
15
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -176,9 +176,10 @@ function validateEntryFiles(entryFiles) {
|
|
|
176
176
|
// Check if there are multiple files with the same base name
|
|
177
177
|
const filePathWithoutExt = filePath.slice(0, -path__default.default.extname(filePath).length).replace(/\\/g, '/');
|
|
178
178
|
const segments = filePathWithoutExt.split('/');
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
segments.
|
|
179
|
+
let lastSegment = segments[segments.length - 1];
|
|
180
|
+
while(lastSegment && (lastSegment === 'index' || lastSegment === '')){
|
|
181
|
+
segments.pop();
|
|
182
|
+
lastSegment = segments[segments.length - 1];
|
|
182
183
|
}
|
|
183
184
|
const fileBasePath = segments.join('/');
|
|
184
185
|
if (fileBasePaths.has(fileBasePath)) {
|
|
@@ -646,7 +647,7 @@ function lint$1(pkg) {
|
|
|
646
647
|
}
|
|
647
648
|
}
|
|
648
649
|
|
|
649
|
-
var version = "6.3.
|
|
650
|
+
var version = "6.3.3";
|
|
650
651
|
|
|
651
652
|
async function writeDefaultTsconfig(tsConfigPath) {
|
|
652
653
|
await fs.promises.writeFile(tsConfigPath, JSON.stringify(DEFAULT_TS_CONFIG, null, 2), 'utf-8');
|
|
@@ -730,10 +731,11 @@ async function collectSourceEntriesByExportPath(sourceFolderPath, originalSubpat
|
|
|
730
731
|
...availableExtensions
|
|
731
732
|
].join(',')}}`
|
|
732
733
|
];
|
|
733
|
-
const entryFiles = await
|
|
734
|
+
const entryFiles = await fastGlob.glob(entryFilesPatterns, {
|
|
734
735
|
cwd: dirPath,
|
|
735
|
-
|
|
736
|
-
|
|
736
|
+
ignore: [
|
|
737
|
+
PRIVATE_GLOB_PATTERN
|
|
738
|
+
]
|
|
737
739
|
});
|
|
738
740
|
validateEntryFiles(entryFiles);
|
|
739
741
|
for (const file of entryFiles){
|
|
@@ -778,17 +780,15 @@ async function collectSourceEntries(sourceFolderPath) {
|
|
|
778
780
|
const srcPattern = `**/*.{${[
|
|
779
781
|
...availableExtensions
|
|
780
782
|
].join(',')}}`;
|
|
781
|
-
const binMatches = await
|
|
783
|
+
const binMatches = await fastGlob.glob(binPattern, {
|
|
782
784
|
cwd: sourceFolderPath,
|
|
783
|
-
nodir: true,
|
|
784
785
|
ignore: [
|
|
785
786
|
PRIVATE_GLOB_PATTERN,
|
|
786
787
|
TESTS_GLOB_PATTERN
|
|
787
788
|
]
|
|
788
789
|
});
|
|
789
|
-
const srcMatches = await
|
|
790
|
+
const srcMatches = await fastGlob.glob(srcPattern, {
|
|
790
791
|
cwd: sourceFolderPath,
|
|
791
|
-
nodir: true,
|
|
792
792
|
ignore: [
|
|
793
793
|
PRIVATE_GLOB_PATTERN,
|
|
794
794
|
TESTS_GLOB_PATTERN
|
|
@@ -1050,6 +1050,16 @@ function logOutputState(stats) {
|
|
|
1050
1050
|
});
|
|
1051
1051
|
}
|
|
1052
1052
|
|
|
1053
|
+
function normalizeError(error) {
|
|
1054
|
+
// Remove the noise from rollup plugin error
|
|
1055
|
+
if (error.code === 'PLUGIN_ERROR') {
|
|
1056
|
+
const normalizedError = new Error(error.message);
|
|
1057
|
+
normalizedError.stack = error.stack;
|
|
1058
|
+
error = normalizedError;
|
|
1059
|
+
}
|
|
1060
|
+
return error;
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1053
1063
|
const helpMessage = `
|
|
1054
1064
|
Usage: bunchee [options]
|
|
1055
1065
|
|
|
@@ -1266,10 +1276,14 @@ async function run(args) {
|
|
|
1266
1276
|
}
|
|
1267
1277
|
}
|
|
1268
1278
|
}
|
|
1279
|
+
function onBuildError(error) {
|
|
1280
|
+
logError(error);
|
|
1281
|
+
}
|
|
1269
1282
|
let buildError;
|
|
1270
1283
|
bundleConfig._callbacks = {
|
|
1271
1284
|
onBuildStart,
|
|
1272
|
-
onBuildEnd
|
|
1285
|
+
onBuildEnd,
|
|
1286
|
+
onBuildError
|
|
1273
1287
|
};
|
|
1274
1288
|
if (watch) {
|
|
1275
1289
|
logger.log(`Watching changes in the project directory...`);
|
|
@@ -1355,11 +1369,8 @@ function logWatcherBuildTime(result, spinner) {
|
|
|
1355
1369
|
});
|
|
1356
1370
|
});
|
|
1357
1371
|
}
|
|
1358
|
-
function logError(
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
if (error.frame) {
|
|
1362
|
-
process.stderr.write(error.frame + '\n');
|
|
1363
|
-
}
|
|
1372
|
+
function logError(err) {
|
|
1373
|
+
const error = normalizeError(err);
|
|
1374
|
+
logger.error(error);
|
|
1364
1375
|
}
|
|
1365
1376
|
main().catch(exit);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var fsp = require('fs/promises');
|
|
|
4
4
|
var fs = require('fs');
|
|
5
5
|
var path = require('path');
|
|
6
6
|
require('pretty-bytes');
|
|
7
|
-
var
|
|
7
|
+
var fastGlob = require('fast-glob');
|
|
8
8
|
var require$$0 = require('tty');
|
|
9
9
|
var module$1 = require('module');
|
|
10
10
|
var rollup = require('rollup');
|
|
@@ -277,9 +277,10 @@ function validateEntryFiles(entryFiles) {
|
|
|
277
277
|
// Check if there are multiple files with the same base name
|
|
278
278
|
const filePathWithoutExt = filePath.slice(0, -path__default.default.extname(filePath).length).replace(/\\/g, '/');
|
|
279
279
|
const segments = filePathWithoutExt.split('/');
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
segments.
|
|
280
|
+
let lastSegment = segments[segments.length - 1];
|
|
281
|
+
while(lastSegment && (lastSegment === 'index' || lastSegment === '')){
|
|
282
|
+
segments.pop();
|
|
283
|
+
lastSegment = segments[segments.length - 1];
|
|
283
284
|
}
|
|
284
285
|
const fileBasePath = segments.join('/');
|
|
285
286
|
if (fileBasePaths.has(fileBasePath)) {
|
|
@@ -817,10 +818,11 @@ async function collectSourceEntriesByExportPath(sourceFolderPath, originalSubpat
|
|
|
817
818
|
...availableExtensions
|
|
818
819
|
].join(',')}}`
|
|
819
820
|
];
|
|
820
|
-
const entryFiles = await
|
|
821
|
+
const entryFiles = await fastGlob.glob(entryFilesPatterns, {
|
|
821
822
|
cwd: dirPath,
|
|
822
|
-
|
|
823
|
-
|
|
823
|
+
ignore: [
|
|
824
|
+
PRIVATE_GLOB_PATTERN
|
|
825
|
+
]
|
|
824
826
|
});
|
|
825
827
|
validateEntryFiles(entryFiles);
|
|
826
828
|
for (const file of entryFiles){
|
|
@@ -884,10 +886,11 @@ async function collectSourceEntriesByExportPath(sourceFolderPath, originalSubpat
|
|
|
884
886
|
...availableExtensions
|
|
885
887
|
].join(',');
|
|
886
888
|
const privatePattern = `**/_*{,/*}{,{.${suffixPattern}}}.{${extPattern}}`;
|
|
887
|
-
const privateFiles = await
|
|
889
|
+
const privateFiles = await fastGlob.glob(privatePattern, {
|
|
888
890
|
cwd: sourceFolderPath,
|
|
889
|
-
|
|
890
|
-
|
|
891
|
+
ignore: [
|
|
892
|
+
TESTS_GLOB_PATTERN
|
|
893
|
+
]
|
|
891
894
|
});
|
|
892
895
|
for (const file of privateFiles){
|
|
893
896
|
const sourceFileAbsolutePath = path__default.default.join(sourceFolderPath, file);
|
|
@@ -1497,6 +1500,7 @@ async function buildInputConfig(entry, bundleConfig, exportCondition, buildConte
|
|
|
1497
1500
|
decorators: true
|
|
1498
1501
|
};
|
|
1499
1502
|
const hasBrowserslistConfig = !!(browserslistConfig && !hasSpecifiedTsTarget);
|
|
1503
|
+
const sourceMap = bundleConfig.sourcemap;
|
|
1500
1504
|
const swcOptions = {
|
|
1501
1505
|
jsc: {
|
|
1502
1506
|
...!hasSpecifiedTsTarget && !hasBrowserslistConfig && {
|
|
@@ -1511,11 +1515,11 @@ async function buildInputConfig(entry, bundleConfig, exportCondition, buildConte
|
|
|
1511
1515
|
...shouldMinify && {
|
|
1512
1516
|
minify: {
|
|
1513
1517
|
...swcMinifyOptions,
|
|
1514
|
-
sourceMap:
|
|
1518
|
+
sourceMap: sourceMap
|
|
1515
1519
|
}
|
|
1516
1520
|
}
|
|
1517
1521
|
},
|
|
1518
|
-
sourceMaps:
|
|
1522
|
+
sourceMaps: sourceMap,
|
|
1519
1523
|
inlineSourcesContent: false,
|
|
1520
1524
|
isModule: true,
|
|
1521
1525
|
...hasBrowserslistConfig && {
|
|
@@ -1712,7 +1716,7 @@ async function buildOutputConfigs(bundleConfig, exportCondition, buildContext, d
|
|
|
1712
1716
|
interop: 'auto',
|
|
1713
1717
|
freeze: false,
|
|
1714
1718
|
strict: false,
|
|
1715
|
-
sourcemap: bundleConfig.sourcemap,
|
|
1719
|
+
sourcemap: bundleConfig.sourcemap && !dts,
|
|
1716
1720
|
manualChunks: createSplitChunks(pluginContext.moduleDirectiveLayerMap, entryFiles),
|
|
1717
1721
|
chunkFileNames () {
|
|
1718
1722
|
const isCjsFormat = format === 'cjs';
|
|
@@ -1826,6 +1830,16 @@ async function buildConfig(bundleConfig, exportCondition, pluginContext, bundleE
|
|
|
1826
1830
|
return Promise.all(outputConfigs);
|
|
1827
1831
|
}
|
|
1828
1832
|
|
|
1833
|
+
function normalizeError(error) {
|
|
1834
|
+
// Remove the noise from rollup plugin error
|
|
1835
|
+
if (error.code === 'PLUGIN_ERROR') {
|
|
1836
|
+
const normalizedError = new Error(error.message);
|
|
1837
|
+
normalizedError.stack = error.stack;
|
|
1838
|
+
error = normalizedError;
|
|
1839
|
+
}
|
|
1840
|
+
return error;
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1829
1843
|
async function createAssetRollupJobs(options, buildContext, bundleJobOptions) {
|
|
1830
1844
|
const { isFromCli, generateTypes } = bundleJobOptions;
|
|
1831
1845
|
const assetsConfigs = await buildEntryConfig(options, buildContext, {
|
|
@@ -1843,7 +1857,12 @@ async function createAssetRollupJobs(options, buildContext, bundleJobOptions) {
|
|
|
1843
1857
|
}
|
|
1844
1858
|
}
|
|
1845
1859
|
const rollupJobs = allConfigs.map((rollupConfig)=>bundleOrWatch(options, rollupConfig));
|
|
1846
|
-
|
|
1860
|
+
try {
|
|
1861
|
+
return await Promise.all(rollupJobs);
|
|
1862
|
+
} catch (err) {
|
|
1863
|
+
const error = normalizeError(err);
|
|
1864
|
+
throw error;
|
|
1865
|
+
}
|
|
1847
1866
|
}
|
|
1848
1867
|
async function bundleOrWatch(options, rollupConfig) {
|
|
1849
1868
|
if (options.watch) {
|
|
@@ -1889,7 +1908,7 @@ function hasMultiEntryExport(exportPaths) {
|
|
|
1889
1908
|
return exportKeys.length > 0 && exportKeys.every((name)=>name.startsWith('.'));
|
|
1890
1909
|
}
|
|
1891
1910
|
async function bundle(cliEntryPath, { cwd: _cwd, ...options } = {}) {
|
|
1892
|
-
var _options__callbacks_onBuildStart, _options__callbacks
|
|
1911
|
+
var _options__callbacks_onBuildStart, _options__callbacks;
|
|
1893
1912
|
const cwd = path.resolve(process.cwd(), _cwd || '');
|
|
1894
1913
|
assignDefault(options, 'format', 'esm');
|
|
1895
1914
|
assignDefault(options, 'minify', false);
|
|
@@ -1993,8 +2012,15 @@ async function bundle(cliEntryPath, { cwd: _cwd, ...options } = {}) {
|
|
|
1993
2012
|
isFromCli,
|
|
1994
2013
|
generateTypes
|
|
1995
2014
|
};
|
|
1996
|
-
|
|
1997
|
-
|
|
2015
|
+
try {
|
|
2016
|
+
var _options__callbacks_onBuildEnd, _options__callbacks1;
|
|
2017
|
+
const assetJobs = await createAssetRollupJobs(options, buildContext, rollupJobsOptions);
|
|
2018
|
+
(_options__callbacks1 = options._callbacks) == null ? void 0 : (_options__callbacks_onBuildEnd = _options__callbacks1.onBuildEnd) == null ? void 0 : _options__callbacks_onBuildEnd.call(_options__callbacks1, assetJobs);
|
|
2019
|
+
} catch (error) {
|
|
2020
|
+
var _options__callbacks_onBuildError, _options__callbacks2;
|
|
2021
|
+
(_options__callbacks2 = options._callbacks) == null ? undefined : (_options__callbacks_onBuildError = _options__callbacks2.onBuildError) == null ? undefined : _options__callbacks_onBuildError.call(_options__callbacks2, error);
|
|
2022
|
+
return Promise.reject(error);
|
|
2023
|
+
}
|
|
1998
2024
|
}
|
|
1999
2025
|
|
|
2000
2026
|
exports.bundle = bundle;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunchee",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.3",
|
|
4
4
|
"description": "zero config bundler for js/ts/jsx libraries",
|
|
5
5
|
"bin": "./dist/bin/cli.js",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@swc/core": "^1.10.7",
|
|
47
47
|
"@swc/helpers": "^0.5.11",
|
|
48
48
|
"clean-css": "^5.3.3",
|
|
49
|
-
"glob": "^
|
|
49
|
+
"fast-glob": "^3.3.3",
|
|
50
50
|
"magic-string": "^0.30.17",
|
|
51
51
|
"ora": "^8.0.1",
|
|
52
52
|
"picomatch": "^4.0.2",
|
|
@@ -72,10 +72,8 @@
|
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@huozhi/testing-package": "1.0.0",
|
|
74
74
|
"@swc-node/register": "^1.10.9",
|
|
75
|
-
"@swc/jest": "^0.2.37",
|
|
76
75
|
"@swc/types": "^0.1.17",
|
|
77
76
|
"@types/clean-css": "^4.2.11",
|
|
78
|
-
"@types/jest": "29.0.0",
|
|
79
77
|
"@types/node": "^22.9.3",
|
|
80
78
|
"@types/picomatch": "^3.0.1",
|
|
81
79
|
"@types/react": "19.0.1",
|
|
@@ -83,42 +81,22 @@
|
|
|
83
81
|
"bunchee": "link:./",
|
|
84
82
|
"cross-env": "^7.0.3",
|
|
85
83
|
"husky": "^9.0.11",
|
|
86
|
-
"jest": "29.7.0",
|
|
87
84
|
"lint-staged": "^15.2.2",
|
|
88
85
|
"next": "^15.0.4",
|
|
89
86
|
"picocolors": "^1.0.0",
|
|
90
|
-
"prettier": "
|
|
87
|
+
"prettier": "3.4.2",
|
|
91
88
|
"react": "^19.0.0",
|
|
92
89
|
"react-dom": "^19.0.0",
|
|
93
|
-
"typescript": "^5.7.2"
|
|
90
|
+
"typescript": "^5.7.2",
|
|
91
|
+
"vitest": "^3.0.4"
|
|
94
92
|
},
|
|
95
93
|
"lint-staged": {
|
|
96
94
|
"*.{js,jsx,ts,tsx,md,json,yml,yaml}": "prettier --write"
|
|
97
95
|
},
|
|
98
|
-
"jest": {
|
|
99
|
-
"moduleDirectories": [
|
|
100
|
-
"node_modules"
|
|
101
|
-
],
|
|
102
|
-
"moduleNameMapper": {
|
|
103
|
-
"^bunchee$": "<rootDir>/src/index.ts"
|
|
104
|
-
},
|
|
105
|
-
"transform": {
|
|
106
|
-
"^.+\\.(t|j)sx?$": [
|
|
107
|
-
"@swc/jest"
|
|
108
|
-
]
|
|
109
|
-
},
|
|
110
|
-
"testPathIgnorePatterns": [
|
|
111
|
-
"/node_modules/",
|
|
112
|
-
"<rootDir>/test/integration/.*/*src",
|
|
113
|
-
"<rootDir>/test/fixtures"
|
|
114
|
-
],
|
|
115
|
-
"testTimeout": 60000
|
|
116
|
-
},
|
|
117
96
|
"scripts": {
|
|
118
|
-
"test": "
|
|
119
|
-
"test:ci": "pnpm test -- --ci",
|
|
97
|
+
"test": "vitest run",
|
|
120
98
|
"test:update": "TEST_UPDATE_SNAPSHOT=1 pnpm test",
|
|
121
|
-
"test:post": "cross-env POST_BUILD=1 pnpm
|
|
99
|
+
"test:post": "cross-env POST_BUILD=1 pnpm test test/compile.test.ts test/integration.test.ts",
|
|
122
100
|
"docs:dev": "next dev docs",
|
|
123
101
|
"docs:build": "next build docs",
|
|
124
102
|
"clean": "rm -rf ./dist",
|