Bugfix: Bug 5 (BLOCKING): AOT-compiled components render nothing bec...

Documentation for Sessions

🐛 Bugfix: Bug 5 (BLOCKING): AOT-compiled components render nothing bec...

Date: 2026-03-24
Time: 19:40:21 UTC
Session: gspace1-264.5
Agent: angular
Confidence: 95%
Status: ✅ Documented


📋 Decision Context

Question:

Bug 5 (BLOCKING): AOT-compiled components render nothing because ɵɵdefineComponent lacks dependencies field

Task: S264.4: Fix AOT Bug 5 — missing dependencies in ɵɵdefineComponent


🎯 Decision Made

Chosen:

Extract imports array from @Component metadata → add as dependencies field in ɵɵdefineComponent. Also extract changeDetection and schemas.

Options Considered:

  1. Option A: Extract imports from string regex (fragile for nested arrays)
  2. Option B: Bracket-depth-aware extraction with identifier validation (chosen)
  3. Option C: Use ts-morph AST for metadata parsing (overkill, adds dependency)

💭 Reasoning

Root cause: When the decorator transformer strips @Component({ imports: [CommonModule, RouterLink, ...] }), the imports array was discarded. Angular's Ivy runtime uses the dependencies field in ɵɵdefineComponent() to know which directives/components/pipes are available in the template. Without it, Angular silently ignores unknown elements — app-root exists in DOM but renders nothing. Fix: extractImportsProp() parses the imports array from metadata string using bracket-depth tracking (handles nested arrays), returns identifier names. These are injected as dependencies: [...] in the ɵɵdefineComponent call. The TypeScript import statements for those classes are preserved (they're above the @Component decorator which we strip, not inside it).


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation