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

Add option to limit Lerna to symlink only packages defined in scope #1766

Closed
ibezkrovnyi opened this issue Nov 7, 2018 · 5 comments
Closed

Comments

@ibezkrovnyi
Copy link

ibezkrovnyi commented Nov 7, 2018

A - monorepo packages

S - scope packages, list of packages combined together by --scope, --include-filtered-dependents, --include-filtered-dependencies, --since

N - 'not in scope' packages: A - S

Expected Behavior

Lerna symlinks only projects from list S to their dependents from list S.

Current Behavior

Lerna symlinks projects from list A to their dependents from list A

Tested locally

if (forceLocal || resolved.fetchSpec === depNode.location || depNode.satisfies(resolved)) {

If I change above line into:

const local = forceLocal || resolved.fetchSpec === depNode.location || depNode.satisfies(resolved);
if (local && depName !== 'project-name') {

then node_modules/project-name in all lerna.json packages will not be replaced with symlink.

Solution

We need to filter out some packages from being symlinked

Option 1

To add cli parameter (let's say, --exclude-from-local-dependencies) and pass its argument (list of packages or minimatch patterns) into PackageGraph (for all commands).
But is more like tricky workaround - we will need to manually calculate difference between lerna ls and lerna ls --since --include-filtered-dependents, and pass diff to --exclude-from-local-dependencies

Option 2 (best solution)

To add cli parameter (let's say, --exclude-non-scope-from-local-dependencies, or --scope-local by analogy with force-local) and auto-diff by lerna and pass result to PackageGraph (for all commands). It would be the best solution

Context

We have couple of monorepos with ~200 projects in each, and with current behavior of Lerna we have to manually build almost all our projects just to test couple of them.

Related issues

#1421 - is about --ignore option, and this issue is about scope

Your Environment

Executable Version
lerna --version 3.4.3
npm --version 6.4.1
node --version 10.13.0
OS
NAME
RedHat
Windows
@olvnikon
Copy link

olvnikon commented Nov 7, 2018

We faced a similar problem. I'm also interested in the solution.

@ibezkrovnyi ibezkrovnyi changed the title Lerna symlinks packages not in scope Add option to limit Lerna to symlink only packages defined in scope Nov 7, 2018
@stale
Copy link

stale bot commented Jan 6, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@ibezkrovnyi
Copy link
Author

For anyone who will have this issue there is workaround with writing custom script:
#1421 (comment)

It still is not as perfect as native lerna functionality, but at least it solves this issue without touching Lerna code.

@stale stale bot removed the stale label Jan 10, 2019
@evocateur
Copy link
Member

I don't believe altering the initial graph painting is the right place, it should be a method similar to PackageGraph's partitionCycles(), but instead returns a brand new PackageGraph with the unchanged siblings excluded.

@lock
Copy link

lock bot commented Apr 10, 2019

This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Apr 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants