intlify / vue-i18n

Vue I18n for Vue 3
https://vue-i18n.intlify.dev/
MIT License
2.19k stars 335 forks source link

v10.0.1 throws error at build time (Vite/Nuxt) #1946

Closed Anton-Plagemann closed 2 months ago

Anton-Plagemann commented 2 months ago

Reporting a bug?

Got a build error after upgrading to v10.

Expected behavior

Should build without errors

Reproduction

The error seems straighforward, if you need a reproduction let me know and I will try to create one.

System Info

System:
    OS: Linux 5.15 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (20) x64 13th Gen Intel(R) Core(TM) i7-13800H
    Memory: 16.41 GB / 19.53 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 22.8.0 - /usr/local/share/nvm/versions/node/v22.8.0/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.3 - /usr/local/share/nvm/versions/node/v22.8.0/bin/npm
    pnpm: 9.1.1 - /usr/local/share/npm-global/bin/pnpm
  Browsers:
    Chrome: 128.0.6613.119
  npmPackages:
    @intlify/unplugin-vue-i18n: ^5.0.0 => 5.0.0 
    @vue/eslint-config-prettier: ^9.0.0 => 9.0.0 
    vite-plugin-top-level-await: ^1.4.4 => 1.4.4 
    vue: ^3.5.4 => 3.5.4 
    vue-echarts: ^7.0.3 => 7.0.3 
    vue-i18n: ^10.0.1 => 10.0.1 
    vue-json-pretty: ^2.4.0 => 2.4.0 
    vue-router: ^4.4.3 => 4.4.4 
    vue-toast-notification: ^3.1.2 => 3.1.2 
    vue-tsc: ^2.1.6 => 2.1.6 
    vue3-apexcharts: ^1.6.0 => 1.6.0

Screenshot

image

Additional context

