Skip to content
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

Clean handling of several versions of React - yarn link of node modules with Lerna #5

Closed
eric-burel opened this issue Sep 21, 2020 · 2 comments
Labels
enhancement New feature or request lerna

Comments

@eric-burel
Copy link
Collaborator

eric-burel commented Sep 21, 2020

This concerns the development environment, when one want to test the local version of Vulcan NPM in a Vulcan app.

facebook/react#13991
facebook/react#14257
https://stackoverflow.com/questions/34706817/how-prevent-multiple-copies-of-react-from-loading
https://next.material-ui.com/getting-started/faq/#duplicated-module-in-node-modules
https://robkendal.co.uk/blog/2019-12-22-solving-react-hooks-invalid-hook-call-warning

Using npm link or yarn link on Lerna packages ends up loading 2 versions of React and React Dom. We might avoid this by making React and React DOM peer dependencies, or using more robust commands in Vulcan Next

Current fix:

  • In Vulcan NPM, run cd node_modules/react && yarn link, same with react-dom or any problematic duplicate package
  • In your project, run yarn link react, yarn link react-dom, etc. with any problematic library. This way the Vulcan NPM version will be preferred

Alternative: using Webpack but that's not good.

Possible solution:
Allow to pass a VULCAN_PACKAGE_DIRS env variable like we did in Meteor and handle yarn link ourselves, so the end user doesn't need to know it.

@eric-burel eric-burel added lerna enhancement New feature or request labels Sep 21, 2020
@eric-burel eric-burel changed the title Clean handling of several versions of React Clean handling of several versions of React - yarn link of node modules with Lerna Sep 21, 2020
@eric-burel
Copy link
Collaborator Author

yalc seems to have been proposed as a solution https://www.npmjs.com/package/yalc.
Also hitting this bug with Next.js Webpack versions...

@eric-burel
Copy link
Collaborator Author

Sister issue in Vulcan Next: VulcanJS/vulcan-next#104, that would provide an efficient solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lerna
Projects
None yet
Development

No branches or pull requests

1 participant