blob: 92162fa4f75923e599c0bd4b921e61ff0bd6222f (
plain) (
blame)
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
|
import * as Bun from "../index.mjs";
import process from "process";
await Bun.init(new URL("../bun.wasm", import.meta.url));
const buf =
(process.argv.length > 2 ? process.argv.at(-1) : "") ||
new TextEncoder().encode(`
export function hi() {
return <div>Hey</div>;
}
`);
const result = Bun.transformSync(buf, "hi.jsx", "jsx");
if (result.errors?.length) {
console.log(JSON.stringify(result.errors, null, 2));
throw new Error("Failed");
}
if (!result.files.length) {
throw new Error("unexpectedly empty");
}
process.stdout.write(result.files[0].data);
|