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 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 is same to CLI options
106
- await bundle(entryFilePath, options)
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.3";
30
+ var version = "2.1.4";
31
31
 
32
32
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
33
33
  try {
package/dist/lib.d.ts CHANGED
@@ -1,126 +1,34 @@
1
- import * as url from 'url';
2
- import * as worker_threads from 'worker_threads';
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 const spread: {
6
- globalThis: typeof globalThis;
7
- eval(x: string): any;
8
- parseInt(string: string, radix?: number | undefined): number;
9
- parseFloat(string: string): number;
10
- isNaN(number: number): boolean;
11
- isFinite(number: number): boolean;
12
- decodeURI(encodedURI: string): string;
13
- decodeURIComponent(encodedURIComponent: string): string;
14
- encodeURI(uri: string): string;
15
- encodeURIComponent(uriComponent: string | number | boolean): string;
16
- escape(string: string): string;
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 function loadList(): Promise<number[]>;
115
- declare const optionalChainFn: {
116
- <T>(this: T, thisArg: ThisParameterType<T>): OmitThisParameter<T>;
117
- <T_1, A0, A_1 extends any[], R>(this: (this: T_1, arg0: A0, ...args: A_1) => R, thisArg: T_1, arg0: A0): (...args: A_1) => R;
118
- <T_2, A0_1, A1, A_2 extends any[], R_1>(this: (this: T_2, arg0: A0_1, arg1: A1, ...args: A_2) => R_1, thisArg: T_2, arg0: A0_1, arg1: A1): (...args: A_2) => R_1;
119
- <T_3, A0_2, A1_1, A2, A_3 extends any[], R_2>(this: (this: T_3, arg0: A0_2, arg1: A1_1, arg2: A2, ...args: A_3) => R_2, thisArg: T_3, arg0: A0_2, arg1: A1_1, arg2: A2): (...args: A_3) => R_2;
120
- <T_4, A0_3, A1_2, A2_1, A3, A_4 extends any[], R_3>(this: (this: T_4, arg0: A0_3, arg1: A1_2, arg2: A2_1, arg3: A3, ...args: A_4) => R_3, thisArg: T_4, arg0: A0_3, arg1: A1_2, arg2: A2_1, arg3: A3): (...args: A_4) => R_3;
121
- <T_5, AX, R_4>(this: (this: T_5, ...args: AX[]) => R_4, thisArg: T_5, ...args: AX[]): (...args: AX[]) => R_4;
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
- export { A, loadList, optionalChainFn, spread };
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") : file ? name + ".d.ts" : typings;
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 format = (ref1 = outputExports[0]) == null ? void 0 : ref1.format;
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 || format,
409
+ format: cliArgs.format || fallbackFormat,
411
410
  useTypescript: useTypescript
412
411
  }), pkg, typescriptOptions),
413
412
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunchee",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "description": "zero config bundler for js/ts/jsx libraries",
5
5
  "bin": {
6
6
  "bunchee": "./dist/cli.js"