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.

36 lines
986 B

4 years ago
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const { ConcatSource } = require("webpack-sources");
  7. class NodeHotUpdateChunkTemplatePlugin {
  8. apply(hotUpdateChunkTemplate) {
  9. hotUpdateChunkTemplate.hooks.render.tap(
  10. "NodeHotUpdateChunkTemplatePlugin",
  11. (modulesSource, modules, removedModules, hash, id) => {
  12. const source = new ConcatSource();
  13. source.add(
  14. "exports.id = " + JSON.stringify(id) + ";\nexports.modules = "
  15. );
  16. source.add(modulesSource);
  17. source.add(";");
  18. return source;
  19. }
  20. );
  21. hotUpdateChunkTemplate.hooks.hash.tap(
  22. "NodeHotUpdateChunkTemplatePlugin",
  23. hash => {
  24. hash.update("NodeHotUpdateChunkTemplatePlugin");
  25. hash.update("3");
  26. hash.update(
  27. hotUpdateChunkTemplate.outputOptions.hotUpdateFunction + ""
  28. );
  29. hash.update(hotUpdateChunkTemplate.outputOptions.library + "");
  30. }
  31. );
  32. }
  33. }
  34. module.exports = NodeHotUpdateChunkTemplatePlugin;