Closed elevu closed 1 year ago
wait for the craco package to support React 18
I've come across a problem when trying to update to React 18. Certain packages in our project, such as 'probe-image-size', seem to be having issues because they need the 'stream' module, which is part of node.js.
The upgrade to React 18 uses webpack 5, which has made some changes. One of those changes is that it no longer automatically includes certain features that come with node.js, known as polyfills. The 'stream' module is one of those features, and without it, our project won't compile properly.
The exact error we get is:
Module not found: Error: Can't resolve 'stream' in '/Users/mohammed.darrah/gits/statina-ui/node_modules/probe-image-size/lib' BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
We could fix this by manually adding back the 'stream' module with a workaround, but that's more of a temporary patch. I think it's a better idea to hold off on updating to React 18 until a more lasting fix is available.
Which packages that we are directly using are causing this? probe-image-size is a dependency, but of which package?
It seems that plotly.js requires a polyfill to operate with the probe-image-size library.
Done!
https://reactjs.org/blog/2022/03/29/react-v18.html