Skip to content

SWC panic with MDX files containing Japanese (multibyte) characters in 16.1.0+ #87713

@katanabe

Description

@katanabe

Link to the code that reproduces this issue

https://github.com/katanabe/nextjs-mdx-multibyte-bug

To Reproduce

  1. Clone the reproduction repo
  2. Run npm install
  3. Run npm run build

The MDX file (app/test/page.mdx) contains Japanese text with full-width parentheses:

export const metadata = {
  title: "Test",
};

# Test

これはテスト(サンプル)です。

The issue is triggered by multibyte characters in the MDX body (e.g., ()), not by export const metadata content.

Current vs. Expected behavior

Current behavior:
Build fails with SWC panic:

thread '<unnamed>' panicked at swc_common-18.0.0/src/source_map.rs:657:62:
byte index 88 is not a char boundary; it is inside '(' (bytes 87..90)

Expected behavior:
Build should succeed, as it does in Next.js 16.0.10.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin 25.1.0
  Available memory (MB): 65536
  Available CPU cores: 12
Binaries:
  Node: 24.11.1
  npm: 11.3.0
  pnpm: 9.15.9
Relevant Packages:
  next: 16.1.1
  react: 19.0.0
  react-dom: 19.0.0

Which area(s) are affected? (Select all that apply)

SWC (minification/transpilation), Turbopack

Which stage(s) are affected? (Select all that apply)

next build (default compiler)

Additional context

Version comparison:

Version Result
16.0.10 ✅ Build succeeds
16.1.0 ❌ SWC panic
16.1.1 ❌ SWC panic

Likely cause:
This regression was likely introduced by the SWC version bump in 16.1.0:

The issue occurs when Rust string slicing attempts to access a byte index that falls in the middle of a multibyte UTF-8 character (Japanese full-width parenthesis is 3 bytes).

Metadata

Metadata

Assignees

Labels

SWCRelated to minification/transpilation in Next.js.TurbopackRelated to Turbopack with Next.js.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions