remorses/esbuild-plugins

Switch polyfill lib

Niek opened this issue Β· 5 comments

Niek commented

Please consider switching the polyfill lib to: https://github.com/snowpackjs/rollup-plugin-polyfill-node

It's the forked & maintained/updated version of the lib you are currently using.

niksy commented

I would also like to mention my fork of popular Webpack polyfill library, maintained with newer versions of dependencies and with newer stuff like timers/promises: https://github.com/niksy/node-stdlib-browser

It’s build-tool agnostic so it works with esbuild as well.

+1. I just ran into issues due to this, because many modern methods (like util.promisify) aren't available in the very outdated rollup polyfills. util.promisify was added in Node v8, released in 2017, so it's not exactly cutting edge!

Since this issue was opened it seems that Snowpack have closed their fork, but node-stdlib-browser does look like a great & actively maintained compilation of the best existing polyfills to me.

As an alternative, being able to provide an option to override the polyfills used in some cases would make it easier to at least manually work around these cases.

niksy commented

I think node-stdlib-browser could be easily used as replacement for current polyfills/globals without changing the API.

@niksy I just switched to node-stdlib-browser β€” specifically the vite plugin: vite-plugin-node-stdlib-browser β€” works like a charm.

New version uses different polyfill library