ts-loader with Typescript 4.5 beta: "Error: TypeScript emitted no output for .../index.mts"
See original GitHub issueAnyone have luck webpack-5-ing with the new .mts
extension? I’m able to output from tsc -p .
fine, but through webpack I’m getting “Error: TypeScript emitted no output for …/index.mts”.
Thanks!
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: [".mts", ".ts", ".tsx", ".js"]
},
module: {
rules: [
{
test: /(\.mts$)|(\.tsx?$)/,
use: [
{
loader: 'ts-loader',
options: {
//transpileOnly: true
compilerOptions: {
noEmit: false
}
}
}
]
}
]
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:47 (24 by maintainers)
Top Results From Across the Web
Typescript emitted no output for '/path/to/file.ts' - Stack Overflow
I can reproduce this error if the application tries to import a TypeScript source file from the library (i.e., from the lib subdirectory)....
Read more >typescript emitted no output for - You.com | The search engine you ...
Hi, using your module with webpack, ts-loader 1.3 and typescript 2.1.4: modulesModuleBuildError: Module build failed: Error: Typescript emitted no output for ...
Read more >ts-loader - npm
Start using ts-loader in your project by running `npm i ts-loader`. ... ts-loader. This is the TypeScript loader for webpack.
Read more >Announcing TypeScript 4.5 Beta - Microsoft Developer Blogs
ts file is compiled as an ES module, ECMAScript import / export syntax is left alone in the .js output; when it's compiled...
Read more >webpack/webpack - Gitter
src/app.ts Module build failed: Error: Typescript emitted no output for ... /TypescriptFifthApp/node_modules/ts-loader/index.js:456:15) @ multi main.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@alexander-akait I put up a super simple repro showing that
.js
resolution to.ts
doesn’t work, but haven’t had time to start seeing how ts-loader could be involved here. Honestly my expectation was that this would not work; I’m not super familiar with how ts-loader contributes to Webpack’s resolution, but my impression was that this would be a Webpack-level thing, not a ts-loader thing. https://github.com/andrewbranch/nodenext-webpack@alexander-akait the issue is that in the new TypeScript module resolution modes, users must write
import "./foo.js"
even though on disk, the colocated file is./foo.ts
. This is because TypeScript expects TS code to be compiled to JS with these import paths unchanged, that way the output JS will resolve correctly at runtime. But this breaks the expectations of bundlers like Webpack, which does module resolution before a 1:1 TS→JS compilation happens. So the correct specifier for Webpack would beimport "./foo.ts"
but TypeScript doesn’t allow that. The correct specifier for TypeScript isimport "./foo.js"
but Webpack can’t resolve that by default.