question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`--include-dependencies` misses transitive deps that come from external packages

See original GitHub issue

I have a situation where there are three packages that depend on one another like so:

  • pkg-c depends on pkg-b
  • pkg-b depends on pkg-a

pkg-c and pkg-a both live together in a Lerna repo, but pkg-b lives elsewhere (e.g. pulled in from NPM).

When I make a change to pkg-c, I’d like to be able to build it and it’s local dependencies, but Lerna doesn’t seem to realize that this should include pkg-a.

Expected Behavior

When I make a change to pkg-c and run lerna exec --include-dependencies --since -- 'echo $PWD', I see:

/path/to/monorepo/packages/pkg-a
/path/to/monorepo/packages/pkg-c

Current Behavior

When I make a change to pkg-c and run lerna exec --include-dependencies --since -- 'echo $PWD', I see:

/path/to/monorepo/packages/pkg-c

Possible Solution

When using Yarn workspaces, you could detect this dependency with yarn why pkg-a.

Steps to Reproduce (for bugs)

  1. git clone https://github.com/mxmul/lerna-transitive-example
  2. $ make repro
lerna.json

{
  "packages": [
    "packages/*"
  ],
  "npmClient": "yarn",
  "useWorkspaces": true,
  "version": "0.0.0"
}

Context

I’m migrating a set of related packages into a Lerna repo, and would like (for some amount of time) to have some of the packages in the monorepo and some outside. I would expect lerna exec --include-dependencies --since to be agnostic to the fact that some intermediate deps are not in the monorepo, and to be able to exec commands for all of the dependencies (or dependents) of a package that are local to the monorepo.

Your Environment

Executable Version
lerna --version 3.18.3
yarn --version 1.17.3
node --version v12.9.1
OS Version
macOS Sierra 10.14.6

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mxmulcommented, Jun 3, 2020

FWIW we worked around this by walking the dependency tree in our yarn.lock to detect any dependency chains that flowed through an NPM dependency, and using that to augment the dependencies found by Lerna.

1reaction
kylemhcommented, Apr 25, 2020

Regarding making everything monorepo-local, my team and I are trying! 😂

Our situation is that we’re moving separate packages into a monorepo one-by-one. We we’re trying to prioritize based off of difficulty and how often a package is changed (we want to import rapidly changing packages sooner, for example).

Any idea on if this would ever be entertained? Even if it’s something explicit like listing the name of the package in lerna.json via some property.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Exclude all transitive dependencies of a single dependency
The wildcard on both groupId and artifactId exclude all dependencies that normally would propagate through to the module using this dependency. Share.
Read more >
How to Ensure That Your Dependencies Are Up to Date
Commonly referred to as a "dependency of a dependency", a transitive dependency is a library called by one of your direct dependencies.
Read more >
Maven – Optional Dependencies and Dependency Exclusions
Since Maven resolves dependencies transitively, it is possible for unwanted dependencies to be included in your project's classpath.
Read more >
Publish to custom - will also include dependencies - Studio
Hi , When we are publishing the package using custom feed , does the package also have the dependencies ? Is there a...
Read more >
Dependency Managers Don't Manage Your Dependencies
However, their ease of use and the high modularization of packages come with many downsides. Existing JavaScript dependency managers are ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found