Skip to content

Instantly share code, notes, and snippets.

@Hebilicious
Last active April 10, 2024 01:01
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Hebilicious/88e5a444f42b8dc09fb86dfa865c6ed3 to your computer and use it in GitHub Desktop.
Save Hebilicious/88e5a444f42b8dc09fb86dfa865c6ed3 to your computer and use it in GitHub Desktop.
Cloudflare Pages and Bun
# Bun is now officially supported and these environments variables are no longer needed. Keeping this gist for legacy purposes.
# SKIP_DEPENDENCY_INSTALL=true
# UNSTABLE_PRE_BUILD=asdf install bun latest && asdf global bun latest && bun i
@markjaquith
Copy link

Note: When using Bun to install packages for Astro sites on Cloudflare Pages, you will have to manually install Sharp using npm for now, until this bug is resolved.

In addition to the above environment variables, your build step should be: npm i --no-save sharp && bun run build

@markjaquith
Copy link

As of a few hours ago, the asdf plugin add bun part causes an error. After removing it, deploys work again.

UNSTABLE_PRE_BUILD=asdf install bun latest && asdf global bun latest && bun i

@Hebilicious
Copy link
Author

As of a few hours ago, the asdf plugin add bun part causes an error. After removing it, deploys work again.

UNSTABLE_PRE_BUILD=asdf install bun latest && asdf global bun latest && bun i

Thanks, I edited the gist accordingly. I assume it's because they're working on adding official bun support.

@thienandangthanh
Copy link

thienandangthanh commented Oct 11, 2023

Bun is now supported in the build image by default.

As JohnDotAwesome - Cloudflare Engineer stated on Septemeber 19th 2023.
https://discord.com/channels/595317990191398933/1134543567004631121/1153709963043160187

It's supported only on Cloudflare build system V2.

Just like in other tools, you can specify exact versions (e.g. by setting the env var BUN_VERSION to 1.0.2) The Pages build image ships with bun 1.0.1. We'll update pre-installed versions periodically

https://discord.com/channels/595317990191398933/1134543567004631121/1152321372786274314

So we no longer need to set these ENV.
Only set BUN_VERSION to more current version if needed.

@aquaPumpers
Copy link

My Greetings,

Use this guide and have a result

https://github.com/aquaPumpers/Strapi-Aquapumpers

TY

@mariusbolik
Copy link

mariusbolik commented Feb 14, 2024

Note: When using Bun to install packages for Astro sites on Cloudflare Pages, you will have to manually install Sharp using npm for now, until this bug is resolved.

In addition to the above environment variables, your build step should be: npm i --no-save sharp && bun run build

Sharp does now work with the Bun Runtime: lovell/sharp#3511 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment