fix(bun): Support application builds with Bun #6344
Merged
+10
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?
Description
This PR fixes support for Bun in Qwik by just removing
bun
from the results ofgetEnv
function inpackages/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 aspnpm build
without any issueActual 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: