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.

Can we use published packages instead of rebuilding?

See original GitHub issue

Expected 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
bengrycommented, Mar 20, 2019

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.

1reaction
benderrcommented, Oct 29, 2019

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

Read more comments on GitHub >

github_iconTop 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 >

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