Breaks when built using Vite 8 / rolldown
What platform were you using when you found the bug?
- React Flow / Svelte Flow version: React flow 12.10.1
- Browser and version: Chrome
- OS and version: Mac OS latest
Live code example
No response
Describe the Bug
When we build with Vite 8 we get an error "Dynamic require of "react" is not supported"
After analyzing this deeply we found that there is still a hard CJS dependency coming from zustand v4, specifically these
"use-sync-external-store", "use-sync-external-store/shim"
We are trying to build ESM only however all downstream apps are not able to run due to this error, it seems the default rolldown polyfill or shim is not able to shim this particular CJS usage.
One fix may be to migrate to zustand v5.
We have tested many builds and many components and so far only this xyflow is causing us these issues with Vite 8, so it will be related to the change from rollup to rolldown I suspect and clearly a CJS downstream issue.
Steps to reproduce the bug or issue
Create a react project Install latest @xyflow/react Build using vite Inspect the dist output and see the usage of require in there alternatively try to import and use the component in an ESM only react app, it will show the error
Expected behavior
No require CJS usage
Screenshots or Videos
No response
Additional context
No response
Source: xyflow/xyflow