Using polyfills in Workers for ESNext features

I wanted to know if there's a way to use polyfills in workers for ESNext features, specifically, the iterator functions, ie. Iterator.prototype.filter ,etc... Or does it work just fine? Sometimes workers seems too simplified and I can't tell how the JS is being transformed.
2 Replies
DaniFoldi
DaniFoldi10mo ago
You can append --outdir dist --dry-run to your deploy command to see the code exactly as it gets uploaded. As Leo said, very little polyfilling is needed since the runtime is updated with the newest v8 version regularly. For non-standard features such as the sync helpers in iterators, until they're stabilized you'd need to use a custom build command (docs: https://developers.cloudflare.com/workers/wrangler/custom-builds/) and build with babel or something similar.
Piero512
Piero512OP10mo ago
I see. I sometimes wish that js didn't have such a poor standard library I read somewhere you can use other languages to write workers, although they're overkill for my usecase oh my, there's dart support lol
Want results from more Discord servers?
Add your server