From cddd1e9ff0f0c842478455771f737b5d1aa122d4 Mon Sep 17 00:00:00 2001 From: Vasily Mikhaylovsky Date: Sun, 28 Nov 2021 09:47:58 +0100 Subject: [PATCH] fix: windows path contains \u symbols (#152) (#154) Co-authored-by: Vasily Mikhaylovsky --- src/main.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main.ts b/src/main.ts index facfe06..152a94e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -192,7 +192,9 @@ async function genTemplateRequest( const query = `?vue${from}&type=template${srcQuery}${attrsQuery}` const templateRequest = src + query return { - code: `import { render as __vue2_render, staticRenderFns as __vue2_staticRenderFns } from '${templateRequest}'`, + code: `import { render as __vue2_render, staticRenderFns as __vue2_staticRenderFns } from ${JSON.stringify( + templateRequest + )}`, templateRequest, } } @@ -229,26 +231,26 @@ function genHmrCode( functional: boolean, templateRequest?: string ) { + const idJSON = JSON.stringify(id) return `\n/* hot reload */ -import __VUE_HMR_RUNTIME__ from "${vueHotReload}" +import __VUE_HMR_RUNTIME__ from ${JSON.stringify(vueHotReload)} import vue from "vue" __VUE_HMR_RUNTIME__.install(vue) if(__VUE_HMR_RUNTIME__.compatible){ - if (!__VUE_HMR_RUNTIME__.isRecorded('${id}')) { - __VUE_HMR_RUNTIME__.createRecord('${id}', __component__.options) + if (!__VUE_HMR_RUNTIME__.isRecorded(${idJSON})) { + __VUE_HMR_RUNTIME__.createRecord(${idJSON}, __component__.options) } import.meta.hot.accept((update) => { __VUE_HMR_RUNTIME__.${ functional ? 'rerender' : 'reload' - }('${id}', update.default) + }(${idJSON}, update.default) }) ${ templateRequest - ? `import.meta.hot.accept('${normalizeDevPath( - root, - templateRequest - )}', (update) => { - __VUE_HMR_RUNTIME__.rerender('${id}', update) + ? `import.meta.hot.accept(${JSON.stringify( + normalizeDevPath(root, templateRequest) + )}, (update) => { + __VUE_HMR_RUNTIME__.rerender(${idJSON}, update) })` : '' }