generated from actions/typescript-action
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.config.js
56 lines (52 loc) · 1.32 KB
/
esbuild.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// @ts-check
import * as esbuild from 'esbuild'
/**
* @type esbuild.SameShape<esbuild.BuildOptions, esbuild.BuildOptions>
*/
const config = {
bundle: true,
format: 'esm',
keepNames: true,
target: 'node20',
platform: 'node',
sourcemap: true,
legalComments: 'external',
logLevel: 'info',
minify: false,
minifySyntax: true,
minifyWhitespace: true,
external: ['wrangler'],
treeShaking: true,
banner: {
/**
* Adding banner js import fixes the error of
* "Error: Dynamic require of "os" is not supported"
* When running the build output in node.
* Related issues:
* - https://github.com/evanw/esbuild/issues/1921
* - https://github.com/evanw/esbuild/issues/1944
*
* Taken from :
* https://github.com/serverless-stack/sst/blob/1aaf1bc06b94c2036f147cb24b25a037c5a95b0a/packages/sst/build.mjs#L26-L29
*/
js: [
`import { createRequire as topLevelCreateRequire } from 'module';`,
`const require = topLevelCreateRequire(import.meta.url);`
].join('')
},
define: {
'process.env.NODE_ENV': JSON.stringify('production')
}
}
// deploy
await esbuild.build({
...config,
entryPoints: ['src/deploy/index.ts'],
outdir: './dist/deploy'
})
// delete
await esbuild.build({
...config,
entryPoints: ['src/delete/index.ts'],
outdir: './dist/delete'
})