Convention: How should Angular barrel imports be handled in framework-ag...

Documentation for Sessions

📏 Convention: How should Angular barrel imports be handled in framework-ag...

Date: 2026-03-23
Time: 17:02:50 UTC
Session: gspace1-258.6
Agent: angular
Confidence: 95%
Status: ✅ Documented


📋 Decision Context

Question:

How should Angular barrel imports be handled in framework-agnostic libraries?

Task: S258: Convention for framework-agnostic library imports


🎯 Decision Made

Chosen:

Framework-agnostic libraries must NEVER import from Angular library barrels, even if the specific type needed is pure TypeScript. Barrel imports transitively pull the entire module graph including Angular services/decorators. Instead: (1) Import types from @libs-foundational/core-models (verified pure TS). (2) Define lightweight local types for shapes needed from Angular barrels (PluginDropPayload instead of DragPayload, CHAT_MODEL_IDS instead of AI_MODELS_CONFIG). (3) Define provider interfaces that Angular services implement.

Options Considered:

  1. Import from barrels and hope tree-shaking removes Angular (doesn't work — type imports still resolve the module graph)
  2. Use deep path imports like @libs-ux/embeddable-bridge/src/lib/models/... (fragile, breaks on refactor)
  3. Define local lightweight types + provider interfaces (chosen — clean dependency boundary)

💭 Reasoning

Three Angular barrel contamination vectors discovered during S258: (A) @libs-ux/embeddable-bridge — DragPayload is pure TS but barrel re-exports Angular directives/services. (B) @libs-foundational/api-config — AI_MODELS_CONFIG is pure TS but barrel re-exports InjectionToken from @angular/core. (C) @libs-ai/vitto-core — VittoPageContextRegistry is an @Injectable Angular service. All three would have broken the zero-Angular-deps guarantee of chat-plugin-core. This is a systemic pattern: most NX library barrels mix pure TS types with Angular constructs. Any framework-agnostic library must verify each dependency's barrel before importing.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation