material-motion-js
material-motion-js copied to clipboard
Sharing dependencies across packages
Problem
package A depends on [email protected]. package B depends on [email protected]. Someone downstream now has two copies of the same dependency because we weren't diligent about using consistent versions across packages.
Solution 1
Use "*" as the version number for all dependencies in packages. Use a specific version number in the repo root. Write a tool that replaces * with a specific version during release.
Challenges
- The tool would either require upstream modifications to or wrapping of
lerna:- We'd need to separate intrarepo linking from
npm installing. Now, they are both comingled inbootstrap. - Ideally, the tool itself could be contributed upstream into lerna.
- We'd need to separate intrarepo linking from
- We'd need to ensure we aren't implicitly depending on a package by nature of it being depended on in the root repo
- This can be solved via CI. We can ensure that each package only has access to its own dependencies during testing.
Solution 2
Write a linter that asserts that each package.json has the same number for each dependency
Challenges
Simpler, but more manual, than solution 1.
@thejameskyle @gigabo be curious for your thoughts here. You guys have definitely worked on more monorepos than I have. 😃
Solution 2 should be pretty easy to implement:
- Keep a master list of dependencies in the root
package.json. - Walk each package. Ensure that
dependenciesonly contains k:v pairs that are in the rootpackage.json's dependencies.