Ts-loader
lastmod 2025-02-14created 2020-09-257 edits
TypeScript loader for webpack.
| WARNING |
| ts-loader uses tsc, the TypeScript compiler, and follows the settings in tsconfig.json. Be careful not to set the module to "CommonJS", or webpack won't be able to tree-shake your code. |
ts-loader vs @babel/preset-typescript
Troubleshooting
Error: TypeScript emitted no output for xxx.ts
An error saying no output was emitted is printed:
$ 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.
If the compilerOptions.emitDeclarationOnly property in tsconfig.json is true, remove it.
See also
- TypeScript
- Webpack
- @babel/preset-typescript - A typescript preset for babel.
Favorite site
Pages that link here