nextjs - ✅(Solved) Fix SWC panic with MDX files containing Japanese (multibyte) characters in 16.1.0+ [1 pull requests, 5 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#87713Fetched 2026-04-08 02:06:29
View on GitHub
Comments
5
Participants
3
Timeline
15
Reactions
0
Author
Assignees
Timeline (top)
commented ×5labeled ×3referenced ×2assigned ×1

Fix Action

Fixed

PR fix notes

PR #87841: Turbopack: Update to swc_core v50.2.3

Description (problem / solution / changelog)

Update to swc_core v50.2.3 to address a parse issue with mdx files that should be fixed by swc-project/swc#11372:

I'm intentionally not updating to the latest SWC here to reduce risk, as I'd like to cherry-pick this into the Next 16.1 branch.

Changelog: https://github.com/swc-project/swc/blob/f9b4da2bd85d160b3ee4b3296ed520388675b90e/CHANGELOG-CORE.md#swc_corev5023---2025-12-15

Changed files

  • Cargo.lock (modified, +80/-87)
  • Cargo.toml (modified, +10/-10)
  • crates/next-custom-transforms/tests/loader/issue-30389/output.js (modified, +2/-2)
  • turbopack/crates/turbopack-tests/tests/snapshot/swc_transforms/preset_env/output/5c1d0_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_5aaf1327.js (modified, +35/-11)
  • turbopack/crates/turbopack-tests/tests/snapshot/swc_transforms/preset_env/output/780ce_turbopack-tests_tests_snapshot_swc_transforms_preset_env_input_index_5aaf1327.js.map (modified, +4/-4)

Code Example

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

# Test

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

---

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)

---

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
RAW_BUFFERClick to expand / collapse

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:

VersionResult
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:

  • #86240 (Bump to SWC 48)
  • #86689 (Bump to SWC 49)

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).

extent analysis

TL;DR

Downgrade SWC to a version prior to 48 or wait for a fix in a future Next.js release to resolve the SWC panic caused by multibyte characters in MDX files.

Guidance

  • Verify the issue by checking if the build succeeds when removing multibyte characters from the MDX file or when using Next.js version 16.0.10.
  • Consider downgrading Next.js to version 16.0.10 as a temporary workaround, as it is known to work with multibyte characters in MDX files.
  • Keep an eye on the Next.js repository for updates related to SWC version bumps (#86240 and #86689) that may address this regression.
  • If possible, test the build process with a different compiler or minification tool to isolate the issue to SWC.

Example

No code snippet is provided as the issue is related to a specific version of SWC and Next.js, and the fix involves downgrading or waiting for an update.

Notes

The provided information suggests that the issue is specific to SWC versions 48 and 49, and downgrading to an earlier version may resolve the issue. However, this may not be a viable long-term solution, and waiting for a fix in a future release may be necessary.

Recommendation

Apply workaround: Downgrade Next.js to version 16.0.10, as it is a known working version that can handle multibyte characters in MDX files without causing an SWC panic.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - ✅(Solved) Fix SWC panic with MDX files containing Japanese (multibyte) characters in 16.1.0+ [1 pull requests, 5 comments, 3 participants]