bunchee 2.1.3 → 2.1.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/README.md +12 -2
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +1 -1
- package/dist/lib.d.ts +29 -121
- package/dist/lib.js +3 -4
- package/package.json +1 -1
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
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
|
@@ -334,7 +334,7 @@ function buildOutputConfigs(options, pkg, param) {
|
|
|
334
334
|
var dtsDir = typings ? path.dirname(path.resolve(config.rootDir, typings)) : path.resolve(config.rootDir, "dist");
|
|
335
335
|
// file base name without extension
|
|
336
336
|
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") :
|
|
337
|
+
var dtsFile = file ? name + ".d.ts" : (exportCondition == null ? void 0 : exportCondition.name) ? path.resolve(dtsDir, (exportCondition.name === "." ? "index" : exportCondition.name) + ".d.ts") : typings;
|
|
338
338
|
// If there's dts file, use `output.file`
|
|
339
339
|
var dtsPathConfig = dtsFile ? {
|
|
340
340
|
file: dtsFile
|
|
@@ -386,7 +386,6 @@ function buildConfig(entry, pkg, cliArgs, dtsOnly) {
|
|
|
386
386
|
if (dtsOnly) {
|
|
387
387
|
outputConfigs = [
|
|
388
388
|
buildOutputConfigs(_extends$1({}, cliArgs, {
|
|
389
|
-
file: undefined,
|
|
390
389
|
format: "es",
|
|
391
390
|
useTypescript: useTypescript
|
|
392
391
|
}), pkg, typescriptOptions),
|
|
@@ -403,11 +402,11 @@ function buildConfig(entry, pkg, cliArgs, dtsOnly) {
|
|
|
403
402
|
// CLI output option is always prioritized
|
|
404
403
|
if (file) {
|
|
405
404
|
var ref1;
|
|
406
|
-
var
|
|
405
|
+
var fallbackFormat = (ref1 = outputExports[0]) == null ? void 0 : ref1.format;
|
|
407
406
|
outputConfigs = [
|
|
408
407
|
buildOutputConfigs(_extends$1({}, cliArgs, {
|
|
409
408
|
file: file,
|
|
410
|
-
format: cliArgs.format ||
|
|
409
|
+
format: cliArgs.format || fallbackFormat,
|
|
411
410
|
useTypescript: useTypescript
|
|
412
411
|
}), pkg, typescriptOptions),
|
|
413
412
|
];
|