Skip to content

fix: Move AST transformer of useExtracted to SWC plugin & handle source maps#2114

Merged
amannn merged 104 commits intomainfrom
canary
Nov 19, 2025
Merged

fix: Move AST transformer of useExtracted to SWC plugin & handle source maps#2114
amannn merged 104 commits intomainfrom
canary

Conversation

@amannn
Copy link
Owner

@amannn amannn commented Nov 14, 2025

# Conflicts:
#	packages/next-intl/.size-limit.ts
#	packages/next-intl/__mocks__/react.tsx
#	packages/next-intl/src/navigation/shared/createSharedNavigationFns.tsx
#	packages/next-intl/src/react-server/index.test.tsx
#	packages/next-intl/src/server/react-server/RequestLocale.tsx
#	packages/next-intl/src/server/react-server/getConfig.tsx
In Next.js 15.3, [Turbopack config has become
stable](https://nextjs.org/blog/next-15-3#turbopack-configuration-in-nextconfigts-stable).
With this fix, the new option is used in order to avoid a deprecation
warning.
# Conflicts:
#	packages/next-intl/src/plugin/getNextConfig.tsx
…on APIs (#1922)

With #959, the middleware
already handled decoding of non-ASCII characters.

This allows you to define localized
[`pathnames`](https://next-intl.dev/docs/routing#pathnames) like so:

```tsx
import {defineRouting} from 'next-intl/routing';
 
export const routing = defineRouting({
  locales: ['en', 'ja'],
  defaultLocale: 'en',
  pathnames: {
    '/about': {
      'de': '/über-uns'
  }
}
```

Since Next.js automatically encodes incoming pathnames, this supports
incoming requests both for decoded pathnames (e.g. `/de/über-uns`), as
well as encoded ones (e.g. `/de/%C3%BCber-uns`).

One piece has been missing though: Pathnames returned from [navigation
APIs](https://next-intl.dev/docs/routing/navigation) should be turned
into an encoded form.

Now, `next-intl` handles this as well:

```tsx
import {Link, getPathname} from '@/i18n/navigation';

// href="/de/%C3%BCber-uns"
<Link href="/about" locale="de" />

// pathname = "/de/%C3%BCber-uns"
const pathname = getPathname({href: '/about', locale: 'de'});
```

This change brings the navigation APIs in line with [Google's
recommendation to encode non-ASCII
pathnames](https://developers.google.com/search/docs/crawling-indexing/url-structure).
@vercel
Copy link

vercel bot commented Nov 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
next-intl-docs Ready Ready Preview Comment Nov 19, 2025 11:55am
next-intl-example-app-router Ready Ready Preview Comment Nov 19, 2025 11:55am
next-intl-example-app-router-without-i18n-routing Ready Ready Preview Comment Nov 19, 2025 11:55am

amannn and others added 21 commits November 17, 2025 11:25
Removes tests for t.rich, t.markup, object syntax, and getExtracted as they are no longer relevant.

Co-authored-by: jan <jan@amann.work>
Move most `MessageExtractor.test.tsx` tests to Rust fixtures to separate
simple input/output transforms from integration and error-handling
tests.

---
<a
href="https://cursor.com/background-agent?bcId=bc-7b2f8500-1a72-41a6-8f3c-4795a9b7ae1d"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-cursor-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-cursor-light.svg"><img alt="Open in
Cursor"
src="https://cursor.com/open-in-cursor.svg"></picture></a>&nbsp;<a
href="https://cursor.com/agents?id=bc-7b2f8500-1a72-41a6-8f3c-4795a9b7ae1d"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/open-in-web-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/open-in-web-light.svg"><img alt="Open in Web"
src="https://cursor.com/open-in-web.svg"></picture></a>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
…to fix/useextracted-sourcemap

# Conflicts:
#	packages/next-intl/src/extractor/extractor/MessageExtractor.test.tsx
…urce maps (#2094)

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: DongYun Kang <kdy.1997.dev@gmail.com>
@amannn amannn changed the title fix: Improvements for useExtracted fix: Move AST transformer of useExtracted to SWC plugin & handle source maps Nov 19, 2025
@amannn amannn merged commit e63fbc5 into main Nov 19, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants