D
D
Django Almighty2020-05-30 11:27:44
Angular
Django Almighty, 2020-05-30 11:27:44

Why does lazy loading load all js files to the client?

app.routing.module.ts file

const routes: Routes = [

  
 { path: '', loadChildren: () => import('./threads-lazy/threads-lazy.module').then(m => m.ThreadsLazyModule) },
 { path: 'thread/:guid', loadChildren: () => import('./thread-lazy/thread-lazy.module').then(m => m.ThreadLazyModule) },

];


When forming a bundle, the output files are 5.js and 6.js.
When you go to the main page, only 5.js should be loaded, but for some reason 6.js is also loaded, which has nothing to do with it.

Where is the error?

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ThreadLazyRoutingModule } from './thread-lazy-routing.module';
import { ThreadComponent } from './thread/thread.component';


@NgModule({
  declarations: [ThreadComponent],
  imports: [
    CommonModule,
    ThreadLazyRoutingModule
  ]
})
export class ThreadLazyModule { }


import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ThreadComponent } from './thread/thread.component';


const routes: Routes = [
  {
    path: '', component: ThreadComponent
  }
];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule]
})
export class ThreadLazyRoutingModule { }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question