-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ts
45 lines (39 loc) · 881 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
42
43
44
45
import { $ } from "bun";
import pattycake from "pattycake";
// clean
await $`rimraf lib/schema/__generated__ out`;
// codegen
await $`bun generate`;
// typecheck
await $`tsc`;
// build
const out = await Bun.build({
entrypoints: ["./bin/app.ts"],
outdir: "./out",
target: "bun",
plugins: [
// pattycake: for ts-pattern
pattycake.esbuild({ disableOptionalChaining: true }),
// allows for: `import contents from "./foo.gql"; => string`
{
name: "inline-graphql",
setup(build) {
build.onLoad(
{
filter: /\.gql$/,
},
async args => {
return {
loader: "text",
contents: await Bun.file(args.path).text(),
};
},
);
},
},
],
});
for (const line of out.logs) {
console.log(line);
}
process.exit(out.success ? 0 : 1);