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

Handle when unacceptedModule is not in moduleMap #306

Open
vjpr opened this issue May 6, 2018 · 3 comments
Open

Handle when unacceptedModule is not in moduleMap #306

vjpr opened this issue May 6, 2018 · 3 comments

Comments

@vjpr
Copy link

vjpr commented May 6, 2018

I encountered a problem where the module that could not be updated was not in the moduleMap resulting in - undefined being printed when listing the modules that couldn't be hot updated.

function logUpdates(updatedModules, renewedModules) {
var unacceptedModules = updatedModules.filter(function(moduleId) {
return renewedModules && renewedModules.indexOf(moduleId) < 0;
});
if(unacceptedModules.length > 0) {
if (options.warn) {
console.warn(
"[HMR] The following modules couldn't be hot updated: " +
"(Full reload needed)\n" +
"This is usually because the modules which have changed " +
"(and their parents) do not know how to hot reload themselves. " +
"See " + hmrDocsUrl + " for more details."
);
unacceptedModules.forEach(function(moduleId) {
console.warn("[HMR] - " + moduleMap[moduleId]);
});
}
performReload();
return;
}

screen shot 2018-05-04 at 11 29 16 pm

@glenjamin
Copy link
Collaborator

This is a good idea, i’d take a pull request for it.

The other option might be to remove this feature entirely and advise people to use the named modules plugin

@Zdend
Copy link
Contributor

Zdend commented Sep 17, 2018

I encountered a similar issue but in my case moduleMap didn't contain renewedModules which resulted in a bunch of - undefined in the console. Is there a known solution for that?

renewedModules = [
"./src/scripts/apps/enb/routes/records.js",
"./src/scripts/apps/enb/routes/index.js",
"./src/scripts/apps/enb/app.js"
]
moduleMap = {
"./src/scripts/apps/enb/routes/records.js": "./src/scripts/apps/enb/routes/records.js"
}
      if(!renewedModules || renewedModules.length === 0) {
        console.log("[HMR] Nothing hot updated.");
      } else {
        console.log("[HMR] Updated modules:");
        renewedModules.forEach(function(moduleId) {
          console.log("[HMR]  - " + moduleMap[moduleId]);
        });
      }

"./src/scripts/apps/enb/app.js"
This module contains React Hot Loader and wraps the module with hot(module)(MyApp)

"./src/scripts/apps/enb/routes/index.js"
Routes/index contains dynamic imports for code splitting <Route path="/records" component={load(() => import(/* webpackChunkName: 'enb.records' */ './records'))} />

"./src/scripts/apps/enb/routes/records.js"
This module is where the change actually occurred.

Is it possible that because of the code splitting the module map doesn't have any information about its parent modules and hence it prints out undefined? Would it be possible in this case to print out renewedModule id as a fallback?

@glenjamin
Copy link
Collaborator

Yep, that seems sensible, i’d take a PR.

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

3 participants