New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

typescript-monorepo-toolkit

Package Overview
Dependencies
Maintainers
2
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typescript-monorepo-toolkit

## CLI tool to automatically setup typescript project references for yarn workspaces monorepos and other tasks

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
310
increased by121.43%
Maintainers
2
Weekly downloads
 
Created
Source

typescript-monorepo-toolkit

CLI tool to automatically setup typescript project references for yarn workspaces monorepos and other tasks

It can inject the appropriate tsconfig.references for all of the packages in a yarn workspace, and also help you change rootDir and outDir across all of the packages

Background / Motivation:

  • https://github.com/thi-ng/ 100+ packages monorepo that i want to move to project refs
  • #32028 Build-Free Editing for Project References
  • Infer project references from common monorepo patterns / tools #25376

How to use

npx typescript-monorepo-toolkit inject-refs ../path-to/yarn-project-root

For debug info

DEBUG=typescript-monorepo-toolkit npx typescript-monorepo-toolkit inject-refs ../path-to/yarn-project-root
Usage:  [options] [command]

Options:
  -V, --version                                 output the version number
  -p, --tsconfig-path <tsconfigpath>            Use alterative config path inside the package. eg: test/tsconfig.json (default: "tsconfig.json")
  -h, --help                                    output usage information

Commands:
  inject-refs [options] <yarn-project-root>              Inject the appropriate tsconfig references based on yarn workspaces dependency graph
  set-outDir <yarn-project-root> [newOutDir]             Set the compilerOptions.outDir in all of the packages. omit new value to delete
  set-rootDir <yarn-project-root> [newRootDir]           Set the compilerOptions.rootDir in all of the packages. omit new value to delete
  set-extend <yarn-project-root> [extendedTsconfigPath]  Set the extends entry in all of the tsconfigs. omit new value to delete

How does it work

yarn workspaces info command has all the info we need.

The tsconfig.json manipulation is done using recast, as tsconfig.json is not really JSON, so we can keep the comments. Unfortunately recast changes some of the formatting of the file.

This tool might break your tsconfigs Please run this tool on a clean git state, and inspect the diff

Future possible improvements

  • Become obsolete when #25376 is fixed
  • Find a good name
  • Support tsconfig.test.json and similar patterns
  • Support lerna/other monorepo tools that can provider us with the dependency graph

Need TypeScript/JavaScript help with your open-source project? Feel free to contact me directly!

Need TypeScript/JavaScript help in your company? I'm available for consultation :)

Keywords

FAQs

Package last updated on 17 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc