Skip to content

Commit 503b040

Browse files
committed
build: compile react wrappers to dist
1 parent 9746ff0 commit 503b040

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

build.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,22 @@ if (!core.success) {
1515
process.exit(1)
1616
}
1717

18-
const { outputs } = await Bun.build({
19-
entrypoints: ["src/index.ts"],
18+
const react = await Bun.build({
19+
entrypoints: ["src/react/index.ts"],
20+
outdir: "dist/react",
21+
format: "esm",
22+
target: "browser",
23+
external: ["react", "react-dom"],
2024
minify: true,
25+
banner: '"use client";',
2126
})
2227

23-
const output = outputs[0]
24-
if (!output) throw new Error("Build produced no output")
28+
if (!react.success) {
29+
for (const log of react.logs) console.error(log)
30+
process.exit(1)
31+
}
2532

26-
const gzipped = Bun.gzipSync(await output.arrayBuffer())
33+
const gzipped = Bun.gzipSync(await Bun.file("dist/index.js").arrayBuffer())
2734
const sizeKB = `${(gzipped.length / 1024).toFixed(1)}kB`
2835

2936
const glob = new Bun.Glob("tests/*.spec.ts")

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"./src": "./src/index.ts",
2222
"./react": {
2323
"types": "./src/react/index.ts",
24-
"default": "./src/react/index.ts"
24+
"default": "./dist/react/index.js"
2525
}
2626
},
2727
"typesVersions": {
@@ -31,7 +31,7 @@
3131
},
3232
"files": ["dist", "src"],
3333
"scripts": {
34-
"build": "bun build.ts",
34+
"build": "NODE_ENV=production bun build.ts",
3535
"test": "playwright test",
3636
"lint": "biome check src tests",
3737
"lint:fix": "biome check --write src tests",

0 commit comments

Comments
 (0)