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

Migrate to Bun #114

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open

Migrate to Bun #114

wants to merge 36 commits into from

Conversation

WarningImHack3r
Copy link
Member

@WarningImHack3r WarningImHack3r commented Sep 10, 2023

As Bun 1.0 is officially out and we are always the first to opt-in to the latest technologies, let's try it and see if we can get better performance!

We don't have much to change as Bun is a drop-in replacement and we don't use many components that Bun replaces, so it's pretty straightforward.

Changes

  • Replace pnpm with Bun in the lock file and CI
  • Change from @sveltejs/adapter-static to svelte-adapter-bun (that should work the same)
  • Add .gitattributes for optimal lock file support

Speed gains

What will be impacted

  • Dependencies installation (both locally and in CI, you're welcome, GitHub)
    • As the install process in CI is much easier than for pnpm, the Unlighthouse step now uses Bun and will thus be significantly faster
  • Startup times of package.json scripts

What won't be impacted

  • Website speed: As the output is static anyway, there won't be any change on that side. If we were to host it on a "Node" server, however, we would notice a significant improvement
  • All the rest

What's needed before merge

  • Find a way to ensure the other non-PR CI jobs won't break
  • Wait for the soon-to-be Windows port for @MinixBF? (or if it's fine enough to use WSL)
  • Check that it's compatible with static GitHub Pages we don't have any bun-specific feature in src, should be fine
  • Make a last tour on what could be migrated/improved

Note

To optimize support for bun.lockb by git, add this to your global configuration (source):

git config --global diff.lockb.textconv bun
git config --global diff.lockb.binary true

@WarningImHack3r
Copy link
Member Author

WarningImHack3r commented Sep 10, 2023

First speed test comparison

Dependencies installation (Husky included - from scratch)

pnpm ibun i (macOS): 13s ➜ 0.5-4s
pnpm ibun i (CI): 2.5s ➜ 1-3s

Build

macOS: 21s ➜ 22s
CI: 1m10s ➜ 1m5s

Note
The build time is almost unchanged apart from a few ms to start the vite command.
90% of our build time is due to the svelte-icons dependency anyway.

CI Node+pnpm / Bun installation (Husky included)

Before: 8s
After: 1-3s

Unlighthouse check

Before: 1m15s
After: 50s

Overall CI improvements (PR only)

Before: 2m10s
After: 1m40s

@WarningImHack3r
Copy link
Member Author

Follow-up for SSG (GitHub Pages) support: gornostay25/svelte-adapter-bun#26

@github-actions github-actions bot changed the title Migrate to Bun infra: Migrate to Bun Nov 13, 2023
@WarningImHack3r WarningImHack3r marked this pull request as ready for review March 1, 2024 22:14
@WarningImHack3r WarningImHack3r requested a review from a team as a code owner March 1, 2024 22:14
@WarningImHack3r
Copy link
Member Author

This migration is finally ready to be performed.
I can't wait to be blazingly fast 🏎️

One last doubt: I often see (and I experienced it) people complaining about some little different behaviors between Node and Bun, that the Bun team is well aware of and actively working on. I'm a bit hesitant because for now, everything's good, however, nothing guarantees that we won't stumble across a similar issue someday... Do we need to wait a little more? Do we care? Couldn't we simply revert this PR if something goes wrong? I don't know...

@WarningImHack3r WarningImHack3r changed the title infra: Migrate to Bun Migrate to Bun Mar 1, 2024
@MinixBF
Copy link
Contributor

MinixBF commented Mar 18, 2024

I finally tested it and reviewed it, it works perfectly. Well done! 👋
I'm ready to migrate when you think it will be good (I have less hindsight on this).

@github-actions github-actions bot changed the title Migrate to Bun infra: Migrate to Bun Apr 1, 2024
@WarningImHack3r WarningImHack3r changed the title infra: Migrate to Bun Migrate to Bun Apr 1, 2024
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.

2 participants