bundle-tools icon indicating copy to clipboard operation
bundle-tools copied to clipboard

`onlyLocales` not working for SFC <i18n locale="xx">

Open alexbidenko opened this issue 2 years ago • 0 comments

Reporting a bug?

Forwared from https://github.com/nuxt-modules/i18n/issues/2588

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

Expected behavior

Expected result is only locales described in onlyLocales will be included.

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

Issue Package

unplugin-vue-i18n

System Info

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

# sub dependencies of @nuxtjs/[email protected]
"@intlify/unplugin-vue-i18n": "1.5.0"

Screenshot

image

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.

Validations

  • [X] Read the Contributing Guidelines.
  • [X] Read the README
  • [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • [X] Check that this is a concrete bug. For Q&A open a GitHub Discussion.

alexbidenko avatar Dec 04 '23 12:12 alexbidenko