-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Live reloading translations is not working #153
Comments
I have the same behavior as well. after upgrading from vite-plugin-vue-i18n 3 to 5. custom i18n blocks in SFCs reloads as expected. however translations imported in vite.config.ts don't.
|
importing messages from json actual path instead of "@intlify/vite-plugin-vue-i18n/messages", then appending it to unfortunately I'm using yaml instead of json :( |
Could you give minimue reproduction repo to us please? |
@kazupon I've also experienced this issue. |
@marekvospel |
Hmm 🤔 , This issue might be in vite. I have found out the cause, but I could not figure it out. In vite v3, experimental HMR feature has been released. And also there are several HMR fixes in the later v2 version. We need to find out which version we have the problem from, whether vite 3 or some version of vite 2. |
Resolved in Vite v3.0.5. |
Unfortunately I can still reproduce the issue both in my own repo and in @marekvospel’s minimal one using Vite v3.0.5 |
I think the problem is the wrong ID. I have created a simple plugin and this is what I get with different IDs: function I18nHotReload(): PluginOption {
return {
name: "i18n-hot-reload",
handleHotUpdate({ file, server }) {
console.log(file)
const module = server.moduleGraph.getModuleById("@intlify/vite-plugin-vue-i18n/messages")
console.log(module) // <- undefined
const module2 = server.moduleGraph.getModuleById("\x00@intlify/vite-plugin-vue-i18n/messages")
console.log(module2) // <- ModuleNode
if (module2) {
server.moduleGraph.invalidateModule(module2)
return [module2!]
}
},
}
} I also found an example for another library to update messages without reloading the entire page: |
|
I've just released v6.0.1 please check it! |
Thanks it's working now! |
Same problem in unplugin-vue-i18n |
@hooray I think separate issue tagged as * vite-plugin-vue-i18n's hot update implementation |
I've just supported HRM for vite at v0.7.0 Please check it! 😉 |
Reporting a bug?
We just upgraded to vite version 3 and vite-plugin-vue-i18n to version 5, and reloading translations is not working. We detected this problem by starting a new project, but also found this problem with an old project.
I've tested it with vite version 2 and vite-plugin-vue-i18n version 3 before upgrading and everything worked as expected, after upgrading both packages the translations won't reload. In the vite console, there is also no message the translations are modified. After re-running the vite dev server, the new translations are working.
Expected behavior
I expect in the console to see the message:
12:34:14 PM [vite] page reload lang/nl.json
And also that the page is reloading.
Reproduction
Issue Package
vite-plugin-vue-i18n
System Info
Screenshot
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: