Filter flag combination for dependencies or dependents only?
See original GitHub issueNot a bug. More of a potential opportunity in the semantics of filter flags or a feature request: a filter flag combination that enables operating on dependents or dependencies only.
Expected Behavior
Given lerna --include-dependencies --scope packageC run build
where packageC
depends on packageA
and packageB
, all 3 will run build
.
I have a scenario where I want to build the dependencies of packageC
one time, then build and watch for changes on packageC
. Unfortunately, packageC
gets built twice, once when I run the command above, and again when I run lerna --scope packageC run dev
—simply because by necessary convention all the packages have a build
script (build number 1 build
) and the build tool runs an initial build when watching (build number 2 dev
).
Some of the builds are involved (and therefore take long) enough that it improves developer experience to optimize away a second build.
That can possibly be solved in other reasonable ways, but this isn’t the first time I’ve wished for the ability to filter this way.
Another case I’ve run into is when I’ve been working on packageC
and now want to verify its dependents, packageD
and packageE
. While working on packageC
, I’ve built it and verified it, so it’s actually extraneous in lerna --include-dependents --scope packageC run build && lerna --include-dependents --scope packageC run test
.
Current Behavior
I tried npx lerna --include-dependen(t|cie)s --scope packageC --ignore packageC
just in case it might work, but it errors as not matching any packages.
Possible Solution
I think the semantics of a command with --scope
and --ignore
being set to the same package and an --include-dependencies
/--include-dependents
flag could reasonably be interpreted to match the dependencies / dependents only. But that may not be widely intuitive and I understand implementation details might preclude it; another flag like --only-dependencies
/--only-dependents
could also meet the need.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:16
- Comments:8 (2 by maintainers)
Top GitHub Comments
Bump! I have the exact same requirement.
In a situation where one works with
create-react-app (cra)
, it is required to first ensure all dependencies are build before actually starting or building the react app.Now in my situation, during development, the main package (which would map to
packageC
mentioned in the OP) is executed via webpack and uses hot-reloading, however before the server is started I need to build all dependencies first while excluding the current package to avoid triggering (and waiting) for an unnecessary build of the main package (which handled by webpack).Intuitively I used the same semantics as suggested in the OP (
npx lerna --include-dependencies --scope main-app --ignore main-app
), however this did not work.Of course, I could add all
build
commands for my dependencies manually one-by-one and chain them via&&
in myapp-main
package before I start the webpack server but this is redundant and error-prone 👎I would rather prefer being able to do this 👍
this is the very sketchy shell script I came up with: