I have the following function a file @/lang/index.js
:
async function fetchMessages(locale) {
const module = await import(/*
webpackChunkName: "lang/[request]",
webpackExclude: /index/
*/ `@/lang/${locale}`)
return module.default
}
I would like to hot-reload the modules imported by this function. I've tried a several different variations of module.hot.accept()
but without success.
Here's my hot reload code at the end of the same file that doesn't work:
if (process.env.NODE_ENV !== "production" && module.hot) {
module.hot.accept(["./en-US"], () => {
const { locale } = i18n
fetchMessages(locale).then((strings) => {
i18n.setLocaleMessage(locale, strings)
})
})
}
Any thoughts? I would like to hot-reload my language files when a change is detected.
Thanks!
from How do I hot reload a module wrapped in a native import context?
No comments:
Post a Comment