hotReload.js 786 B

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. // __VUE_HMR_RUNTIME__ is injected to global scope by @vue/runtime-core
  3. Object.defineProperty(exports, "__esModule", { value: true });
  4. exports.genHotReloadCode = void 0;
  5. function genHotReloadCode(id, templateRequest) {
  6. return `
  7. /* hot reload */
  8. if (module.hot) {
  9. __exports__.__hmrId = "${id}"
  10. const api = __VUE_HMR_RUNTIME__
  11. module.hot.accept()
  12. if (!api.createRecord('${id}', __exports__)) {
  13. console.log('reload')
  14. api.reload('${id}', __exports__)
  15. }
  16. ${templateRequest ? genTemplateHotReloadCode(id, templateRequest) : ''}
  17. }
  18. `;
  19. }
  20. exports.genHotReloadCode = genHotReloadCode;
  21. function genTemplateHotReloadCode(id, request) {
  22. return `
  23. module.hot.accept(${request}, () => {
  24. console.log('re-render')
  25. api.rerender('${id}', render)
  26. })
  27. `;
  28. }