Refactor: How should the 1,330-line bundler-filesystem.service.ts be d...
Documentation for Sessions
♻️ Refactor: How should the 1,330-line bundler-filesystem.service.ts be d...
Date: 2026-03-27
Time: 14:09:05 UTC
Session: gspace1-276.6
Agent: angular
Confidence: 97%
Status: ✅ Documented
📋 Decision Context
Question:
How should the 1,330-line bundler-filesystem.service.ts be decomposed to follow the Global Engineering Standard?
Task: Decompose bundler-filesystem god-class per Global Engineering Standard
🎯 Decision Made
Chosen:
Extract 3 pure-function modules (P0+P1): enrichment/vfs-path-utils.ts (42 lines, 3 shared path functions), enrichment/scss-flattener.ts (188 lines, recursive descent SCSS parser), enrichment/source-transforms.ts (178 lines, 4 independent regex transforms). Service drops from 1,330 to 923 lines. The enrichFileMap pipeline becomes a clean sequence of named function calls.
Options Considered:
- Extract 3 pure-function modules P0+P1 (chosen — safest, highest impact-to-risk)
- Extract all 6 concerns at once (higher risk, touches more callsites)
- Leave as-is and add tests (doesn't fix the structural problem)
- Rewrite from scratch (nuclear option, high regression risk)
💭 Reasoning
The bundler-filesystem.service.ts contained 6 distinct concerns in one file: SCSS compiler (recursive descent parser with 7 methods), app shell synthesizer (6 methods), angular resource inliner (3 methods), import path repair (4 methods), stub generator (3 methods), and source transforms (4 methods). The extraction targeted the 3 concerns with zero Angular dependencies (pure functions) as a safe first pass. Each extracted module has no internal state, no DI, and can be unit tested independently. The remaining service retains methods that need DI context (strategy injection, SDK stubs). Key risk mitigated: the source-transforms module contains the S271 trailing comma bugfix in injectNoErrorsSchema — extraction preserved this fix character-for-character.
📁 Files Involved
libs/libs-structural/platform-preview/src/lib/services/bundler-filesystem.service.tslibs/libs-structural/platform-preview/src/lib/enrichment/vfs-path-utils.tslibs/libs-structural/platform-preview/src/lib/enrichment/scss-flattener.tslibs/libs-structural/platform-preview/src/lib/enrichment/source-transforms.ts
🔗 Related
- Decision ID:
dev_1774620542044_8lc5etc - Session: 276
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation