Skip to content

feat(metro): support manifest hashes for native caching#4700

Merged
zackarychapple merged 15 commits into
module-federation:mainfrom
jbroma:feat/native-cache-hashes
May 7, 2026
Merged

feat(metro): support manifest hashes for native caching#4700
zackarychapple merged 15 commits into
module-federation:mainfrom
jbroma:feat/native-cache-hashes

Conversation

@jbroma
Copy link
Copy Markdown
Member

@jbroma jbroma commented Apr 29, 2026

Description

Builds on top of #4576 to finalize Metro manifest hashes for native cache workflows.

The main change is that manifest hashes are now produced from Metro's serialized bundle output instead of being derived during the earlier manifest generation path. That matters because Metro dev builds lazily compile federated entrypoints, exposes, and shared modules only after they are requested for a platform. Computing hashes from serialization gives us the final emitted bundle content in both production bundling and dev-server requests.

This PR also makes platform-scoped dev manifest requests warm the required federated modules before returning mf-manifest.json, which enables testing federated module caching during development instead of only after production bundle output exists.

In scope:

  • Move manifest hash collection into Metro bundle serialization so hashes reflect emitted bundle code.
  • Support dev manifest hashes after Metro lazily compiles platform-specific federated modules.
  • Keep the Metro core plugin path minimal and avoid pushing manifest hash/cache concerns into metroCorePlugin.
  • Remove the old cache interface module from this PR's final shape.
  • Fix generated remote string escaping so generated module code is valid for arbitrary remote config strings.
  • Fix shared import alias resolution so shared modules using shared.import resolve through the configured shared key while loading the actual import target.
  • Add focused coverage for manifest generation, manifest middleware, serializer-driven hash updates, generated remotes, and shared resolver aliases.

Validation run locally:

  • pnpm --filter @module-federation/metro run test -- __tests__/plugin/resolver.spec.ts
  • pnpm --filter @module-federation/metro run typecheck
  • pnpm --filter @module-federation/metro run lint
  • pnpm --filter @module-federation/metro run build
  • pnpm --filter @module-federation/metro-plugin-rock run build
  • pnpm --filter @module-federation/metro-plugin-rock run typecheck
  • pnpm --filter @module-federation/metro-plugin-rock run lint
  • pnpm exec turbo run build --filter=@module-federation/metro-plugin-rock
  • pnpm exec prettier --check .changeset/metro-dev-manifest-hashes.md
  • git diff --check

Related Issue

Follow-up to #4576.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have updated the documentation.

jbroma added 2 commits April 30, 2026 00:49
Compute hashes during serialization and thread them through manifest
generation so the native cache layer can verify bundle integrity.
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 29, 2026

Deploy Preview for module-federation-docs ready!

Name Link
🔨 Latest commit 974bf2e
🔍 Latest deploy log https://app.netlify.com/projects/module-federation-docs/deploys/69fcaa8afa50f600081e6608
😎 Deploy Preview https://deploy-preview-4700--module-federation-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 29, 2026

🦋 Changeset detected

