Skip to content

HMR support for ESM #19561

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

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft

Conversation

3ru
Copy link

@3ru 3ru commented May 25, 2025

This PR implements Hot Module Replacement (HMR) support for ESM output format. Currently, when using experiments.outputModule: true, HMR throws an error HMR is not implemented for module chunk format yet and prevents developers from using HMR with ESM builds.

What kind of change does this PR introduce?
This is a feature implementation that enables HMR functionality for ESM output format. The changes include:

  • Modifying ModuleChunkFormatPlugin to generate ESM-formatted hot update chunks
  • Extending ModuleChunkLoadingPlugin to register HMR handlers for ESM
  • Implementing import()-based hot update loading in ModuleChunkLoadingRuntimeModule
  • Adding necessary runtime requirements in HotModuleReplacementPlugin for ESM chunks

Did you add tests for your changes?
Tests will be added to cover:

Does this PR introduce a breaking change?
No, this change is backward compatible. It only affects builds that explicitly enable both ESM output (experiments.outputModule: true) and HMR, which previously resulted in an error.

What needs to be documented once your changes are merged?

@3ru 3ru force-pushed the feat/esm-hmr-chunk-generation branch from 289c5ec to c4159c4 Compare June 1, 2025 02:48
@3ru 3ru force-pushed the feat/esm-hmr-chunk-generation branch from 67abe1c to 2ee3111 Compare June 1, 2025 15:08
RuntimeGlobals.hasOwnProperty
])
);
}
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need this here? I think we should add them in ModuleChunkLoadingPlugin.js. Can you provide more information here?

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