No module factory available for

2021-05-26  本文已影响0人  越前君

今天在优化 Webpack 配置时,使用到 speed-measure-webpack-plugin 来测算 Webpack 各项打包速度。

const SpeedMeasurePlugin = require('speed-measure-webpack-plugin')
const smp = new SpeedMeasurePlugin()

const webpackConfig = {
  // ...
}

module.exports = smp.wrap(webpackConfig)

在初次启动项目的时候,可以成功编译。可就在热更新的时候,就报了以下错误:

ℹ 「wdm」: Compiling...
✖ 「wdm」: Error: No module factory available for dependency type: ModuleHotAcceptDependency
    at addDependency (/Users/frankie/Desktop/Web/company-git/pro234/react-demo/node_modules/webpack/lib/Compilation.js:800:12)
    at iterationOfArrayCallback (/Users/frankie/Desktop/Web/company-git/pro234/react-demo/node_modules/webpack/lib/Compilation.js:208:3)
    at addDependenciesBlock (/Users/frankie/Desktop/Web/company-git/pro234/react-demo/node_modules/webpack/lib/Compilation.js:816:5)
    at Compilation.processModuleDependencies (/Users/frankie/Desktop/Web/company-git/pro234/react-demo/node_modules/webpack/lib/Compilation.js:827:4)
    at afterBuild (/Users/frankie/Desktop/Web/company-git/pro234/react-demo/node_modules/webpack/lib/Compilation.js:954:15)
    at processTicksAndRejections (internal/process/task_queues.js:75:11)
/Users/frankie/Desktop/Web/company-git/pro234/react-demo/node_modules/neo-async/async.js:16
    throw new Error('Callback was already called.');
    ^

似乎是使用了 speed-measure-webpack-plugin 导致的,移除即可。

但如果同时该插件如何解决报错,暂时没找到解决方案,若后续有解决方案会回来更新的。

相关 issues:

上一篇下一篇

猜你喜欢

热点阅读