nuxt3
nuxt3 copied to clipboard
messageCompiler is not a function on build. how to set runtimeOnly: false?
readme at https://github.com/intlify/bundle-tools/tree/main/packages/vite-plugin-vue-i18n states that for build you need to set the runtimeOnly option to false.
but how to set it in Nuxt3? build fails with messageCompiler is not a function
such things don't work:
export default defineNuxtConfig({
buildModules: ['@intlify/nuxt3'],
vite: {
resolve: {
alias: {
'vue-i18n': 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js'
}
}
},
alias: {
'vue-i18n': 'vue-i18n/dist/vue-i18n.runtime.esm-bundler.js'
},
(in fact these options are completely ignored because setting there non-existent files doesn't break build)
UPD looking at callstack, it is error in compileMessageFormat func, that is part of @intlify/core-base
aliasing it also doesn't work:
vite: {
resolve: {
alias: {
'@intlify/core-base': '@intlify/core-base/dist/core-base.esm-bundler.js'
}
}
},
alias: {
'@intlify/core-base': '@intlify/core-base/dist/core-base.esm-bundler.js'
},
I've been working on something called Vista and it sets runtimeOnly to false. It's a module for Nuxt 3 and it has this code in it to set the value:
extendViteConfig((config) => {
const i = config.plugins.findIndex((value) => (value as Record<string, any>).name === 'vite-plugin-vue-i18n')
if (i === -1) throw new Error('[vista] requires @intlify/nuxt3, please load it before vista')
const viteOptions = {
compositionOnly: false,
runtimeOnly: false
}
if (hasLocaleFiles) {
viteOptions['include'] = resolve(localeDir, './**')
}
config.plugins[i] = vueI18n(viteOptions)
})
https://github.com/intlify/nuxt3/issues/39#issuecomment-1114544562 I have found a solution