Can we use published packages instead of rebuilding?
See original GitHub issueExpected Behavior
Currently we have our repo set up such that both local development and CI do lerna bootstrap
, which in turn runs the prepare
script for all packages, which in turn builds each of them (npm run build
-> some-build-command-for-that-package
(e.g. tsc
)).
Current Behavior
This is fine, except for the fact that when we have lots of packages (currently ~35), this takes a lot of time to do (can be ~10 minutes). At the same time, we do publish the built packages post-build, and thus we already have them built in the npm feed.
Possible Solution
When in CI - check if foo@1.2.3
exists in the npm feed - use that, otherwise, build locally.
Context
- Shortening CI build time
Your Environment
- VSTS
Executable | Version |
---|---|
lerna --version |
3.13.1 |
npm --version |
6.9.0 |
node --version |
10.x |
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
You Don't Need to Rebuild Your Development Docker Image ...
Just because you're mounting the code directory, does not mean you can't ADD code to the image. It's perfectly fine to build your...
Read more >Create and publish a NuGet package using Visual Studio ...
With Microsoft Visual Studio, you can create a NuGet package from a .NET class library, and then publish it to nuget.org using a...
Read more >npm-rebuild
If one or more package specs are provided, then only packages with a name and version matching one of the specifiers will be...
Read more >angular 9 library publish error "Trying to publish a package ...
Yes - but it still has to be set up as production configuration for your library in angular.json file - otherwise you will...
Read more >Publishing packages - Rush.js
You need two steps to publish your packages when version policies are used. The first step is to increase the package versions. And...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
No worries.
Most of our projects inside the repo are indeed TypeScript based, some maybe using project references would indeed help. I’ll have to see how it plays with Angular libraries, they do some magic there sometimes which tends breaks standard stuff unfortunately.
However, at any rate - the issue is at a higher level - the CI. Just like I can ask the CI to restore a cache of my npm packages (external ones, that is) (e.g. CircleCI, but most other CIs offer the same thing) - I’d like to be able to ask lerna to restore the cache of the built result, if one is available (on the npm registry).
Even if TypeScript project references or the like would work - a CI usually starts from a clean state (via a container or otherwise), so incremental builds won’t speed it up, only something at the Lerna-level would.
I’m not sure I understand why this “breaks one of the fundamental contracts of a Lerna monorepo”, I’d appreciate further explanation of this. The requirement/feature request here is that if the same version of a package already exists in the npm feed exists - use that. If no such version exists, or if a different version is declared in the
package.json
- built it as being done today.Hi. @bengry I ran into a similar problem and found a solution. Perhaps it will help you if you use the lerna in conjunction with the yarn workspaces. We used the
yarn install --focus
command to set the dependencies from the registry. The script in CI/CD looked something like this:yarn install //install all dependencies and symlinks
lerna version ...params //bump version if there are changes in packages
lerna publish ...params //publish packages
cd packages/app //go to workspaces project "app" to build site
yarn install --focus //install workspaces dependencies from registry (verdaccio in our case)
yarn build //build site