Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module factory available for dependency type: ModuleHotAcceptDependency #10897

Closed
flyingFlowers opened this issue May 15, 2020 · 9 comments
Closed

Comments

@flyingFlowers
Copy link

flyingFlowers commented May 15, 2020

Bug report

What is the current behavior?
image

If the current behavior is a bug, please provide the steps to reproduce.
package.json(has deleted some extra npm package) { "name": "h5_friends_editor", "version": "1.0.0", "description": "圈子详情页面", "repository": {}, "license": "MIT", "private": true, "dependencies": { "@babel/polyfill": "^7.8.7", "babel-polyfill": "^6.26.0", "babel-runtime": "~6.26.0", "classnames": "^2.2.6", "history": "~4.7.2", "immutability-helper": "~2.9.0", "linaria": "1.3.1", "lodash.get": "^4.4.2", "pubsub-js": "^1.8.0", "query-string": "~5.1.1", "rc-util": "^4.13.0", "react": "^16.13.1", "react-dom": "^16.13.1", "react-redux": "^7.2.0", "react-router-dom": "~4.3.1", "react-string-replace": "^0.4.4", "redux": "^4.0.5", "redux-actions": "^2.6.5", "redux-thunk": "^2.3.0", "socket.io-client": "^2.3.0", "styled-components": "3.4.10", "superagent": "~3.8.2" }, "devDependencies": { "@babel/cli": "^7.8.4", "@babel/core": "^7.9.6", "@babel/plugin-proposal-class-properties": "^7.8.3", "@babel/plugin-proposal-decorators": "^7.8.3", "@babel/plugin-proposal-export-default-from": "^7.8.3", "@babel/plugin-proposal-json-strings": "^7.0.0", "@babel/plugin-syntax-dynamic-import": "^7.0.0", "@babel/plugin-syntax-import-meta": "^7.0.0", "@babel/plugin-transform-runtime": "^7.9.6", "@babel/preset-env": "^7.9.6", "@babel/preset-react": "^7.9.4", "@types/classnames": "^2.2.9", "@types/friendly-errors-webpack-plugin": "^0.1.2", "@types/lodash.get": "^4.4.6", "@types/mini-css-extract-plugin": "^0.9.1", "@types/node": "^14.0.1", "@types/pubsub-js": "^1.5.18", "@types/react": "^16.9.17", "@types/react-dom": "^16.9.4", "@types/react-redux": "^7.1.8", "@types/speed-measure-webpack-plugin": "^1.3.0", "@types/webpack": "^4.41.13", "@types/webpack-dev-server": "^3.10.1", "@types/webpack-merge": "^4.1.5", "autoprefixer": "^7.1.3", "babel-eslint": "^8.0.2", "babel-loader": "^8.1.0", "babel-minify-webpack-plugin": "^0.2.0", "babel-plugin-import": "^1.4.0", "babel-plugin-react-transform": "^2.0.2", "babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-transform-runtime": "^6.23.0", "babel-preset-env": "^1.6.1", "babel-preset-minify": "^0.2.0", "babel-preset-react": "^6.24.1", "bundle-loader": "~0.5.6", "clean-webpack-plugin": "^3.0.0", "core-js": "~2.6.0", "css-loader": "^3.5.3", "eslint-config-ali": "^2.0.2", "eslint-plugin-compat": "^2.1.0", "eslint-plugin-es5": "^1.3.1", "file-loader": "~1.1.5", "friendly-errors-webpack-plugin": "^1.7.0", "html-loader": "^0.5.1", "html-webpack-plugin": "^4.3.0", "json-loader": "^0.5.7", "less-loader": "^6.1.0", "mini-css-extract-plugin": "^0.9.0", "postcss-loader": "^2.0.6", "postcss-pxtorem": "^4.0.1", "pre-commit": "^1.2.2", "react-transform-hmr": "^1.0.4", "speed-measure-webpack-plugin": "^1.3.3", "style-loader": "^0.18.2", "svg-sprite-loader": "^3.2.5", "ts-loader": "^4.5.0", "ts-node": "^8.10.1", "typescript": "^3.7.4", "url-loader": "^4.1.0", "webpack": "^4.43.0", "webpack-build-notifier": "^2.0.0", "webpack-bundle-analyzer": "^2.9.1", "webpack-cli": "^3.3.11", "webpack-dev-server": "^3.11.0", "webpack-hot-middleware": "^2.25.0", "webpack-merge": "^4.2.2" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "webpack-dev-server --config config/webpack.config.dev.ts --progress --color --host 0.0.0.0", "build": "node build.js", "analyzer": "node build.js --analyzer", "prestart": "npm run update-i18n", "prebuild": "npm run update-i18n", "update-i18n": "update-i18n ./translationKeys.js ./i18nResource -n circle -b \"id_ID|ms_MY|ne_NP|th_TH\"", "windows": "set NODE_ENV=development&&ding socket -p 8080", "precommit-msg": "echo '正在执行eslint验证...' && exit 0", "eslint": "sh eslint.sh", "eslint-fix": "./node_modules/eslint/bin/eslint.js --fix ./src/", "eslint-build": "./node_modules/eslint/bin/eslint.js --no-eslintrc -c ./.eslintForBuildrc ./build/" }, "pre-commit": [ "precommit-msg" ], "browserslist": [ "iOS >= 7", "Android >= 4", "ChromeAndroid >= 40", "UCAndroid >= 11", "Chrome >= 40" ] }
`webpack.config.base.ts

import path from 'path';
import webpack from 'webpack';

const config: webpack.Configuration = {
entry: {
vendor: [
"react",
"react-dom",
"react-router",
"react-router-dom"
],
},
output: {
path: path.resolve(__dirname, 'circle'),
filename: '[name].js',
publicPath: '/'
},
module: {
rules: [
{
test: /.tsx?$/,
use: [
'babel-loader',
'ts-loader'
],
include: [
path.resolve(__dirname, '../src'),
path.resolve(__dirname, "../node_modules/@ali/ding-circle-pro"),
path.resolve(__dirname, '../i18nResource')
]
},
{
test: /.jsx?$/,
use: 'babel-loader',
include: [
path.resolve(__dirname, '../src'),
path.resolve(__dirname, "../node_modules/@ali/ding-circle-pro"),
path.resolve(__dirname, '../i18nResource')
]
},
{
test: /.css$/,
use: [
'style-loader',
'css-loader'
],
include: [
path.resolve(__dirname, '../src'),
path.resolve(__dirname, "../node_modules/@ali/ding-circle-pro"),
]
},
{
test: /.less$/,
use: [
'style-loader',
'css-loader',
{
loader: 'less-loader',
options: {
lessOptions: {
javascriptEnabled: true
},
sourceMap: true
}
}
],
include: [
path.resolve(__dirname, "../src"),
path.resolve(__dirname, "../node_modules/antd"),
path.resolve(__dirname, "../node_modules/@ali/ding-circle-pro"),
path.resolve(__dirname, "../node_modules/@ali/swift-ui-result"),
path.resolve(__dirname, "../node_modules/@ali/swift-ui-follow-circle"),
path.resolve(__dirname, "../node_modules/@ali/swift-ui-work-score-tag"),
path.resolve(__dirname, "../node_modules/@ali/swift-ui-ding-face"),
path.resolve(__dirname, "../node_modules/@ali/swift-ui-complex-text")
]
},
{
test: /.html$/,
use: "html-loader"
},
// json-loader isn't necessary anymore in webpack version greater than or equal to 2.0
// {
// test: /.json$/,
// use: "json-loader",
// exclude: /node_modules/,
// },
{
test: /.(png|gif|jpeg|jpg)$/,
use: "url-loader?limit=100000"
},
{
test: /.(woff|woff2|ttf|eot)(?.+)?$/,
use: "url-loader"
},
{
test: /.(svg)$/i,
loader: "svg-sprite-loader",
options: {
runtimeCompat: true
},
}
]
},
resolve: {
modules: ['node_modules', path.resolve(__dirname, "src")],
extensions: [".web.ts", ".web.jsx", ".web.js", '.tsx', '.ts',".js", ".jsx", ".react.js"],
alias: {
"@components": path.resolve(__dirname, '../src/components'),
}
},
optimization: {},
}

export default config;

// webpack.config.dev.ts
import path from 'path';
import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import WebpackBuildNotifierPlugin from 'webpack-build-notifier';
import webpackBaseConfig from './webpack.config.base';
import WebpackMerge from 'webpack-merge';
import SpeedMeasurePlugin from 'speed-measure-webpack-plugin';
import FriendlyErrorsWebpackPlugin from 'friendly-errors-webpack-plugin';
import { CleanWebpackPlugin } from 'clean-webpack-plugin';

const smp = new SpeedMeasurePlugin();

const config: webpack.Configuration = WebpackMerge(webpackBaseConfig, {
mode: 'development',
entry: {
postDetail: ['webpack-hot-middleware/client','./src/entry/postDetail']
},
devtool: 'source-map',
devServer: {
inline: true,
open: true, // 服务器启动成功后,将自动打开浏览器
overlay: {//当出现编译器错误或警告时,就在网页上显示一层黑色的背景层和错误信息
errors: true
},
hot: true,
},
plugins: [
new FriendlyErrorsWebpackPlugin({
// compilationSuccessInfo: {
// messages: ['You application is running here http://localhost:8002'],
// notes: ['Some additionnal notes to be displayed unpon successful compilation']
// },
clearConsole: true,
additionalFormatters: [],
additionalTransformers: []
}),
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
title: "圈子页面title",
filename: "postDetail.html",
mete: {
viewport: 'viewport-fit=cover,width=device-width,user-scalable=no,initial-scale=1,maximum-scale=1,minimum-scale=1'
}
}),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new WebpackBuildNotifierPlugin({
title: 'H5_friend_editor Project Webpack Build',
suppressSuccess: false,
suppressCompileStart: false,
suppressWarning: false,
activateTerminalOnError: true
})
]
});

export default smp.wrap(config);
`

What is the expected behavior?
hot replace

Other relevant information:
webpack version: 4.41.13
Node.js version: 10.15.0
Operating System: macOS High Sierra 10.13.6
Additional tools:

@sokra
Copy link
Member

sokra commented May 15, 2020

Sorry the issue is totally unreadable.

It would be great if you reduce your issue to a small reproducible example. Best put this example into a github repository together with instructions how to get to the problem.

@dadaa1
Copy link

dadaa1 commented Jun 5, 2020

I have this problem, too
Maybe it's the speed-measure-webpack-plugin,You can remove it

这样就好了

@jtdaugh
Copy link

jtdaugh commented Jun 24, 2020

Thanks @dadaa1 , we also had speed-measure-webpack-plugin and removing it seems to have fixed this error

@alexander-akait
Copy link
Member

alexander-akait commented Jun 24, 2020

Please open an issue in speed-measure-webpack-plugin, the issue is not readable, so I will close, anyway if you still think the problem on webpack side, please open a new issue with reproducible test repo or readable configuration, thanks

@camsjams
Copy link

camsjams commented Sep 9, 2020

Doesn't seem to be caused by speed-measure-webpack-plugin (not using it).

I am using the hard-source-webpack-plugin, which might be using a similar API as speed-measure-webpack-plugin.

Basically the current workaround I have is to

  1. rm -rf node_modules/
  2. npm i
  3. Run webpack - in my project its using webpack-dev-server

If I stop webpack and restart, the error comes back.

@camsjams
Copy link

camsjams commented Sep 9, 2020

This is just for other travelers ^

Once I figure out what the root cause is I will either create a new issue or post it on the relevant plugin's GitHub repo 👍

@alexander-akait
Copy link
Member

alexander-akait commented Sep 9, 2020

Please open an issue in hard-source-webpack-plugin repo, just note with webpack@5 you don't need hard-source-webpack-plugin

@toFrankie
Copy link

toFrankie commented May 26, 2021

I have this problem, too
Maybe it's the speed-measure-webpack-plugin,You can remove it

这样就好了

It is possible to remove speed-measure-webpack-plugin, but no solution has been found yet. Related isuees are here: issues#117

@shafqatalix
Copy link

shafqatalix commented Aug 3, 2023

setting lazy & caching to 'false' worked for me

const wrapForPnp = packageName => path.dirname(require.resolve(path.join(packageName, "package.json")));

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants