@@ -8,6 +8,9 @@ const sharedOptions = {
88 minify : false ,
99 allowOverwrite : true ,
1010 packages : "external" ,
11+ target : "es2022" ,
12+ format : "esm" ,
13+ platform : "neutral" ,
1114} ;
1215
1316async function main ( ) {
@@ -18,8 +21,6 @@ async function main() {
1821 entryPoints : await glob ( [ "./src/*.ts" , "./src/**/*.ts" ] ) ,
1922 outdir : "pkg/dist-src" ,
2023 bundle : false ,
21- platform : "neutral" ,
22- format : "esm" ,
2324 ...sharedOptions ,
2425 sourcemap : false ,
2526 } ) ;
@@ -33,29 +34,12 @@ async function main() {
3334 await rm ( typeFile ) ;
3435 }
3536
36- const entryPoints = [ "./pkg/dist-src/index.js" ] ;
37-
38- await Promise . all ( [
39- // Build the a CJS Node.js bundle
40- esbuild . build ( {
41- entryPoints,
42- outdir : "pkg/dist-node" ,
43- bundle : true ,
44- platform : "node" ,
45- target : "node14" ,
46- format : "cjs" ,
47- ...sharedOptions ,
48- } ) ,
49- // Build an ESM browser bundle
50- esbuild . build ( {
51- entryPoints,
52- outdir : "pkg/dist-web" ,
53- bundle : true ,
54- platform : "browser" ,
55- format : "esm" ,
56- ...sharedOptions ,
57- } ) ,
58- ] ) ;
37+ await esbuild . build ( {
38+ entryPoints : [ "./dist-src/index.js" ] ,
39+ outdir : "pkg/dist-bundle" ,
40+ bundle : true ,
41+ ...sharedOptions ,
42+ } ) ;
5943
6044 // Copy the README, LICENSE to the pkg folder
6145 await copyFile ( "LICENSE" , "pkg/LICENSE" ) ;
@@ -74,10 +58,12 @@ async function main() {
7458 {
7559 ...pkg ,
7660 files : [ "dist-*/**" , "bin/**" ] ,
77- main : "dist-node/index.js" ,
78- browser : "dist-web/index.js" ,
79- types : "dist-types/index.d.ts" ,
80- module : "dist-src/index.js" ,
61+ exports : {
62+ "." : {
63+ types : "./dist-types/index.d.ts" ,
64+ import : "./dist-bundle/index.js" ,
65+ } ,
66+ } ,
8167 sideEffects : false ,
8268 } ,
8369 null ,
0 commit comments