Pattern: How to handle the NX lint error 'Static imports of lazy-load...

Documentation for Sessions

🎨 Pattern: How to handle the NX lint error 'Static imports of lazy-load...

Date: 2026-02-05
Time: 04:40:27 UTC
Session: editor2-89.12
Agent: angular
Confidence: 95%
Status: ✅ Documented


📋 Decision Context

Question:

How to handle the NX lint error 'Static imports of lazy-loaded libraries are forbidden' when using @auth-ui?

Task: Not specified


🎯 Decision Made

Chosen:

Statically import everything from @auth-ui

Options Considered:

  1. Lazy-load all @auth-ui imports
  2. Statically import everything from @auth-ui
  3. Split @auth-ui into separate libraries
  4. Use different auth libraries per app

💭 Reasoning

NX enforces that a library must be EITHER statically imported OR lazy-loaded, not both. Since AuthService, guards (strictAuthGuard, loginPageGuard), and authInterceptor must be statically imported for app.config.ts and root component usage, any components from @auth-ui (like UnauthorizedPageComponent) must also be statically imported. In routes, use 'component: UnauthorizedPageComponent' instead of 'loadComponent: () => import('@auth-ui').then(m => m.UnauthorizedPageComponent)'. This is a fundamental NX constraint for library boundaries.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation