forked from hgraph-io/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mjs
56 lines (49 loc) · 1.12 KB
/
build.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import esbuild from 'esbuild'
import fs from 'fs'
// https://esbuild.github.io/api/#main-fields-for-package-authors
const common = {
entryPoints: ['src/index.ts'],
bundle: true,
minify: true,
loader: {
'.gql': 'text',
'.graphql': 'text',
},
}
esbuild.build({
...common,
entryPoints: ['src/server/index.ts'],
format: 'cjs',
platform: 'node',
target: ['node18'],
outfile: 'dist/node-cjs.js',
})
esbuild.build({
...common,
entryPoints: ['src/server/index.ts'],
format: 'esm',
platform: 'node',
target: ['node18'],
outfile: 'dist/node-esm.js',
packages: 'external',
})
esbuild.build({
...common,
format: 'esm',
platform: 'browser',
target: ['chrome58', 'firefox57', 'safari11', 'edge88'],
outfile: 'dist/browser-esm.js',
jsx: 'automatic',
external: ['react', 'react-dom'],
})
esbuild.build({
...common,
format: 'cjs',
platform: 'browser',
target: ['chrome58', 'firefox57', 'safari11', 'edge88'],
outfile: 'dist/browser-cjs.js',
jsx: 'automatic',
})
// fs.mkdir('dist', console.error)
fs.mkdir('dist', () => {})
fs.copyFile('src/types/index.ts', 'dist/index.d.ts', () => {})