Typescript: Yarn Workspaces IDE Support (IntelliJ, VSCode ...)

Viewed 8041

Working on a larger typescript project we decided to move the code to a monorepo with yarn workspaces.

We use webpack to build and bundle and everything works well (especially the linking between local modules/packages).

Since yarn workspaces will store most of the node_modules in the mono repo's root folder, the IDE (IntelliJ as well as VSCode) have problems resolving the imports to any node_modules when coding inside a "inner" project (so called "package" of a monorepo).

The strange thing is that imports are not known but on the other hand most of the time you can navigate to the correct source / definition within the IDEs for the same import if you write it down manually.

We have tried to tell IntelliJ to look into another folder for node_modules, but still not satisfying.

Please share your experience with yarn workspaces / monorepo (e.g. lerna) and how you develop the code living in these monorepos.

Which IDE do you use?

Did you add any special configurations to the IDE and/or package.json, tsconfig.json?

4 Answers

https://github.com/Izhaki/mono.ts

It uses yarn workspaces and marry well with VSCode. I hope the README is clear enough.

Basically, use two (parallel) typescript configuration trees:

  • Pre-build - uses aliases (for VSCode, tests, webpack, etc).
  • Build - uses typescript 3 project references for publishing essentially.
Related