Standalone components in initial bundle

Discussão em 'Angular' iniciado por Błażej, Outubro 22, 2024.

  1. Błażej

    Błażej Guest

    I am using Angular 18, and I have a problem with one of my modules.

    I checked initial bundles using 'source-map-explorer' plugin, and I see that 3 components (all of them are standalone components) from one module are placed in initial bundle. They are only used within this module.

    Do you have any suggestion what can I check to solve this issue?

    App Routing def

    provideRouter(
    {..},
    {
    path: 'news',
    loadChildren: () => import('./news/news.module').then((m) => m.NewsModule),
    canMatch: [() => enabledFeatures.newsSection],
    canActivate: [authGuardCanActivate],
    }
    )


    Module def

    @NgModule({
    imports: [NewsRoutingModule, NgxsModule.forFeature(newsStateObjects)],
    })
    export class NewsModule {}


    Module routing:

    @NgModule({
    imports: [RouterModule.forChild(
    { path: '', component: NewsDashboardComponent },
    )],
    exports: [RouterModule],
    })
    export class NewsRoutingModule {}


    Component def

    @Component({
    selector: 'app-news-item',
    templateUrl: './news-item.component.html',
    styleUrls: ['./news-item.component.scss'],
    standalone: true,
    changeDetection: ChangeDetectionStrategy.OnPush,
    imports: [
    NgOptimizedImage,MiddleClickDirectiveDirective,NgClass, NewsItemUserLabelsComponent,DatePipe,
    TranslateModule,TimeAgoPipe, MatCard,MatCardTitle, MatCardSubtitle,
    MatCardContent, MatTooltip,MatCardActions, MatButton,MatIcon,
    ],
    })
    export class NewsItemComponent {}

    Continue reading...

Compartilhe esta Página