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

implement --polyfill-node / config.polyfill_node #101

Closed
Tracked by #151
threepointone opened this issue Dec 13, 2021 · 3 comments · Fixed by planetscale/database-js#102
Closed
Tracked by #151

implement --polyfill-node / config.polyfill_node #101

threepointone opened this issue Dec 13, 2021 · 3 comments · Fixed by planetscale/database-js#102

Comments

@threepointone
Copy link
Contributor

Lots of libraries in the ecosystem assume a node.js environment. Those modules just aren't available in Workers, but some can be polyfilled (e.g - path, url, etc). I made an attempt at landing this in #72, but removed it in #100 because the polyfills are made for the browser, not Workers (eg - the http polyfill assumes the presence of XMLHTTPRequest). Some polyfills just don't exist (eg - crypto). It's all quite bad really, and it's not good enough even as a prototype.

So this issue tracks the proper implementation of this feature. We'll have to implement some of them scratch, and have proper messaging around the ones that do get used.

This was referenced Dec 19, 2021
@petebacondarwin petebacondarwin added this to the Wrangler 2.1 milestone Feb 1, 2022
@mangs
Copy link

mangs commented Apr 19, 2022

I had an interesting thought, not sure if this is useful or not. Workers APIs seem to follow much more closely to modern browser APIs than Node.js ones which got me thinking of Deno (which also does so) and how it would be nice if wrangler could have its own built-in runtime with said polyfills. Then I remembered the deno compile command wherein you could essentially build a custom runtime into its own executable then ship it as part of wrangler2 perhaps? A zero additional dependency way to emulate workers would be great (not having to also have Node.js installed in addition to wrangler2)

@mangs
Copy link

mangs commented May 9, 2022

Wow. I'm so looking forward to having an open-sourced Workers runtime and trying it with wrangler2. Great job to everyone at Cloudflare and beyond who made that happen!!

@threepointone
Copy link
Contributor Author

We landed initial support for this in 2.0 (as config.node_compat / --node-compat). We'll continue working on this, and file fresh issues for it. Closing this one. Personally very excited about this myself!

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 a pull request may close this issue.

3 participants