gaearon / react-hot-loader

Tweak React components in real time. (Deprecated: use Fast Refresh instead.)

Home Page:http://gaearon.github.io/react-hot-loader/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[HMR] unexpected require(./src/__generated__/AppQuery.graphql.js) from disposed module ./src/App.js

dminkovsky opened this issue · comments

I am using react-hot-loader 4.3.3. When my application reloads, I am warned:

[HMR] unexpected require(./src/__generated__/AppQuery.graphql.js) from disposed module ./src/App.js

My index.js and App.js are set up per the README.

Apart for the warnings, the reload seems to work:

[WDS] Hot Module Replacement enabled.
2client:80 [WDS] App updated. Recompiling...
client:212 [WDS] App hot update...
log.js:23 [HMR] Checking for updates on the server...
client:80 [WDS] App updated. Recompiling...
bundle-b55897808298ac6d7154.js:86 [HMR] unexpected require(./src/__generated__/AppQuery.graphql.js) from disposed module ./src/App.js
bundle-b55897808298ac6d7154.js:86 [HMR] unexpected require(./src/__generated__/AppQuery.graphql.js) from disposed module ./src/App.js
log.js:23 [HMR] Updated modules:
log.js:23 [HMR]  - ./src/Private/Message/index.js
log.js:23 [HMR]  - ./src/Private/Message/MessageRouteContainer.js
log.js:23 [HMR]  - ./src/Router.js
log.js:23 [HMR]  - ./src/App.js
log.js:23 [HMR] App is up to date.
client:80 [WDS] App updated. Recompiling...
client:212 [WDS] App hot update...
log.js:23 [HMR] Checking for updates on the server...
log.js:23 [HMR] Nothing hot updated.
log.js:23 [HMR] App is up to date.

But what is the warning about? Is something not working?

The require it's warning about is declared like this (inside App.js, it is output from the Relay compiler):

var query = function query() {
    var node = __webpack_require__("./src/__generated__/AppQuery.graphql.js");

    if (node.hash && node.hash !== 'a664570d8a5c82655bb51085b2463b75') {
        console.error('The definition of \'AppQuery\' appears to have changed. Run `relay-compiler` to update the generated files to receive the expected data.');
    }

    return __webpack_require__("./src/__generated__/AppQuery.graphql.js");
};

The warning is thrown at:

/******/          function hotCreateRequire(moduleId) { // eslint-disable-line no-unused-vars
/******/ 		var me = installedModules[moduleId];
/******/ 		if(!me) return __webpack_require__;
/******/ 		var fn = function(request) {
/******/ 			if(me.hot.active) {   <--- this is false for some reason
/******/ 				if(installedModules[request]) {
/******/ 					if(installedModules[request].parents.indexOf(moduleId) < 0)
/******/ 						installedModules[request].parents.push(moduleId);
/******/ 				} else {
/******/ 					hotCurrentParents = [moduleId];
/******/ 					hotCurrentChildModule = request;
/******/ 				}
/******/ 				if(me.children.indexOf(request) < 0)
/******/ 					me.children.push(request);
/******/ 			} else {
/******/ 	here --->	   console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId);
/******/ 				hotCurrentParents = [];
/******/ 			}
/******/ 			return __webpack_require__(request);
/******/ 		};
/******/ 		// more ...

For some reason me.hot.active is not true for the App.js module.

I tried including the Relay compiler before and after the hot loader plugin, but it made no difference.

Expected behavior

What you think should happen:

I shouldn't have warnings and everything should work :)

Environment

React Hot Loader version: 4.3.3

Run these commands in the project folder and fill in their results:

  1. node -v: 8.2.1
  2. npm -v: 5.3.0

Then, specify:

  1. Operating system: OS X Yosemite 10.10.5
  2. Browser and version: Chrome 67

Update: hot reloading seems to be working well. I get this warning in general, though, for various relay queries that got compiled by the relay compiler into the form above, with the require().

The problem - hot reloading is not "complete", a few things left unreplaced.
But usually that is about "unchanged" parts, so should be fine for you, and couldn't fight with them from our side yet.

@theKashey thanks for your response. Yes, I've observed sometimes some old code is left unreplaced after a reload. It seems like a reload replaces code, but then code that was replaced by a prior reload gets "unreplaced." It's odd. I'm still observing it as I develop.

I do get the "unexpected require($relayQuery) from disposed module" warning not just for the hot App module but for modules in general that have these Relay compiler requires.

Anyway, this current setup is still a big improvement for me over my 3.0.0 configuration, which wasn't configured properly to retain state. Wondering what the issue is though.

In short - we are not reflecting some changes made in class constructors.

Is that a problem or should I close the issue?

2018-07-14T19:27:18.684Z] [info] Bitcoin.com Wallet v4.12.2 #bc326e8

gotoon

[HMR] unexpected require(./src/generated/AppQuery.graphql.js) from disposed module ./src/App.js #1032

It seems to be working very well. Thank you.

@dminkovsky - that is a problem, and we have an issue to track it - #1024

我遇到了同样的问题

@theKashey Haha! I updated to v3 at around the same time it reached its end too :). Very good. Makes sense, thank you again. It's been very fun seeing individual functions swapped out.