Skip to content

localeDetector, autoImports: false and compatibilityVersion: 5 #3950

@geferon

Description

@geferon

Environment

Operating system Windows 10.0.22631
CPU AMD Ryzen 9 3900X 12-Core Processor (24 cores)
Node.js version v24.3.0
nuxt/cli version 3.34.0
Package manager pnpm@10.30.3
Nuxt version 4.4.2
Nitro version 2.13.1
Builder vite@7.3.1
Config -
Modules -

Reproduction

Minimal reproduction: https://stackblitz.com/edit/github-n7mbrwf6?file=nuxt.config.ts
Hi there,
I'm running into an issue where if you turn off autoImports: false and use compatibilityVersion: 5 within nuxt.config.ts, with localeDetector.ts being the following:

import { defineI18nLocaleDetector, tryCookieLocale, tryHeaderLocale, tryQueryLocale } from "#build/types/nitro-imports"

// Detect based on query, cookie, header
export default defineI18nLocaleDetector((event, config) => {
	// try to get locale from query
	const query = tryQueryLocale(event, { lang: '' }) // disable locale default value with `lang` option
	if (query) {
		return query.toString()
	}

	// try to get locale from cookie
	const cookie = tryCookieLocale(event, { lang: '', name: 'i18n_redirected' }) // disable locale default value with `lang` option
	if (cookie) {
		return cookie.toString()
	}

	// try to get locale from header (`accept-header`)
	const header = tryHeaderLocale(event, { lang: '' }) // disable locale default value with `lang` option
	if (header) {
		return header.toString()
	}

	// If the locale cannot be resolved up to this point, it is resolved with the value `defaultLocale` of the locale config passed to the function
	return config.defaultLocale
})

This error comes up:

[nitro 21:38:17]  ERROR  RollupError: i18n/localeDetector.ts (1:9): "defineI18nLocaleDetector" is not exported by "impound:proxy", imported by "i18n/localeDetector.ts".

Or

[nitro 21:49:29]  ERROR  RollupError: [plugin impound] Vue app aliases are not allowed in server runtime. [importing #build/types/nitro-imports from i18n/localeDetector.ts]

Describe the bug

Import breaks due to new Vite environments/etc, with error previously provided.
How should autoImport: false be approached in the future?

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions