hotReload.js 731 B

1234567891011121314151617181920212223242526
  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. api.reload('${id}', __exports__)
  14. }
  15. ${templateRequest ? genTemplateHotReloadCode(id, templateRequest) : ''}
  16. }
  17. `;
  18. }
  19. exports.genHotReloadCode = genHotReloadCode;
  20. function genTemplateHotReloadCode(id, request) {
  21. return `
  22. module.hot.accept(${request}, () => {
  23. api.rerender('${id}', render)
  24. })
  25. `;
  26. }