You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Doing a big re-architecture of a monolith frontend. We are too big to safely upgrade React and other fundamental libraries across the whole app. It causes too many issues. Better to upgrade page by page. That means several versions of React need to co-exist in one app.
I managed to achieve this by breaking down the monolith onto multiple npm packages. There is a shell package, which references individual page packages. Shell also has the central storybook instance, which imports all the stories from the other packages.
node_modules
react 17
packages
shell
storybook
pageA @ react 17
pageB @ react 18
node_modules
react 18
This all works correctly in webpack. It loads the right version depending on where the code lives. But storybook (@storybook/react, webpack5) seem to hard-wire react to always be from the root node_modules. I can see it adds webpack resolve aliases for react and react-dom. This means that anything expecting react 18 gets react 17.
So far I haven't found any way to resolve this. Has anyone done anything similar? Is it possible at all?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Doing a big re-architecture of a monolith frontend. We are too big to safely upgrade React and other fundamental libraries across the whole app. It causes too many issues. Better to upgrade page by page. That means several versions of React need to co-exist in one app.
I managed to achieve this by breaking down the monolith onto multiple npm packages. There is a shell package, which references individual page packages. Shell also has the central storybook instance, which imports all the stories from the other packages.
This all works correctly in webpack. It loads the right version depending on where the code lives. But storybook (
@storybook/react
,webpack5
) seem to hard-wire react to always be from the root node_modules. I can see it adds webpack resolve aliases for react and react-dom. This means that anything expecting react 18 gets react 17.So far I haven't found any way to resolve this. Has anyone done anything similar? Is it possible at all?
Beta Was this translation helpful? Give feedback.
All reactions