Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"@iconify-json/simple-icons": "^1.2.78",
"@iconify-json/vscode-icons": "^1.2.45",
"@nuxt/fonts": "0.14.0",
"@nuxt/scripts": "^1.0.5",
"@nuxt/scripts": "^1.3.0",
"better-sqlite3": "^12.9.0",
"nuxt": "^4.4.2",
"nuxt": "^4.4.8",
"nuxt-llms": "0.2.0"
}
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@intlify/unplugin-vue-i18n": "^11.1.2",
"@intlify/utils": "^0.14.1",
"@miyaneee/rollup-plugin-json5": "^1.2.0",
"@nuxt/kit": "^4.4.4",
"@nuxt/kit": "^4.4.8",
"@rollup/plugin-yaml": "^4.1.2",
"@vue/compiler-sfc": "^3.5.22",
"defu": "^6.1.4",
Expand All @@ -97,12 +97,12 @@
"unrouting": "^0.1.5",
"unstorage": "^1.16.1",
"vue-i18n": "^11.4.0",
"vue-router": "^5.0.4"
"vue-router": "^5.1.0"
},
"devDependencies": {
"@nuxt/eslint-config": "^1.15.2",
"@nuxt/eslint-config": "^1.16.0",
"@nuxt/module-builder": "^1.0.2",
"@nuxt/schema": "^4.4.4",
"@nuxt/schema": "^4.4.8",
"bumpp": "^10.2.0",
"consola": "^3.4.2",
"eslint": "^10.2.1",
Expand All @@ -112,7 +112,7 @@
"jiti": "^2.5.1",
"knip": "6.9.0",
"nitropack": "^2.13.1",
"nuxt": "^4.4.4",
"nuxt": "^4.4.8",
"ofetch": "^1.4.1",
"playwright-core": "^1.59.1",
"scule": "^1.3.0",
Expand All @@ -122,7 +122,7 @@
"unbuild": "^3.6.0",
"undici": "^8.1.0",
"vitest": "^4.1.5",
"vue": "^3.5.30"
"vue": "^3.5.39"
},
"publishConfig": {
"access": "public"
Expand Down
3,729 changes: 2,987 additions & 742 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function checkLayerOptions(_options: NuxtI18nOptions, nuxt: Nuxt) {
}
} catch (err) {
if (!(err instanceof Error)) { throw err }
throw new Error(`[nuxt-i18n] ${layerHint} ${err.message}`)
throw new Error(`[nuxt-i18n] ${layerHint} ${err.message}`, { cause: err })
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ export default defineNuxtModule<NuxtI18nOptions>({
nuxt.options.alias['@intlify/core'] = resolveModule(`@intlify/core/dist/core.node`)
nuxt.options.build.transpile.push('@nuxtjs/i18n', ...deps)

// the aliased node build has no declaration file, drop the generated paths entries
// so TS resolves types from the package `types` export (`dist/core.d.ts`) instead
nuxt.hook('prepare:types', ({ tsConfig, nodeTsConfig, sharedTsConfig }) => {
for (const cfg of [tsConfig, nodeTsConfig, sharedTsConfig]) {
delete cfg?.compilerOptions?.paths?.['@intlify/core']
}
})

nuxt.options.alias['#i18n'] = ctx.resolver.resolve('./runtime/composables/index')
nuxt.options.alias['#i18n-kit'] = ctx.resolver.resolve('./runtime/kit')
nuxt.options.alias['#internal-i18n-types'] = ctx.resolver.resolve('./types')
Expand Down
15 changes: 12 additions & 3 deletions src/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,13 @@ export function collectCompactPrerenderRoutes(pages: NarrowedNuxtPage[]): string
/**
* Expression to to find the `RouteNamedMap` generated by uvr, used to replace with `RouteNamedMapI18n`
*/
const routeNamedMapTypeRE = /RouteNamedMap\b/
const routeNamedMapTypeRE = /\bRouteNamedMap\b/g

/**
* Vue Router 5.1+ declares `_RouteFileInfoMap` in the same file, renamed so it
* doesn't merge with the interface in the project's own `typed-router.d.ts`
*/
const routeFileInfoMapTypeRE = /\b_RouteFileInfoMap\b/g

/**
* Declaration file containing the generated route types
Expand Down Expand Up @@ -280,9 +286,12 @@ async function setupExperimentalTypedRoutes(userOptions: NuxtI18nOptions, nuxt:
await originalScanPages(watchers)

const dtsContent = await readFile(dtsFile, 'utf-8')
const renamed = dtsContent
.replace(routeNamedMapTypeRE, 'RouteNamedMapI18n')
.replace(routeFileInfoMapTypeRE, '_RouteFileInfoMapI18n')

if (routeNamedMapTypeRE.test(dtsContent)) {
await writeFile(dtsFile, dtsContent.replace(routeNamedMapTypeRE, 'RouteNamedMapI18n'))
if (renamed !== dtsContent) {
await writeFile(dtsFile, renamed)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/runtime/server/utils/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const _getMergedMessages = async (locale: string, fallbackLocales: string[]) =>

return merged
} catch (e) {
throw new Error('Failed to merge messages: ' + (e as Error).message)
throw new Error('Failed to merge messages: ' + (e as Error).message, { cause: e })
}
}

Expand Down Expand Up @@ -75,7 +75,7 @@ const _getAllMergedMessages = async (locales: string[]) => {

return merged
} catch (e) {
throw new Error('Failed to merge messages: ' + (e as Error).message)
throw new Error('Failed to merge messages: ' + (e as Error).message, { cause: e })
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/shared/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async function getLocaleMessages(locale: string, loader: LocaleLoader) {
const getter = await nuxtApp.runWithContext(loader.load).then(x => (isModule(x) ? x.default : x))
return isFunction(getter) ? await nuxtApp.runWithContext(() => getter(locale)) : getter
} catch (e: unknown) {
throw new Error(`Failed loading locale (${locale}): ` + (e as Error).message)
throw new Error(`Failed loading locale (${locale}): ` + (e as Error).message, { cause: e })
}
}

Expand Down
Loading