-
-
Notifications
You must be signed in to change notification settings - Fork 517
Description
Environment
nuxt@3.20.2@nuxt/kit@3.20.2@nuxtjs/i18n@10.2.1
Reproduction
Nuxt I18n documentation "Installing from a module" page : https://i18n.nuxtjs.org/docs/guide/install-module
(file docs/content/docs/02.guide/17.install-module.md)
Describe the bug
Hello, while adding i18n in a module as per the docs, my IDE warned me of the deprecation.
In the exemple shown in the "Installing from a module" page,
The function installModule() from @nuxt/kit shows a deprecated notice: Deprecated: Use module dependencies.
Also there is a warning in the Nuxt documentation:
https://nuxt.com/docs/4.x/api/kit/modules#installmodule
The "correct/modern" way is to use module dependencies as shown in Nuxt Documentation:
https://nuxt.com/docs/4.x/api/kit/modules#specifying-module-dependencies
Additional context
I donk have a reproduction but I successfully used this module dependencies config in a Nuxt v3 project.
The equivalent of the exemple code block from the docs is:
export default defineNuxtModule({
moduleDependencies: {
'@nuxtjs/i18n': {
defaults: {
vueI18n: resolve(dirname(fileURLToPath(import.meta.url)), './i18n.config.ts'),
langDir: resolve(dirname(fileURLToPath(import.meta.url)), './lang'),
locales: [
{
code: 'en',
file: resolve(dirname(fileURLToPath(import.meta.url)), './lang/en.json'),
},
],
},
},
},
setup() {
// ...
}
})Or, it can also be defined as a function to use createResolver like in the current docs :
export default defineNuxtModule({
moduleDependencies (nuxt) {
const { resolve } = createResolver(import.meta.url)
return {
'@nuxtjs/i18n': {
defaults: {
vueI18n: resolve('./i18n.config.ts'),
langDir: resolve('./lang'),
locales: [
{
code: 'en',
file: resolve('./lang/en.json'),
},
],
},
},
}
},
setup() {
// ...
}
})Both worked perfectly for me as-is with just a different folder.