unenv icon indicating copy to clipboard operation
unenv copied to clipboard

Dedicated `wrangler` preset

Open pi0 opened this issue 1 year ago • 4 comments

We have introduced a new cloudflare preset and set of $cloudflare polyfill variations set by this preset to allow leveraging hybrid Node.js compatibility available in workerd runtime.

Initially, cloudflare preset was introduced to be included in Nitro (rollup based) and we are working with cloudflare team to also integrate unenv into wrangler tooling (esbuild based)

Apart from bundler subtle differences (rollup and esbuild), from discussions like #257 i can predict in the future, we might have legit reasons that Nitro and Wrangler might need different ways of adding Cloudflare polyfills.

One way is to expose standard plugin (~> https://github.com/unjs/unenv/issues/263) but still decisions might vary on tool level between wrangler and Nitro objectives.

I propose to introduce a new wrangler preset ahead of time (maintained by @IgorMinar @jculvey as well) to allow forward-compatible way to collaborate releases between unenv and wrangler without imposing unwanted changes to the end users.

pi0 avatar Jun 18 '24 08:06 pi0

I'll think about this more, but I'd really like to avoid wrangler specific preset. The hybrid polyfill we implemented relies on aligning versions of workerd and unenv and this will become much harder to reason about if we in addition to this also have to think about two different presets.

IgorMinar avatar Jun 18 '24 15:06 IgorMinar

I also wish minimum possible variations and wrangler preset (extending cloudflare > nodeless) to be as empty as possible.

My intention is not to duplicate efforts but have a safe space that we can put wrangler-specific requirements. For example injection for global Performance polyfills with Node.js addons.

(i might have better idea for configurable presets to avoid additional one but the gist of idea will be same: a way to cerianly know if we are exporting preset for wrangler or nitro and with or without Node global API)

pi0 avatar Jun 18 '24 17:06 pi0

hey @pi0 looking for solution for 4 days, using Nuxt and cloudflare deployment and get this "[unenv] crypto.createHash is not implemented yet!" what shall i do ?

Dmytro-Tihunov avatar Aug 14 '24 22:08 Dmytro-Tihunov

@Dmytro-Tihunov please report issue in either Nuxt or Nitro repository with reproduction and avoid pining in other threads 🙏🏼

pi0 avatar Aug 14 '24 22:08 pi0

Cloudflare / Wrangler preset is being externalized #336

pi0 avatar Dec 02 '24 12:12 pi0