카테고리 없음

student class program

wooseobsssss 2023. 12. 19. 16:34
  • --rootDir ./src
    • 프로그램의 소스 파일이 들어가는 경로는 src 디렉토리입니다.
  • --outDir ./dist
    • 컴파일이 된 파일들이 들어가는 디렉토리는 dist 디렉토리입니다.
  • --esModuleInterop
    • CommonJS 방식의 모듈을 ES모듈 방식의 import 구문으로 가져올 수 있습니다!

 

자주 쓰는 스크립트

 

"scripts": {
    "start": "tsc && node ./dist/index.js",
    "build": "tsc --build",
    "clean": "tsc --build --clean"
},

 



 

TS의 큰줄기

 

우선 

 

TYPESCRIPT을 NPM 다운로드하고

NPM INIT 을 해주고

 

tsc --init --rootDir ./src --outDir ./dist --esModuleInterop --module commonjs --strict true --allowJS true --checkJS true

 

이런식으로 TSC 설정을 하고

rootDir에서 

 

로직을 만들어 코드를 적어주고

 

npm run build 빌드로 만들어주면 outdir로 그거에 맞게 build가 된다.


PAKAGE.JSON 설정

 

"scripts": {
    "start": "tsc && node ./dist/index.js",
    "build": "tsc --build",
    "clean": "tsc --build --clean"
},