Skip to content

feat(builder): Add a cachePath option for the federation cache - #182

Merged
Aukevanoost merged 2 commits into
mainfrom
feat/configurable-cache-path
Oct 18, 2026
Merged

Aukevanoost merged 2 commits into
mainfrom
feat/configurable-cache-path

Conversation

@Aukevanoost

Copy link
Copy Markdown
Contributor

Part 1 of #179: makes the federation cache location configurable. The default doesn't change.

Changes

  • New cachePath option on the build and remote builders. A relative path resolves against the workspace root; the default stays node_modules/.cache/native-federation.
  • resolveCachePath (src/utils/resolve-cache-path.ts) replaces the hard-coded getDefaultCachePath call in both builders. Everything that already read cache.cachePath follows automatically: shared externals, the context tsconfigs, the compiler SourceFileCache and the stylesheet cache.
  • A path at or above the workspace root is rejected. On an adapter minor bump, core runs removeDir on <cachePath>/<project>, so cachePath: "." could delete a source folder.
  • The schema description warns against placing the cache directly under .angular/cache. purgeStaleBuildCache deletes every folder there except the current version folder, and buildApplicationInternal runs it on every build, including our own.

Not in this PR

Tests

  • src/utils/resolve-cache-path.spec.ts: default, relative, absolute, .. segments, names that start with .., and rejecting the root and folders above it.
  • pnpm typecheck, pnpm lint and pnpm test pass.

Refs #179

Both builders take a cachePath, resolved against the workspace root, and
default to node_modules/.cache/native-federation as before. A path at or
above the workspace root is rejected, since core purges <cachePath>/<project>
on an adapter minor bump.

Refs #179
Drop the '.angular/cache/<version>' suggestion, which Angular purges on
upgrade, and note that a custom cache folder must be gitignored.
@Aukevanoost
Aukevanoost merged commit d571b4d into main Oct 18, 2026
1 check passed
Aukevanoost added a commit that referenced this pull request Oct 18, 2026
Backports 22.2.2..22.2.3 onto the Angular 21 layout.

Incoming:
- #177: i18n fails the build when localize-translate fails.
- #178: init generates the v4 federation.config.mjs defaults (all of
  @angular/* shared with keepAll, denseExternals) and installs orchestrator
  ^4.8.0; the builder warns about flat externals and Angular packages
  shared without keepAll.
- #182: cachePath builder option for the federation cache.
- #183: federation outputs written as raw bytes.
- @softarc/native-federation ~4.8.0, orchestrator ^4.8.0.

Angular 21 specific adaptations:
- None of the incoming changes touch @angular/build internals, so no
  // upstream: tags change (still angular-cli v21.2.19, 1a728258d6).
- Skipped the remote builder schema/cachePath changes: this branch has no
  remote builder.
- Kept the -v4 name, 21.2.15 version, ng21 pins and this branch's global
  pnpm overrides; main's nx>undici override isn't needed, the lock already
  resolves undici 7.29.1.
- pnpm-lock.yaml regenerated rather than merged.
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.

1 participant