davidmyersdev/vite-plugin-node-polyfills

exclude polyfills for specific dependencies

UnCor3 opened this issue · 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)

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.

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 ?