-
Notifications
You must be signed in to change notification settings - Fork 12k
[Bug] cli needs to be reloaded when a lazy loaded module is added in routes (FIXED) #9825
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
I have the same issue |
+1 |
1 similar comment
+1 |
+1 Confirming that restarting 'ng serve' fixes the issue. |
Update: This also happen when the lazy module throws an error in the first build. |
+1 |
+1 same problem here! |
+1 |
+1 same issue, restarting fixes it for me too |
+1 |
3 similar comments
+1 |
+1 |
+1 |
Possible duplicate of #9488. |
+1 |
2 similar comments
+1 |
+1 |
+1; I fixed my issue with |
+1 |
1 similar comment
+1 |
I recomended change to
|
@dkarski does that work with AoT? |
The above solution from @dkarski fixed this for me. However, @michaeljota it doesnt work with AoT. You can't use function expressions in decorators as of now. |
Czesc, @dkarski :). Is this |
@karol-depka, that's not a solution, it's just a work around. The only real solution is to reload the CLI. You only can use the string version for AoT. So if you aren't using AoT for anything, sure, you can do this. But, still, it is recommended to use the string version. |
For some reason, the string version stopped working for me even after reloading the CLI. This happened after I updated to @angular/cli@1.7.3 from v1.6.5... After downgrading to v1.6.5, the strings are working fine again (still needs reloading) |
@hermbit Try to load the string from root. Sometimes this works, something the other works. IDKW. |
Angular CLI: 6.0.8 Restarting Running as Running as Running as inside
inside
I believe that this issue has to do with the way chunks are named. After a partial build, it's losing track of them. |
It seems like this is a regression introduced somewhere in 1.7.0 (works with 1.7.0-rc.0), I didn't have the issue with cli@1.7.0-rc.0 and now I have it with cli@1.7.0. |
@sluglit Thanks, your solution is the true solution, works fine! Thanks! |
@sluglit that works for me. Thanks |
@sluglit you indeed have to make sure that AppRoutingModule is the last in line, that fixed my problems. |
Hey @dkarski, can you explain this solution? "{ path: 'user-panel', loadChildren: () => UserPanelModule, }," I'm sorry if that's a silly question ... |
its because you just stoped lazy loading and it is loaded with rest of app
wt., 7.08.2018, 14:19 użytkownik Rafael Fronteira <notifications@github.com>
napisał:
… Hey @dkarski <https://github.com/dkarski>, can you explain this solution?
This worked for me, but I really did not understand how it works.
"{ path: 'user-panel', loadChildren: () => UserPanelModule, },"
I'm sorry if that's a silly question ...
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#9825 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHgz-_lDKjnwjHcQuUBdA0BIdNjAy6smks5uOYXGgaJpZM4SXaZz>
.
|
@Antoniossss thanks man, but have you found a solution without losing lazy loading? |
@RafaelFronteira That worked for me what @sluglit suggested:
The second one solved the problem for me. And leave the lazy loading as it was: And don't use AOT in dev build, it's just a workaround, but not a solution. |
@speti43 It worked for me too. Thanks a lot! |
This worked for me. loadChildren loads the module dynamically. No need to import the module in your app.module. Cheers |
@speti43 no need for ng-cli downgrade and AOT |
The workaround by @sluglit @speti43 also worked for me running CLI v6.1.0 Also, if you're on Angular 6 and needs to use a absolute path you may want to try |
It worked for me: |
It works for me. Thanks. Cheers!!! |
Don't do that, prod build will fail, this is just a dirty workaround. |
Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version. As this should have been also addressed in #12418 If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior. |
I had this same issue but was not importing the lazy module in my I was lazy loading a module that was using a custom angular component library. This library worked fine in ng5 but as soon as we upgraded to ng6, this error started occurring. The fix was COMPLETELY unrelated to the error message, in fact, the error was terribly misleading and useless! We had to start stripping modules from our app ONE BY ONE to finally see what was causing the error to get some clue as to what the actual root cause was. As it turns out in our custom library we were importing a few modules from an // This is BAD!
import { MyModule } from '../my-modules/index';
// This is GOOD?
import { MyModule } from '../my-modules/my.module'; Sounds like my case is rare given that most people were able to resolve their issue with the solutions listed above but I wanted to comment in hopes that this could help someone else. |
Can confirm this issue is not longer reproducible. Thanks! |
thanks @ |
@basantkumarpogeyan bad idea, that will fail in prod build. That's just a workaround, not the solution. |
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. |
Versions
Repro steps
ng serve
to start the application bundleObserved behavior
The lazy module cannot be loaded.
Stack
Desired behavior
The module should load without errors.
Mention any other details that might be useful (optional)
The real problem here, is that the cli does not catch up the module after the path is changed.
Current workarounds:
I haven't try every recommended workaround, but some of them are clearly not a option if you really want those modules to be lazy loaded. This is especially true for solutions like:
Anything that makes the module to be bundle with the app, is not an acceptable workaround.
If you are having issues with a lazy loaded module, that is NOT about changing the route o creating another lazy loaded module into the path when the CLI is serving, then you should look a proper issue, or create a new one.
The text was updated successfully, but these errors were encountered: