material-motion-js icon indicating copy to clipboard operation
material-motion-js copied to clipboard

Sharing dependencies across packages

Open appsforartists opened this issue 9 years ago • 2 comments

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 in bootstrap.
    • Ideally, the tool itself could be contributed upstream into lerna.
  • 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.

appsforartists avatar Dec 12 '16 17:12 appsforartists

@thejameskyle @gigabo be curious for your thoughts here. You guys have definitely worked on more monorepos than I have. 😃

appsforartists avatar Dec 12 '16 18:12 appsforartists

Solution 2 should be pretty easy to implement:

  • Keep a master list of dependencies in the root package.json.
  • Walk each package. Ensure that dependencies only contains k:v pairs that are in the root package.json's dependencies.

appsforartists avatar Jan 24 '17 10:01 appsforartists