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 🙏

© 2026 – Pkg Stats / Ryan Hefner

lorenzini-test-workspaces

v0.0.2

Published

[![github actions](https://github.com/Quramy/npm-ts-workspaces-example/workflows/build/badge.svg)](https://github.com/Quramy/npm-ts-workspaces-example/actions)

Readme

How to build TypeScript mono-repo project

github actions

This repository explains how to create monorepos project using npm and TypeScript.

ToC

Tools

  • npm cli(v7 or later)
  • TypeScript

Directory Structure

Put each package under the packages directory.

.
├── node_modules/
├── README.md
├── package-lock.json
├── package.json
├── packages
│   ├── x-cli
│   │   ├── lib
│   │   │   ├── cli.d.ts
│   │   │   ├── cli.js
│   │   │   ├── cli.js.map
│   │   │   ├── main.d.ts
│   │   │   ├── main.js
│   │   │   └── main.js.map
│   │   ├── package.json
│   │   ├── src
│   │   │   ├── cli.ts
│   │   │   └── main.ts
│   │   └── tsconfig.json
│   └── x-core
│       ├── lib
│       │   ├── index.d.ts
│       │   ├── index.js
│       │   └── index.js.map
│       ├── package.json
│       ├── src
│       │   └── index.ts
│       └── tsconfig.json
├── tsconfig.build.json
└── tsconfig.json

Workspaces

Using npm workspaces feature, configure the following files:

Open package.json and append the workspaces key.

/* package.json */

{
  "name": "npm-ts-workspaces-example",
  "private": true,
  ...
  "workspaces": ["packages/*"]
}

Exec npm install. After successful running, all dependencies included from each package are downloaded under the repository root node_modules directory.

Dependencies across packages

In this example, the x-cli package depends on another package, x-core. So to execute (or test) x-cli, x-core packages should be installed. But in development the x-core package is not published so you can't install it.

For example, packages/x-cli/src/main.spec.ts is a test code for main.ts, which depends on packages/x-core/src/index.ts .

/* packages/x-cli/src/main.ts.*/

import { awesomeFn } from "@quramy/x-core";

export async function main() {
  // dependencies across child packages
  const out = await awesomeFn();
  return out;
}

So we need to link x-core package from x-cli to execute the x-cli 's test.

Workspaces feature of npm also solves this problem. npm i creates sim-links of each package into the top-level node_modules dir.

Resolve dependencies as TypeScript projects

As mentioned above, npm cli resolves dependencies across packages. It's enough for "runtime". However considering TypeScript sources, in other words "static", it's not.

We need to tell "x-cli package depends on x-core" to TypeScript compiler. TypeScript provides much useful feature to do this, "Project References".

First, you add composite: true to project-root tsconfig.json to use project references feature.

/* tsconfig.json */

{
  "compilerOptions": {
    ...
    "composite": true
  }
}

Second, configure each package's tsconfig and configure dependencies across packages.

/* packages/x-cli/tsconfig.json */

{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "rootDir": "src",
    "outDir": "lib"
  },
  "references": [{ "path": "../x-core" }]
}

And create a project which depends on all packages:

/* tsconfig.build.json */

{
  "files": [],
  "references": [{ "path": "packages/x-core" }, { "path": "packages/x-cli" }]
}

Let's exec npx tsc --build tsconfig.build.json. The .ts files included in all packages are build at once!

Do we still need Lerna ?

Partially, yes.

TypeScript project references and npm workspaces features resolves dependencies across each package in both runtime and compile. So we no longer need lerna bootstrap .

But npm cli don't have functions provided by lerna's sub command, such as lerna version or lerna run. If you want them, you can use lerna or consider introducing another CLI.

Updated

Since npm CLI 7.7.0, we can use --workspaces option.

# Excecute npm test in all workspaces
$ npm test --workspaces

This option works as well as lerna run test .

License

The MIT License (MIT)