-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ts
41 lines (33 loc) · 876 Bytes
/
build.ts
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
import { Glob, build } from 'bun';
import fs from 'node:fs';
const glob = new Glob('src/**/*.ts');
const entrypoints = [...glob.scanSync('.')];
const r = await build({
entrypoints,
outdir: './dist',
external: ['ol'],
minify: true,
});
if (!r.success) throw new Error('Compilation failed');
const pkg = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
fs.writeFileSync(
'./dist/package.json',
JSON.stringify({
...Object.fromEntries(
['name', 'version', 'description', 'author', 'homepage', 'license', 'dependencies'].map((k) => [k, pkg[k]]),
),
type: 'module',
main: './index.js',
types: './index.d.ts',
exports: {
'.': {
types: './index.d.ts',
import: './index.js',
},
'./ol': {
types: './ol/index.d.ts',
import: './ol/index.js',
},
},
}, undefined, 2),
);