Skip to content

fix(builder): Write federation outputs as raw bytes - #183

Merged
Aukevanoost merged 1 commit into
mainfrom
fix/write-binary-outputs
Oct 18, 2026
Merged

Aukevanoost merged 1 commit into
mainfrom
fix/write-binary-outputs

Conversation

@Aukevanoost

Copy link
Copy Markdown
Contributor

Fixes #181: the federation build now writes each esbuild output as raw bytes, so binary assets are no longer corrupted.

Changes

  • writeResult (src/tools/esbuild/angular-esbuild-adapter.ts) writes outFile.contents instead of outFile.text. text decodes the output as UTF-8, which replaced invalid byte sequences in images and fonts (e.g. from a file loader) with U+FFFD. This matches the esbuild adapter's write-result.ts.

Tests

  • New spec: a PNG-like output with bytes that aren't valid UTF-8 reaches fs.writeFileSync unchanged. It fails against the old .text write.
  • The existing write spec now mocks contents and checks for the bytes.
  • pnpm typecheck, pnpm lint and pnpm test pass.

Closes #181

Writing outFile.text decoded every output as UTF-8, corrupting binary
assets such as images and fonts. Closes #181.
@Aukevanoost
Aukevanoost merged commit 6952e39 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.

Federation build writes binary assets as text, corrupting them

1 participant