bunchee 3.0.0-beta.11 → 3.0.0-beta.12
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 +118 -83
- package/dist/cli.js +68 -29
- package/dist/{lib.d.ts → index.d.ts} +11 -17
- package/dist/{lib.js → index.js} +151 -62
- package/package.json +14 -12
package/README.md
CHANGED
|
@@ -22,31 +22,19 @@ npm install --save-dev bunchee
|
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## Usage
|
|
25
|
-
### Package.json Configuration
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
Create your library
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
```json
|
|
34
|
-
{
|
|
35
|
-
"main": "dist/pkg.cjs.js",
|
|
36
|
-
"module": "dist/pkg.esm.js",
|
|
37
|
-
"scripts": {
|
|
38
|
-
"build": "bunchee ./src/index.js"
|
|
39
|
-
},
|
|
40
|
-
"types": "dist/types/index.d.ts"
|
|
41
|
-
}
|
|
28
|
+
```sh
|
|
29
|
+
cd ./my-lib && mkdir src
|
|
30
|
+
touch ./src/index.js
|
|
31
|
+
touch package.json
|
|
42
32
|
```
|
|
43
|
-
|
|
44
|
-
#### Configure `exports` field
|
|
33
|
+
Configure module exports
|
|
45
34
|
|
|
46
35
|
[exports sugar in Node.js](https://nodejs.org/api/packages.html#exports-sugar)
|
|
47
36
|
|
|
48
|
-
You can use the exports field to support different conditions and leverage the same functionality as other bundlers, such as webpack. The exports field allows you to define multiple conditions.
|
|
49
|
-
|
|
37
|
+
You can use the `exports` field to support different conditions and leverage the same functionality as other bundlers, such as webpack. The exports field allows you to define multiple conditions.
|
|
50
38
|
|
|
51
39
|
```json
|
|
52
40
|
{
|
|
@@ -56,102 +44,96 @@ You can use the exports field to support different conditions and leverage the s
|
|
|
56
44
|
"module": "dist/index.esm.js"
|
|
57
45
|
},
|
|
58
46
|
"scripts": {
|
|
59
|
-
"build": "bunchee
|
|
47
|
+
"build": "bunchee"
|
|
60
48
|
},
|
|
61
49
|
}
|
|
62
50
|
```
|
|
63
51
|
|
|
64
|
-
|
|
52
|
+
Using pure ESM package?
|
|
65
53
|
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"type": "module",
|
|
57
|
+
"main": "./dist/index.js",
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "bunchee"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
66
62
|
```
|
|
67
|
-
Usage: bunchee [options]
|
|
68
|
-
|
|
69
|
-
Options:
|
|
70
|
-
-v, --version output the version number
|
|
71
|
-
-w, --watch watch src files changes
|
|
72
|
-
-m, --minify compress output. default: false
|
|
73
|
-
-o, --output <file> specify output filename
|
|
74
|
-
-f, --format <format> type of output (esm, amd, cjs, iife, umd, system), default: esm
|
|
75
|
-
-e, --external <mod> specify an external dependency
|
|
76
|
-
-h, --help output usage information
|
|
77
|
-
--target <target> js features target: swc target es versions. default: es2015
|
|
78
|
-
--runtime <runtime> build runtime (nodejs, browser). default: browser
|
|
79
|
-
--cwd <cwd> specify current working directory
|
|
80
|
-
--sourcemap enable sourcemap generation, default: false
|
|
81
|
-
--dts determine if need to generate types, default: false
|
|
82
|
-
|
|
83
|
-
Usage:
|
|
84
|
-
$ bunchee ./src/index.js # if you set main fields in package.json
|
|
85
|
-
$ bunchee ./src/index.ts -o ./dist/bundle.js # specify the dist file path
|
|
86
|
-
```
|
|
87
63
|
|
|
88
|
-
|
|
64
|
+
Then just run `npm run build`, or `pnpm build` / `yarn build` if you're using these package managers.
|
|
65
|
+
|
|
66
|
+
## Configuration
|
|
67
|
+
|
|
68
|
+
`bunchee` CLI provides few options to create different bundles or generating types.
|
|
69
|
+
|
|
70
|
+
### CLI Options
|
|
71
|
+
|
|
72
|
+
- Output (`-o <file>`): Specify output filename.
|
|
73
|
+
- Format (`-f <format>`): Set output format (default: `'esm'`).
|
|
74
|
+
- External (`--external <dep,>`): Specifying extra external dependencies, by default it is the list of `dependencies` and `peerDependencies` from `package.json`. Values are separate by comma.
|
|
75
|
+
- Target (`--target <target>`): Set ECMAScript target (default: `'es2016'`).
|
|
76
|
+
- Runtime (`--runtime <runtime>`): Set build runtime (default: `'browser'`).
|
|
77
|
+
- Environment (`--env <env,>`): Define environment variables. (default: `NODE_ENV`, separate by comma)
|
|
78
|
+
- Working Directory (`--cwd <cwd>`): Set current working directory where containing `package.json`.
|
|
79
|
+
- Types only (`--dts`): Generate TypeScript declaration files without assets.
|
|
80
|
+
- Minify (`-m`): Compress output.
|
|
81
|
+
- Watch (`-w`): Watch for source file changes.
|
|
82
|
+
|
|
83
|
+
### Basic Example
|
|
89
84
|
|
|
90
85
|
```sh
|
|
91
86
|
cd <project-root-dir>
|
|
92
|
-
bunchee ./src/index.js -f cjs -o ./dist/bundle.js
|
|
93
87
|
|
|
88
|
+
# specifying input, output and format
|
|
89
|
+
|
|
90
|
+
bunchee ./src/index.js -f cjs -o ./dist/bundle.js
|
|
94
91
|
bunchee ./src/index.js -f esm -o ./dist/bundle.esm.js
|
|
95
|
-
|
|
96
|
-
#
|
|
92
|
+
|
|
93
|
+
# build node.js library, or change target to es2019
|
|
94
|
+
bunchee ./src/index.js --runtime node --target es2019
|
|
97
95
|
```
|
|
98
96
|
|
|
99
|
-
|
|
97
|
+
#### Specifying extra external dependencies
|
|
100
98
|
|
|
101
|
-
|
|
102
|
-
import path from 'path'
|
|
103
|
-
import { bundle } from 'bunchee'
|
|
99
|
+
If you want to mark specific dependencies as external and not include them in the bundle, use the `--external` option followed by a comma-separated list of dependency names:
|
|
104
100
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
dts: false,
|
|
108
|
-
watch: false,
|
|
109
|
-
minify: false,
|
|
110
|
-
sourcemap: false,
|
|
111
|
-
external: [],
|
|
112
|
-
format: 'esm',
|
|
113
|
-
target: 'es2016',
|
|
114
|
-
runtime: 'nodejs',
|
|
115
|
-
})
|
|
101
|
+
```sh
|
|
102
|
+
bunchee --external=dependency1,dependency2,dependency3
|
|
116
103
|
```
|
|
117
104
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
Bunchee offers a convenient watch mode for rebuilding your library whenever changes are made to the source files. To enable this feature, use either -w or --watch.
|
|
105
|
+
Replace `dependency1`, `dependency2`, and `dependency3` with the names of the dependencies you want to exclude from the bundle.
|
|
121
106
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
By default bunchee includes Typescript v3.9.x inside as a dependency. If you want to use your own version, just install typescript as another dev dependency then bunchee will automatically pick it.
|
|
107
|
+
#### Bundling everything without external dependencies
|
|
108
|
+
To bundle your library without external dependencies, use the `--no-external` option:
|
|
125
109
|
|
|
126
110
|
```sh
|
|
127
|
-
|
|
111
|
+
bunchee --no-external
|
|
128
112
|
```
|
|
113
|
+
This will include all dependencies within your output bundle.
|
|
129
114
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
This library requires at least [TypeScript 3.7](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html).
|
|
133
|
-
|
|
115
|
+
### Environment Variables
|
|
116
|
+
To pass environment variables to your bundled code, use the --env option followed by a comma-separated list of environment variable names:
|
|
134
117
|
|
|
135
|
-
|
|
118
|
+
```bash
|
|
119
|
+
bunchee --env=ENV1,ENV2,ENV3
|
|
120
|
+
```
|
|
136
121
|
|
|
137
|
-
|
|
122
|
+
Replace `ENV1`, `ENV2`, and `ENV3` with the names of the environment variables you want to include in your bundled code. These environment variables will be inlined during the bundling process.
|
|
138
123
|
|
|
139
|
-
## Advanced
|
|
140
124
|
|
|
141
|
-
###
|
|
125
|
+
### Entry Files Convention
|
|
142
126
|
|
|
143
127
|
While `exports` filed is becoming the standard of exporting in node.js, bunchee also supports to build multiple exports all in one command.
|
|
144
128
|
|
|
145
129
|
What you need to do is just add an entry file with the name (`[name].[ext]`) that matches the exported name from exports field in package.json. For instance:
|
|
146
130
|
|
|
147
|
-
*
|
|
148
|
-
*
|
|
131
|
+
* `<cwd>/src/index.ts` will match `"."` export name or the if there's only one main export.
|
|
132
|
+
* `<cwd>/src/lite.ts` will match `"./lite"` export name.
|
|
149
133
|
|
|
150
134
|
The build script will be simplified to just `bunchee` in package.json without configure any input sources for each exports. Of course you can still specify other arguments as you need.
|
|
151
135
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
Assuming you have main entry export `"."` and subpath export `"./lite"` with different exports condition listed in package.json
|
|
136
|
+
Assuming you have default export package as `"."` and subpath export `"./lite"` with different exports condition listed in package.json
|
|
155
137
|
|
|
156
138
|
```json
|
|
157
139
|
{
|
|
@@ -172,13 +154,66 @@ Assuming you have main entry export `"."` and subpath export `"./lite"` with dif
|
|
|
172
154
|
Then you need to add two entry files `index.ts` and `lite.ts` in project root directory to match the export name `"."` and `"./lite"`, bunchee will associate these entry files with export names then use them as input source and output paths information.
|
|
173
155
|
|
|
174
156
|
```
|
|
175
|
-
-
|
|
176
|
-
|- lite.ts
|
|
177
|
-
|- index.ts
|
|
157
|
+
- my-lib/
|
|
178
158
|
|- src/
|
|
159
|
+
|- lite.ts
|
|
160
|
+
|- index.ts
|
|
179
161
|
|- package.json
|
|
180
162
|
```
|
|
181
163
|
|
|
164
|
+
#### Package lint
|
|
165
|
+
|
|
166
|
+
`bunchee` has support for checking the package bundles are matched with package exports configuration.
|
|
167
|
+
|
|
168
|
+
### TypeScript
|
|
169
|
+
|
|
170
|
+
By default bunchee includes Typescript v3.9.x inside as a dependency. If you want to use your own version, just install typescript as another dev dependency then bunchee will automatically pick it.
|
|
171
|
+
|
|
172
|
+
```sh
|
|
173
|
+
yarn add -D bunchee typescript
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Create `tsconfig.json` to specify any compiler options for TypeScript.
|
|
177
|
+
|
|
178
|
+
This library requires at least [TypeScript 3.7](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html).
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
Adding `"types"` or `"typing"` field in your package.json, types will be generated with that path.
|
|
182
|
+
|
|
183
|
+
```json
|
|
184
|
+
{
|
|
185
|
+
"types": "dist/types/index.d.ts"
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Node.js API
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
import path from 'path'
|
|
193
|
+
import { bundle, type BundleConfig } from 'bunchee'
|
|
194
|
+
|
|
195
|
+
// The definition of these options can be found in help information
|
|
196
|
+
await bundle(path.resolve('./src/index.ts'), {
|
|
197
|
+
dts: false, // Boolean
|
|
198
|
+
watch: false, // Boolean
|
|
199
|
+
minify: false, // Boolean
|
|
200
|
+
sourcemap: false, // Boolean
|
|
201
|
+
external: [], // string[]
|
|
202
|
+
format: 'esm', // 'esm' | 'cjs'
|
|
203
|
+
target: 'es2016', // ES syntax target
|
|
204
|
+
runtime: 'nodejs', // 'browser' | 'nodejs'
|
|
205
|
+
cwd: process.cwd(), // string
|
|
206
|
+
})
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
#### Watch Mode
|
|
210
|
+
|
|
211
|
+
Bunchee offers a convenient watch mode for rebuilding your library whenever changes are made to the source files. To enable this feature, use either -w or --watch.
|
|
212
|
+
|
|
213
|
+
#### `target`
|
|
214
|
+
|
|
215
|
+
If you specify `target` option in `tsconfig.json`, then you don't have to pass it again through CLI.
|
|
216
|
+
|
|
182
217
|
### License
|
|
183
218
|
|
|
184
219
|
MIT
|
package/dist/cli.js
CHANGED
|
@@ -1,22 +1,57 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
var path = require('path');
|
|
3
3
|
var arg = require('arg');
|
|
4
|
-
var fs = require('fs');
|
|
4
|
+
var fs = require('fs/promises');
|
|
5
5
|
|
|
6
|
+
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
7
|
+
try {
|
|
8
|
+
var info = gen[key](arg);
|
|
9
|
+
var value = info.value;
|
|
10
|
+
} catch (error) {
|
|
11
|
+
reject(error);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (info.done) {
|
|
15
|
+
resolve(value);
|
|
16
|
+
} else {
|
|
17
|
+
Promise.resolve(value).then(_next, _throw);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function _async_to_generator$1(fn) {
|
|
21
|
+
return function() {
|
|
22
|
+
var self = this, args = arguments;
|
|
23
|
+
return new Promise(function(resolve, reject) {
|
|
24
|
+
var gen = fn.apply(self, args);
|
|
25
|
+
function _next(value) {
|
|
26
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
27
|
+
}
|
|
28
|
+
function _throw(err) {
|
|
29
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
30
|
+
}
|
|
31
|
+
_next(undefined);
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
}
|
|
6
35
|
function exit(err) {
|
|
7
36
|
logger.error(err);
|
|
8
37
|
process.exit(1);
|
|
9
38
|
}
|
|
10
39
|
const formatDuration = (duration)=>duration >= 1000 ? `${duration / 1000}s` : `${duration}ms`;
|
|
11
40
|
function getPackageMeta(cwd) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
41
|
+
return _getPackageMeta.apply(this, arguments);
|
|
42
|
+
}
|
|
43
|
+
function _getPackageMeta() {
|
|
44
|
+
_getPackageMeta = _async_to_generator$1(function*(cwd) {
|
|
45
|
+
const pkgFilePath = path.resolve(cwd, 'package.json');
|
|
46
|
+
let targetPackageJson = {};
|
|
47
|
+
try {
|
|
48
|
+
targetPackageJson = JSON.parse((yield fs.readFile(pkgFilePath, {
|
|
49
|
+
encoding: 'utf-8'
|
|
50
|
+
})));
|
|
51
|
+
} catch (_) {}
|
|
52
|
+
return targetPackageJson;
|
|
53
|
+
});
|
|
54
|
+
return _getPackageMeta.apply(this, arguments);
|
|
20
55
|
}
|
|
21
56
|
const logger = {
|
|
22
57
|
log (arg) {
|
|
@@ -30,7 +65,7 @@ const logger = {
|
|
|
30
65
|
}
|
|
31
66
|
};
|
|
32
67
|
|
|
33
|
-
var version = "3.0.0-beta.
|
|
68
|
+
var version = "3.0.0-beta.12";
|
|
34
69
|
|
|
35
70
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
36
71
|
try {
|
|
@@ -46,7 +81,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
46
81
|
Promise.resolve(value).then(_next, _throw);
|
|
47
82
|
}
|
|
48
83
|
}
|
|
49
|
-
function
|
|
84
|
+
function _async_to_generator(fn) {
|
|
50
85
|
return function() {
|
|
51
86
|
var self = this, args = arguments;
|
|
52
87
|
return new Promise(function(resolve, reject) {
|
|
@@ -70,10 +105,12 @@ Options:
|
|
|
70
105
|
-m, --minify compress output. default: false
|
|
71
106
|
-o, --output <file> specify output filename
|
|
72
107
|
-f, --format <format> type of output (esm, amd, cjs, iife, umd, system), default: esm
|
|
73
|
-
-e, --external <mod> specify an external dependency
|
|
74
108
|
-h, --help output usage information
|
|
75
|
-
--
|
|
109
|
+
--external <mod> specify an external dependency, separate by comma
|
|
110
|
+
--no-external do not bundle external dependencies
|
|
111
|
+
--target <target> js features target: swc target es versions. default: es2016
|
|
76
112
|
--runtime <runtime> build runtime (nodejs, browser). default: browser
|
|
113
|
+
--env <env> inlined process env variables, separate by comma. default: NODE_ENV
|
|
77
114
|
--cwd <cwd> specify current working directory
|
|
78
115
|
--sourcemap enable sourcemap generation, default: false
|
|
79
116
|
--dts determine if need to generate types, default: false
|
|
@@ -85,14 +122,14 @@ function lintPackage(cwd) {
|
|
|
85
122
|
return _lintPackage.apply(this, arguments);
|
|
86
123
|
}
|
|
87
124
|
function _lintPackage() {
|
|
88
|
-
_lintPackage =
|
|
125
|
+
_lintPackage = _async_to_generator(function*(cwd) {
|
|
89
126
|
const { publint } = yield import('publint');
|
|
90
127
|
const { printMessage } = yield import('publint/utils');
|
|
91
128
|
const messages = yield publint({
|
|
92
129
|
pkgDir: cwd,
|
|
93
130
|
level: 'error'
|
|
94
131
|
});
|
|
95
|
-
const pkg = getPackageMeta(cwd);
|
|
132
|
+
const pkg = yield getPackageMeta(cwd);
|
|
96
133
|
for (const message of messages){
|
|
97
134
|
console.log(printMessage(message, pkg));
|
|
98
135
|
}
|
|
@@ -113,16 +150,15 @@ function parseCliArgs(argv) {
|
|
|
113
150
|
'--runtime': String,
|
|
114
151
|
'--target': String,
|
|
115
152
|
'--sourcemap': Boolean,
|
|
116
|
-
'--
|
|
117
|
-
|
|
118
|
-
|
|
153
|
+
'--env': String,
|
|
154
|
+
'--external': String,
|
|
155
|
+
'--no-external': Boolean,
|
|
119
156
|
'-h': '--help',
|
|
120
157
|
'-v': '--version',
|
|
121
158
|
'-w': '--watch',
|
|
122
159
|
'-o': '--output',
|
|
123
160
|
'-f': '--format',
|
|
124
|
-
'-m': '--minify'
|
|
125
|
-
'-e': '--external'
|
|
161
|
+
'-m': '--minify'
|
|
126
162
|
}, {
|
|
127
163
|
permissive: true,
|
|
128
164
|
argv
|
|
@@ -141,7 +177,8 @@ function parseCliArgs(argv) {
|
|
|
141
177
|
version: args['--version'],
|
|
142
178
|
runtime: args['--runtime'],
|
|
143
179
|
target: args['--target'],
|
|
144
|
-
external: args['--external']
|
|
180
|
+
external: !!args['--no-external'] ? null : args['--external'],
|
|
181
|
+
env: args['--env']
|
|
145
182
|
};
|
|
146
183
|
return parsedArgs;
|
|
147
184
|
}
|
|
@@ -149,21 +186,23 @@ function run(args) {
|
|
|
149
186
|
return _run.apply(this, arguments);
|
|
150
187
|
}
|
|
151
188
|
function _run() {
|
|
152
|
-
_run =
|
|
153
|
-
|
|
189
|
+
_run = _async_to_generator(function*(args) {
|
|
190
|
+
var _args_external;
|
|
191
|
+
const { source , format , watch , minify , sourcemap , target , runtime , dts , env } = args;
|
|
154
192
|
const cwd = args.cwd || process.cwd();
|
|
155
193
|
const file = args.file ? path.resolve(cwd, args.file) : undefined;
|
|
156
|
-
const
|
|
194
|
+
const bundleConfig = {
|
|
157
195
|
dts,
|
|
158
196
|
file,
|
|
159
197
|
format,
|
|
160
198
|
cwd,
|
|
161
199
|
target,
|
|
162
200
|
runtime,
|
|
163
|
-
external: args.external || [],
|
|
201
|
+
external: ((_args_external = args.external) == null ? void 0 : _args_external.split(',')) || [],
|
|
164
202
|
watch: !!watch,
|
|
165
203
|
minify: !!minify,
|
|
166
|
-
sourcemap: sourcemap === false ? false : true
|
|
204
|
+
sourcemap: sourcemap === false ? false : true,
|
|
205
|
+
env: (env == null ? void 0 : env.split(',')) || []
|
|
167
206
|
};
|
|
168
207
|
if (args.version) {
|
|
169
208
|
return logger.log(version);
|
|
@@ -172,11 +211,11 @@ function _run() {
|
|
|
172
211
|
return help();
|
|
173
212
|
}
|
|
174
213
|
const entry = source ? path.resolve(cwd, source) : '';
|
|
175
|
-
const bundle = require('./
|
|
214
|
+
const bundle = require('./index').bundle;
|
|
176
215
|
let timeStart = Date.now();
|
|
177
216
|
let timeEnd;
|
|
178
217
|
try {
|
|
179
|
-
yield bundle(entry,
|
|
218
|
+
yield bundle(entry, bundleConfig);
|
|
180
219
|
timeEnd = Date.now();
|
|
181
220
|
} catch (err) {
|
|
182
221
|
if (err.name === 'NOT_EXISTED') {
|
|
@@ -201,7 +240,7 @@ function main() {
|
|
|
201
240
|
return _main.apply(this, arguments);
|
|
202
241
|
}
|
|
203
242
|
function _main() {
|
|
204
|
-
_main =
|
|
243
|
+
_main = _async_to_generator(function*() {
|
|
205
244
|
let params, error;
|
|
206
245
|
try {
|
|
207
246
|
params = parseCliArgs(process.argv.slice(2));
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { JscTarget } from '@swc/core';
|
|
2
|
-
import {
|
|
2
|
+
import { OutputOptions } from 'rollup';
|
|
3
3
|
|
|
4
4
|
type ExportType = 'require' | 'export' | 'default' | string;
|
|
5
|
-
type
|
|
6
|
-
|
|
5
|
+
type BundleConfig = {
|
|
6
|
+
file?: string;
|
|
7
|
+
cwd?: string;
|
|
8
|
+
watch?: boolean;
|
|
9
|
+
target?: JscTarget;
|
|
7
10
|
format?: OutputOptions['format'];
|
|
8
11
|
minify?: boolean;
|
|
9
12
|
sourcemap?: boolean;
|
|
10
13
|
external?: string[];
|
|
14
|
+
noExternal?: boolean;
|
|
15
|
+
env?: string[];
|
|
16
|
+
dts?: boolean;
|
|
11
17
|
runtime?: string;
|
|
12
18
|
exportCondition?: {
|
|
13
19
|
source: string;
|
|
@@ -16,19 +22,7 @@ type CommonConfig = {
|
|
|
16
22
|
};
|
|
17
23
|
};
|
|
18
24
|
type ExportCondition = string | Record<ExportType, string>;
|
|
19
|
-
type BuncheeRollupConfig = Partial<Omit<RollupOptions, 'input' | 'output'>> & {
|
|
20
|
-
exportName?: string;
|
|
21
|
-
input: InputOptions;
|
|
22
|
-
output: OutputOptions[];
|
|
23
|
-
dtsOnly: boolean;
|
|
24
|
-
};
|
|
25
|
-
type CliArgs = CommonConfig & {
|
|
26
|
-
file?: string;
|
|
27
|
-
watch?: boolean;
|
|
28
|
-
cwd?: string;
|
|
29
|
-
target?: JscTarget;
|
|
30
|
-
};
|
|
31
25
|
|
|
32
|
-
declare function bundle(entryPath: string, { cwd, ...options }?:
|
|
26
|
+
declare function bundle(entryPath: string, { cwd, ...options }?: BundleConfig): Promise<any>;
|
|
33
27
|
|
|
34
|
-
export {
|
|
28
|
+
export { BundleConfig, bundle };
|
package/dist/{lib.js → index.js}
RENAMED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
|
|
3
|
-
var fs = require('fs');
|
|
3
|
+
var fs = require('fs/promises');
|
|
4
4
|
var path = require('path');
|
|
5
5
|
var rollup = require('rollup');
|
|
6
|
+
var fs$1 = require('fs');
|
|
6
7
|
var module$1 = require('module');
|
|
7
8
|
var rollupPluginSwc3 = require('rollup-plugin-swc3');
|
|
8
9
|
var commonjs = require('@rollup/plugin-commonjs');
|
|
9
10
|
var shebang = require('rollup-plugin-preserve-shebang');
|
|
10
11
|
var json = require('@rollup/plugin-json');
|
|
11
12
|
var pluginNodeResolve = require('@rollup/plugin-node-resolve');
|
|
13
|
+
var replace = require('@rollup/plugin-replace');
|
|
12
14
|
|
|
13
15
|
const rootDir = process.cwd();
|
|
14
16
|
var config = {
|
|
@@ -134,20 +136,55 @@ function getExportConditionDist(pkg, exportCondition) {
|
|
|
134
136
|
return dist;
|
|
135
137
|
}
|
|
136
138
|
|
|
139
|
+
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
140
|
+
try {
|
|
141
|
+
var info = gen[key](arg);
|
|
142
|
+
var value = info.value;
|
|
143
|
+
} catch (error) {
|
|
144
|
+
reject(error);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
if (info.done) {
|
|
148
|
+
resolve(value);
|
|
149
|
+
} else {
|
|
150
|
+
Promise.resolve(value).then(_next, _throw);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function _async_to_generator$1(fn) {
|
|
154
|
+
return function() {
|
|
155
|
+
var self = this, args = arguments;
|
|
156
|
+
return new Promise(function(resolve, reject) {
|
|
157
|
+
var gen = fn.apply(self, args);
|
|
158
|
+
function _next(value) {
|
|
159
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
160
|
+
}
|
|
161
|
+
function _throw(err) {
|
|
162
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
163
|
+
}
|
|
164
|
+
_next(undefined);
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
}
|
|
137
168
|
function exit(err) {
|
|
138
169
|
logger.error(err);
|
|
139
170
|
process.exit(1);
|
|
140
171
|
}
|
|
141
172
|
const formatDuration = (duration)=>duration >= 1000 ? `${duration / 1000}s` : `${duration}ms`;
|
|
142
173
|
function getPackageMeta(cwd) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
174
|
+
return _getPackageMeta.apply(this, arguments);
|
|
175
|
+
}
|
|
176
|
+
function _getPackageMeta() {
|
|
177
|
+
_getPackageMeta = _async_to_generator$1(function*(cwd) {
|
|
178
|
+
const pkgFilePath = path.resolve(cwd, 'package.json');
|
|
179
|
+
let targetPackageJson = {};
|
|
180
|
+
try {
|
|
181
|
+
targetPackageJson = JSON.parse((yield fs.readFile(pkgFilePath, {
|
|
182
|
+
encoding: 'utf-8'
|
|
183
|
+
})));
|
|
184
|
+
} catch (_) {}
|
|
185
|
+
return targetPackageJson;
|
|
186
|
+
});
|
|
187
|
+
return _getPackageMeta.apply(this, arguments);
|
|
151
188
|
}
|
|
152
189
|
const logger = {
|
|
153
190
|
log (arg) {
|
|
@@ -164,6 +201,23 @@ function isTypescript(filename) {
|
|
|
164
201
|
const ext = path.extname(filename);
|
|
165
202
|
return ext === '.ts' || ext === '.tsx';
|
|
166
203
|
}
|
|
204
|
+
function fileExists(filePath) {
|
|
205
|
+
return _fileExists.apply(this, arguments);
|
|
206
|
+
}
|
|
207
|
+
function _fileExists() {
|
|
208
|
+
_fileExists = _async_to_generator$1(function*(filePath) {
|
|
209
|
+
try {
|
|
210
|
+
yield fs.access(filePath);
|
|
211
|
+
return true;
|
|
212
|
+
} catch (err) {
|
|
213
|
+
if (err.code === 'ENOENT') {
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
throw err;
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
return _fileExists.apply(this, arguments);
|
|
220
|
+
}
|
|
167
221
|
const isNotNull = (n)=>Boolean(n);
|
|
168
222
|
|
|
169
223
|
function _extends$1() {
|
|
@@ -207,9 +261,22 @@ function resolveTypescript(cwd) {
|
|
|
207
261
|
}
|
|
208
262
|
return ts;
|
|
209
263
|
}
|
|
264
|
+
function getBuildEnv(envs) {
|
|
265
|
+
if (!envs.includes('NODE_ENV')) {
|
|
266
|
+
envs.push('NODE_ENV');
|
|
267
|
+
}
|
|
268
|
+
const envVars = envs.reduce((acc, key)=>{
|
|
269
|
+
const value = process.env[key];
|
|
270
|
+
if (typeof value !== 'undefined') {
|
|
271
|
+
acc['process.env.' + key] = JSON.stringify(value);
|
|
272
|
+
}
|
|
273
|
+
return acc;
|
|
274
|
+
}, {});
|
|
275
|
+
return envVars;
|
|
276
|
+
}
|
|
210
277
|
function buildInputConfig(entry, pkg, options, { tsConfigPath , tsCompilerOptions , dtsOnly }) {
|
|
211
278
|
var _options_external;
|
|
212
|
-
const externals = [
|
|
279
|
+
const externals = options.noExternal ? [] : [
|
|
213
280
|
pkg.peerDependencies,
|
|
214
281
|
pkg.dependencies,
|
|
215
282
|
pkg.peerDependenciesMeta
|
|
@@ -237,6 +304,10 @@ function buildInputConfig(entry, pkg, options, { tsConfigPath , tsCompilerOption
|
|
|
237
304
|
})
|
|
238
305
|
})
|
|
239
306
|
] : [
|
|
307
|
+
replace({
|
|
308
|
+
values: getBuildEnv(options.env || []),
|
|
309
|
+
preventAssignment: true
|
|
310
|
+
}),
|
|
240
311
|
pluginNodeResolve.nodeResolve({
|
|
241
312
|
preferBuiltins: runtime === 'node',
|
|
242
313
|
extensions: [
|
|
@@ -337,11 +408,11 @@ function buildOutputConfigs(options, pkg, { tsCompilerOptions , dtsOnly }) {
|
|
|
337
408
|
sourcemap: options.sourcemap
|
|
338
409
|
});
|
|
339
410
|
}
|
|
340
|
-
function buildConfig(entry, pkg,
|
|
411
|
+
function buildConfig(entry, pkg, bundleConfig, dtsOnly) {
|
|
341
412
|
var _options_exportCondition;
|
|
342
|
-
const { file } =
|
|
413
|
+
const { file } = bundleConfig;
|
|
343
414
|
const useTypescript = isTypescript(entry);
|
|
344
|
-
const options = _extends$1({},
|
|
415
|
+
const options = _extends$1({}, bundleConfig, {
|
|
345
416
|
useTypescript
|
|
346
417
|
});
|
|
347
418
|
let tsCompilerOptions = {};
|
|
@@ -349,7 +420,7 @@ function buildConfig(entry, pkg, cliArgs, dtsOnly) {
|
|
|
349
420
|
if (useTypescript) {
|
|
350
421
|
const ts = resolveTypescript(config.rootDir);
|
|
351
422
|
tsConfigPath = path.resolve(config.rootDir, 'tsconfig.json');
|
|
352
|
-
if (fs.existsSync(tsConfigPath)) {
|
|
423
|
+
if (fs$1.existsSync(tsConfigPath)) {
|
|
353
424
|
const basePath = tsConfigPath ? path.dirname(tsConfigPath) : config.rootDir;
|
|
354
425
|
const tsconfigJSON = ts.readConfigFile(tsConfigPath, ts.sys.readFile).config;
|
|
355
426
|
tsCompilerOptions = ts.parseJsonConfigFileContent(tsconfigJSON, ts.sys, basePath).options;
|
|
@@ -369,7 +440,7 @@ function buildConfig(entry, pkg, cliArgs, dtsOnly) {
|
|
|
369
440
|
// Generate dts job - single config
|
|
370
441
|
if (dtsOnly) {
|
|
371
442
|
outputConfigs = [
|
|
372
|
-
buildOutputConfigs(_extends$1({},
|
|
443
|
+
buildOutputConfigs(_extends$1({}, bundleConfig, {
|
|
373
444
|
format: 'es',
|
|
374
445
|
useTypescript
|
|
375
446
|
}), pkg, typescriptOptions)
|
|
@@ -377,7 +448,7 @@ function buildConfig(entry, pkg, cliArgs, dtsOnly) {
|
|
|
377
448
|
} else {
|
|
378
449
|
// multi outputs with specified format
|
|
379
450
|
outputConfigs = outputExports.map((exportDist)=>{
|
|
380
|
-
return buildOutputConfigs(_extends$1({},
|
|
451
|
+
return buildOutputConfigs(_extends$1({}, bundleConfig, {
|
|
381
452
|
file: exportDist.file,
|
|
382
453
|
format: exportDist.format,
|
|
383
454
|
useTypescript
|
|
@@ -388,9 +459,9 @@ function buildConfig(entry, pkg, cliArgs, dtsOnly) {
|
|
|
388
459
|
var _outputExports_;
|
|
389
460
|
const fallbackFormat = (_outputExports_ = outputExports[0]) == null ? void 0 : _outputExports_.format;
|
|
390
461
|
outputConfigs = [
|
|
391
|
-
buildOutputConfigs(_extends$1({},
|
|
462
|
+
buildOutputConfigs(_extends$1({}, bundleConfig, {
|
|
392
463
|
file,
|
|
393
|
-
format:
|
|
464
|
+
format: bundleConfig.format || fallbackFormat,
|
|
394
465
|
useTypescript
|
|
395
466
|
}), pkg, typescriptOptions)
|
|
396
467
|
];
|
|
@@ -418,7 +489,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
418
489
|
Promise.resolve(value).then(_next, _throw);
|
|
419
490
|
}
|
|
420
491
|
}
|
|
421
|
-
function
|
|
492
|
+
function _async_to_generator(fn) {
|
|
422
493
|
return function() {
|
|
423
494
|
var self = this, args = arguments;
|
|
424
495
|
return new Promise(function(resolve, reject) {
|
|
@@ -447,7 +518,7 @@ function _extends() {
|
|
|
447
518
|
};
|
|
448
519
|
return _extends.apply(this, arguments);
|
|
449
520
|
}
|
|
450
|
-
function
|
|
521
|
+
function _object_without_properties_loose(source, excluded) {
|
|
451
522
|
if (source == null) return {};
|
|
452
523
|
var target = {};
|
|
453
524
|
var sourceKeys = Object.keys(source);
|
|
@@ -459,6 +530,8 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
459
530
|
}
|
|
460
531
|
return target;
|
|
461
532
|
}
|
|
533
|
+
const SRC = 'src' // resolve from src/ directory
|
|
534
|
+
;
|
|
462
535
|
function logBuild(exportPath, dtsOnly, duration) {
|
|
463
536
|
logger.log(` ✓ ${dtsOnly ? 'Typed' : 'Built'} ${exportPath} ${formatDuration(duration)}`);
|
|
464
537
|
}
|
|
@@ -467,35 +540,44 @@ function assignDefault(options, name, defaultValue) {
|
|
|
467
540
|
options[name] = defaultValue;
|
|
468
541
|
}
|
|
469
542
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
543
|
+
function resolveSourceFile(cwd, filename) {
|
|
544
|
+
return path.resolve(cwd, SRC, filename);
|
|
545
|
+
}
|
|
473
546
|
function getSourcePathFromExportPath(cwd, exportPath) {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
547
|
+
return _getSourcePathFromExportPath.apply(this, arguments);
|
|
548
|
+
}
|
|
549
|
+
function _getSourcePathFromExportPath() {
|
|
550
|
+
_getSourcePathFromExportPath = // Map '.' -> './index.[ext]'
|
|
551
|
+
// Map './lite' -> './lite.[ext]'
|
|
552
|
+
// Return undefined if no match or if it's package.json exports
|
|
553
|
+
_async_to_generator(function*(cwd, exportPath) {
|
|
554
|
+
const exts = [
|
|
555
|
+
'js',
|
|
556
|
+
'cjs',
|
|
557
|
+
'mjs',
|
|
558
|
+
'jsx',
|
|
559
|
+
'ts',
|
|
560
|
+
'tsx'
|
|
561
|
+
];
|
|
562
|
+
for (const ext of exts){
|
|
563
|
+
// ignore package.json
|
|
564
|
+
if (exportPath.endsWith('package.json')) return;
|
|
565
|
+
if (exportPath === '.') exportPath = './index';
|
|
566
|
+
const filename = resolveSourceFile(cwd, `${exportPath}.${ext}`);
|
|
567
|
+
if (yield fileExists(filename)) {
|
|
568
|
+
return filename;
|
|
569
|
+
}
|
|
489
570
|
}
|
|
490
|
-
|
|
491
|
-
|
|
571
|
+
return;
|
|
572
|
+
});
|
|
573
|
+
return _getSourcePathFromExportPath.apply(this, arguments);
|
|
492
574
|
}
|
|
493
575
|
function bundle(entryPath) {
|
|
494
576
|
return _bundle.apply(this, arguments);
|
|
495
577
|
}
|
|
496
578
|
function _bundle() {
|
|
497
|
-
_bundle =
|
|
498
|
-
var { cwd } = _param, options =
|
|
579
|
+
_bundle = _async_to_generator(function*(entryPath, _param = {}) {
|
|
580
|
+
var { cwd } = _param, options = _object_without_properties_loose(_param, [
|
|
499
581
|
"cwd"
|
|
500
582
|
]);
|
|
501
583
|
config.rootDir = path.resolve(process.cwd(), cwd || '');
|
|
@@ -505,30 +587,36 @@ function _bundle() {
|
|
|
505
587
|
if (options.dts === undefined && isTypescript(entryPath)) {
|
|
506
588
|
options.dts = true;
|
|
507
589
|
}
|
|
508
|
-
const pkg = getPackageMeta(config.rootDir);
|
|
590
|
+
const pkg = yield getPackageMeta(config.rootDir);
|
|
509
591
|
const packageExports = pkg.exports || {};
|
|
510
592
|
const isSingleEntry = typeof packageExports === 'string';
|
|
511
593
|
const hasMultiEntries = packageExports && !isSingleEntry && Object.keys(packageExports).length > 0;
|
|
512
594
|
if (isSingleEntry) {
|
|
513
595
|
// Use specified string file path if possible, then fallback to the default behavior entry picking logic
|
|
514
596
|
// e.g. "exports": "./dist/index.js" -> use "./index.<ext>" as entry
|
|
515
|
-
entryPath = entryPath || getSourcePathFromExportPath(config.rootDir, '.') || '';
|
|
597
|
+
entryPath = entryPath || (yield getSourcePathFromExportPath(config.rootDir, '.')) || '';
|
|
516
598
|
}
|
|
517
599
|
function buildEntryConfig(packageExports, dtsOnly) {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
source,
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
600
|
+
return _buildEntryConfig.apply(this, arguments);
|
|
601
|
+
}
|
|
602
|
+
function _buildEntryConfig() {
|
|
603
|
+
_buildEntryConfig = _async_to_generator(function*(packageExports, dtsOnly) {
|
|
604
|
+
const configs = Object.keys(packageExports).map(/*#__PURE__*/ _async_to_generator(function*(entryExport) {
|
|
605
|
+
const source = yield getSourcePathFromExportPath(config.rootDir, entryExport);
|
|
606
|
+
if (!source) return undefined;
|
|
607
|
+
if (dtsOnly && !isTypescript(source)) return;
|
|
608
|
+
options.exportCondition = {
|
|
609
|
+
source,
|
|
610
|
+
name: entryExport,
|
|
611
|
+
export: packageExports[entryExport]
|
|
612
|
+
};
|
|
613
|
+
const entry = resolveSourceFile(cwd, source);
|
|
614
|
+
const rollupConfig = buildConfig(entry, pkg, options, dtsOnly);
|
|
615
|
+
return rollupConfig;
|
|
616
|
+
}));
|
|
617
|
+
return (yield Promise.all(configs)).filter((n)=>Boolean(n));
|
|
618
|
+
});
|
|
619
|
+
return _buildEntryConfig.apply(this, arguments);
|
|
532
620
|
}
|
|
533
621
|
const bundleOrWatch = (rollupConfig)=>{
|
|
534
622
|
const { input , exportName } = rollupConfig;
|
|
@@ -543,8 +631,8 @@ function _bundle() {
|
|
|
543
631
|
}
|
|
544
632
|
return runBundle(rollupConfig, buildMetadata);
|
|
545
633
|
};
|
|
546
|
-
if (!
|
|
547
|
-
const hasSpecifiedEntryFile = entryPath === '' ? false : fs.
|
|
634
|
+
if (!(yield fileExists(entryPath))) {
|
|
635
|
+
const hasSpecifiedEntryFile = entryPath === '' ? false : (yield fs.stat(entryPath)).isFile();
|
|
548
636
|
if (!hasSpecifiedEntryFile && !hasMultiEntries) {
|
|
549
637
|
const err = new Error(`Entry file \`${entryPath}\` is not existed`);
|
|
550
638
|
err.name = 'NOT_EXISTED';
|
|
@@ -557,8 +645,9 @@ function _bundle() {
|
|
|
557
645
|
options.dts = hasTypings;
|
|
558
646
|
}
|
|
559
647
|
if (hasMultiEntries) {
|
|
560
|
-
const
|
|
561
|
-
const
|
|
648
|
+
const buildConfigs = yield buildEntryConfig(packageExports, false);
|
|
649
|
+
const assetsJobs = buildConfigs.map((rollupConfig)=>bundleOrWatch(rollupConfig));
|
|
650
|
+
const typesJobs = options.dts ? (yield buildEntryConfig(packageExports, true)).map((rollupConfig)=>bundleOrWatch(rollupConfig)) : [];
|
|
562
651
|
return yield Promise.all(assetsJobs.concat(typesJobs));
|
|
563
652
|
}
|
|
564
653
|
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunchee",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.12",
|
|
4
4
|
"description": "zero config bundler for js/ts/jsx libraries",
|
|
5
5
|
"bin": {
|
|
6
6
|
"bunchee": "./dist/cli.js"
|
|
7
7
|
},
|
|
8
|
-
"main": "./dist/
|
|
9
|
-
"types": "./dist/
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"test": "jest --env node",
|
|
12
12
|
"test:update": "TEST_UPDATE_SNAPSHOT=1 yarn test",
|
|
13
13
|
"clean": "rm -rf ./dist",
|
|
14
14
|
"typecheck": "tsc --noEmit",
|
|
15
15
|
"prepublishOnly": "yarn clean && yarn build && chmod +x ./dist/cli.js && yarn test",
|
|
16
|
-
"build:cli": "tsx ./cli.ts ./cli.ts --runtime node -f cjs -o ./dist/cli.js",
|
|
17
|
-
"build:main": "tsx ./cli.ts ./
|
|
16
|
+
"build:cli": "tsx ./src/cli.ts ./src/cli.ts --runtime node -f cjs -o ./dist/cli.js",
|
|
17
|
+
"build:main": "tsx ./src/cli.ts ./src/index.ts --runtime node -f cjs",
|
|
18
18
|
"build": "yarn build:main && yarn build:cli"
|
|
19
19
|
},
|
|
20
20
|
"type": "commonjs",
|
|
@@ -43,15 +43,16 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@rollup/plugin-commonjs": "24.0.1",
|
|
45
45
|
"@rollup/plugin-json": "6.0.0",
|
|
46
|
-
"@rollup/plugin-node-resolve": "15.0.
|
|
47
|
-
"@
|
|
46
|
+
"@rollup/plugin-node-resolve": "15.0.2",
|
|
47
|
+
"@rollup/plugin-replace": "5.0.2",
|
|
48
|
+
"@swc/core": "1.3.46",
|
|
48
49
|
"arg": "5.0.2",
|
|
49
50
|
"publint": "0.1.11",
|
|
50
|
-
"rollup": "3.
|
|
51
|
-
"rollup-plugin-dts": "5.
|
|
51
|
+
"rollup": "3.20.2",
|
|
52
|
+
"rollup-plugin-dts": "5.3.0",
|
|
52
53
|
"rollup-plugin-preserve-shebang": "1.0.1",
|
|
53
|
-
"rollup-plugin-swc3": "0.8.
|
|
54
|
-
"tslib": "2.
|
|
54
|
+
"rollup-plugin-swc3": "0.8.1",
|
|
55
|
+
"tslib": "2.5.0"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
57
58
|
"typescript": ">= 3.7.0"
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
}
|
|
63
64
|
},
|
|
64
65
|
"devDependencies": {
|
|
66
|
+
"@huozhi/testing-package": "1.0.0",
|
|
65
67
|
"@swc/jest": "0.2.22",
|
|
66
68
|
"@types/jest": "29.0.0",
|
|
67
69
|
"jest": "29.0.1",
|
|
@@ -74,7 +76,7 @@
|
|
|
74
76
|
"node_modules"
|
|
75
77
|
],
|
|
76
78
|
"moduleNameMapper": {
|
|
77
|
-
"bunchee": "<rootDir>/
|
|
79
|
+
"bunchee": "<rootDir>/src/index.ts"
|
|
78
80
|
},
|
|
79
81
|
"transform": {
|
|
80
82
|
"^.+\\.(t|j)sx?$": [
|