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

Enable cloudflare Node.js compatibility layer #1171

Open
pi0 opened this issue Apr 19, 2023 · 6 comments
Open

Enable cloudflare Node.js compatibility layer #1171

pi0 opened this issue Apr 19, 2023 · 6 comments

Comments

@pi0
Copy link
Member

pi0 commented Apr 19, 2023

Cloudflare supports a subset of Node.js compatible imports.

Unenv, has a good coverage for most of the Node.js polyfills and shims. But by replacing the supported subset we can:

  • Reduce bundle size as runtime provides them
  • Leverage node:internal native features are impossible to add into userland such as async_hooks

There are two concerns:

  • Cloudflare shims are not as complete as unenv ones
  • We need to make sure wrangler.toml has enabled compatibility flag and otherwise fail or warn the build to ask users doing this based on usage.
@Hebilicious
Copy link
Member

We need to add a cloudflare preset to unenv first.

@pi0
Copy link
Member Author

pi0 commented Aug 8, 2023

Related unjs/unenv#126

We shall find a way to inject compatible classes from platform

@Hebilicious
Copy link
Member

@luc122c
Copy link
Contributor

luc122c commented Aug 8, 2023

Hopefully this shoud resolve cloudflare/workers-sdk#2081

@Hebilicious
Copy link
Member

Hebilicious commented Aug 8, 2023

Hopefully this shoud resolve cloudflare/workers-sdk#2081

I can see we don't have a tracking repo on our side though, ideally try to pinpoint if its a Nuxt/Nitro/Nuxt-security issue and open an issue there 🙏🏽

@andrevandal
Copy link

great improvement!

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

No branches or pull requests

4 participants