vercel / vercel/next.js

Regression: Next.js doesn't pass comments to SWC Plugin for server components

Open
#86,844 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

SWC
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://github.com/XantreDev/preact-signals/tree/8a4a425030b6b275c15e9fc8405de3f47aa260dc/apps/next-react-test

To Reproduce
  1. build all the packages pnpm run build
  2. start next js dev server
  3. You'lee see an error, because server file is transformed
Current vs. Expected behavior
Current behavior

Next.js passes incorrect comments to the swc plugin for server components. It works for client side components

Expected behavior

Next.js passes the correct comment to the swc plugin and everything works as it worked prior to version 16

Provide environment information
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Fri, 14 Nov 2025 06:54:20 +0000
  Available memory (MB): 31941
  Available CPU cores: 16
Binaries:
  Node: 25.2.1
  npm: 11.6.2
  Yarn: N/A
  pnpm: 10.23.0
Relevant Packages:
  next: 16.0.7 // Latest available version is detected (16.0.7).
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.4.5
Next.js Config:
  output: N/A
Which area(s) are affected? (Select all that apply)

SWC

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

next dev (local)

Additional context

I am maintainer of preact-signals library. It's wrapper around preact-signals and is shipped with an swc plugin. The plugin adds useSignals hook to any react component reading something with .value (in auto mode) or just every component in all mode

You can opt-in or opt-out from the transformation using /** @noUseSignals *///** @useSignals */ comments. It worked perfectly fine for client side and server side components. But after I upgraded my test app to the latest Next version it stopped working for client side components

It isn't an issue of swc itself, it handles it with no issues input, output

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked reproduction at apps/next-react-test, build the packages with pnpm run build, and run the Next.js development server. Compare how Next.js 16.0.7 passes comments to the SWC plugin for server and client components; done means the @noUseSignals and @useSignals comments are preserved correctly and the reproduction works as before version 16.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js
Domain
build-system, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.