davidmyersdev/vite-plugin-node-polyfills

Warning on "use client" directive when using plugin alongside react

KholdStare opened this issue · 3 comments

When using this plugin alongside some react libraries, running a vite build results in a spew of errors like:

../node_modules/wagmi/dist/index.js (1:0) Module level directives cause errors when bundled, "use client" in "../node_modules/wagmi/dist/index.js" was ignored.

There are a bunch of issues filed in several libraries, but I think something is happening when using both this plugin and react, when dependencies use the new use client directive. See this issue in the rollup project:

rollup/rollup#4699

I have created a small stackblitz environment where running npm run build will result in these warnings:

https://stackblitz.com/edit/vitejs-vite-pcpqdr?file=vite.config.ts

The key thing to note is that just removing this plugin fixes all the warnings. So there is some funky interaction.

Looks like this might have been fixed: rollup/rollup#4699 (comment)

Nope still seeing it. Updating vite in stackblitz didn't help either. Seems like it's similar to this issue: #45

This looks like it fixes the issue: #53

Released in v0.16.0.