-
Notifications
You must be signed in to change notification settings - Fork 24.8k
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
ANALYZE_FOR_ENTRY_COMPONENTS not working in production to load modules dynamicly #18786
Comments
I'm back at my work-computer again so I can give the actual error message I got, when try to build for production: |
Any kind of help, would be much appreciated. |
Hello, we reviewed this issue and determined that it doesn't fall into the bug report or feature request category. This issue tracker is not suitable for support requests, please repost your issue on StackOverflow using tag If you are wondering why we don't resolve support issues via the issue tracker, please check out this explanation. |
I can understand why you can not resolve support issues here, however I'm not really sure that it isn't a bug, because the error message "magically" disappears after I re-save the module where I use 'ANALYZE_FOR_ENTRY_COMPONENTS'. So, altough I am fine ask this on StackOverflow, I think it would be best if someone from angular team could have a look on it. I know this isn't something that is commonly used, but we have to for our task. If someone is finding this issue and want to chack on stackoverflow question as well, it is here |
@jasonaden Can you please revisit, reopen this issue? I am not sure that this is not a bug and I cannot go any further to narrow the problem without any help. Unfortunately, there isn't any response on StackOverflow either. What I saw on my end is that when I building for debug the paths I give by If I resave my module where the paths are defined, then everything works fine and the paths are appearing in the map as well. I can provide the full error message and pictures from my console if that helps anything. |
Okay, because nobody helped me I get into this problem again and I found the reason and the solution of my problem. TL;DR:
And where you want to load, you can just use SystemJsNgModuleLoader (or the abstraction above it NgModuleFactoryLoader) to load the module given by its path. You can read my concerns and full description below. The problem is, that you HAVE TO provide the ROUTES injection token from |
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. |
I'm submitting a...
I am trying to create a module to dynamicly load modules (like the router does). Currently I am able to do so in dev environment, but I couldn't build my project in production. I narrowed down the problem and I found out that the problem is somewhere where I tried to mimic the router's provideRoutes function with adding ANALYZE_FOR_ENTRY_COMPONENTS to my modules providers like this:
providers: [ { provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: dynamicModules, multi: true }, { provide: DYNAMIC_MODULE_PATHS, useValue: dynamicModules }, { provide: NgModuleFactoryLoader, useClass: SystemJsNgModuleLoader }, ModuleLoaderService ]
But I keep getting this error:
Error: Cannot find 'DynamicModule' in '../dynamic/dynamic.module'
And it doesn't matter if I use absolute or relative path.
The strange part is that with
ng serve
if I re-save the file where I have the providers then it works just fine.What I could see from the router's source it should work like this, but maybe I'm missing something.
I ignored this for a long time, but now it causes error for me If I try to build for production.
A sample project can be found here:
[https://stackblitz.com/edit/angular-xhhgnk](Sample project)
It will log message into console.
Environment
The text was updated successfully, but these errors were encountered: