Unexpected calls to `build` and `clean` scripts
See original GitHub issueWith our first publish in a bit after upgrading to latest lerna, I’m noticing some unexpected behavior during the publish phase. We have a monorepo with some public (publishable) packages and some private (non-publishable) apps and had been leaning on a prepare
scripts in each app ("prepare": "run-s clean build",
, leaning on npm-run-all
) to handle ensuring the packages were ready pre-publishing. Now when I go to publish, calls to prepare
continue, but I also see the following:
lerna info Executing command in 19 packages: "yarn run clean"
...
lerna info Executing command in 20 packages: "yarn run build"
Lerna is somehow deciding it needs to run clean and build on its own (already handled by the prepare
scripts), which wouldn’t otherwise be a problem except that its also running these in our non-published apps (thus greatly increasing the publish time) instead of relying on prepare
in just the packages bound for our registry.
I can’t find any clues as to what’s causing this behavior after looking all through our repo and the lerna code. Any thoughts?
Expected Behavior
I suppose ideally lerna wouldn’t be calling build
and clean
on its own.
Steps to Reproduce (for bugs)
lerna.json
{
"lerna": "3.13.0",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
"apps/*",
"package-examples/*",
"packages/**"
],
"labels": {
"tag: new feature": ":rocket: New Feature",
"tag: breaking change": ":boom: Breaking Change",
"tag: bug fix": ":bug: Bug Fix",
"tag: enhancement": ":nail_care: Enhancement",
"tag: documentation": ":memo: Documentation",
"tag: internal": ":house: Internal"
},
"version": "9.0.0-alpha.0",
"command": {
"publish": {
"verifyAccess": false
}
}
}
Your Environment
Executable | Version |
---|---|
lerna --version |
3.13.0 |
npm --version |
VERSION |
yarn --version |
1.12.3 |
node --version |
8.10.0 |
OS | Version |
---|---|
macOS High Sierra | 10.13.6 |
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
Lerna isn’t calling clean and build, it is calling the root
prepare
lifecycle (in all likelihood). It’s been doing that for over six months now. I’m just spitballing, because I can’t read your mind and see the package.json files in question…@jptaranto In my usage, lerna works fine with npm-run-all for basically every task on our dev Mac laptops. Many of our commands have lerna invoking npm-run-all which then invokes yarn scripts.
It doesn’t seem to work in Jenkins (maybe due to differences in how spawning works through 3 levels of invocation on our CI linux boxes?), where it has problems exiting properly for some tasks. Thus, our ci scripts look like
yarn lint && yarn prettier && yarn type check && yarn test
. This might also specifically be caused by the interaction of lerna, npm-run-all, and jest in our CI environment.It also does not work locally in our setup for any publish lifecycle methods, as I originally described when I opened the issue, but I chalked this up to having lots of shared dev dependencies listed in the root package.json (including npm-run-all).
@evocateur What do you mean you don’t run build or clean tasks in each package? I didn’t see anything about this in the lerna docs, but am super curious about it.
For instance, we have jest configs in each leaf package’s package.json that are routinely specific to that package (same with webpack, typescript, babel, etc). Are you saying that you would run
jest/webpack/etc --path-to-config=foo/... --path-to-source=foo/...
directly from the root? Or are you referencing doing something more likelerna run build
?