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

nx-update-ts-references

v0.0.8

Published

An Nx plugin to update references in tsconfig based on local dependencies

Downloads

377

Readme

nx-update-ts-references

An Nx plugin that updates your tsconfig.json references based on your local dependencies.

npm package License

Table of Contents

Introduction

When working with typescript in a monorepo, you can use the references field of tsconfig.json to point to packages that your code depends on locally, so Typescript can efficently build and infer types as your codebase grows.

Nx already manages a dependency graph of your local typescript packages based on the dependencies on your package.json.

nx-update-ts-references will use this dependency graph to ensure your typescript configuration is up to date, so you don't have to manage it manually.

Installation

npm i nx-update-ts-references

Register it as a target in your project.json:

{
    "targets": {
        "update-ts-references": {
            "executor": "nx-update-ts-references:update-ts-references"
        }
    }
}

Usage

Due to Nx deriving the dependency graph from your package.json, and the rest of the fields of tsconfig.json being maintained, those are the only two inputs, and the tsconfig.json file is the out, this is a trivially cacheable operation:

{
    "targets": {
        "update-ts-references": {
            "executor": "nx-update-ts-references:update-ts-references",
            "cache": true,
            "inputs": [
                "{projectRoot}/package.json",
                "{projectRoot}/tsconfig.json"
            ],
            "outputs": [
                "{projectRoot}/tsconfig.json"
            ],
        }
    }
}

It is recommended to include this in every project that is based on typescript.

API

The following options can be passed to the options object.

check

boolean

When true, target will fail if the tsconfig.json is out of sync from the desired state.

Defaults to false when executing locally, but defaults to true when running in CI environments. Useful for enforcing that any updates to package dependencies are reflected in the version-controlled code prior to deployment.

dryRun

boolean

When true, will not actually write the tsconfig.json file. Can still fail if check is true.

Defaults to false.