nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.75k stars 483 forks source link

Server locale detector does not work with .yml translation #2835

Closed Applelo closed 7 months ago

Applelo commented 8 months ago

Environment

Reproduction

YML (not working): https://stackblitz.com/edit/nuxt-i18n-localedector-yml?file=nuxt.config.ts JSON (working): https://stackblitz.com/edit/nuxt-i18n-localedector-yml-nuxna8?file=nuxt.config.ts

Describe the bug

When we are using the experimental localeDetector option with .yml file translation and they are a problem with the compilation. There is no problem when we are using json file.

Additional context

No response

Logs

ERROR  [worker reload] [worker init] _import_meta_url_ is not defined                 
  at .nuxt/dev/index.mjs:1:65
  at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
  at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
  at async loadESM (node:internal/process/esm_loader:28:7)
  at async handleMainPromise (node:internal/modules/run_main:113:12)
BobbieGoede commented 8 months ago

I'm getting the same error in the playground after updating nitropack to 2.9.0 or higher, maybe related https://github.com/nuxt/nuxt/issues/26170.

I haven't checked further (yet) if this is related to .yml files as you described.

Applelo commented 8 months ago

I have added the a new reproduction (forked from the previous one) and change all .yml file into .json and it is working.

BobbieGoede commented 8 months ago

Now that https://github.com/unjs/nitro/pull/2275 has been merged this issue can be resolved by overriding nitropack to install its nightly release (you will have to remove lockfiles before reinstalling). I have updated you reproduction to demonstrate here.

Not sure when then next nitro release will be, let's hope it's soon and that Nuxt includes it in the next release!

Let's keep this issue open until that's released, until then if anyone else runs into this add this to your package.json as a temporary workaround:

  "overrides": {
    "nitropack": "npm:nitropack-nightly"
  }
Applelo commented 8 months ago

Thanks for the quick resolution 🔥