-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
43 lines (35 loc) · 976 Bytes
/
build.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
import { globSync } from 'glob';
import * as esbuild from 'esbuild';
import * as tsup from 'tsup';
async function build(path) {
const file = `${path}/src/index.ts`;
const dist = `${path}/dist`;
const esbuildConfig = {
entryPoints: [file],
external: [],
packages: 'external',
bundle: true,
sourcemap: true,
format: 'cjs',
target: 'es2022',
outdir: dist,
};
await esbuild.build(esbuildConfig);
console.log(`Built ${path}/dist/index.js`);
await esbuild.build({
...esbuildConfig,
format: 'esm',
outExtension: { '.js': '.mjs' },
});
console.log(`Built ${path}/dist/index.mjs`);
await tsup.build({
entry: [file],
format: ['cjs', 'esm'],
dts: { only: true },
outDir: dist,
silent: true,
external: [],
});
console.log(`Built ${path}/dist/index.d.ts`);
}
globSync('packages/*').forEach(build);