Latest commit: 974bf2e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 45 packages
Name Type
@module-federation/metro Patch
@module-federation/metro-plugin-rnc-cli Patch
@module-federation/metro-plugin-rnef Patch
@module-federation/metro-plugin-rock Patch
@module-federation/runtime Patch
@module-federation/enhanced Patch
@module-federation/rspack Patch
@module-federation/webpack-bundler-runtime Patch
@module-federation/sdk Patch
@module-federation/runtime-tools Patch
@module-federation/managers Patch
@module-federation/manifest Patch
@module-federation/dts-plugin Patch
@module-federation/third-party-dts-extractor Patch
@module-federation/devtools Patch
@module-federation/bridge-react Patch
@module-federation/bridge-vue3 Patch
@module-federation/bridge-shared Patch
@module-federation/bridge-react-webpack-plugin Patch
@module-federation/modern-js Patch
@module-federation/modern-js-v3 Patch
@module-federation/retry-plugin Patch
@module-federation/rsbuild-plugin Patch
@module-federation/error-codes Patch
@module-federation/inject-external-runtime-core-plugin Patch
@module-federation/runtime-core Patch
create-module-federation Patch
@module-federation/cli Patch
@module-federation/rspress-plugin Patch
@module-federation/treeshake-server Patch
@module-federation/treeshake-frontend Patch
@module-federation/esbuild Patch
@module-federation/nextjs-mf Patch
@module-federation/node Patch
@module-federation/storybook-addon Patch
shared-tree-shaking-no-server-host Patch
shared-tree-shaking-no-server-provider Patch
@module-federation/utilities Patch
remote5 Patch
remote6 Patch
shared-tree-shaking-with-server-host Patch
shared-tree-shaking-with-server-provider Patch
website-new Patch
node-dynamic-remote-new-version Patch
node-dynamic-remote Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 29, 2026

Bundle Size Report

11 package(s) changed, 29 unchanged.

Package dist + ESM entry

Package Total dist (raw) Delta ESM gzip Delta
@module-federation/cli 26.3 kB no change 786 B no change
@module-federation/core 39.1 kB no change 173 B no change
@module-federation/devtools 487.9 kB no change 3.9 kB no change
@module-federation/enhanced 807.3 kB no change 672 B no change
@module-federation/managers 69.8 kB no change 334 B no change
@module-federation/manifest 136.1 kB no change 182 B no change
@module-federation/metro 277.2 kB +25.0 kB (+9.9%) 147 B no change
@module-federation/metro-plugin-rnc-cli 0 B no change 314 B no change
@module-federation/node 193.4 kB no change 217 B no change
@module-federation/storybook-addon 77.7 kB no change 100 B no change
@module-federation/utilities 110.6 kB no change 328 B no change

Bundle targets

Package Web bundle (gzip) Delta Node bundle (gzip) Delta
@module-federation/cli 2.3 kB -35 B (-1.5%) 2.3 kB -35 B (-1.5%)
@module-federation/core 1.1 kB -34 B (-3.0%) 1.0 kB -32 B (-3.0%)
@module-federation/devtools 21.3 kB -28 B (-0.1%) 21.3 kB -28 B (-0.1%)
@module-federation/enhanced 2.6 kB -47 B (-1.7%) 2.6 kB -47 B (-1.7%)
@module-federation/managers 2.4 kB -29 B (-1.2%) 2.4 kB -29 B (-1.2%)
@module-federation/manifest 6.1 kB -43 B (-0.7%) 6.1 kB -43 B (-0.7%)
@module-federation/metro 9.5 kB +1.6 kB (+20.0%) 9.4 kB +1.6 kB (+20.2%)
@module-federation/metro-plugin-rnc-cli 411 B -27 B (-6.2%) 411 B -27 B (-6.2%)
@module-federation/node 9.2 kB -31 B (-0.3%) 9.2 kB -31 B (-0.3%)
@module-federation/storybook-addon 1.9 kB -25 B (-1.3%) 1.7 kB -26 B (-1.4%)
@module-federation/utilities 2.6 kB -34 B (-1.3%) 2.6 kB -34 B (-1.3%)

Consumer scenarios

Scenario Web output (gzip) Delta Node output (gzip) Delta Gap (node-web) Delta
Enhanced remoteEntry 19.8 kB -15 B (-0.1%) 20.8 kB -9 B (-0.0%) +1.0 kB +6 B

Total dist (raw): 6.25 MB (+25.0 kB (+0.4%))
Total ESM gzip: 74.1 kB (no change)
Total web bundle (gzip): 179.7 kB (+1.3 kB (+0.7%))
Total node bundle (gzip): 180.2 kB (+1.3 kB (+0.7%))
Tracked ./bundler entry gzip: 556 B (no change)
Tracked ./bundler web bundle (gzip): 4.8 kB (no change)
Tracked ./bundler node bundle (gzip): 4.8 kB (no change)

Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as ./bundler are measured separately so ENV_TARGET-driven tree-shaking is visible. Bare imports are externalized to keep package-level sizes consistent, and assets are emitted as resources.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 29, 2026

