Infrastructure: Why does Angular JIT throw 'Cannot read properties of undefi...

Documentation for Sessions

📝 Infrastructure: Why does Angular JIT throw 'Cannot read properties of undefi...

Date: 2026-03-20
Time: 17:30:25 UTC
Session: gspace1-244.3
Agent: angular
Confidence: 98%
Status: ✅ Documented


📋 Decision Context

Question:

Why does Angular JIT throw 'Cannot read properties of undefined (reading ɵmod)' in generated platform preview?

Task: S244: Fix ɵmod TypeError in preview


🎯 Decision Made

Chosen:

Expand SDK preview stubs from 2 to 13 UI components. The stubs at platform-preview/sdk-preview-stubs.ts only defined GgsCrudListShellComponent and GgsEntityLookupComponent. Generated code imports GgsCrudFormShellComponent, GgsCrudDetailShellComponent, GgsBadgeComponent, GgsButtonComponent, GgsFilterPanelComponent, GgsFilterChipsComponent, GgsInputComponent, GgsSelectComponent, GgsTextareaComponent, GgsCardComponent, GgsAlertComponent — all resolved to undefined at runtime.

Options Considered:

  1. Add stubs for all missing components
  2. Use dynamic import() with error boundaries instead of static imports
  3. Generate code that doesn't import UI components directly (use a facade)

💭 Reasoning

Root cause chain: (1) rspack WASM compiles generated .ts files in-browser. (2) SDK libraries (@libs-core/*) are replaced with lightweight stubs so the preview doesn't need full SDK. (3) When a generated component declares imports: [GgsBadgeComponent, ...], Angular JIT resolves each import. (4) If the stub barrel doesn't export that symbol, it resolves to undefined. (5) Angular's directiveDefs() calls ɵmod on undefined → TypeError. The fix is to ensure every component the LLM prompt teaches exists as a stub. This is a maintenance coupling: whenever implement.prompt.md adds a new component to the golden examples, a corresponding stub must exist. Convention added to enforce this.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation