log-apply-result.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 optimization.moduleIds: "named" for module names.'
  40. );
  41. }
  42. };