Open in StackBlitz

@module-federation/devtools

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/devtools@974bf2e

@module-federation/cli

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/cli@974bf2e

create-module-federation

pnpm add https://pkg.pr.new/module-federation/core/create-module-federation@974bf2e

@module-federation/dts-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/dts-plugin@974bf2e

@module-federation/enhanced

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/enhanced@974bf2e

@module-federation/error-codes

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/error-codes@974bf2e

@module-federation/esbuild

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/esbuild@974bf2e

@module-federation/managers

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/managers@974bf2e

@module-federation/manifest

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/manifest@974bf2e

@module-federation/metro

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro@974bf2e

@module-federation/metro-plugin-rnc-cli

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro-plugin-rnc-cli@974bf2e

@module-federation/metro-plugin-rnef

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro-plugin-rnef@974bf2e

@module-federation/metro-plugin-rock

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/metro-plugin-rock@974bf2e

@module-federation/modern-js

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/modern-js@974bf2e

@module-federation/modern-js-v3

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/modern-js-v3@974bf2e

@module-federation/native-federation-tests

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/native-federation-tests@974bf2e

@module-federation/native-federation-typescript

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/native-federation-typescript@974bf2e

@module-federation/nextjs-mf

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/nextjs-mf@974bf2e

@module-federation/node

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/node@974bf2e

@module-federation/retry-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/retry-plugin@974bf2e

@module-federation/rsbuild-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rsbuild-plugin@974bf2e

@module-federation/rspack

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rspack@974bf2e

@module-federation/rspress-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/rspress-plugin@974bf2e

@module-federation/runtime

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/runtime@974bf2e

@module-federation/runtime-core

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/runtime-core@974bf2e

@module-federation/runtime-tools

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/runtime-tools@974bf2e

@module-federation/sdk

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/sdk@974bf2e

@module-federation/storybook-addon

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/storybook-addon@974bf2e

@module-federation/third-party-dts-extractor

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/third-party-dts-extractor@974bf2e

@module-federation/treeshake-frontend

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/treeshake-frontend@974bf2e

@module-federation/treeshake-server

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/treeshake-server@974bf2e

@module-federation/typescript

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/typescript@974bf2e

@module-federation/utilities

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/utilities@974bf2e

@module-federation/webpack-bundler-runtime

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/webpack-bundler-runtime@974bf2e

@module-federation/bridge-react

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-react@974bf2e

@module-federation/bridge-react-webpack-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-react-webpack-plugin@974bf2e

@module-federation/bridge-shared

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-shared@974bf2e

@module-federation/bridge-vue3

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/bridge-vue3@974bf2e

@module-federation/inject-external-runtime-core-plugin

pnpm add https://pkg.pr.new/module-federation/core/@module-federation/inject-external-runtime-core-plugin@974bf2e

commit: 974bf2e

@jbroma jbroma marked this pull request as ready for review May 7, 2026 12:36
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1ffc273909

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/metro-core/src/plugin/manifest-middleware.ts
Comment thread packages/metro-core/src/plugin/serializer.ts
@jbroma jbroma changed the title feat(metro-core): add SHA-256 bundle hashes to manifest generation feat(metro): support manifest hashes for native caching May 7, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b58edc8d09

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/metro-core/src/plugin/manifest-middleware.ts
Comment thread packages/metro-core/src/plugin/manifest.ts Outdated
@zackarychapple zackarychapple merged commit 6c9d2ee into module-federation:main May 7, 2026
23 checks passed
@2heal1 2heal1 mentioned this pull request May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants