vite-plugin-node-polyfills icon indicating copy to clipboard operation
vite-plugin-node-polyfills copied to clipboard

exclude polyfills for specific dependencies

Open uncor3 opened this issue 1 year ago • 2 comments

Hi there, is there a way to exclude polyfills for a specific dependency ?

I've had issues with a library because it thinks it's running in node due to the process polyfill. In the source code of this repo banners are used to inject the process polyfill and according to esbuild docs there isn't a way to filter which files to inject the banner so i got stuck

So far i've tried

  • Excluding the dependency from optimizeDeps (didnt work because the library has require calls)
  • Doing a dynamic import instead (didn't work)

uncor3 avatar Jul 23 '24 02:07 uncor3

Sure thing. You can exclude imported polyfills with the exclude option, and you can exclude global polyfills (Buffer, process, or global) with the globals option. Check out this section of the readme.

davidmyersdev avatar Jul 28 '24 20:07 davidmyersdev

Thanks for responding. I think i got misunderstood. I need the polyfills in some of my dependencies but others do not like it(issue explained in my first comment), is there a way to exclude polyfills file based ?

uncor3 avatar Jul 29 '24 22:07 uncor3