npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lerna-workspace

v1.0.0

Published

Illustrating the monorepo concept using lerna

Downloads

2

Readme

lerna-example

lerna

Illustrating the monorepo concept using lerna.

This tool has great benefits:

  • Can manage recursive internal dependencies. Same logic for both internal and external dependencies, it's completely transparent.

  • Ability to hoist common dependencies in 'master' lerna repo, this reduces complexity and build time.

  • Run an npm command in a bulk lenra run on all subrepos or a filtered list (--scope flag) , can be parallelized (--parallel flag). See also lerna exec.

    This is great when dealing with microservices when needing to bring them all up or when needing to run tests for all of them.

  • lerna import enables the import of an external git repository into the monorepo packages.

  • Sophisticated npm package publishing based on many CI/CD scenarios using lerna publish and lerna version commands.

setup of a lerna monorepo from scratch

$ #first you have to install npx command runner gloablly (may need root user)
$ npm install -g npx

#install lerna as a dev dependency
$ npm init
$ npm i lerna --save-dev

$ #init monorepo config , this will create packages folder and lerna.json config
$ npx lerna init --independent

--independant flag means that each subrepo has its own npm versionning, there is also --exact mode : all of the subrepos follow the same versionning.

  • You can customize lerna.json: yarn or npm as a package manager, projects tree, refine package publishing policy etc..

  • Create your subrepo projects under packages folder. Each project under its own folder a it was a repository by itself.

Developer commands

It's preferrable to run commands from project root (where lerna.json resides)

  • npx lerna bootstrap : The first command to launch. Must be ran when a subrepo is added/removed or after a fresh git clone. it links subrepos, installs npm deps and does some magic..

  • npx lerna publish : publish to npm. Each time you publish, you will get a prompt for each package that has changed to specify if it's a patch, minor, major or custom change.

  • npx lerna add <your local or remote package> : installs a package to all of the subrepos. when adding --scope=project-a for exemple this restricts to the given subrepo. Further doc

  • npx lerna create <subrepo name> : adds a new subrepo.

Examples

  • install lodash for project-a : npx lerna add lodash --scope=project-a

  • install project-a as a dep for project-b : npx lerna add project-a --scope=project-b

The dependency schema in this sample monorepo is the following:

project-c -> | project-a | project-b -> project-a

Lerna with docker

base build image docker build . -f Dockerfilebase -t dependencies

then build service image:

docker build . -t project-c