oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.48k stars 2.71k forks source link

[macro] cannot serialize Uint8Array #7112

Open codehz opened 10 months ago

codehz commented 10 months ago

What version of Bun is running?

1.0.11+f7f6233ea

What platform is your computer?

Darwin 23.1.0 arm64 arm

What steps can reproduce the bug?

import { readFile } from "./fsw" assert { type: "macro" };

const file = await readFile("package.json");

console.log(file);

due to https://github.com/oven-sh/bun/issues/7111 I have to create a wrapper the fsw is

export * from "node:fs/promises";

What is the expected behavior?

got the Uint8Array, because the documentation say it can serialize TypedArray

What do you see instead?

error: cannot coerce Uint8Array to Bun's AST. Please return a valid macro using the JSX syntax

const file = await readFile("package.json");
                   ^
###/bun-bug/read.ts:3:20 79

Additional information

No response

infrahead commented 3 months ago

Still experiencing this as of v1.1.12. Is the documentation wrong?

Workaround for now is to explicitly base64 encode before returning