Deploy Typescript NodeJS Server

What is the best practice for deploying a TypeScript NodeJS server for production?

I want to not have 3 files (ts, js, map) for each script in my git repository.

I could use grunt / gulp to create the "dist" directory and copy all the compiled files there, but then I would get them in my repo. I could create a separate repo only for compiled code, but I don't think this is ideal.

Also, when I run node app.ts without js or an existing map, it actually starts everything fine. So, are compiled files needed even for the node server?

Note. I don't have script / task in place compilation, my IDE will automatically compile ts files for me.

+6
source share
1 answer

You can use typescript to do it all for you.

tsconfig.json

 { ... "outDir": "dist", "sourceMap": false, "declaration": false } 
  • outDir files to the dist directory
  • sourceMap will determine whether to output .map files
  • declaration will determine whether to output .d.ts files

Here you can find additional parameters, and information on using the tsconfig.json file can be found here

+6
source

All Articles