개요 TS > JS로 컴파일
- tsc를 활용하여 JS파일을 떨군다.
- concurrently와 nodemon으로 watch 환경을 구성한다.
tsconfig
- src/밑에 ts코드를 dist/경로 밑으로 컴파일
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Language and Environment */
"target": "es5" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
/* Modules */
"module": "commonjs" /* Specify what module code is generated. */,
"outDir": "dist" /* Specify an output folder for all emitted files. */,
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
/* Type Checking */
"strict": true /* Enable all strict type-checking options. */,
"skipLibCheck": true /* Skip type checking all .d.ts files. */
}
}
명렁어 수정
- concurrently를 통해 컴파일과 node 실시간 수행을 동시에 수행
{
"name": "tsc",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"start": "concurrently \"tsc -w\" \"nodemon dist/main.js\""
},
"devDependencies": {
"concurrently": "^7.0.0",
"nodemon": "^2.0.15"
}
}