webpack: Webpack 4. Uncaught ReferenceError: webpackHotUpdate is not defined

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

What is the current behavior? capture

If the current behavior is a bug, please provide the steps to reproduce.

  1. Run webpack-dev-server, it builds sucessfully.
  2. Open page containing my bundled React code.
  3. It runs sucessfully.
  4. Change something in jsx to emit hot-update.
  5. Webpack rebuilds sucessfully, changes applied.
  6. Update whole page using F5 in browser.

What is the expected behavior? After step 6 I expect normal page loading again, but instead I get error messages above and not loaded page. Didn’t have such problems in webpack 3.

With this option it works

  new webpack.HotModuleReplacementPlugin({
     multiStep: true,
  }),

but in webpack 3 it worked like this

  new webpack.HotModuleReplacementPlugin(),

If this is a feature request, what is motivation or use case for changing the behavior? not feature request

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

webpack: 4.1.0 chrome: last stable node: 8.9.4 react: 16.2.0

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 20
  • Comments: 37 (13 by maintainers)

Commits related to this issue

Most upvoted comments

I have fixed this by switching runtimeChunk to true. image

Still present.

Hi, i know its an old issue but i had the same problem. If you are using webpack-assets-manifest and reading the manifest.json on reload you have to ignore the hot-update files on hmr. webpack-assets-manifest already includes an regex but reads the webpack.config.js option if its set. If you set the defaults in webpack.config.js it will ignore them automatically and will no longer override your base files in manifest.json.

output: {
    ...,
    hotUpdateChunkFilename: '[id].[fullhash].hot-update.js',
    hotUpdateMainFilename: '[runtime].[fullhash].hot-update.json',
},

Hope it helps

Also sometimes clearing project cache and rebuilding from scratch might help temporary. EG remove dist build folder and run webpack again. Cause of it might be some of the mentioned above.

    "webpack": "^4.20.2",
    "webpack-bundle-analyzer": "^3.4.1",
    "webpack-dev-server": "^3.8.0"
    "webpack-cli": "^3.3.6",
    "webpack-merge": "^4.1.4"
    "copy-webpack-plugin": "^5.0.4",
    "friendly-errors-webpack-plugin": "^1.7.0",
    "html-webpack-plugin": "^4.0.0-beta.11",

Add multiStep can fix the issue, but multiStep will break html-webpack-plugin as https://github.com/jantimon/html-webpack-plugin/issues/533 described.

@sokra @jantimon Can we discuss a better solution ?

Somebody can create reproducible test repo?

I think the issue was with the plugin assets-webpack-plugin.

If anyone is having the same problem, I got to fix the issue I was having simply by changing from assets-webpack-plugin to webpack-manifest-plugin, the same one that create-react-app uses. After that, i could remove the multiStep: true, and everything returned back to normal.

@evilebottnawi I just tested using 4.8.2, still the same thing.

I can post my webpack/babel/whatever config, if you think it’s necessary.