Tamar Tamar - 14 days ago 7x
TypeScript Question

typescript - include a library import to all files

I started a node js project written in TypeScript. I want to include

import 'source-map-support/register';
in all my
files so I see the TS source on stack traces. Is there a way to do that without adding it to each file separately? Is there a different way to get the pre-compiled mapping on stack-traces \ debugging that will apply to the entire project?


Instead of doing it in source files, you can do it on the command line when you launch node, e.g:

node --require source-map-support/register

Or you can use a package like ts-node

P.S. Even doing it in your source files, you don't need it in every source file, just the "first" on you launch. Others required by the first (directly or indirectly) should get source-map-support automatically.