intlify / bundle-tools

bundling for intlify i18n tools
MIT License
232 stars 37 forks source link

Failed locale loading: Unexpected token 'const'. #324

Closed AnoRebel closed 7 months ago

AnoRebel commented 8 months ago

Reporting a bug?

Trying to setup a clean nuxt app with translations, using @nuxtjs/i18n and @intlify/unplugin-vue-i18n but the app fails with the error below:

@nuxtjs/i18n Failed locale loading: [vite-node] [plugin:unplugin-vue-i18n] [VITE_ERROR] /locales/en.json <br><pre>const resource = {
  "title": (()=&gt;{const fn=(ctx) =&gt; {const { normalize: _normalize } = ctx;return _normalize(["Portfolio"])};fn.source="Portfolio";return fn;})()
}
export default resource</pre><br>

 ERROR  Internal server error: Unexpected token 'const'.                                                                                 3:08:59 PM
  Plugin: unplugin-vue-i18n

Expected behavior

No errors and translations to work normally.

Reproduction

https://stackblitz.com/edit/nuxt-starter-jpctmx?file=package.json,i18n.config.ts,nuxt.config.ts

Issue Package

unplugin-vue-i18n

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 8.10.5 - /usr/local/bin/pnpm

Screenshot

image

Additional context

No response

Validations

AnoRebel commented 7 months ago

I'll close this issue due to the help I got.