@@ -12,6 +12,9 @@ const sharedOptions = {
12
12
minify : false ,
13
13
allowOverwrite : true ,
14
14
packages : "external" ,
15
+ platform : "neutral" ,
16
+ format : "esm" ,
17
+ target : "es2022" ,
15
18
} ;
16
19
17
20
async function main ( ) {
@@ -22,8 +25,6 @@ async function main() {
22
25
entryPoints : await glob ( [ "./src/*.ts" , "./src/**/*.ts" ] ) ,
23
26
outdir : "pkg/dist-src" ,
24
27
bundle : false ,
25
- platform : "neutral" ,
26
- format : "esm" ,
27
28
...sharedOptions ,
28
29
sourcemap : false ,
29
30
} ) ;
@@ -39,27 +40,13 @@ async function main() {
39
40
40
41
const entryPoints = [ "./pkg/dist-src/index.js" ] ;
41
42
42
- await Promise . all ( [
43
- // Build the a CJS Node.js bundle
44
- esbuild . build ( {
45
- entryPoints,
46
- outdir : "pkg/dist-node" ,
47
- bundle : true ,
48
- platform : "node" ,
49
- target : "node18" ,
50
- format : "cjs" ,
51
- ...sharedOptions ,
52
- } ) ,
53
- // Build an ESM browser bundle
54
- esbuild . build ( {
55
- entryPoints,
56
- outdir : "pkg/dist-web" ,
57
- bundle : true ,
58
- platform : "browser" ,
59
- format : "esm" ,
60
- ...sharedOptions ,
61
- } ) ,
62
- ] ) ;
43
+ // Build an ESM bundle
44
+ await esbuild . build ( {
45
+ entryPoints,
46
+ outdir : "pkg/dist-bundle" ,
47
+ bundle : true ,
48
+ ...sharedOptions ,
49
+ } ) ;
63
50
64
51
// Copy the README, LICENSE to the pkg folder
65
52
await copyFile ( "LICENSE" , "pkg/LICENSE" ) ;
@@ -78,15 +65,19 @@ async function main() {
78
65
{
79
66
...pkg ,
80
67
files : [ "dist-*/**" , "bin/**" ] ,
81
- main : "dist-node/index.js" ,
82
- module : "dist-web/index.js" ,
83
- types : "dist-types/index.d.ts" ,
84
- source : "dist-src/index.js" ,
68
+ types : "./dist-types/index.d.ts" ,
69
+ exports : {
70
+ "." : {
71
+ types : "./dist-types/index.d.ts" ,
72
+ import : "./dist-bundle/index.js" ,
73
+ default : "./dist-bundle/index.js" ,
74
+ } ,
75
+ } ,
85
76
sideEffects : false ,
86
77
} ,
87
78
null ,
88
- 2
89
- )
79
+ 2 ,
80
+ ) ,
90
81
) ;
91
82
}
92
83
main ( ) ;
0 commit comments