정리/Typescript
Typescript 라이브러리 프로젝트 구성
워로디스
2026. 3. 22. 20:20
프로젝트 구성 절차
mkdir test-lib
cd test-lib
npm init -y
npm pkg set main=dist/index.js
npm pkg set types=dist/index.d.ts
npm pkg set exports=./dist/index.js
npm pkg set type=module
npm pkg set scripts.build=tsc
배포에 dist 만 포함
npm pkg set files[0]=dist
npm install -D typescript
npx tsc --init --rootDir ./src --outDir ./dist
mkdir src
New-Item ./src/index.ts
index.ts 예시
다시 내보내기 방식
export * from "./math.js";
export * from "./string.js";
export * from "./types.js";