Bugfix: Why did provideAnimations() cause NG0201 and NG0200 errors i...
Documentation for Sessions
🐛 Bugfix: Why did provideAnimations() cause NG0201 and NG0200 errors i...
Date: 2026-03-24
Time: 17:49:06 UTC
Session: gspace1-264.3
Agent: angular
Confidence: 95%
Status: ✅ Documented
📋 Decision Context
Question:
Why did provideAnimations() cause NG0201 and NG0200 errors in the preview, and how to fix it?
Task: S264: Fix NG0201/NG0200 DomRendererFactory2 provider errors in preview
🎯 Decision Made
Chosen:
Remove provideAnimations() from synthesized appConfig and use noop stubs for @angular/platform-browser/animations subpath entries
Options Considered:
- Remove provideAnimations() and use noop stubs (chosen)
- Bundle platform-browser + platform-browser/animations as single file (naming conflicts, fragile)
- Keep CDN for animations only (re-introduces CDN dependency)
- Use provideNoopAnimations() from the noop stub (still loads the conflicting bundle)
💭 Reasoning
Root cause: Angular FESM flat bundles for subpath entries pre-inline parent package code. When esbuild builds platform-browser-animations.mjs, it includes its own copy of DomRendererFactory2 (from @angular/platform-browser). This creates TWO different DomRendererFactory2 classes — one in platform-browser.mjs (used by bootstrapApplication's BROWSER_MODULE_PROVIDERS) and one in platform-browser-animations.mjs (used by provideAnimations). Angular DI uses object identity for tokens, so the animation renderer's dependency on DomRendererFactory2 doesn't match the provider registered by bootstrapApplication. Fix: (1) Remove provideAnimations() since animations are cosmetic for preview. (2) Create noop stubs for the animation subpath entries that export empty functions — satisfies import resolution without duplicating singletons. CSS transitions still work. This is not fixable by adjusting esbuild externals — the FESM format pre-inlines by design.
📁 Files Involved
libs/libs-structural/platform-preview/src/lib/services/bundler-filesystem.service.tstools/scripts/build/bundle-angular-runtime.tslibs/libs-structural/platform-preview/src/lib/config/esm-cdn-map.ts
🔗 Related
- Decision ID:
dev_1774374546157_fzlunc5 - Session: 264
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation