unjs / unenv

🕊️ Convert javaScript code to be runtime agnostic
MIT License
358 stars 19 forks source link

`cloudflare` preset #97

Closed pi0 closed 8 months ago

pi0 commented 1 year ago

Related notes: https://github.com/unjs/nitro/issues/1171

https://developers.cloudflare.com/workers/runtime-apis/nodejs/

Hebilicious commented 1 year ago

Cloudflare node compat doesn't include node:crypto, but we could add a cloudflare-node-compat preset to unenv to avoid polyfill what they already polyfill.

Originally posted by @Hebilicious in https://github.com/unjs/unenv/issues/111#issuecomment-1615152492

pi0 commented 1 year ago

Let's hope they do support crypto too in the future. My main intention of this was AsyncLocalStorage support which is impossible in userland + possibly reduce bundle sizes when cloudflare supports some APIs.

pi0 commented 1 year ago

More i am thinking, it makes more sense to take better control in framework level since it tightly depends on platform integration (and configuration!). Taking approach like https://github.com/unjs/unenv/pull/126 to allow platform injections via globalThis.

pi0 commented 8 months ago

Seems we need to reconsider this since platforms seem liking to stick with their flavored polyfill. Also added for deno https://github.com/unjs/unenv/pull/155