Skip to content

Commit

Permalink
feat: add hmr to fluent-vue-loader
Browse files Browse the repository at this point in the history
  • Loading branch information
Demivan committed Dec 21, 2020
1 parent 0dccbcf commit 4c05f49
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/fluent-vue-loader/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ export default function (Component) {
const target = Component.options || Component
target.fluent = target.fluent || {}
target.fluent['${query.locale}'] = new FluentResource(\`${data}\`)
if (module.hot) {
if (typeof __VUE_HMR_RUNTIME__ !== 'undefined' ) {
// Vue 3
const id = target.__hmrId
const api = __VUE_HMR_RUNTIME__
api.reload(id, target)
} else {
// Vue 2
// There is no proper api to access HMR for component from custom block
// so use this magic
delete target._Ctor
}
}
}\n`
}

Expand Down

0 comments on commit 4c05f49

Please sign in to comment.