简体   繁体   中英

Deploying Typescript NodeJS Server

What is the best practice of deploying NodeJS server written in TypeScript to production?

I want to avoid having 3 files (ts, js, map) for every script in my git repository.

I could use grunt/gulp to create "dist" directory and copy all the compiled files there, but then I would have them in my repo anyways. I could create separate repo just for the compiled code, but thats not ideal as well I think.

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

Note: I am dont have any compilation script/task in place, my IDE is compiling the ts files automatically for me.

You can use typescript to do all of this for you

tsconfig.json

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

More options can be found here and information on using a tsconfig.json file can be found here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM