Architecture: How to handle Angular templateUrl/styleUrl in in-browser JIT...

Documentation for Sessions

🏗️ Architecture: How to handle Angular templateUrl/styleUrl in in-browser JIT...

Date: 2026-03-15
Time: 18:08:02 UTC
Session: gspace1-224.7
Agent: angular
Confidence: 95%
Status: ✅ Documented


📋 Decision Context

Question:

How to handle Angular templateUrl/styleUrl in in-browser JIT preview?

Task: Fix Angular component resource resolution in preview


🎯 Decision Made

Chosen:

Pre-process VFS files to inline templateUrl→template and styleUrl→styles before rspack compilation. Regex-based resolution against the VFS file map.

Options Considered:

  1. Inline at VFS level before rspack
  2. Configure rspack to resolve templateUrl
  3. Add custom rspack loader
  4. Serve individual files via SW and let JIT fetch them

💭 Reasoning

Angular JIT in a Service Worker context cannot resolve relative file URLs (no HTTP server to fetch ./foo.component.html). This mimics what @ngtools/webpack does at build time. The inlining happens in enrichFileMap before rspack sees the files, so the compiled output has inline template/styles that JIT can process.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation