nuxt3 icon indicating copy to clipboard operation
nuxt3 copied to clipboard

messageCompiler is not a function on build. how to set runtimeOnly: false?

Open terion-name opened this issue 3 years ago • 2 comments

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'
    },

terion-name avatar Dec 14 '21 18:12 terion-name

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)
})

RossComputerGuy avatar May 03 '22 02:05 RossComputerGuy

https://github.com/intlify/nuxt3/issues/39#issuecomment-1114544562 I have found a solution

RossComputerGuy avatar May 03 '22 02:05 RossComputerGuy