-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
ViteJs causing problem in react monorepo, @emotion stops working during development #11389
Comments
This seems to be a dual package hazard problem.
Vite only uses vite/packages/vite/src/node/plugins/resolve.ts Lines 1102 to 1107 in d617093
So Given that I'm not sure why it works in prod though. |
look like we have a same problem, here is my project https://github.com/MrWangJustToDo/react-ssr-setup |
I am hitting the same problem too. This only affects dev mode as well for me, not prod/preview. I am curious if there is a work around. |
I've come across this before with just a single package, it was in a case where a module was loading from the CJS sources while the app was loading from ESM sources. It would emit that loading twice message. |
Are there any workarounds or is the fix coming any time soon? This is preventing me from updating to latest Chakra UI in my project, since I can not work in dev mode. And since this is confirmed bug in Vite, I guess ChakraUI types were not exported properly, and that's why this issue didn't exist before. |
Running into this issue with |
Since it seems this is not going to be fixed anytime soon, I forked ajna pagination, and exported ESM. Problem solved at least for me. You can get my forked package here: https://www.npmjs.com/package/@paradox37/ajna-pagination |
Running into this as well with Is there any kind of workaround? Or better still, a fix? |
Describe the bug
I am using monorepo setup, in one folder I have a project, another folder is called shared where I keep components to share between projects. In the project I am using ChakraUI, which uses @emotion package for writing css with js.
In the repo I provided, you can see I have Pagination component in shared folder. When I use color='red.400' it's not recognized as CSS. If I apply that same color in AppWrapper which is inside project1 folder it works.
I can see in console log this warning as soon as I import Pagination component to AppWrapper:
You are loading @emotion/react when it is already loaded. Running multiple instances may cause problems. This can happen if multiple versions are used, or if multiple builds of the same version are used.
The strange thing is that this only happens when running in Dev mode. Production build does not give any warnings and CSS is applied properly. Also, when using Create React Scripts, this issue is not present, that is why I think this is some bug with ViteJs.
Same issue exists with v3 and v4.
Reproduction
https://github.com/paradox37/monorepo
Steps to reproduce
Check console and also inspect pagination element, it can be seen that instead of color, plain string is applied, eg 'red.400' instead of #F56565.
No issue in production:
System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: