-
Notifications
You must be signed in to change notification settings - Fork 12k
Does not generate lazy routes chunks #5204
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
This also happens to me even on OSmacOS Sierra 10.12.3 Versions.@angular/cli: 1.0.0-rc.1 |
I tried an app with some lazy loaded routes and could see the lazy chunks being correctly generated on |
I add a repo: https://github.com/Adol1111/ng-lazy-load-demo.git Starting with |
Thank you for making this repro. I cloned it, ran
I tried using linking master copy of the CLI, and on rebuild I didn't see an error and instead I saw a single extra lazy chunk called There's something odd here, will investigate further. |
I'm still not sure where stuff is breaking exactly, but it seems to be related to having the routes in Having them in
|
Actually, the core of it seems to actually be the @hansl I remember there was some conversation about |
Thx, that is ok now. I just provide a AuthGuard for AppRoutingModule. I will move it to coreModule |
@filipesilva putting the routes on my current project to Also tried nuking |
I've the same issues. But I recognised, that after running It doesn't matter how the file ( (Angular 4.0.0-rc.5, Angular CLI 4.0.0-rc.2) |
Seeing the same issue after upgrading to ng4. I import my app routing module without forRoot(). I will try to put together a small example. |
@reblace with current final versions, it's working for me again. |
Just started experiencing this too. However for us it's not everyone on the repo it's just me. When I edit the file that has my lazy loaded routes I get the error from #4246 |
Seeing the same issue as well. I have to change my app-routing.module file, before I see the chunks generated. Happens with ng4 |
I am running into the same issue. I am using @angular/cli 1.0.1 and @angular 4.0.1. |
@filipesilva I find out that it's a bug for @angular/compiler-cli, I have commit a pull request to fix it. angular/angular#16438 |
@Adol1111 wow thanks for fixing this! |
FYI, this same thing is happening with @ngtools in webpack if you use a vendor file and webpack.DllPlugin. The bundles aren't created but it expects them to be there. Using awesome-typescript makes it work again but then you lose AOT obviously. |
@JohnGalt1717 |
Right, but there is no feasible work around in there from what I can see either. Definitely needs to be fixed one way or another to make this all go together properly. |
I'm still seeing this problem. I've actually edited the route module, and that fixes it, but I need to deploy with the lazy loaded module chunks! I've updated the latest the angular-compiler, and I'm using angular 4. Does anyone have a workaround besides editing the app-route-module??? |
The reason why this happens is because you have Angular components in your vendor file. They must be included in your main angular chunk. As soon as you don't, it won't generate the chunks properly. So you need to have code that moves them into the main package and not in the vendor.js if production and using ngtools. |
using angularcli @JohnGalt1717 not to sure on that. have example maybe. |
I use Webpack but the same principle will apply. IF you have a vendor.js being generated make sure that when choosing production you don't have any angular libraries in vendor.js otherwise this will happen. |
ok @JohnGalt1717 so weird I built again and then everything fell in place. Not sure. but it works now and made individual chucks. |
I still have this issue. Upgraded the cli to 1.5. I have one lazy loaded route right now. The chunk file is created, however the I get an error because it's not adding the output directory to the path for the script tag. Anyone else having this? |
I have also upgraded the cli to 1.5 and still facing same issue. If without changing anything, I just save child module (it will re-compile app) than that child routes will work fine. Does anybody have any solution? |
@pateldol Can you upload a repo? In my case, it's a bug about compiler-cli which version under 4.1.3, not cli. |
for some reason it just started working. after I compliled 8 times. weird. |
Any news? |
Yes. I deleted all node modules and then made sure I had at least 2.4
typescript installed. and it worked.
Sent with MailTag <http://www.mailtag.io>
…On Sun, Nov 19, 2017 at 5:53 PM, EnricoMazzucchelli < ***@***.***> wrote:
Any news?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#5204 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADu4owVaeJpfQcL9bEF3TLrefjJQ7kxSks5s4LF8gaJpZM4MSaVQ>
.
--
Anthony P
(919) 671-7234
|
I have the same problem as described by gmetrix commented on 28 Sep 2017. Strange enough, the example code from the tutorial at https://angular.io/guide/lazy-loading-ngmodules is working fine. Ng build generates module chunk js properly. though my app structure is pretty similar to the example in the tutorial. |
Can I load specific lazy loaded chunk in prod build ? |
I met the same issue, in angular5.0 + webpack3.10.0 no chunk files for lazy loading. here is my root cause, hope can help someone: import { NgModule } from '@angular/core';
//import { PreloadAllModules, RouterModule, Routes } from '@angular/router';
import { RouterModule, Routes } from '@angular/router';
import { AppCustomPreloader } from './app.custom.preloader';
const routes: Routes = [
{
path: 'dashboard',
loadChildren: './modules/dashboard/dashboard.module#DashboardModule',
data: { preload: true }
},
{ path: 'settings', loadChildren: './modules/settings/settings.module#SettingsModule' },
{ path: 'reports', loadChildren: './modules/reports/reports.module#ReportsModule' },
];
@NgModule({
// imports: [RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules, useHash: true })],
imports: [RouterModule.forRoot(routes, { preloadingStrategy: AppCustomPreloader, useHash: true })],
exports: [RouterModule],
providers: [AppCustomPreloader]
})
export class AppRoutingModule { } and at the same time I import DashboardModule SettingsModule SettingsModule in my app.module.ts that's the reason why no chunk file for lazy loading module, I guess if there has loadchildren for business modlue and import it in app.module.ts, then angular just ignore the lazy loading settings. remove imported module in app.module.ts , it's working fine. |
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. |
OS?
Mac OS Sierra
Versions.
Repro steps.
At first, I use
ng build --prod --watch=true
with correct path for lazy module, but I can't see any lazy route chunksthen I use an error path like this:
./app/bike/bike.module#BikeModule
finally I change back:
app/bike/bike.module#BikeModule
I see the lazy route chunk output:
The text was updated successfully, but these errors were encountered: