@@ -3,8 +3,7 @@ import { type BuildOptions, context } from 'esbuild'
3
3
import packageJSON from '../package.json'
4
4
5
5
rmSync ( 'dist' , { force : true , recursive : true } )
6
- mkdirSync ( 'dist' )
7
- mkdirSync ( 'dist/node' )
6
+ mkdirSync ( 'dist/node' , { recursive : true } )
8
7
writeFileSync ( 'dist/node/index.d.ts' , "export * from '../../src/node/index.ts'" )
9
8
writeFileSync (
10
9
'dist/node/runtime.d.ts' ,
@@ -26,7 +25,7 @@ const serverOptions: BuildOptions = {
26
25
const clientOptions : BuildOptions = {
27
26
bundle : true ,
28
27
platform : 'browser' ,
29
- target : 'safari14 ' ,
28
+ target : 'es2019 ' ,
30
29
format : 'esm' ,
31
30
sourcemap : true ,
32
31
}
@@ -36,37 +35,20 @@ const watch = async (options: BuildOptions) => {
36
35
await ctx . watch ( )
37
36
}
38
37
39
- void watch ( {
40
- entryPoints : [ 'src/client/client.ts' ] ,
41
- outfile : 'dist/client/client.mjs' ,
42
- external : [ '@vite/env' ] ,
43
- ...clientOptions ,
44
- } )
38
+ // envConfig
45
39
void watch ( {
46
40
entryPoints : [ 'src/client/env.ts' ] ,
47
41
outfile : 'dist/client/env.mjs' ,
48
42
...clientOptions ,
49
43
} )
44
+ // clientConfig
50
45
void watch ( {
51
- ...serverOptions ,
52
- entryPoints : [ './src/node/publicUtils.ts' ] ,
53
- outfile : 'dist/node-cjs/publicUtils.cjs' ,
54
- format : 'cjs' ,
55
- banner : {
56
- js : `
57
- const { pathToFileURL } = require("node:url")
58
- const __url = pathToFileURL(__filename)` . trimStart ( ) ,
59
- } ,
60
- define : {
61
- 'import.meta.url' : '__url' ,
62
- } ,
63
- } )
64
- void watch ( {
65
- ...serverOptions ,
66
- entryPoints : [ './src/runtime/index.ts' ] ,
67
- outfile : 'dist/node/runtime.js' ,
68
- format : 'esm' ,
46
+ entryPoints : [ 'src/client/client.ts' ] ,
47
+ outfile : 'dist/client/client.mjs' ,
48
+ external : [ '@vite/env' ] ,
49
+ ...clientOptions ,
69
50
} )
51
+ // nodeConfig
70
52
void watch ( {
71
53
...serverOptions ,
72
54
entryPoints : {
@@ -106,3 +88,25 @@ void watch({
106
88
} ,
107
89
] ,
108
90
} )
91
+ // runtimeConfig
92
+ void watch ( {
93
+ ...serverOptions ,
94
+ entryPoints : [ './src/runtime/index.ts' ] ,
95
+ outfile : 'dist/node/runtime.js' ,
96
+ format : 'esm' ,
97
+ } )
98
+ // cjsConfig
99
+ void watch ( {
100
+ ...serverOptions ,
101
+ entryPoints : [ './src/node/publicUtils.ts' ] ,
102
+ outfile : 'dist/node-cjs/publicUtils.cjs' ,
103
+ format : 'cjs' ,
104
+ banner : {
105
+ js : `
106
+ const { pathToFileURL } = require("node:url")
107
+ const __url = pathToFileURL(__filename)` . trimStart ( ) ,
108
+ } ,
109
+ define : {
110
+ 'import.meta.url' : '__url' ,
111
+ } ,
112
+ } )
0 commit comments