s-panferov / awesome-typescript-loader

Awesome TypeScript loader for webpack
Other
2.35k stars 181 forks source link

After upgrading to version 3.2.x, TS2307: Cannot find module, declared in *.d.ts #468

Open kukjevov opened 7 years ago

kukjevov commented 7 years ago

With "awesome-typescript-loader": "~3.1.3" everything is working nicely. After upgrading to version 3.2.x i got following error:

ERROR in [at-loader] ./app/components/navigation/navigation.component.ts:11:25 TS2307: Cannot find module 'config/global'.

in this repository https://github.com/kukjevov/ng-universal-demo/tree/mine you can see code.

You will not be able to install it, because of some proprietary packages, but you can see code.

Problem is not during normal build, but only during tests running using karma.

here is d.ts https://github.com/kukjevov/ng-universal-demo/blob/mine/config/global.d.ts here is karma configuration https://github.com/kukjevov/ng-universal-demo/blob/mine/karma.conf.js here is import (one of many) that fails after upgrade https://github.com/kukjevov/ng-universal-demo/blob/mine/app/components/navigation/navigation.component.ts

I can update repository so you will be able to install it if needed.

zry656565 commented 7 years ago

Met this problem also, 3.1.3 is fine.

massimocode commented 7 years ago

I have also come across this problem and 3.1.3 works fine for me too. Our production Webpack build works fine, but the issue arises when running tests using Karma.

senaev commented 7 years ago

I have the same problem with 3.2.1 version, 3.1.3 works fine.

vladimir-tikhonov commented 7 years ago

Still a problem with 3.2.2. @s-panferov, why did you close this issue?

lemonmade commented 7 years ago

We are also having the same issue. It is particularly problematic because we do not even have a way of manually listing out the .d.ts files in the files TSConfig option, which seems to be the solution; we generate typings files for .graphql and .scss files, so these are entirely dynamic.

bronson commented 6 years ago

A number of people seem to be running into this. These appear to be dupes: https://github.com/s-panferov/awesome-typescript-loader/issues/473 https://github.com/s-panferov/awesome-typescript-loader/issues/481

shepmaster commented 6 years ago

This appears to be a deliberate change, but it's certainly a surprising one...

shepmaster commented 6 years ago

I might have found a workaround, at least one that works in my case. Evidently, when I generated tsconfig.json, I never changed the include key from the default of "./src/**/*" to my actual directory ("./app/**/*").

I found this by switching from awesome-typescript-loader to ts-loader, which then printed out the helpful message:

error TS18003: No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["./src/**/*"]' and 'exclude' paths were '["./target/app/"]'.

Fixing that fixed ts-loader, then I switched back to awesome-typescript-loader and it kept working!

qlqllu commented 6 years ago

have the same issue.

JakobJingleheimer commented 6 years ago

I switched to ts-loader, and the problem solved itself.

dancon commented 5 years ago

maybe you should check your declaration.d.ts file whether include your tsconfig.json search scope.

for example: directories structur

|- src
     |-components
|-typings
     |-declaration.d.ts
|-tsconfig.json

tsconfig.json

{
    "include": [ "src" ]
    ...
}

then compiler can not find your declaration types.

hope can help you ~

JakobJingleheimer commented 5 years ago

@dancon that couldn't be the cause as merely switching loaders resolves this. This was quite a while ago though, so maybe it's fixed by now.

dancon commented 5 years ago

@jshado1 maybe you are right, but I does not change the loader and just expand the tscongif.json search scope by change the include pattern to exclude pattern, then it works fine ~~