Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: reduce host bootstrap waterfall with modulepreload#810

Merged
gioboa merged 3 commits into
module-federation:mainfrom
jgodi:main
Jun 12, 2026
Merged

fix: reduce host bootstrap waterfall with modulepreload#810
gioboa merged 3 commits into
module-federation:mainfrom
jgodi:main

Conversation

@jgodi

@jgodi jgodi commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

The MF bootstrap loads hostInit → remoteEntry → _virtual_mf* → index via runtime dynamic imports the browser's preload scanner never sees, causing a serial waterfall on cold cache. The existing fix-preload plugin is gated on exposes so pure hosts were unoptimized.

Adds pluginHostInitPreload which injects <link rel="modulepreload"> for all four host-init chunks via transformIndexHtml (post, build-only), with no exposes gate so all hosts benefit automatically.

The MF bootstrap loads hostInit → remoteEntry → _virtual_mf* → index via
runtime dynamic imports the browser's preload scanner never sees, causing
a serial waterfall on cold cache. The existing fix-preload plugin is gated
on `exposes` so pure hosts were unoptimized.

Adds `pluginHostInitPreload` which injects `<link rel="modulepreload">` for
all four host-init chunks via `transformIndexHtml` (post, build-only), with
no `exposes` gate so all hosts benefit automatically.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@pkg-pr-new

pkg-pr-new Bot commented Jun 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: d87ffec

Remove trailing commas from function call arguments and break lines
exceeding the 100-char print width to pass the fmt.check CI step.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Comment thread src/plugins/pluginHostInitPreload.ts Outdated
@gioboa

gioboa commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

It's working fine:

Screenshot 2026-06-12 at 22 18 01

@gioboa

gioboa commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Tests With Different Frameworks

Screenshot 2026-06-12 at 22 18 39

@gioboa gioboa changed the title feat: inject modulepreload hints for MF host-init chunk chain fix: reduce host bootstrap waterfall with modulepreload Jun 12, 2026

@gioboa gioboa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That's a nice catch 💯
Thank you @jgodi

@gioboa gioboa merged commit 3be70e2 into module-federation:main Jun 12, 2026
19 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.

2 participants