Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support nuxt4 #3009

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: remove deprecate nuxt version checking API
  • Loading branch information
kazupon authored and BobbieGoede committed Jul 5, 2024
commit f608a571744bf21ad6c49fe287dc978af640beab
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"@babel/types": "^7.24.7",
"@eslint/js": "9.5.0",
"@nuxt/module-builder": "^0.6.0",
"@nuxt/schema": "^3.12.3",
"@nuxt/schema": "npm:@nuxt/schema-nightly@latest",
"@types/debug": "^4.1.9",
"@types/eslint": "^8.56.6",
"@unhead/vue": "^1.8.8",
Expand All @@ -125,7 +125,7 @@
"lint-staged": "^15.2.7",
"nitropack": "^2.9.7",
"npm-run-all2": "^6.2.0",
"nuxt": "^3.12.3",
"nuxt": "npm:nuxt-nightly@latest",
"ofetch": "^1.3.4",
"playwright": "^1.38.1",
"prettier": "^3.3.2",
Expand Down
13 changes: 12 additions & 1 deletion playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@ import ModuleExperimental from './module-experimental'
export default defineNuxtConfig({
// devLogs broken, should be resolved by https://github.com/nuxt/nuxt/commit/b3ced3d694c89344c8e77b804a2dc76434d27668
// remove after updating to Nuxt >3.11.0
future: {
compatibilityVersion: 4
},

features: {
devLogs: false
},

experimental: {
typedPages: true
},

vite: {
// Prevent reload by optimizing dependency before discovery
optimizeDeps: {
include: ['@unhead/vue']
}
},

extends: ['layers/i18n-layer'],

modules: [
(_, nuxt) => {
console.log(nuxt.options._installedModules)
Expand Down Expand Up @@ -101,6 +109,7 @@ export default defineNuxtConfig({
'@nuxtjs/i18n',
'@nuxt/devtools'
],

vite: {
build: {
minify: false
Expand Down Expand Up @@ -194,5 +203,7 @@ export default defineNuxtConfig({
// // redirectOn: 'root'
// },
vueI18n: './vue-i18n.options.ts'
}
},

compatibilityDate: '2024-07-02'
})
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 1 addition & 19 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import createDebug from 'debug'
import {
defineNuxtModule,
isNuxt2,
isNuxt3,
getNuxtVersion,
addComponent,
addPlugin,
addTemplate,
Expand Down Expand Up @@ -52,8 +49,7 @@ export default defineNuxtModule<NuxtI18nOptions>({
name: NUXT_I18N_MODULE_ID,
configKey: 'i18n',
compatibility: {
nuxt: '>=3.0.0-rc.11',
bridge: false
nuxt: '>=4.0.0'
}
},
defaults: DEFAULT_OPTIONS,
Expand All @@ -70,20 +66,6 @@ export default defineNuxtModule<NuxtI18nOptions>({

checkLayerOptions(options, nuxt)

if (isNuxt2(nuxt)) {
throw new Error(
formatMessage(
`We will release >=7.3 <8, See about GitHub Discussions https://github.com/nuxt-community/i18n-module/discussions/1287#discussioncomment-3042457: ${getNuxtVersion(
nuxt
)}`
)
)
}

if (!isNuxt3(nuxt)) {
throw new Error(formatMessage(`Cannot support nuxt version: ${getNuxtVersion(nuxt)}`))
}

/**
* Check conflicting options
*/
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/routing/extends/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export function extendI18n<Context = unknown, TI18n extends I18n = I18n>(

// prettier-ignore
const exported = i18n.mode === 'composition'
? app.config.globalProperties.$i18n
? app.config.globalProperties.$i18n as ExportedGlobalComposer
// for legacy mode
: null
if (exported) {
Expand Down