Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bun build stucks with async reading file in macro #14104

Open
sirenkovladd opened this issue Sep 23, 2024 · 2 comments
Open

Bun build stucks with async reading file in macro #14104

sirenkovladd opened this issue Sep 23, 2024 · 2 comments
Labels
bug Something isn't working bundler Something to do with the bundler confirmed bug We can reproduce this issue

Comments

@sirenkovladd
Copy link
Contributor

What version of Bun is running?

1.1.29+6d43b3662

What platform is your computer?

Darwin 23.6.0 arm64 arm

What steps can reproduce the bug?

Bun.write(
  "randomFile",
  '123'
);

Bun.write(
  "content.ts",
  // works
  // 'export function content() { return require("node:fs").readFileSync("./randomFile", "utf8"); }',

  // stucks
  'export function content() { return Bun.file("./randomFile").text(); }'
);
Bun.write(
  "test.ts",
  'import { content } from "./content" with { type: "macro" };\n console.log(await content())'
);

await Bun.$`bun test.ts`
console.log('\n')
await Bun.$`bun build --minify test.ts`

await Bun.$`rm -f randomFile content.ts test.ts`

What is the expected behavior?

❯ bun index.ts
123


console.log(await"123");

What do you see instead?

❯ bun index.ts
123


^C

Additional information

No response

@sirenkovladd sirenkovladd added bug Something isn't working needs triage labels Sep 23, 2024
@sirenkovladd
Copy link
Contributor Author

it doesn't work with this code either

export async function content() { return await require("node:fs/promises").readFile("./randomFile", "utf8"); }

so it looks like the problem is with asynchronous file reading

@sirenkovladd sirenkovladd changed the title Bun build stucks with Bun.file in macro Bun build stucks with async reading file in macro Sep 23, 2024
@pfgithub pfgithub added bundler Something to do with the bundler confirmed bug We can reproduce this issue and removed needs triage labels Nov 6, 2024
@brainkim
Copy link

Probably a duplicate of #7611

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bundler Something to do with the bundler confirmed bug We can reproduce this issue
Projects
None yet
Development

No branches or pull requests

3 participants