Skip to content

fix: content-hash bootstrap entry asset#751

Merged
gioboa merged 1 commit into
module-federation:mainfrom
cschroeter:fix/bootstrap-entry-content-hash
May 28, 2026
Merged

fix: content-hash bootstrap entry asset#751
gioboa merged 1 commit into
module-federation:mainfrom
cschroeter:fix/bootstrap-entry-content-hash

Conversation

@cschroeter
Copy link
Copy Markdown
Contributor

Summary

  • Append a short sha256 hash of the bootstrap source to the emitted bootstrap filename so it participates in the standard cache-busting flow.
  • Without the hash, mf-entry-bootstrap-0.js is referenced from index.html but never invalidates in browser/CDN caches after a deploy, breaking app load until caches expire.
  • Update test for the new mf-entry-bootstrap-<index>-<hash>.js shape.

Fixes #750

Before

dist/index.html               → <script src="/mf-entry-bootstrap-0.js">
dist/mf-entry-bootstrap-0.js  ← no hash, stale on deploy

After

dist/index.html                        → <script src="/mf-entry-bootstrap-0-3f1c9a2b.js">
dist/mf-entry-bootstrap-0-3f1c9a2b.js  ← content-hashed, invalidates on deploy

Test plan

  • pnpm test (417 passing)
  • pnpm typecheck
  • Existing pluginAddEntry build-mode test updated to assert the new filename shape and that the HTML references the hashed bootstrap

Bootstrap entry was emitted as `mf-entry-bootstrap-${index}.js` with no
content hash. Since this file is referenced from `index.html` as the app
entry, stale browser/CDN caches kept serving the old bootstrap after deploys,
breaking app load until caches expired.

Append a short sha256 hash of the bootstrap source to the filename
(`mf-entry-bootstrap-${index}-${hash}.js`) so it participates in the
normal cache-busting flow alongside every other built asset.

Fixes module-federation#750
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 28, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@module-federation/vite@751

commit: 85c2a35

Copy link
Copy Markdown
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

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

Tests With Different Frameworks

Image

Copy link
Copy Markdown
Collaborator

@gioboa gioboa left a comment

Choose a reason for hiding this comment

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

Thanks @cschroeter
That's simply amazing 🚀

@gioboa gioboa merged commit c2bfdbe into module-federation:main May 28, 2026
19 of 20 checks passed
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.

[Bug]: Bootstrap entry asset is not content-hashed

2 participants