Skip to content

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

@XantreDev

Description

@XantreDev

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    SWCRelated to minification/transpilation in Next.js.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions