Skip to content

Conversation

@shash-hq
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Other (Sample)

What is the current behavior?

Currently, there is no example showing how to configure Hot Module Replacement (HMR) in a project using ESM ("type": "module"). When users attempt to standard HMR recipe, they encounter require is not defined in ES module scope because the CLI uses require to load the webpack configuration.

Issue Number: #14331

What is the new behavior?

This PR adds sample/36-hmr-esm, which demonstrates the correct configuration for HMR with ESM:

  1. Using "type": "module" in package.json.
  2. Renaming the configuration file to webpack-hmr.config.cjs to allow require via CommonJS.
  3. Configuring output.filename: 'main.cjs' in webpack to ensure correct runtime execution.

Does this PR introduce a breaking change?

  • Yes
  • No

@coveralls
Copy link

Pull Request Test Coverage Report for Build 679b9e76-c7f0-409b-804d-eb7b51a7f2d0

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 89.666%

Totals Coverage Status
Change from base Build eaf9b6b0-1f07-466d-8da5-2f41241edd3c: 0.0%
Covered Lines: 7401
Relevant Lines: 8254

💛 - Coveralls

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