[log] Nuxt 3.13.1 with Nitro 2.9.7
[info] [nuxt:tailwindcss] Using Tailwind CSS from ~/assets/main.css
[info] Nuxt Icon server bundle mode is set to `local`
[info] Running with compatibility version `4`
[info] Building client...
[info] vite v5.4.3 building for production...
[info] transforming...
[info] ✓ 3307 modules transformed.
Error:  x Build failed in 28.18s
Error:  Nuxt Build Error: node_modules/vue-i18n/dist/vue-i18n.mjs (7:[9](https://github.com/Studicon-GmbH/studicon-ai/actions/runs/10842044385/job/30087033552?pr=2211#step:5:10)): "CORE_WARN_CODES_EXTEND_POINT" is not exported by "node_modules/@intlify/core-base/dist/core-base.mjs", imported by "node_modules/vue-i18n/dist/vue-i18n.mjs".
file: /home/runner/work/studicon-ai/studicon-ai/node_modules/vue-i18n/dist/vue-i18n.mjs:7:9

5:   */
6: import { getGlobalThis, format, makeSymbol, isObject, isPlainObject, isArray, deepCopy, isString, hasOwn, warn, isBoo...
7: import { CORE_WARN_CODES_EXTEND_POINT, CORE_ERROR_CODES_EXTEND_POINT, createCompileError, DEFAULT_LOCALE, updateFallb...
            ^
8: import { createVNode, Text, computed, watch, getCurrentInstance, ref, shallowRef, Fragment, defineComponent, h, effec...
9: import { setupDevtoolsPlugin } from '@vue/devtools-api';

  file: node_modules/vue-i18n/dist/vue-i18n.mjs:7:9

  5:   */
  6: import { getGlobalThis, format, makeSymbol, isObject, isPlainObject, isArray, deepCopy, isString, hasOwn, warn, isBoo...
  7: import { CORE_WARN_CODES_EXTEND_POINT, CORE_ERROR_CODES_EXTEND_POINT, createCompileError, DEFAULT_LOCALE, updateFallb...
  ^
  8: import { createVNode, Text, computed, watch, getCurrentInstance, ref, shallowRef, Fragment, defineComponent, h, effec...
  9: import { setupDevtoolsPlugin } from '@vue/devtools-api';

  at getRollupError (node_modules/rollup/dist/es/shared/parseAst.js:392:41)
  at error (node_modules/rollup/dist/es/shared/parseAst.js:388:42)
  at Module.error (node_modules/rollup/dist/es/shared/node-entry.js:13967:16)
  at Module.traceVariable (node_modules/rollup/dist/es/shared/node-entry.js:14414:29)
  at ModuleScope.findVariable (node_modules/rollup/dist/es/shared/node-entry.js:[12](https://github.com/Studicon-GmbH/studicon-ai/actions/runs/10842044385/job/30087033552?pr=2211#step:5:13)121:39)
  at Identifier.bind (node_modules/rollup/dist/es/shared/node-entry.js:6941:40)
  at Property.bind (node_modules/rollup/dist/es/shared/node-entry.js:4808:23)
  at ObjectExpression.bind (node_modules/rollup/dist/es/shared/node-entry.js:4804:28)
  at VariableDeclarator.bind (node_modules/rollup/dist/es/shared/node-entry.js:4808:23)
  at VariableDeclaration.bind (node_modules/rollup/dist/es/shared/node-entry.js:4804:28)
Error: Process completed with exit code 1.

Validations

BobbieGoede commented 2 months ago

Can you check what version @intlify/core-base is installed? It sounds like you have an older version installed and refreshing lockfiles and reinstalling dependencies might resolve this issue.

If that doesn't resolve it, a minimal reproduction would be very helpful in debugging this further 🙏

Anton-Plagemann commented 2 months ago

Deleting the lockfile and reinstalling packages did not solve it, but changed the error message to a different one:

 ERROR  x Build failed in 13.90s                                                                                                                                      7:07:05 AM

[7:07:05 AM]  ERROR  Nuxt Build Error: node_modules/@intlify/core-base/dist/core-base.mjs (7:9): "CompileWarnCodes" is not exported by "node_modules/@intlify/message-compiler/dist/message-compiler.mjs", imported by "node_modules/@intlify/core-base/dist/core-base.mjs".
file: /app/node_modules/@intlify/core-base/dist/core-base.mjs:7:9

5:   */
6: import { getGlobalThis, isObject, isFunction, isString, isNumber, isPlainObject, assign, join, toDisplayString, isArr...
7: import { CompileWarnCodes, CompileErrorCodes, createCompileError, detectHtmlTag, defaultOnError, baseCompile as baseC...
            ^
8: export { CompileErrorCodes, createCompileError } from '@intlify/message-compiler';

  file: node_modules/@intlify/core-base/dist/core-base.mjs:7:9

  5:   */
  6: import { getGlobalThis, isObject, isFunction, isString, isNumber, isPlainObject, assign, join, toDisplayString, isArr...
  7: import { CompileWarnCodes, CompileErrorCodes, createCompileError, detectHtmlTag, defaultOnError, baseCompile as baseC...
  ^
  8: export { CompileErrorCodes, createCompileError } from '@intlify/message-compiler';

  at getRollupError (node_modules/rollup/dist/es/shared/parseAst.js:392:41)
  at error (node_modules/rollup/dist/es/shared/parseAst.js:388:42)
  at Module.error (node_modules/rollup/dist/es/shared/node-entry.js:13968:16)
  at Module.traceVariable (node_modules/rollup/dist/es/shared/node-entry.js:14415:29)
  at ModuleScope.findVariable (node_modules/rollup/dist/es/shared/node-entry.js:12122:39)
  at MemberExpression.bind (node_modules/rollup/dist/es/shared/node-entry.js:8843:49)
  at VariableDeclarator.bind (node_modules/rollup/dist/es/shared/node-entry.js:4808:23)
  at VariableDeclaration.bind (node_modules/rollup/dist/es/shared/node-entry.js:4804:28)
  at Program.bind (node_modules/rollup/dist/es/shared/node-entry.js:4804:28)
  at Module.bindReferences (node_modules/rollup/dist/es/shared/node-entry.js:13947:18)

I will try to create a reproduction later 👍

@intlify/core-base version (same before reinstall and after):

node ➜ /app (feature/o1) $ npm list @intlify/core-base
app@10.29.0 /app
├─┬ @intlify/unplugin-vue-i18n@5.0.0
│ └─┬ @intlify/vue-i18n-extensions@6.2.0
│   └─┬ vue-i18n@9.14.0
│     └── @intlify/core-base@9.14.0 deduped
├─┬ @nuxtjs/i18n@8.5.3
│ ├─┬ @intlify/h3@0.5.0
│ │ └─┬ @intlify/core@9.14.0
│ │   └── @intlify/core-base@9.14.0 deduped
│ └─┬ vue-i18n@9.14.0
│   └── @intlify/core-base@9.14.0
└─┬ vue-i18n@10.0.1
  └── @intlify/core-base@10.0.1
Anton-Plagemann commented 2 months ago

Ok, after adding

  "overrides": {
    "@intlify/core-base": "^10.0.1"
  }

to my package.json, resulting in

node ➜ /app (feature/o1) $ npm list @intlify/core-base
app@10.29.0 /app
├─┬ @intlify/unplugin-vue-i18n@5.0.0
│ └─┬ @intlify/vue-i18n-extensions@6.2.0
│   └─┬ vue-i18n@9.14.0
│     └── @intlify/core-base@10.0.1 deduped
├─┬ @nuxtjs/i18n@8.5.3
│ ├─┬ @intlify/h3@0.5.0
│ │ └─┬ @intlify/core@9.14.0
│ │   └── @intlify/core-base@10.0.1 deduped
│ └─┬ vue-i18n@9.14.0
│   └── @intlify/core-base@10.0.1 deduped
└─┬ vue-i18n@10.0.1
  └── @intlify/core-base@10.0.1 overridden

I get a third, also different error message 😄

 ERROR  x Build failed in 13.62s                                                                                                                                      7:12:36 AM

[7:12:36 AM]  ERROR  Nuxt Build Error: node_modules/@nuxtjs/i18n/node_modules/vue-i18n/dist/vue-i18n.mjs (6:24): "incrementer" is not exported by "node_modules/@intlify/shared/dist/shared.mjs", imported by "node_modules/@nuxtjs/i18n/node_modules/vue-i18n/dist/vue-i18n.mjs".
file: /app/node_modules/@nuxtjs/i18n/node_modules/vue-i18n/dist/vue-i18n.mjs:6:24

4:   * Released under the MIT License.
5:   */
6: import { getGlobalThis, incrementer, format, makeSymbol, isPlainObject, isArray, deepCopy, isString, hasOwn, isObject...
                           ^
7: import { CoreWarnCodes, CoreErrorCodes, createCompileError, DEFAULT_LOCALE, updateFallbackLocale, setFallbackContext,...
8: import { createVNode, Text, computed, watch, getCurrentInstance, ref, shallowRef, Fragment, defineComponent, h, effec...

  file: node_modules/@nuxtjs/i18n/node_modules/vue-i18n/dist/vue-i18n.mjs:6:24

  4:   * Released under the MIT License.
  5:   */
  6: import { getGlobalThis, incrementer, format, makeSymbol, isPlainObject, isArray, deepCopy, isString, hasOwn, isObject...
  ^
  7: import { CoreWarnCodes, CoreErrorCodes, createCompileError, DEFAULT_LOCALE, updateFallbackLocale, setFallbackContext,...
  8: import { createVNode, Text, computed, watch, getCurrentInstance, ref, shallowRef, Fragment, defineComponent, h, effec...

  at getRollupError (node_modules/rollup/dist/es/shared/parseAst.js:392:41)
  at error (node_modules/rollup/dist/es/shared/parseAst.js:388:42)
  at Module.error (node_modules/rollup/dist/es/shared/node-entry.js:13968:16)
  at Module.traceVariable (node_modules/rollup/dist/es/shared/node-entry.js:14415:29)
  at ModuleScope.findVariable (node_modules/rollup/dist/es/shared/node-entry.js:12122:39)
  at Identifier.bind (node_modules/rollup/dist/es/shared/node-entry.js:6941:40)
  at CallExpression.bind (node_modules/rollup/dist/es/shared/node-entry.js:4808:23)
  at CallExpression.bind (node_modules/rollup/dist/es/shared/node-entry.js:9224:15)
  at VariableDeclarator.bind (node_modules/rollup/dist/es/shared/node-entry.js:4808:23)
  at VariableDeclaration.bind (node_modules/rollup/dist/es/shared/node-entry.js:4804:28)
Anton-Plagemann commented 2 months ago

Ok, solved it. After adding

"overrides": {
    "vue-i18n": "^10.0.1"
  }

to the package.json-file everything works again.

The issue seems to be in the @nuxtjs/i18n package. I will open an issue there. Thanks for your support! 🙏

node ➜ /app (feature/o1) $ npm list vue-i18n
app@10.29.0 /app
├─┬ @intlify/unplugin-vue-i18n@5.0.0
│ ├─┬ @intlify/vue-i18n-extensions@6.2.0
│ │ └── vue-i18n@9.14.0
│ └── vue-i18n@10.0.1 deduped
├─┬ @nuxtjs/i18n@8.5.3
│ ├─┬ @intlify/unplugin-vue-i18n@3.0.1
│ │ └── vue-i18n@9.14.0 deduped
│ └── vue-i18n@9.14.0
└── vue-i18n@10.0.1
BobbieGoede commented 2 months ago

Oh I see you're using @nuxtjs/i18n v8 which does not support vue-i18n v10, we're working on @nuxtjs/i18n v9 which among other changes supports vue-i18n v10. Check out https://github.com/nuxt-modules/i18n/issues/3002 for its progress.

Anton-Plagemann commented 2 months ago

Ah nice, thanks! Then I will wait for @nuxtjs/i18n v9 to be released 🙌 Thanks again!

DamageESP commented 1 month ago

I'm also getting this. Unfortunately, the fix proposed by @Anton-Plagemann didn't work.

 ERROR  x Build failed in 3.54s                                                         9:51:49 PM

[9:51:49 PM]  ERROR  Nuxt Build Error: ../../../node_modules/@intlify/core-base/dist/core-base.mjs (6:121): "incrementer" is not exported by "../../../node_modules/@intlify/shared/dist/shared.mjs", imported by "../../../node_modules/@intlify/core-base/dist/core-base.mjs".
file: /home/damageesp/myapp/node_modules/@intlify/core-base/dist/core-base.mjs:6:121

4:   * Released under the MIT License.
5:   */
6: import { getGlobalThis, isObject, isFunction, isString, isNumber, isPlainObject, assign, join, toDisplayString, isArray, incremente...
                                                                                                                            ^
7: import { CompileWarnCodes, CompileErrorCodes, createCompileError, detectHtmlTag, defaultOnError, baseCompile as baseCompile$1 } fro...
8: export { CompileErrorCodes, createCompileError } from '@intlify/message-compiler';

  file: /home/damageesp/myapp/node_modules/@intlify/core-base/dist/core-base.mjs:6:121

  4:   * Released under the MIT License.
  5:   */
  6: import { getGlobalThis, isObject, isFunction, isString, isNumber, isPlainObject, assign, join, toDisplayString, isArray, incremente...
  ^
  7: import { CompileWarnCodes, CompileErrorCodes, createCompileError, detectHtmlTag, defaultOnError, baseCompile as baseCompile$1 } fro...
  8: export { CompileErrorCodes, createCompileError } from '@intlify/message-compiler';

  at getRollupError (/home/damageesp/myapp/node_modules/rollup/dist/es/shared/parseAst.js:392:41)
  at error (/home/damageesp/myapp/node_modules/rollup/dist/es/shared/parseAst.js:388:42)
  at Module.error (/home/damageesp/myapp/node_modules/rollup/dist/es/shared/node-entry.js:13968:16)
  at Module.traceVariable (/home/damageesp/myapp/node_modules/rollup/dist/es/shared/node-entry.js:14415:29)
  at ModuleScope.findVariable (/home/damageesp/myapp/node_modules/rollup/dist/es/shared/node-entry.js:12122:39)
  at Identifier.bind (/home/damageesp/myapp/node_modules/rollup/dist/es/shared/node-entry.js:6941:40)
  at CallExpression.bind (/home/damageesp/myapp/node_modules/rollup/dist/es/shared/node-entry.js:4808:23)
  at CallExpression.bind (/home/damageesp/myapp/node_modules/rollup/dist/es/shared/node-entry.js:9224:15)
  at VariableDeclarator.bind (/home/damageesp/myapp/node_modules/rollup/dist/es/shared/node-entry.js:4808:23)
  at VariableDeclaration.bind (/home/damageesp/myapp/node_modules/rollup/dist/es/shared/node-entry.js:4804:28)

npm error Lifecycle script `build` failed with error:
npm error code 1
npm error path /home/damageesp/myapp/packages/apps/matcher
npm error workspace myapp@1.0.0
npm error location /home/damageesp/myapp/packages/apps/matcher
npm error command failed
npm error command sh -c nuxt build

FWIW the issue started when moving to a monorepo structure with Lerna, although I don't think it's related.

Anton-Plagemann commented 1 month ago

Hi @DamageESP, I had the same issue again, this time caused by the @intlify/unplugin-vue-i18n package. After downgrading it from 5.0.0 to 4.0.0 it worked again, so maybe that could help you too 😊

{
  "dependencies": {
    "vue-i18n": "^9.14.0"
  },
  "devDependencies": {
    "@intlify/unplugin-vue-i18n": "^4.0.0"
  }
}
DamageESP commented 1 month ago

Thanks for the suggestion @Anton-Plagemann, but the solution was different (and simpler).

As @BobbieGoede very well pointed out, @nuxtjs/i18n does not yet support the latest versions of vue-i18n. So I had to simply change the version from next (which points to version 10.0.1 of the breaking module @intlify/shared) to ^8.0.0 (which uses the older 9.9.0 version):

- "@nuxtjs/i18n": "next",
+ "@nuxtjs/i18n": "^8.0.0",

This resolved all my problems, of course after running a clean install (deleted package-lock.json as well as the node_modules folder)

I hope this helps clean up your package.json a bit, as well as others!

Note: It's interesting though that we have a broken version of the library in main, I'm surprised there isn't a lot more noise about this.

StijnCoolen commented 1 month ago

Downgrading to an older version of @nuxtjs/i18n is not an option for us (using ^9.0.0-alpha.1). Thefore I had to lock @intlify/shared to a version that did not have any issues (9.9.0), this however introduced the following error:

Uncaught SyntaxError: The requested module 'http://localhost:3000/_nuxt/@fs/Users/xxx/Development/xxx/node_modules/.cache/vite/client/deps/@intlify_core-base.js?v=63061a40' doesn't provide an export named: 'CORE_ERROR_CODES_EXTEND_POINT'

Perhaps related to the fact that @nuxtjs/i18n does not yet support the latest versions of vue-i18n @DamageESP ?

BobbieGoede commented 1 month ago

@StijnCoolen That's very likely caused by a mismatch of versions, for clarity:

You should not use any other combination.

If you're using @nuxtjs/i18n I think you should be able to fully rely on it installing the correct dependencies (removing vue-i18n and its dependencies from your package file). Though I have ran into projects that needed these dependencies explicitly added YMMV.

If you are using compatible versions, make sure these are up to date and refresh/remove your lock files to force the installation of correct sub-dependencies (these errors seem to hint at this being the issue).

StijnCoolen commented 1 month ago

@BobbieGoede thanks for thinking with me! Installing only "@nuxtjs/i18n": "^9.0.0-alpha.3" and removing the override that I had in place (vue-i18n) and the lockfile results in the following error:

Error: Build failed with 1 error: node_modules/@intlify/core-base/dist/core-base.mjs:6:121: ERROR: No matching export in "node_modules/@intlify/shared/dist/shared.mjs" for import "incrementer"

BobbieGoede commented 1 month ago

That's odd, can you try doing the same but installing the latest nightly release channel instead ("@nuxtjs/i18n": "npm:@nuxtjs/i18n-edge@9.0.0-alpha.3-28788324.b9e5296")? If that still doesn't work can you try creating a minimal reproduction of this issue? 🙏

alexcroox commented 3 weeks ago

I fixed the CORE_ERROR_CODES_EXTEND_POINT errors in @nuxtjs/i18n (9.0.0-rc.2) with:

"overrides": {
  "vue-i18n": "latest",
  "@intlify/core-base": "latest",
  "@intlify/message-compiler": "latest"
}

All 3 were required to stop the error from appearing at build time or runtime