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

Warning: Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead. #2856

Open
frasza opened this issue Mar 18, 2024 · 10 comments
Labels
🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing v8

Comments

@frasza
Copy link

frasza commented Mar 18, 2024

Environment


  • Operating System: Windows_NT
  • Node Version: v21.6.2
  • Nuxt Version: 3.11.0
  • CLI Version: 3.10.1
  • Nitro Version: 2.9.4
  • Package Manager: [email protected]
  • Builder: -
  • User Config: modules, devtools
  • Runtime Modules: @nuxtjs/[email protected]
  • Build Modules: -

Reproduction

https://github.com/frasza/i18n-warn

Spin up dev server, open dev tools and click on NuxtLink. Warning appears.

Describe the bug

Recently I noticed warning popup in my Nuxt project and I have tried to set up fresh Nuxt project with i18n dependacy and I still get warning when for navigating across pages.

Warning:

[Vue warn]: Avoid app logic that relies on enumerating keys on a component instance. The keys will be empty in production mode to avoid performance overhead.

Noticed that I get warning the moment I add i18n to the modules.

Additional context

No response

Logs

No response

@BobbieGoede
Copy link
Collaborator

I'm unable to reproduce this using your reproduction, I did have to update Nuxt to 3.11.1 or the dev server wouldn't run. Has this already been resolved?

@frasza
Copy link
Author

frasza commented Mar 20, 2024

I still have problem with warning even tho I am on Nuxt 3.11.1.

@BobbieGoede
Copy link
Collaborator

Do you get the warning using this updated reproduction? https://stackblitz.com/edit/frasza-i18n-warn-76cwcr?file=nuxt.config.ts

@frasza
Copy link
Author

frasza commented Mar 20, 2024

Yeah, I have downloaded the project, run it locally and I still get it 🤔
image

@BobbieGoede
Copy link
Collaborator

Ah after running it locally I get the same warning, looks like this happens when you add Nuxt I18n without configuring any locales. The module tries to navigate/redirect to a localized page but there are none, maybe we should add some checks to disable the module if nothing is configured.

@BobbieGoede BobbieGoede added 🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing and removed pending triage question❓ labels Mar 20, 2024
@frasza
Copy link
Author

frasza commented Mar 20, 2024

Locally I have it configured tho.

i18n: {
    vueI18n: '@/i18n.config.ts',
  },
import en from '@/locales/en.json'
import si from '@/locales/si.json'

export default defineI18nConfig(() => ({
  legacy: false,
  locale: 'si',
  messages: {
    si,
    en,
  },
}))

Perhaps something here wrong as well...

@BobbieGoede
Copy link
Collaborator

BobbieGoede commented Mar 20, 2024

Let me know if these changes fix it for you:

i18n: {
    vueI18n: '@/i18n.config.ts',
+   locales: ['en', 'si']
+   defaultLocale: ['si']
},
import en from '@/locales/en.json'
import si from '@/locales/si.json'

export default defineI18nConfig(() => ({
   legacy: false,
-  locale: 'si',
   messages: {
     si,
     en,
   },
}))

@frasza
Copy link
Author

frasza commented Mar 20, 2024

I see this forces locale in URL paht (e.g.: /si). How can I escape this, since we are not using locales in url pahts?

@BobbieGoede
Copy link
Collaborator

Check out the docs on routing strategies https://i18n.nuxtjs.org/docs/guide

@frasza
Copy link
Author

frasza commented Mar 20, 2024

Thank you.

Indeed! In this case I do not get warning. Now it is a bit 'weird' that configuration is split between the files but yeah, it seems to be working well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍰 p2-nice-to-have Priority 2: nothing is broken but it's worth addressing v8
Projects
None yet
Development

No branches or pull requests

2 participants