webpack-contrib / webpack-hot-middleware

Webpack hot reloading you can attach to your own server
MIT License
2.34k stars 297 forks source link

TypeError: cb is not a function #382

Closed Realybig closed 1 year ago

Realybig commented 4 years ago

Why did this error appear when I modified the page, the page did not refresh HMR stopped work after webpack upgrade from 2 to 4 config

webpack4 "webpack-hot-middleware": "^2.12.2"

// dev-server.js
var hotMiddleware = require('webpack-hot-middleware')(compiler, {
    log: () => {}
});
// force page reload when html-webpack-plugin template changes
compiler.plugin('compilation', function (compilation) {
    compilation.plugin('html-webpack-plugin-after-emit', function (data, cb) {
        console.log('html-webpack-plugin-after-emit', data, cb)
        hotMiddleware.publish({ action: 'reload' });
        cb();
    });
});
TypeError: cb is not a function
    at /Users/labs/webpack/office/build/dev-server.js:39:9
    at Promise (eval at create (/Users/labs/webpack/office/node_modules/tapable/lib/HookCodeFactory.js:74:10), <anonymous>:17:16)
    at new Promise (<anonymous>)
    at AsyncSeriesWaterfallHook.eval [as promise] (eval at create (/Users/labs/webpack/office/node_modules/tapable/lib/HookCodeFactory.js:74:10), <anonymous>:4:8)
    at AsyncSeriesWaterfallHook.lazyCompileHook (/Users/labs/webpack/office/node_modules/tapable/lib/Hook.js:154:20)
    at /Users/labs/webpack/office/node_modules/html-webpack-plugin/index.js:673:47
    at Promise.resolve.then.then.then.then.then.then.then.then.catch.then.then (/Users/labs/webpack/office/node_modules/html-webpack-plugin/index.js:214:21)
    at process._tickCallback (internal/process/next_tick.js:68:7)
alexander-akait commented 1 year ago

Closing due to inactivity. Please test with latest version and feel free to reopen if still regressions. Thanks!