bunchee 2.1.3 → 2.1.5
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 +12 -2
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +14 -4
- package/dist/lib.d.ts +29 -121
- package/dist/lib.js +33 -19
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -100,10 +100,20 @@ bunchee ./src/index.js -f esm -o ./dist/bundle.esm.js
|
|
|
100
100
|
### Node.js API
|
|
101
101
|
|
|
102
102
|
```js
|
|
103
|
+
import path from 'path'
|
|
103
104
|
import { bundle } from 'bunchee'
|
|
104
105
|
|
|
105
|
-
// options
|
|
106
|
-
await bundle(
|
|
106
|
+
// The definition of these options can be found in help information
|
|
107
|
+
await bundle(path.resolve('./src/index.ts'), {
|
|
108
|
+
dts: false,
|
|
109
|
+
watch: false,
|
|
110
|
+
minify: false,
|
|
111
|
+
sourcemap: false,
|
|
112
|
+
external: [],
|
|
113
|
+
format: 'esm',
|
|
114
|
+
target: 'es2016',
|
|
115
|
+
runtime: 'nodejs',
|
|
116
|
+
})
|
|
107
117
|
```
|
|
108
118
|
|
|
109
119
|
### Typescript
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.js
CHANGED
|
@@ -27,7 +27,7 @@ var logger = {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
var version = "2.1.
|
|
30
|
+
var version = "2.1.5";
|
|
31
31
|
|
|
32
32
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
33
33
|
try {
|
|
@@ -208,15 +208,25 @@ function run(args) {
|
|
|
208
208
|
}
|
|
209
209
|
function _run() {
|
|
210
210
|
_run = _asyncToGenerator(function(args) {
|
|
211
|
-
var source, format, watch, minify, sourcemap, target, runtime, dts, cwd, file, cliArgs,
|
|
211
|
+
var source, format, watch, minify, sourcemap, target, runtime, dts, cwd, file, cliArgs, entry, bundle, timeStart, timeEnd, err, duration;
|
|
212
212
|
return __generator(this, function(_state) {
|
|
213
213
|
switch(_state.label){
|
|
214
214
|
case 0:
|
|
215
215
|
source = args.source, format = args.format, watch = args.watch, minify = args.minify, sourcemap = args.sourcemap, target = args.target, runtime = args.runtime, dts = args.dts;
|
|
216
216
|
cwd = args.cwd || process.cwd();
|
|
217
217
|
file = args.file ? path__default["default"].resolve(cwd, args.file) : undefined;
|
|
218
|
-
|
|
219
|
-
|
|
218
|
+
cliArgs = {
|
|
219
|
+
dts: dts,
|
|
220
|
+
file: file,
|
|
221
|
+
format: format,
|
|
222
|
+
cwd: cwd,
|
|
223
|
+
target: target,
|
|
224
|
+
runtime: runtime,
|
|
225
|
+
external: args.external || [],
|
|
226
|
+
watch: !!watch,
|
|
227
|
+
minify: !!minify,
|
|
228
|
+
sourcemap: sourcemap === false ? false : true
|
|
229
|
+
};
|
|
220
230
|
if (args.version) {
|
|
221
231
|
return [
|
|
222
232
|
2,
|
package/dist/lib.d.ts
CHANGED
|
@@ -1,126 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import * as _babel_core from '@babel/core';
|
|
1
|
+
import { JscTarget } from '@swc/core';
|
|
2
|
+
import { RollupOptions, InputOptions, OutputOptions } from 'rollup';
|
|
4
3
|
|
|
5
|
-
declare
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
unescape(string: string): string;
|
|
18
|
-
NaN: number;
|
|
19
|
-
Infinity: number;
|
|
20
|
-
Symbol: SymbolConstructor;
|
|
21
|
-
Object: ObjectConstructor;
|
|
22
|
-
Function: FunctionConstructor;
|
|
23
|
-
String: StringConstructor;
|
|
24
|
-
Boolean: BooleanConstructor;
|
|
25
|
-
Number: NumberConstructor;
|
|
26
|
-
Math: Math;
|
|
27
|
-
Date: DateConstructor;
|
|
28
|
-
RegExp: RegExpConstructor;
|
|
29
|
-
Error: ErrorConstructor;
|
|
30
|
-
EvalError: EvalErrorConstructor;
|
|
31
|
-
RangeError: RangeErrorConstructor;
|
|
32
|
-
ReferenceError: ReferenceErrorConstructor;
|
|
33
|
-
SyntaxError: SyntaxErrorConstructor;
|
|
34
|
-
TypeError: TypeErrorConstructor;
|
|
35
|
-
URIError: URIErrorConstructor;
|
|
36
|
-
JSON: JSON;
|
|
37
|
-
Array: ArrayConstructor;
|
|
38
|
-
Promise: PromiseConstructor;
|
|
39
|
-
ArrayBuffer: ArrayBufferConstructor;
|
|
40
|
-
DataView: DataViewConstructor;
|
|
41
|
-
Int8Array: Int8ArrayConstructor;
|
|
42
|
-
Uint8Array: Uint8ArrayConstructor;
|
|
43
|
-
Uint8ClampedArray: Uint8ClampedArrayConstructor;
|
|
44
|
-
Int16Array: Int16ArrayConstructor;
|
|
45
|
-
Uint16Array: Uint16ArrayConstructor;
|
|
46
|
-
Int32Array: Int32ArrayConstructor;
|
|
47
|
-
Uint32Array: Uint32ArrayConstructor;
|
|
48
|
-
Float32Array: Float32ArrayConstructor;
|
|
49
|
-
Float64Array: Float64ArrayConstructor;
|
|
50
|
-
Intl: typeof Intl;
|
|
51
|
-
Map: MapConstructor;
|
|
52
|
-
WeakMap: WeakMapConstructor;
|
|
53
|
-
Set: SetConstructor;
|
|
54
|
-
WeakSet: WeakSetConstructor;
|
|
55
|
-
Proxy: ProxyConstructor;
|
|
56
|
-
Reflect: typeof Reflect;
|
|
57
|
-
SharedArrayBuffer: SharedArrayBufferConstructor;
|
|
58
|
-
Atomics: Atomics;
|
|
59
|
-
BigInt: BigIntConstructor;
|
|
60
|
-
BigInt64Array: BigInt64ArrayConstructor;
|
|
61
|
-
BigUint64Array: BigUint64ArrayConstructor;
|
|
62
|
-
babel: typeof _babel_core;
|
|
63
|
-
structuredClone<T>(value: T, transfer?: {
|
|
64
|
-
transfer: readonly worker_threads.TransferListItem[];
|
|
65
|
-
} | undefined): T;
|
|
66
|
-
process: NodeJS.Process;
|
|
67
|
-
console: Console;
|
|
68
|
-
__filename: string;
|
|
69
|
-
__dirname: string;
|
|
70
|
-
require: NodeRequire;
|
|
71
|
-
module: NodeModule;
|
|
72
|
-
exports: any;
|
|
73
|
-
gc: (() => void) | undefined;
|
|
74
|
-
AbortController: {
|
|
75
|
-
new (): AbortController;
|
|
76
|
-
prototype: AbortController;
|
|
4
|
+
declare type ExportType = 'require' | 'export' | 'default' | string;
|
|
5
|
+
declare type CommonConfig = {
|
|
6
|
+
dts?: boolean;
|
|
7
|
+
format?: OutputOptions['format'];
|
|
8
|
+
minify?: boolean;
|
|
9
|
+
sourcemap?: boolean;
|
|
10
|
+
external?: string[];
|
|
11
|
+
runtime?: string;
|
|
12
|
+
exportCondition?: {
|
|
13
|
+
source: string;
|
|
14
|
+
name: string;
|
|
15
|
+
export: ExportCondition;
|
|
77
16
|
};
|
|
78
|
-
AbortSignal: {
|
|
79
|
-
new (): AbortSignal;
|
|
80
|
-
prototype: AbortSignal;
|
|
81
|
-
};
|
|
82
|
-
global: typeof globalThis;
|
|
83
|
-
spyOn<T_1>(object: T_1, method: keyof T_1): jasmine.Spy;
|
|
84
|
-
pending(reason?: string | undefined): void;
|
|
85
|
-
fail(error?: any): never;
|
|
86
|
-
beforeAll: jest.Lifecycle;
|
|
87
|
-
beforeEach: jest.Lifecycle;
|
|
88
|
-
afterAll: jest.Lifecycle;
|
|
89
|
-
afterEach: jest.Lifecycle;
|
|
90
|
-
describe: jest.Describe;
|
|
91
|
-
fdescribe: jest.Describe;
|
|
92
|
-
xdescribe: jest.Describe;
|
|
93
|
-
it: jest.It;
|
|
94
|
-
fit: jest.It;
|
|
95
|
-
xit: jest.It;
|
|
96
|
-
test: jest.It;
|
|
97
|
-
xtest: jest.It;
|
|
98
|
-
jest: typeof jest;
|
|
99
|
-
jasmine: typeof jasmine;
|
|
100
|
-
atob(data: string): string;
|
|
101
|
-
btoa(data: string): string;
|
|
102
|
-
Buffer: BufferConstructor;
|
|
103
|
-
setTimeout: typeof setTimeout;
|
|
104
|
-
clearTimeout(timeoutId: string | number | NodeJS.Timeout | undefined): void;
|
|
105
|
-
setInterval: typeof setInterval;
|
|
106
|
-
clearInterval(intervalId: string | number | NodeJS.Timeout | undefined): void;
|
|
107
|
-
setImmediate: typeof setImmediate;
|
|
108
|
-
clearImmediate(immediateId: NodeJS.Immediate | undefined): void;
|
|
109
|
-
queueMicrotask(callback: () => void): void;
|
|
110
|
-
URLSearchParams: typeof url.URLSearchParams;
|
|
111
|
-
URL: typeof url.URL;
|
|
112
|
-
undefined: undefined;
|
|
113
17
|
};
|
|
114
|
-
declare
|
|
115
|
-
declare
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
18
|
+
declare type ExportCondition = string | Record<ExportType, string>;
|
|
19
|
+
declare type BuncheeRollupConfig = Partial<Omit<RollupOptions, 'input' | 'output'>> & {
|
|
20
|
+
exportName?: string;
|
|
21
|
+
input: InputOptions;
|
|
22
|
+
output: OutputOptions[];
|
|
23
|
+
dtsOnly: boolean;
|
|
24
|
+
};
|
|
25
|
+
declare type CliArgs = CommonConfig & {
|
|
26
|
+
file?: string;
|
|
27
|
+
watch?: boolean;
|
|
28
|
+
cwd?: string;
|
|
29
|
+
target?: JscTarget;
|
|
122
30
|
};
|
|
123
|
-
declare class A {
|
|
124
|
-
}
|
|
125
31
|
|
|
126
|
-
|
|
32
|
+
declare function bundle(entryPath: string, { cwd, ...options }?: CliArgs): Promise<any>;
|
|
33
|
+
|
|
34
|
+
export { BuncheeRollupConfig, CliArgs, bundle };
|
package/dist/lib.js
CHANGED
|
@@ -7,7 +7,7 @@ var rollupPluginSwc3 = require('rollup-plugin-swc3');
|
|
|
7
7
|
var commonjs = require('@rollup/plugin-commonjs');
|
|
8
8
|
var shebang = require('rollup-plugin-preserve-shebang');
|
|
9
9
|
var json = require('@rollup/plugin-json');
|
|
10
|
-
var
|
|
10
|
+
var pluginNodeResolve = require('@rollup/plugin-node-resolve');
|
|
11
11
|
var module$1 = require('module');
|
|
12
12
|
|
|
13
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -17,7 +17,6 @@ var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
|
17
17
|
var commonjs__default = /*#__PURE__*/_interopDefaultLegacy(commonjs);
|
|
18
18
|
var shebang__default = /*#__PURE__*/_interopDefaultLegacy(shebang);
|
|
19
19
|
var json__default = /*#__PURE__*/_interopDefaultLegacy(json);
|
|
20
|
-
var nodeResolve__default = /*#__PURE__*/_interopDefaultLegacy(nodeResolve);
|
|
21
20
|
|
|
22
21
|
var rootDir = process.cwd();
|
|
23
22
|
var config = {
|
|
@@ -255,9 +254,9 @@ function buildInputConfig(entry, pkg, options, param) {
|
|
|
255
254
|
incremental: false,
|
|
256
255
|
jsx: (tsCompilerOptions == null ? void 0 : tsCompilerOptions.jsx) || "react"
|
|
257
256
|
})
|
|
258
|
-
})
|
|
257
|
+
})
|
|
259
258
|
] : [
|
|
260
|
-
|
|
259
|
+
pluginNodeResolve.nodeResolve({
|
|
261
260
|
preferBuiltins: runtime === "node",
|
|
262
261
|
extensions: [
|
|
263
262
|
".mjs",
|
|
@@ -290,7 +289,7 @@ function buildInputConfig(entry, pkg, options, param) {
|
|
|
290
289
|
}),
|
|
291
290
|
sourceMaps: options.sourcemap,
|
|
292
291
|
inlineSourcesContent: false
|
|
293
|
-
})
|
|
292
|
+
})
|
|
294
293
|
]).filter(isNotNull);
|
|
295
294
|
return {
|
|
296
295
|
input: entry,
|
|
@@ -334,7 +333,7 @@ function buildOutputConfigs(options, pkg, param) {
|
|
|
334
333
|
var dtsDir = typings ? path.dirname(path.resolve(config.rootDir, typings)) : path.resolve(config.rootDir, "dist");
|
|
335
334
|
// file base name without extension
|
|
336
335
|
var name = file ? file.replace(new RegExp("" + path.extname(file) + "$"), "") : undefined;
|
|
337
|
-
var dtsFile = (exportCondition == null ? void 0 : exportCondition.name) ? path.resolve(dtsDir, (exportCondition.name === "." ? "index" : exportCondition.name) + ".d.ts") :
|
|
336
|
+
var dtsFile = file ? name + ".d.ts" : (exportCondition == null ? void 0 : exportCondition.name) ? path.resolve(dtsDir, (exportCondition.name === "." ? "index" : exportCondition.name) + ".d.ts") : typings;
|
|
338
337
|
// If there's dts file, use `output.file`
|
|
339
338
|
var dtsPathConfig = dtsFile ? {
|
|
340
339
|
file: dtsFile
|
|
@@ -386,10 +385,9 @@ function buildConfig(entry, pkg, cliArgs, dtsOnly) {
|
|
|
386
385
|
if (dtsOnly) {
|
|
387
386
|
outputConfigs = [
|
|
388
387
|
buildOutputConfigs(_extends$1({}, cliArgs, {
|
|
389
|
-
file: undefined,
|
|
390
388
|
format: "es",
|
|
391
389
|
useTypescript: useTypescript
|
|
392
|
-
}), pkg, typescriptOptions)
|
|
390
|
+
}), pkg, typescriptOptions)
|
|
393
391
|
];
|
|
394
392
|
} else {
|
|
395
393
|
// multi outputs with specified format
|
|
@@ -403,13 +401,13 @@ function buildConfig(entry, pkg, cliArgs, dtsOnly) {
|
|
|
403
401
|
// CLI output option is always prioritized
|
|
404
402
|
if (file) {
|
|
405
403
|
var ref1;
|
|
406
|
-
var
|
|
404
|
+
var fallbackFormat = (ref1 = outputExports[0]) == null ? void 0 : ref1.format;
|
|
407
405
|
outputConfigs = [
|
|
408
406
|
buildOutputConfigs(_extends$1({}, cliArgs, {
|
|
409
407
|
file: file,
|
|
410
|
-
format: cliArgs.format ||
|
|
408
|
+
format: cliArgs.format || fallbackFormat,
|
|
411
409
|
useTypescript: useTypescript
|
|
412
|
-
}), pkg, typescriptOptions)
|
|
410
|
+
}), pkg, typescriptOptions)
|
|
413
411
|
];
|
|
414
412
|
}
|
|
415
413
|
}
|
|
@@ -476,6 +474,24 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
476
474
|
}
|
|
477
475
|
return target;
|
|
478
476
|
}
|
|
477
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
478
|
+
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
479
|
+
if (it) return (it = it.call(o)).next.bind(it);
|
|
480
|
+
if (Array.isArray(o) || (it = unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
481
|
+
if (it) o = it;
|
|
482
|
+
var i = 0;
|
|
483
|
+
return function() {
|
|
484
|
+
if (i >= o.length) return {
|
|
485
|
+
done: true
|
|
486
|
+
};
|
|
487
|
+
return {
|
|
488
|
+
done: false,
|
|
489
|
+
value: o[i++]
|
|
490
|
+
};
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
throw new TypeError("Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
494
|
+
}
|
|
479
495
|
var __generator = undefined && undefined.__generator || function(thisArg, body) {
|
|
480
496
|
var f, y, t, g, _ = {
|
|
481
497
|
label: 0,
|
|
@@ -590,8 +606,8 @@ function getSourcePathFromExportPath(cwd, exportPath) {
|
|
|
590
606
|
"ts",
|
|
591
607
|
"tsx"
|
|
592
608
|
];
|
|
593
|
-
for(var
|
|
594
|
-
var ext =
|
|
609
|
+
for(var _iterator = _createForOfIteratorHelperLoose(exts), _step; !(_step = _iterator()).done;){
|
|
610
|
+
var ext = _step.value;
|
|
595
611
|
// ignore package.json
|
|
596
612
|
if (exportPath.endsWith("package.json")) return;
|
|
597
613
|
if (exportPath === ".") exportPath = "./index";
|
|
@@ -607,7 +623,7 @@ function bundle(entryPath) {
|
|
|
607
623
|
}
|
|
608
624
|
function _bundle() {
|
|
609
625
|
_bundle = _asyncToGenerator(function(entryPath, _param) {
|
|
610
|
-
var cwd, options, pkg, packageExports,
|
|
626
|
+
var cwd, options, pkg, packageExports, isSingleEntry, hasMultiEntries, bundleOrWatch, hasSpecifiedEntryFile, err, hasTypings, assetsJobs, typesJobs, rollupConfig;
|
|
611
627
|
function buildEntryConfig(packageExports, dtsOnly) {
|
|
612
628
|
var configs = Object.keys(packageExports).map(function(entryExport) {
|
|
613
629
|
var source = getSourcePathFromExportPath(config.rootDir, entryExport);
|
|
@@ -641,8 +657,7 @@ function _bundle() {
|
|
|
641
657
|
options.dts = true;
|
|
642
658
|
}
|
|
643
659
|
pkg = getPackageMeta(config.rootDir);
|
|
644
|
-
|
|
645
|
-
packageExports = pkg.exports || _tmp;
|
|
660
|
+
packageExports = pkg.exports || {};
|
|
646
661
|
isSingleEntry = typeof packageExports === "string";
|
|
647
662
|
hasMultiEntries = packageExports && !isSingleEntry && Object.keys(packageExports).length > 0;
|
|
648
663
|
if (isSingleEntry) {
|
|
@@ -674,8 +689,7 @@ function _bundle() {
|
|
|
674
689
|
Promise.reject(err)
|
|
675
690
|
];
|
|
676
691
|
}
|
|
677
|
-
|
|
678
|
-
hasTypings = !!getTypings(pkg) || typeof packageExports === "object" && Array.from(Object.values(packageExports || _tmp1)).some(function(condition) {
|
|
692
|
+
hasTypings = !!getTypings(pkg) || typeof packageExports === "object" && Array.from(Object.values(packageExports || {})).some(function(condition) {
|
|
679
693
|
return condition.hasOwnProperty("types");
|
|
680
694
|
});
|
|
681
695
|
// If there's no entry file specified, should enable dts bundling based on package.json exports info
|
|
@@ -741,7 +755,7 @@ function runWatch(param, metadata) {
|
|
|
741
755
|
"node_modules/**"
|
|
742
756
|
]
|
|
743
757
|
}
|
|
744
|
-
})
|
|
758
|
+
})
|
|
745
759
|
];
|
|
746
760
|
var watcher = rollup.watch(watchOptions);
|
|
747
761
|
var startTime = Date.now();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunchee",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
4
4
|
"description": "zero config bundler for js/ts/jsx libraries",
|
|
5
5
|
"bin": {
|
|
6
6
|
"bunchee": "./dist/cli.js"
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@rollup/plugin-commonjs": "22.0.2",
|
|
42
42
|
"@rollup/plugin-json": "4.1.0",
|
|
43
|
-
"@rollup/plugin-node-resolve": "
|
|
44
|
-
"@swc/core": "^1.3.
|
|
43
|
+
"@rollup/plugin-node-resolve": "14.1.0",
|
|
44
|
+
"@swc/core": "^1.3.5",
|
|
45
45
|
"arg": "5.0.0",
|
|
46
|
-
"rollup": "2.
|
|
47
|
-
"rollup-plugin-dts": "4.2.
|
|
46
|
+
"rollup": "2.79.1",
|
|
47
|
+
"rollup-plugin-dts": "4.2.3",
|
|
48
48
|
"rollup-plugin-preserve-shebang": "1.0.1",
|
|
49
49
|
"rollup-plugin-swc3": "0.6.0",
|
|
50
50
|
"tslib": "2.4.0"
|