log-apply-result.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. module.exports = function(updatedModules, renewedModules) {
  6. var unacceptedModules = updatedModules.filter(function(moduleId) {
  7. return renewedModules && renewedModules.indexOf(moduleId) < 0;
  8. });
  9. var log = require("./log");
  10. if(unacceptedModules.length > 0) {
  11. log("warning", "[HMR] The following modules couldn't be hot updated: (They would need a full reload!)");
  12. unacceptedModules.forEach(function(moduleId) {
  13. log("warning", "[HMR] - " + moduleId);
  14. });
  15. }
  16. if(!renewedModules || renewedModules.length === 0) {
  17. log("info", "[HMR] Nothing hot updated.");
  18. } else {
  19. log("info", "[HMR] Updated modules:");
  20. renewedModules.forEach(function(moduleId) {
  21. if(typeof moduleId === "string" && moduleId.indexOf("!") !== -1) {
  22. var parts = moduleId.split("!");
  23. log.groupCollapsed("info", "[HMR] - " + parts.pop());
  24. log("info", "[HMR] - " + moduleId);
  25. log.groupEnd("info");
  26. } else {
  27. log("info", "[HMR] - " + moduleId);
  28. }
  29. });
  30. var numberIds = renewedModules.every(function(moduleId) {
  31. return typeof moduleId === "number";
  32. });
  33. if(numberIds)
  34. log("info", "[HMR] Consider using the NamedModulesPlugin for module names.");
  35. }
  36. };