Skip to content

Defer Block + HMR automatically prefeches chunks #60846

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JeanMeche opened this issue Apr 11, 2025 · 3 comments
Open

Defer Block + HMR automatically prefeches chunks #60846

JeanMeche opened this issue Apr 11, 2025 · 3 comments
Labels
area: core Issues related to the framework runtime core: defer Issues related to @defer blocks. core: hot module replacement (HMR)
Milestone

Comments

@JeanMeche
Copy link
Member

JeanMeche commented Apr 11, 2025

Description

When HMR is enabled, defered chunks are automatically prefetched despite any prefetching triggers.

repro: https://github.com/JeanMeche/test-defer.git

@JeanMeche JeanMeche changed the title Defer + HMR automatically prefeches chuckns Defer + HMR automatically prefeches chuncks Apr 11, 2025
@JeanMeche JeanMeche added core: defer Issues related to @defer blocks. core: hot module replacement (HMR) labels Apr 11, 2025
@JeanMeche JeanMeche changed the title Defer + HMR automatically prefeches chuncks Defer Block + HMR automatically prefeches chuncks Apr 11, 2025
@kirjs kirjs added the area: core Issues related to the framework runtime label Apr 11, 2025
@ngbot ngbot bot added this to the needsTriage milestone Apr 11, 2025
@thePunderWoman
Copy link
Contributor

thePunderWoman commented Apr 11, 2025

This is expected and unavoidable due to the nature of HMR. The initial load should behave as normal, but after changes, the modules are already fetched / cached and the page hasn't refreshed. We really just need to update the defer guide to make this clear. I think we need this as a callout both on the @defer guide and the incremental hydration guide.

@thePunderWoman thePunderWoman changed the title Defer Block + HMR automatically prefeches chuncks Defer Block + HMR automatically prefeches chunks Apr 11, 2025
@JeanMeche
Copy link
Member Author

What I noticed it that the defered component is pre-fetched on bootstrap.

@thePunderWoman
Copy link
Contributor

Per our offline conversation, it's not prefetched. It's bundled in with the main bundle with HMR enabled. This is probably expected due to HMR complexity, but definitely confusing. It needs follow up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues related to the framework runtime core: defer Issues related to @defer blocks. core: hot module replacement (HMR)
Projects
None yet
Development

No branches or pull requests

3 participants