Skip to content

Commit 4c05f49

Browse files
committed
feat: add hmr to fluent-vue-loader
1 parent 0dccbcf commit 4c05f49

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/fluent-vue-loader/src/index.ts

+14
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@ export default function (Component) {
3131
const target = Component.options || Component
3232
target.fluent = target.fluent || {}
3333
target.fluent['${query.locale}'] = new FluentResource(\`${data}\`)
34+
35+
if (module.hot) {
36+
if (typeof __VUE_HMR_RUNTIME__ !== 'undefined' ) {
37+
// Vue 3
38+
const id = target.__hmrId
39+
const api = __VUE_HMR_RUNTIME__
40+
api.reload(id, target)
41+
} else {
42+
// Vue 2
43+
// There is no proper api to access HMR for component from custom block
44+
// so use this magic
45+
delete target._Ctor
46+
}
47+
}
3448
}\n`
3549
}
3650

0 commit comments

Comments
 (0)