nuxt-modules / i18n

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

feat: support nuxt4 #3009

Open kazupon opened 4 months ago

kazupon commented 4 months ago

๐Ÿ”— Linked issue

3002

โ“ Type of change

๐Ÿ“š Description

๐Ÿ“ Checklist

kazupon commented 4 months ago

Hmm ๐Ÿค” This is strange... rollup v4.18 could not import resources in relative paths... https://github.com/nuxt-modules/i18n/actions/runs/9775263922/job/26985312555#step:11:2032

kazupon commented 4 months ago

I've added console.log on unplugin-vue-i18n. I've faced the below log:

resolveId ../../../layers/layer-server/app/locales/en.json5 /path/to/Projects/oss/nuxt/i18n/specs/fixtures/basic_usage/.nuxt/___basic_usage_spec_ts/i18n.options.mjs
resolveId ../../../layers/layer-server/app/locales/en.json5 /path/to/Projects/oss/nuxt/i18n/node_modules/.pnpm/nuxt-nightly@4.0.0-28664573.9f4f4d56_@opentelemetry+api@1.9.0_@parcel+watcher@2.4.1_@types+no_3dkmkqqbk22rzp2kskenwj4dky/node_modules/nuxt-nightly

I can't understand why en.json5 is importing from nuxt-nightly. ๐Ÿ˜…

BobbieGoede commented 4 months ago

I've added console.log on unplugin-vue-i18n. I've faced the below log:

resolveId ../../../layers/layer-server/app/locales/en.json5 /path/to/Projects/oss/nuxt/i18n/specs/fixtures/basic_usage/.nuxt/___basic_usage_spec_ts/i18n.options.mjs
resolveId ../../../layers/layer-server/app/locales/en.json5 /path/to/Projects/oss/nuxt/i18n/node_modules/.pnpm/nuxt-nightly@4.0.0-28664573.9f4f4d56_@opentelemetry+api@1.9.0_@parcel+watcher@2.4.1_@types+no_3dkmkqqbk22rzp2kskenwj4dky/node_modules/nuxt-nightly

I can't understand why en.json5 is importing from nuxt-nightly. ๐Ÿ˜…

This is due to the folder structure changes in Nuxt 4, I have changed the fixture configurations to use the same structure as Nuxt 3 did using the example shown here.

The tests will still fail due to other factors, which should be resolved with https://github.com/nuxt-modules/i18n/pull/3015. I made a branch that's rebased on that PR (and main) to demonstrate here: https://github.com/BobbieGoede/i18n/pull/46.

BobbieGoede commented 4 months ago

@kazupon I have updated/rebased this branch, it looks like it's mostly working except for the nested fixtures.. All fixtures inside specs/fixtures/issues fail with Error: Cannot find module '@nuxtjs/i18n' ๐Ÿค”

BobbieGoede commented 4 months ago

@kazupon I have updated/rebased this branch, it looks like it's mostly working except for the nested fixtures.. All fixtures inside specs/fixtures/issues fail with Error: Cannot find module '@nuxtjs/i18n' ๐Ÿค”

Fixing this required adding the following to pnpm-workspace.yaml:

- 'specs/fixtures/issues/*'

Not sure why or how it previously worked without issue ๐Ÿค” but it looks like all tests succeed now ๐Ÿ’ช

kazupon commented 4 months ago

@BobbieGoede Thanks! Oh, I missed the srcDir change ... ๐Ÿคฆโ€โ™‚๏ธ

The build of the nuxt docs is failing. It seems that nuxt modules that depend on them have not yet been released in a version compatible with nuxt 4.