Skip to content

Conversation

@AndreasLoukakis
Copy link

Problem
When running both production builds (ng build) and dev server (ng serve) for the same project, the dev server fails to serve federation chunk files. The chunks exist in the cache with -dev.js suffix, but are never copied to the dist folder because the metadata file lists production filenames (without -dev suffix). This causes module loading failures as remoteEntry.json references files that don't exist in the dist folder.

Root Cause
If I am not mistaken, in v3.4.x, the caching system was refactored to use a single metadata file (browser-shared.meta.json) for both dev and production builds. This causes production builds to overwrite the dev metadata:

  • Production build creates chunks without -dev suffix and writes these filenames to browser-shared.meta.json
  • Dev server reads the same browser-shared.meta.json which lists production filenames
  • The copyFiles() function tries to copy files like _angular_core.XXX.js from cache
  • These files don't exist in cache (only _angular_core.XXX-dev.js exists)
  • The function silently skips missing files (line 55-57 in bundle-caching.js: if (fs.existsSync(cachedFile)))
  • Result: No federation chunks are copied to dist folder at all

These 2 small changes should make sure dev and production builds maintain independent metadata with correct filenames.

@Aukevanoost
Copy link
Collaborator

Aukevanoost commented Jan 8, 2026

Hi @AndreasLoukakis, while the root issue should already be fixed in v21.0.4, this solution is bang on! With your PR we can have 2 builds cached at the same time, dev and prod!

I'll be sure to review the code soon! Thanks for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants