Open navichawla92 opened 5 years ago
I just started getting the same thing on my project. I check my commits and files and it appears nothing has changed. I've even pulled an old version of my project that I know was working, and it is now showing this error.
I'm running into this issue as well after attempting to update from version 2.22.2. I make a change, the page refreshes and shows the success message in the console, but the actual changes in the app are not applied, so I have to force a full refresh to get them.
For what it's worth, this seems to be related to Babel 7 upgrades at least in my case. I haven't been able to narrow down what exactly it's having issues with, but it didn't start happening until after I made the change from v6 to v7.
This is my babel config:
{
"plugins": [
"styled-components",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-modules-commonjs"
],
"presets": [
[
"@babel/preset-env",
{
"modules": false
}
],
"@babel/preset-react"
],
"env": {
"production": {
"only": [
"app",
],
"plugins": [
"transform-react-remove-prop-types",
"@babel/plugin-transform-react-inline-elements",
"@babel/plugin-transform-react-constant-elements"
]
},
"test": {
"plugins": [
"@babel/plugin-transform-modules-commonjs",
"dynamic-import-node"
]
}
}
}
In my app entry file, I have the babel-polyfill
replacement as they suggest:
import 'core-js/stable';
import 'regenerator-runtime/runtime';
Has anyone gotten hot reloading to work properly with babel 7? Is there something special I'm missing that I need to add?
For anyone else hitting this issue, this solution below worked in our case. We had to change the module.hot.accept
logic to reimport the top level app component and rerender it.
app.js
import App from 'containers/App';
...
const render = (messages, AppComponent = App) => {
ReactDOM.render(
<Provider store={store}>
<LanguageProvider messages={messages}>
<ConnectedRouter history={history}>
<AppComponent />
</ConnectedRouter>
</LanguageProvider>
</Provider>,
MOUNT_NODE,
);
};
...
if (module.hot) {
// Hot reloadable React components and translation json files
// modules.hot.accept does not accept dynamic dependencies,
// have to be constants at compile-time
module.hot.accept(['./i18n', 'containers/App'], () => {
import('containers/App').then(({ default: NewApp }) => {
render(translationMessages, NewApp);
});
});
}
"use strict"; require("dotenv").config(); var webpack = require("webpack"); var path = require("path"); var ProgressBarPlugin = require("progress-bar-webpack-plugin");
Server.js
const send = require("koa-send"); const Router = require("koa-router"); const serve = require("koa-static"); const bodyParser = require("koa-bodyparser"); const logger = require("koa-logger"); const Koa = require("koa"); const webpack = require("webpack"); const devMiddleware = require("webpack-dev-middleware"); const hotMiddleware = require("webpack-hot-middleware"); const devConfig = require("./webpack.config"); const koa2Connect = require("koa2-connect"); const helmet = require("koa-helmet"); const RateLimit = require("koa2-ratelimit").RateLimit; const { API } = require("mobx-model"); const { dreamfactoryMiddleware } = require("./server/dreamfactory/middleware"); const { notify } = require("./server/recaptcha"); const { exportExcel, exportCsv } = require("./server/export"); const { importExcel, importCsv } = require("./server/import"); const { generateUrl, generateUrlNoAuth, verifyOtp, verifyOtpNoAuth, login, confirm } = require("./server/otp");