-
Notifications
You must be signed in to change notification settings - Fork 194
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
Hot reloading does not work with @babel/plugin-transform-modules-commonjs #120
Comments
anything I can do to help investigate this? super excited to adopt react refresh in our app! |
👍 |
I haven't had a lot of time to look at this just yet, but having the transformed source of |
I reduced import * as React from 'react';
import ClassDefault from './ClassDefault';
export function App() {
return (
<div>
This is App.jsx!!!!!!
</div>
);
} The result is: /* 11 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _interopRequireDefault = __webpack_require__(4);
var _interopRequireWildcard = __webpack_require__(1);
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.App = App;
var React = _interopRequireWildcard(__webpack_require__(0));
var _ClassDefault = _interopRequireDefault(__webpack_require__(12));
function App() {
return /*#__PURE__*/React.createElement("div", null, "This is App.jsx!!!!!!");
}
_c = App;
var _c;
$RefreshReg$(_c, "App");
/***/ }), |
So it looks like it does: Object.defineProperty(exports, "__esModule", {
value: true
});
exports.App = App; on the app component. Should that interfere with hot reloading? |
I did a bit of digging and it seems that this only happens when The culprit of this issue is that somehow the referential equality of the object which we use to calculate whether the change is acceptable is broken - I'll have to look further (and maybe even ping Dan) to get this properly fixed. |
@michaelgmiller1 I think I've found the culprit. The issue in the repro is that there are two instances of After making sure that only one copy is loaded, I seem to have successful results. |
@pmmmwh thanks for diving in! just one comment on your codebox, it uses |
This ... is ... so ... strange! I've tested with a bare bones example on my local machine with Edit: Okay - so it seems that if the file have imports with classes/default exports it will break HMR. Investigating further. |
Uhh ... okay. I have something working. I will add a regression test and some notes in the code base. |
RE-FIXED in |
When I use the
@babel/plugin-transform-modules-commonjs
plugin and change the repo to use an object export forApp
, hot reloading breaks with the following error:I've developed a minimum repro here: https://github.com/michaelgmiller1/react-refresh-webpack-plugin/tree/transform-repro
After patching, you can run the
webpack-dev-server
example and modify theApp.jsx
file to reproduce.Let me know if you need any more info!
Thanks!
Mike
The text was updated successfully, but these errors were encountered: