-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.mjs
39 lines (35 loc) · 867 Bytes
/
esbuild.mjs
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
import { build } from 'esbuild';
import { readFileSync } from 'fs';
try {
let options = {
bundle: true,
platform: 'node',
target: ['node16.14'],
format: 'esm', // switch esbuild output to ESM
mainFields: [ 'module', 'main' ], // force switch AWS SDK to module mode
};
const entryPoint = process.argv[2];
if (entryPoint) {
options = {
...options,
entryPoints: [ entryPoint ],
};
} else {
options = {
...options,
stdin: { contents: readFileSync(0, 'utf-8'), loader: 'js' },
};
}
const outfile = process.argv[3];
if (outfile) {
options = {
...options,
outfile,
};
}
const result = await build(options);
}
catch (err) {
console.error(err);
process.exit(1);
}