Architecture: How to wire the compilation strategy pattern into the bundle...
Documentation for Sessions
🏗️ Architecture: How to wire the compilation strategy pattern into the bundle...
Date: 2026-03-24
Time: 17:56:18 UTC
Session: gspace1-264.6
Agent: angular
Confidence: 93%
Status: ✅ Documented
📋 Decision Context
Question:
How to wire the compilation strategy pattern into the bundler pipeline without breaking the working JIT flow?
Task: S264: Wire compilation strategy pattern into bundler pipeline
🎯 Decision Made
Chosen:
Injectable COMPILATION_STRATEGY token with JitCompilationStrategy as default factory. Three integration points: BundlerService (externals + source transform), PreviewServerService (prerequisites + specifier rewriting), BundlerFilesystemService (main.ts imports). AOT path gated on strategy.mode === 'aot'.
Options Considered:
- Injectable token with factory default (chosen - zero-config, backwards compatible)
- Abstract service class with concrete implementations (heavier, requires NgModule)
- Config flag in BundlerConfig (simpler but less extensible)
- Runtime detection based on Angular version (fragile, version-specific)
💭 Reasoning
The strategy pattern allows switching compilation modes without changing pipeline code. Using an InjectionToken with a factory default (JitCompilationStrategy) means the existing behavior is preserved with zero configuration. The AOT transform is conditionally applied only when mode is 'aot', so the JIT path has zero overhead. Three integration points cover the full compilation flow: what to externalize (rspack config), how to transform sources (pre-bundling), and what to load at runtime (prerequisites). This makes the switch to AOT a single provider override.
📁 Files Involved
libs/libs-structural/platform-preview/src/lib/services/bundler.service.tslibs/libs-structural/platform-preview/src/lib/services/preview-server.service.tslibs/libs-structural/platform-preview/src/lib/services/bundler-filesystem.service.ts
🔗 Related
- Decision ID:
dev_1774374978196_tyaf9gj - Session: 264
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation