Skip to content

Ts-loader

TypeScript loader for webpack.

WARNING

ts-loader 는 TypeScript 컴파일러인 tsc를 사용하고, tsconfig.json의 설정을 따릅니다. 모듈을 "CommonJS"로 설정하지 않도록 주의하세요. 안그러면 webpack이 코드 tree-shake를 할 수 없습니다.

ts-loader vs @babel/preset-typescript

@babel/preset-typescript 항목 참조.

Troubleshooting

Error: TypeScript emitted no output for xxx.ts

방출된 출력이 없다는 에러가 출력:

$ yarn build
yarn run v1.22.10
$ webpack --mode=production --node-env=production
assets by status 28.1 KiB [cached] 52 assets
./lib/index.ts 39 bytes [built] [code generated]

ERROR in ./lib/index.ts
Module build failed (from ./node_modules/ts-loader/index.js):
Error: TypeScript emitted no output for /home/your/Project/answer-dev/api/lib/index.ts.
    at makeSourceMapAndFinish (/home/your/Project/answer-dev/api/node_modules/ts-loader/dist/index.js:52:18)
    at successLoader (/home/your/Project/answer-dev/api/node_modules/ts-loader/dist/index.js:39:5)
    at Object.loader (/home/your/Project/answer-dev/api/node_modules/ts-loader/dist/index.js:22:5)

webpack 5.72.0 compiled with 1 error in 2989 ms
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

tsconfig.json에서 compilerOptions.emitDeclarationOnly 속성이 true 이면 제거한다.

See also

Favorite site