Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

HotUpdateChunkTemplate.js 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const Template = require("./Template");
  7. const HotUpdateChunk = require("./HotUpdateChunk");
  8. const { Tapable, SyncWaterfallHook, SyncHook } = require("tapable");
  9. module.exports = class HotUpdateChunkTemplate extends Tapable {
  10. constructor(outputOptions) {
  11. super();
  12. this.outputOptions = outputOptions || {};
  13. this.hooks = {
  14. modules: new SyncWaterfallHook([
  15. "source",
  16. "modules",
  17. "removedModules",
  18. "moduleTemplate",
  19. "dependencyTemplates"
  20. ]),
  21. render: new SyncWaterfallHook([
  22. "source",
  23. "modules",
  24. "removedModules",
  25. "hash",
  26. "id",
  27. "moduleTemplate",
  28. "dependencyTemplates"
  29. ]),
  30. hash: new SyncHook(["hash"])
  31. };
  32. }
  33. render(
  34. id,
  35. modules,
  36. removedModules,
  37. hash,
  38. moduleTemplate,
  39. dependencyTemplates
  40. ) {
  41. const hotUpdateChunk = new HotUpdateChunk();
  42. hotUpdateChunk.id = id;
  43. hotUpdateChunk.setModules(modules);
  44. hotUpdateChunk.removedModules = removedModules;
  45. const modulesSource = Template.renderChunkModules(
  46. hotUpdateChunk,
  47. m => typeof m.source === "function",
  48. moduleTemplate,
  49. dependencyTemplates
  50. );
  51. const core = this.hooks.modules.call(
  52. modulesSource,
  53. modules,
  54. removedModules,
  55. moduleTemplate,
  56. dependencyTemplates
  57. );
  58. const source = this.hooks.render.call(
  59. core,
  60. modules,
  61. removedModules,
  62. hash,
  63. id,
  64. moduleTemplate,
  65. dependencyTemplates
  66. );
  67. return source;
  68. }
  69. updateHash(hash) {
  70. hash.update("HotUpdateChunkTemplate");
  71. hash.update("1");
  72. this.hooks.hash.call(hash);
  73. }
  74. };