ts-loader: ts-loader cannot accept *.js file as an entry point although `allowJs` parameter is set to `true`

If you specify any *.js file as an entry point inside the webpack configuration, ts-loader will throw an error (Module build failed: Error: Could not find file: …).

...
entry: [
  './src/app.js'
],
...

I think this is ts-loader issue because TypeScript 1.8.0 and greater can transpile JavaScript files and import them. You have to set allowJs property to true to get this functionality working. Simply run the following code to test this.

tsc ./src/app.js --allowJs --outDir tsDist

For ts-loader, it seems that just an entry point must be always a *.ts file. Inside the entry module you actually are allowed to import and use both es6 and ts files.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 4
  • Comments: 16 (6 by maintainers)

Most upvoted comments

Any news on this?

Will try to address this in the next release.

What is the timeline for the next release?

No worries!