-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warning with use client
directive with Vite
#5175
Comments
please see the discussion on the PR: @Ephem I don't think there's anything we can do right now about this? |
No, besides removing the directives entirely there's nothing we can do in React Query itself sadly, at least that I know of. A bit swamped this week but I'll try to find some time to open issues (if none exist) and perhaps contribute an ignore for the warning to the Vite React plugin. TL;DR for this warning: You can safely ignore it. If you want to hide it, you can use Rollups |
Hi, I'm also getting the same errors, at least we know now that is safe to ignore them.
|
As @Ephem said, we can add the following in our rollup options: onwarn(warning, warn) {
if (warning.code === 'MODULE_LEVEL_DIRECTIVE') {
return
}
warn(warning)
} |
As an update to anyone reading this, the Vite React-plugin will soon silence this warning by default. This is not available in a stable release yet, but is in the 4.0.0-beta.0 release. Thanks a lot to @ArnaudBarre for adding the fix and @thebuilder for reporting it over there! 👏 |
Sounds good 👌 |
I can still see it with version 4.1.0. |
im not even using react-query and i get this error on latest vite |
I'm using Vite |
It's possible another plugin is overwriting the warning handler. That was the case for me with node polyfill plugin (fixed now). So maybe try removing other plugins to see if the warnings go away. |
@derekdavenport I'm still seeing the same issue with node polyfill plugin, with latest versions of everything: davidmyersdev/vite-plugin-node-polyfills#49 |
We are still getting the warnings with these versions |
Yeah this is coming from |
Which file am I going to add this? |
You can add it in vite.config.js like that. |
I resolved my problem
Refer links: https://github.com/laravel/vite-plugin/blob/1.x/UPGRADE.md |
For some reason, using Rollup's onLog(level, log, handler) {
if (log.code === "MODULE_LEVEL_DIRECTIVE") {
return;
}
handler(level, log);
}, |
Describe the bug
Module level directives cause errors when bundled, "use client" in "node_modules/@tanstack/react-query/build/lib/useSyncExternalStore.mjs" was ignored.
Your minimal, reproducible example
I don't have time
Steps to reproduce
Use query v4.28.0 with vite. I wonder does it affect the build or not.
Expected behavior
I will not see the warning
How often does this bug happen?
Every time
Screenshots or Videos
Platform
Windows: 11
Tanstack Query adapter
react-query
TanStack Query version
v4.28.0
TypeScript version
v5
Additional context
No response
The text was updated successfully, but these errors were encountered: