File tree 2 files changed +13
-9
lines changed
2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -7,11 +7,12 @@ export function genHotReloadCode(
7
7
return `
8
8
/* hot reload */
9
9
if (module.hot) {
10
- script .__hmrId = "${ id } "
10
+ __exports__ .__hmrId = "${ id } "
11
11
const api = __VUE_HMR_RUNTIME__
12
12
module.hot.accept()
13
- if (!api.createRecord('${ id } ', script)) {
14
- api.reload('${ id } ', script)
13
+ if (!api.createRecord('${ id } ', __exports__)) {
14
+ console.log('reload')
15
+ api.reload('${ id } ', __exports__)
15
16
}
16
17
${ templateRequest ? genTemplateHotReloadCode ( id , templateRequest ) : '' }
17
18
}
@@ -21,6 +22,7 @@ if (module.hot) {
21
22
function genTemplateHotReloadCode ( id : string , request : string ) {
22
23
return `
23
24
module.hot.accept(${ request } , () => {
25
+ console.log('re-render')
24
26
api.rerender('${ id } ', render)
25
27
})
26
28
`
Original file line number Diff line number Diff line change @@ -245,10 +245,6 @@ export default function loader(
245
245
propsToAttach . push ( [ `__scopeId` , `"data-v-${ id } "` ] )
246
246
}
247
247
248
- if ( needsHotReload ) {
249
- code += genHotReloadCode ( id , templateRequest )
250
- }
251
-
252
248
// Expose filename. This is used by the devtools and Vue runtime warnings.
253
249
if ( ! isProduction ) {
254
250
// Expose the file's full path in development, so that it can be opened
@@ -286,13 +282,19 @@ export default function loader(
286
282
287
283
// finalize
288
284
if ( ! propsToAttach . length ) {
289
- code += `\n\nexport default script`
285
+ code += `\n\nconst __exports__ = script; `
290
286
} else {
291
287
code += `\n\nimport exportComponent from ${ exportHelperPath } `
292
- code += `\nexport default /*#__PURE__*/exportComponent(script, [${ propsToAttach
288
+ code += `\nconst __exports__ = /*#__PURE__*/exportComponent(script, [${ propsToAttach
293
289
. map ( ( [ key , val ] ) => `['${ key } ',${ val } ]` )
294
290
. join ( ',' ) } ])`
295
291
}
292
+
293
+ if ( needsHotReload ) {
294
+ code += genHotReloadCode ( id , templateRequest )
295
+ }
296
+
297
+ code += `\n\nexport default __exports__`
296
298
return code
297
299
}
298
300
You can’t perform that action at this time.
0 commit comments