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:
- Add stubs for all missing components
- Use dynamic import() with error boundaries instead of static imports
- 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
libs/libs-structural/platform-preview/src/lib/config/sdk-preview-stubs.tsAPIs/backend-vitto-api/src/prompts/module-gen/implement.prompt.md
🔗 Related
- Decision ID:
dev_1774027825040_zmbluyz - Session: 244
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation