You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.3 KiB

4 years ago
  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(
  12. "warning",
  13. "[HMR] The following modules couldn't be hot updated: (They would need a full reload!)"
  14. );
  15. unacceptedModules.forEach(function(moduleId) {
  16. log("warning", "[HMR] - " + moduleId);
  17. });
  18. }
  19. if (!renewedModules || renewedModules.length === 0) {
  20. log("info", "[HMR] Nothing hot updated.");
  21. } else {
  22. log("info", "[HMR] Updated modules:");
  23. renewedModules.forEach(function(moduleId) {
  24. if (typeof moduleId === "string" && moduleId.indexOf("!") !== -1) {
  25. var parts = moduleId.split("!");
  26. log.groupCollapsed("info", "[HMR] - " + parts.pop());
  27. log("info", "[HMR] - " + moduleId);
  28. log.groupEnd("info");
  29. } else {
  30. log("info", "[HMR] - " + moduleId);
  31. }
  32. });
  33. var numberIds = renewedModules.every(function(moduleId) {
  34. return typeof moduleId === "number";
  35. });
  36. if (numberIds)
  37. log(
  38. "info",
  39. "[HMR] Consider using the NamedModulesPlugin for module names."
  40. );
  41. }
  42. };