type=”module” on script tag results in “Cannot read property ‘webpackHotUpdate’ of undefined” when hot reloading is enabled.

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
The compiled bundle fails to execute with the error Uncaught TypeError: Cannot read property 'webpackHotUpdate' of undefined when using type="module" on script tags.

If the current behavior is a bug, please provide the steps to reproduce.
https://github.com/RDGthree/webpackHotUpdate-bug-example

Clone this repo, npm install, and npm run start. Open index.html in a browser and check the console. I used webpack-dev-server, but the issue relates to Webpack’s core.

I’m pretty sure the issue relates to this no longer referring to window with type="module".

What is the expected behavior?
When using type="module" on script tags, Hot Module Reloading works the same as with type="text/javascript", or has a helpful error.

Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.

  • Operating System: MacOS 10.12
  • Node Version: 8.4.0
  • NPM Version: 5.3.0
  • webpack Version: 3.6.0
  • webpack-dev-server Version: 2.9.1

Author: Fantashit

1 thought on “type=”module” on script tag results in “Cannot read property ‘webpackHotUpdate’ of undefined” when hot reloading is enabled.

  1. I don’t think so. As far as I can see, this is exclusively related to the new module script standard for browsers. Everything is working as expected, other than this being undefined.

Comments are closed.