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

Support for Bun could easily be added #530

Closed
leo opened this issue May 1, 2024 · 1 comment · Fixed by #531
Closed

Support for Bun could easily be added #530

leo opened this issue May 1, 2024 · 1 comment · Fixed by #531

Comments

@leo
Copy link
Contributor

leo commented May 1, 2024

We just ran into the following error earlier, which was blocking our CI after having introduced bunchee to a Bun monorepo:

CleanShot 2024-05-01 at 14 04 26@2x

In this case, bunchee announces that typescript is not available, but the reality is that it's not require that is throwing an error, but instead the fact that m (presumably the current module) is not defined, which means that .require is not even available and cannot be invoked.

We temporarily fixed the problem by removing the module resolving logic entirely, which made it work:

CleanShot 2024-05-01 at 14 46 05@2x

As mentioned above, it's a Bun monorepo with several different workspaces, but typescript and tsconfig.json sit at the top, while bunchee is invoked with bunchee --tsconfig ../../tsconfig.json from a workspace.

Perhaps it would make sense to switch over to an entirely different module resolving logic? Happy to give it a try and report back if it resolves our issue, so that you don't need to set up an entire reproduction Bun monorepo. Or perhaps you already have another idea for what the cause could be.

Like I said it is a Bun monorepo, but since bunchee has a Node.js shebang in its binary entry point file, it should still be Node.js that is running bunchee, unless I'm missing something.

We're also not using bun run --bun to overwrite the shebang.

@leo leo changed the title Logic for resolving typescript is not reliable Support for Bun could easily be added May 1, 2024
@leo
Copy link
Contributor Author

leo commented May 1, 2024

After running bunchee with npx (Node.js) and then bunx --bun (Bun), I was able to confirm that this logic doesn't work in Bun, so it seems like we were running bunchee via Bun after all. Or, to be specific, Bun was automatically replacing the Node.js shebang with bun, which might've been a result of us using bun run --filter at the root.


Regardless, the summary is that bunchee doesn't seem to work on Bun. But the good news is that this logic seems to be the only thing that is not working in Bun — the rest is. Perhaps there's an equivalent that bunchee could use here that would work in both Node.js and Bun?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant