diff options
Diffstat (limited to 'packages/bun-wasm/test/node.mjs')
-rw-r--r-- | packages/bun-wasm/test/node.mjs | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/packages/bun-wasm/test/node.mjs b/packages/bun-wasm/test/node.mjs index 832b3f67b..92162fa4f 100644 --- a/packages/bun-wasm/test/node.mjs +++ b/packages/bun-wasm/test/node.mjs @@ -1,17 +1,25 @@ import * as Bun from "../index.mjs"; +import process from "process"; await Bun.init(new URL("../bun.wasm", import.meta.url)); -const hey = Bun.transformSync( - ` +const buf = + (process.argv.length > 2 ? process.argv.at(-1) : "") || + new TextEncoder().encode(` export function hi() { - return true; + return <div>Hey</div>; } -`, - "hi.js", - "js" -); +`); +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"); +} -console.log(JSON.stringify(hey, null, 2)); +process.stdout.write(result.files[0].data); |