-
-
Notifications
You must be signed in to change notification settings - Fork 354
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
You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with boolean literals to get proper tree-shaking in the final bundle. #789
Comments
Thank you for your reporting!
The meaning of this warning message is that you need to specify the flag explicitly in the bundler when you do a production build. Please refer to the following link for packages provided by vue-i18n for bundlers. One advice to help you out is to use the plugins for each bundler listed in the Thanks! |
The warning message still doesn’t make sense to me.
What feature flags is it referring to? The documentation at https://vue-i18n.intlify.dev/installation.html#from-cdn-or-without-a-bundler doesn’t explain anything about feature flags nor does it explain how one sets up vue-i18n when using a bundler. That information is then available at https://github.com/intlify/bundle-tools/tree/main/packages/vue-i18n-loader, but that’s not telling me how that can be done using Vue CLI. That in turn is documented at https://vue-i18n.intlify.dev/guide/advanced/sfc.html#vue-cli, but none of these pieces of documentation even mention feature flags. So, what are these feature flags? I found https://vue-i18n.intlify.dev/guide/advanced/optimization.html#reduce-bundle-size-with-feature-build-flags after searching for it on the website. Now looking at them, I don’t want to change their defaults, so why should I configure them in the first place? Also, this page, again, doesn’t actually tell you how those flags are configured using Vue CLI. Going back to the warning, I would really like the warning itself to link to https://vue-i18n.intlify.dev/guide/advanced/optimization.html#reduce-bundle-size-with-feature-build-flags directly and for that document to also include instructions on how to actually set these flags in the vue.config.js. It shouldn’t be necessary to jump through four pieces of documentation one by one to find the information one needs to finish a basic project setup. |
Hello philipp-rudlof-sendcloud I absolutely agree with your comment, would you please give more insight on what exactly has to be done and where? Best Regards |
@IbrahimSinann In my case, I’m dealing with a Vue application that uses Vue 3 via Vue CLI (which means that under the hood, the project is built and bundled using Webpack). In the documentation, the relevant section for updating the vue.config.js file in my project is found here: https://vue-i18n.intlify.dev/guide/advanced/sfc.html#vue-cli. I used these settings as is. My translation files happened to be stored in |
@philipp-rudloff-sendcloud Thank you very much for your reply! I have the same case, I'm doing a Vue application with Vue 3 and VueCLI, and I also have my translation files inside the ./src/locales folder, I can run my build and it works but I still get that warning, and also two other warnings per language that I add which are:
And in the end, the translations work as wanted, whenever I change the locale to the preferred language the translation gets executed but I get the two warnings above for every locale file that I add in the locales folder. |
Same problem here, Vue.js 3, Vue CLI. Localization works, but I'm still getting this warning. No idea how to get rid of it. |
Same thing, i have this warning, i've done that :
but i don't like it at all, i should not have to do that, global flags like that should be avoided at all cost |
in vite.config.ts, you can resolve the problem like:
|
With Vite
import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueI18n from '@intlify/vite-plugin-vue-i18n'
export default defineConfig({
// ...
alias: {
'vue-i18n': 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js'
},
plugins: [
vue(),
vueI18n({
include: path.resolve(__dirname, './path/to/src/locales/**')
})
],
// ...
}) https://vue-i18n.intlify.dev/guide/advanced/optimization.html |
I'm having the same issue using Vue3 + vue-cli (webpack under the hood). I'd like to find a way to make this warning go away. |
chainWebpack: (config) => {
// set environment variables
config.plugin('define').tap((definitions) => {
Object.assign(definitions[0], {
// ... rest of your injected vars here
// get rid of vue-i18n warning
__VUE_I18N_FULL_INSTALL__: JSON.stringify(true),
__INTLIFY_PROD_DEVTOOLS__: JSON.stringify(false),
__VUE_I18N_LEGACY_API__: JSON.stringify(false),
})
return definitions
})
}, This should work for vue-cli with webpack. |
Tried this. Still can't get rid of the warning. Guess it's too much for newbies with vue-i18n. |
I have solved this using @intlify/vite-plugin-vue-i18n step 1: install @intlify/vite-plugin-vue-i18n plugin yarn step 2: goto vite.config.js import { defineConfig } from 'vite'
import { resolve, dirname } from 'node:path'
import { fileURLToPath } from 'url'
import vue from '@vitejs/plugin-vue'
import vueI18n from '@intlify/vite-plugin-vue-i18n'
export default defineConfig({
plugins: [
vue(), // you need to install `@vitejs/plugin-vue`
vueI18n({
// if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false`
// compositionOnly: false,
// you need to set i18n resource including paths !
include: resolve(dirname(fileURLToPath(import.meta.url)), './path/to/src/locales/**'),
})
]
}) Source: https://www.npmjs.com/package/@intlify/vite-plugin-vue-i18n?activeTab=readme |
Why? Why does it have to be so convoluted and undocumented? Anyway, all the above didn't work. Had to change the import like so:
Next project I'll just ditch Vue. It's a huge pain to migrate to v3. Just because they want to look more like react... |
This is vue-i18n, it's not vue itself |
This worked for getting rid of the warning, thank you! 9/10 because you wrote |
It might look like this:
|
None of the above works for me using ts and composition api... |
I fixed the warnings with this solution! |
why do I have to install the plugin to remove the message from the console? Terrible! |
With the release of Vite 4 the package First uninstall the old package if you have it then install the new one: Then your import { defineConfig } from 'vite'
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
import path from 'path'
export default defineConfig({
base: './',
resolve: {
alias: {
// ...
'vue-i18n': 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js',
},
},
plugins: [
// ...
VueI18nPlugin({
include: path.resolve(__dirname, './src/i18n/**'), // PUT YOUR OWN PATH TO LOCALES HERE
}),
],
}) |
Adding the following alias was enough for me to fix this warning with Nuxt 3:
I agree the error is unhelpful and the documentation is lacking on this part. |
这个解决了我的提示 |
I am getting this warning as well. I am using the Vue CLI to build the project. What should I put in my vue.config.js to get rid of this? |
@mcrapts can you give any example or what you also add to nuxt 3
i have error
|
on Nuxt 3 with Vite just add this and warning will disappear
|
I'm using this plugin: This is my configuration:
|
On Vue3 + Vite, it disappeared when I updated vue-i18n from 9.2.2 to 9.9.0. |
Reporting a bug?
I have created an app with vue 3.2 and added vue-i18n.
and i get the following warning in the browser console:
Expected behavior
no warning on the console
Reproduction
in my main.ts
in the @/locales/i18n-config file
System Info
Screenshot
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: