askill
vendix-frontend-lazy-routing

vendix-frontend-lazy-routingSafety 92Repository

Instructions for creating always lazy-loaded routes for sub-modules.

4 stars
1.2k downloads
Updated 2/7/2026

Package Files

Loading files...
SKILL.md

Vendix Frontend Lazy Routing

ALWAYS LAZY - Pattern for creating sub-module routes that load on demand to optimize bundle size and initial load time.

🎯 Core Principle

NEVER import feature components directly in routing files. ALWAYS use loadChildren for modules or loadComponent for standalone components.

πŸ“‹ Route Configuration Patterns

1. Lazy Loading Standalone Components (Preferred)

Use this pattern when routing to a specific page or component that is standalone.

// βœ… CORRECT: Lazy load component
{
  path: 'settings',
  loadComponent: () => 
    import('./settings/settings.component').then(m => m.SettingsComponent)
}

// ❌ INCORRECT: Eager load
// import { SettingsComponent } from './settings/settings.component';
// { path: 'settings', component: SettingsComponent }

2. Lazy Loading Child Modules/Routes

Use this pattern when a route has its own child routing (e.g., a feature module like 'shipping').

// βœ… CORRECT: Lazy load child routes
{
  path: 'shipping',
  loadChildren: () => 
    import('./shipping/shipping.module').then(m => m.ShippingModule)
}

πŸ› οΈ Step-by-Step Implementation

Step 1: Create the Component/Module

Ensure your target component is standalone: true or wrapped in a configured NgModule.

Step 2: Define the Route

CRITICAL: Identify the actual parent routing file that is being used.

  • For Store Admin features, this is often apps/frontend/src/app/routes/private/store_admin.routes.ts.
  • Do NOT assume a local settings.routes.ts is active unless you verify it is imported.
  1. Do NOT import the component at the top of the file.
  2. Add the route object using loadComponent or loadChildren.
// Example in store_admin.routes.ts
export const storeAdminRoutes: Routes = [
  {
    path: 'settings',
    children: [
      {
        path: 'shipping',
        loadChildren: () => import('@/modules/settings/shipping/shipping.module').then(m => m.ShippingModule)
      }
    ]
  }
];

Step 3: Verify Chunk Generation

When building (or in vendix_frontend logs), verify that a separate chunk is created for your new route.

chunk-PG4JAFED.js | general-settings-component | 177.75 kB

🚨 Critical Rules

  1. No Static Imports: Check the top of your .routes.ts file. If you see import { FeatureComponent } ..., delete it.
  2. Path Resolution: Use relative paths (./) finding the component file.
  3. Typing: Ensure the then(m => m.ComponentName) matches the exported class name exactly.

πŸ’‘ Benefits

  • Performance: Reduces the initial JavaScript bundle size.
  • Speed: Faster time-to-interactive for the application.
  • Isolation: Keeps features decoupled.

Install

Download ZIP
Requires askill CLI v1.0+β–Ά

AI Quality Score

72/100Analyzed 2/20/2026

Well-structured Angular lazy routing skill with clear code examples and step-by-step instructions. Covers the core pattern effectively but is somewhat project-specific with references to internal file paths (store_admin.routes.ts) and project-specific modules (@/modules/settings/). The technical content is accurate and actionable for Angular developers, though the project-specific details limit broader reusability.

92
85
55
75
88

Metadata

Licenseunknown
Version-
Updated2/7/2026
PublisherRzyfront

Tags

No tags yet.