Skip to content
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

bundle.onlyLocales not working for SFC #2588

Closed
alexbidenko opened this issue Dec 3, 2023 · 5 comments
Closed

bundle.onlyLocales not working for SFC #2588

alexbidenko opened this issue Dec 3, 2023 · 5 comments

Comments

@alexbidenko
Copy link

alexbidenko commented Dec 3, 2023

Environment

"nuxt": "^3.8.2"
"@nuxtjs/i18n": "^8.0.0-rc.6"
"node": "20.7.0"

Reproduction

https://github.com/alexbidenko/i18n-problem

Just pnpm i, pnpm build and pnpm preview. In network tab of dev tools you can see, that both of lacales exists in bundle.

P.S. in example I use Lazy for component, but and without it problem is same. Lazy is added for better visibility in the network tab

image

Describe the bug

New bundle.onlyLocales feature is very usefull, but not working for Single File Component locales. If I use <i18n> blocks in component, every locales will be included in result bundle. Expected result is only locales described in bundle.onlyLocales will be included.

Additional context

Motivation.

If project is large (hundreds of pages with tens of locales) that performance will be bad. For optimization is usefull build different versions of site for every locales. Every build will contains only one locale. And every page (or components) of every build will contains self locale strings. Then every locales will be downloaded to browser optimized.

Logs

No response

@BobbieGoede
Copy link
Collaborator

Hmm that's odd, specifically when using multiple <i18n> blocks it doesn't work, it does work when using multiple locales in a single <i18n> block.

This functionality is powered by @intlify/unplugin-vue-i18n, I think onlyLocales currently does not support multiple <i18n locale="x"> block, I recommend opening an issue on its repo here https://github.com/intlify/bundle-tools/tree/main/packages/unplugin-vue-i18n.

@alexbidenko
Copy link
Author

@BobbieGoede thank you very much for single block hint - I didn't know :)

But different blocks is also problem - and I have opened issue in their repository: intlify/bundle-tools#329

@imslepov
Copy link
Contributor

@BobbieGoede I fixed this bug, the issue can be closed when the packages @intlify/bundle-tools and @intlify/unplugin-vue-i18n are updated.

@kazupon
Copy link
Collaborator

kazupon commented May 16, 2024

@intlify/unplugin-vue-i18n latest version will not still released ...
We will release the latest version of @intlify/unplugin-vue-i18n with vue-i18n v10.
nuxt i18n also needs a major release.

@BobbieGoede BobbieGoede added v9 and removed v8 labels Sep 30, 2024
@BobbieGoede
Copy link
Collaborator

Can confirm this is resolved in v9, since it depends on a breaking dependency update this can't be backported to v8. Modified reproduction using v9 here https://stackblitz.com/edit/alexbidenko-i18n-problem-icaomd?file=nuxt.config.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants