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

fix(bun): Support application builds with Bun #6344

Merged
merged 9 commits into from
May 21, 2024

Conversation

octet-stream
Copy link
Contributor

@octet-stream octet-stream commented May 20, 2024

Overview

Fixes #5917 (partially)

While Qwik has adapter for Bun, there's no support for running Qwik's CLI via Bun itself. Because of this developers must depend on Node.js during deployments just to build their applications even if they don't use it on their servers.

What is it?

  • Feature / enhancement
  • Bug
  • Docs / tests / types / typos

Description

This PR fixes support for Bun in Qwik by just removing bun from the results of getEnv function in packages/qwik/src/optimizer/src/platform.ts. I am not quite satisfied with the solution, but it works. Still, I will be much appreciated if somebody helps me find a better solution, because I am not much familiar with the codebase.

In addition, this PR limits the number of workers for SSG, because otherwise the build will just hang without any progress. I wasn't able to properly isolate this bug and versify whether it is an issue with Qwik or Bun itself, so I just added the limit. The fact that the same code works in Node.js suggest that it can be on Bun's side, so I will report this issue to them and we'll see.

Lastly, this PR adds another place where we patch TextEncoderStream for bun, because bun does's have their implementation.

Also, since Qwik already uses polyfills in other places, this is something that needs to be better organized. I suggest we add a function that will (conditionally) apply all needed polyfill. You can look it Remix as the example: https://remix.run/docs/en/main/other-api/node#polyfills - they have a function installGlobals that does the same thing.

Use cases and why

Expected behavior was: bun run --bun build is able to run just as pnpm build without any issue

Actual behavior was: bun run --bun build fails with the error saying that the platform is not supported.

Currently to work around this issue, I had to setup Node.js in one of my Docker layers just to build my application during deployments.

Checklist:

  • My code follows the developer guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • Added new tests to cover the fix / functionality

Sorry, something went wrong.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
Copy link

netlify bot commented May 20, 2024

👷 Deploy request for qwik-insights pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 8954321

@octet-stream octet-stream marked this pull request as ready for review May 20, 2024 16:58
@PatrickJS
Copy link
Member

@octet-stream thanks!

@PatrickJS PatrickJS merged commit 0b8410b into QwikDev:main May 21, 2024
21 checks passed
@octet-stream octet-stream deleted the fix/build-with-bun branch May 21, 2024 18:14
@PatrickJS
Copy link
Member

@octet-stream this is in 1.5.5

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 this pull request may close these issues.

[🐞] Can't build project via bun run --bun
2 participants