1

Is there a way I can hook into the command tsc --build in order to leverage an extra build-step in composite TypeScript projects?

I have a monorepo with many TypeScript projects. But each one needs an extra step when building, which converts Joi schemas to TypeScript definitions.

Obviously I'm able to simply run a script from npm, but the tsc --build command actually builds all projects that have been referenced in the tsconfig.json files, which means I can build everything with one command. But when it builds I need a way to hook into each build such that each project can also add this Joi -> TypeScript step, for every (or some) projects referenced.

Is there any way to do this?

shennan
  • 10,798
  • 5
  • 44
  • 79
  • You can do it programmatically if you use the compiler API. There is a project `ttypescript` that allows exactly this (to specify transforms in tsconfig) but seems to not be maintained. Still, might be a good starting point https://github.com/cevek/ttypescript – Titian Cernicova-Dragomir Nov 23 '21 at 10:18
  • @TitianCernicova-Dragomir thanks, I'll check this out. – shennan Nov 23 '21 at 11:05

0 Answers0