HotModuleReplacementRuntimeModule.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const RuntimeGlobals = require("../RuntimeGlobals");
  7. const RuntimeModule = require("../RuntimeModule");
  8. const Template = require("../Template");
  9. class HotModuleReplacementRuntimeModule extends RuntimeModule {
  10. constructor() {
  11. super("hot module replacement", RuntimeModule.STAGE_BASIC);
  12. }
  13. /**
  14. * @returns {string | null} runtime code
  15. */
  16. generate() {
  17. return Template.getFunctionContent(
  18. require("./HotModuleReplacement.runtime.js")
  19. )
  20. .replace(/\$getFullHash\$/g, RuntimeGlobals.getFullHash)
  21. .replace(
  22. /\$interceptModuleExecution\$/g,
  23. RuntimeGlobals.interceptModuleExecution
  24. )
  25. .replace(/\$moduleCache\$/g, RuntimeGlobals.moduleCache)
  26. .replace(/\$hmrModuleData\$/g, RuntimeGlobals.hmrModuleData)
  27. .replace(/\$hmrDownloadManifest\$/g, RuntimeGlobals.hmrDownloadManifest)
  28. .replace(
  29. /\$hmrInvalidateModuleHandlers\$/g,
  30. RuntimeGlobals.hmrInvalidateModuleHandlers
  31. )
  32. .replace(
  33. /\$hmrDownloadUpdateHandlers\$/g,
  34. RuntimeGlobals.hmrDownloadUpdateHandlers
  35. );
  36. }
  37. }
  38. module.exports = HotModuleReplacementRuntimeModule;