-
Notifications
You must be signed in to change notification settings - Fork 12k
(AOT) Cannot find modules when tsconfig paths are used #6973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Don't know if the reason behind my problem is the same with: #6632. I don't understand how come |
I am experiencing the same issue. It doesn't even work if you switch from tsconfig path to plain imports like A bit more detailed about my case: https://stackoverflow.com/questions/45234210/aot-compiler-generates-wrong-import |
This problem seems to occur in shared library scenarios. The workaround for me is to use a tsconfig that is in a common root path of all shared libraries. You can still set the root of the app and reference the tsconfig as "../../tsconfig.hacketyhack.json". In the error you'll see $$_gendir is already in the admin app. The virtual file system represented by $$_gendir seems to start from the tsconfig location and can't navigate above itself. An additional AOT problem that resembles the rc.0 -> rc.1 fix occurs (even in rc.1) if the entrypoint ts is not included in the tsconfig (even though ng will include the main automatically). So you need to make a tsconfig for each app in the common root or include paths to all main.ts's for libraries sharing this tsconfig. |
An official answer would be much appreciated. I believe that this should be fixed than implementing a workaround. The same code and file structure should be working with AOT from the moment ng serve/build works without it, don't you agree? |
Marking as a duplicate of #7087 since it's being tracked there already. |
@EricABC Could you explain the workaround? I am trying with no success. I need this and from what I see it is not considered urgent by the angular-cli team, so I will have to try your workaround.
tsconfig.protocol.json:
|
@nekkon Perhaps the tsconfig needs to go up one more directory. I think paths using a '..' causes typescript to calculate a common root internally (not 100% sure), which is why you would still get an error for 'app' even though its not 'shared'.
I elevate several items to the root of the mono-repo, including tslint, angular-cli config, etc... All tsconfigs extend tsconfig.base.json I use 1.3.0-rc.1+ |
Thanks @EricABC ! I managed to make it work and it builds properly with AOT. |
Spent a great deal of time trying to understand this issue as well. It seems that ngc doesn't respect As @EricABC mentioned, it appears the tsconfig file you target with ngc must exist at the most common root shared by all of your project's libraries. Solution:
When running ngc, previously I would target a platform config file, which messed up ngfactory import paths (ultimately the bug, because I provided a rootDir and baseUrl of "../../") The solution is the
I target that file with
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
In my tsconfig.json I have added the following code so that I can import modules using "@orco/.." I am using multiple apps in the same repo. I want to share between apps common modules. The tsconfig below does work properly with ng serve and ng build. It does not work with ng build -prod. Probably it is an AOT problem. I would like to know if there is something else that needs to be done, as I could not find a documented way of doing this. An example of the errors I get:
ERROR in C:/Users/nekkon/Desktop/angular/orco-frontend/src/admin/$$_gendir/shared/other/core.root.module.ngfactory.ts (10,21): Cannot find module './core.root.module'.
The text was updated successfully, but these errors were encountered: