nextjs - ✅(Solved) Fix Turbopack compilation error with Swagger [1 pull requests, 2 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#86507Fetched 2026-04-08 02:10:34
View on GitHub
Comments
2
Participants
3
Timeline
12
Reactions
6
Author
Timeline (top)
subscribed ×5commented ×2labeled ×2cross-referenced ×1

Error Message

Turbopack can't compile the Swagger correctly and returns an error in the console:

Root Cause

In the UI, there is an infinite loader, and the content can't be loaded because of the issue

Fix Action

Fixed

PR fix notes

PR #86584: Turbopack: keep sideeffectful barrel file

Description (problem / solution / changelog)

Turbopack incorrectly ignores the second barrel file and drops the assignment.

Closes PACK-5995 Closes #86507

  • Test
  • Fix

Changed files

  • turbopack/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/reexport-side-effect-barrel/input/index.js (added, +5/-0)
  • turbopack/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/reexport-side-effect-barrel/input/library/index.js (added, +1/-0)
  • turbopack/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/reexport-side-effect-barrel/input/library/object.js (added, +1/-0)
  • turbopack/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/reexport-side-effect-barrel/input/library/package.json (added, +5/-0)
  • turbopack/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/reexport-side-effect-barrel/input/library/registration.js (added, +3/-0)

Code Example

import SwaggerUI from "swagger-ui-react";
import "swagger-ui-react/swagger-ui.css";

export default function Home() {
  return (
    <div>
      <main>
        <SwaggerUI spec={schema} />
      </main>
    </div>
  );
}

---

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11
  Available memory (MB): 65281
  Available CPU cores: 24
Binaries:
  Node: 22.21.0
  npm: 10.9.4
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.0.4
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
  swagger-ui-react: 5.30.3
Next.js Config:
  output: standalone
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/vigorous-water-dtwl8q

To Reproduce

  1. npm i swagger-ui-react
  2. npm run dev

Current vs. Expected behavior

import SwaggerUI from "swagger-ui-react";
import "swagger-ui-react/swagger-ui.css";

export default function Home() {
  return (
    <div>
      <main>
        <SwaggerUI spec={schema} />
      </main>
    </div>
  );
}

Turbopack can't compile the Swagger correctly and returns an error in the console:

<img width="1361" height="525" alt="Image" src="https://github.com/user-attachments/assets/7c0abd32-fe0b-4777-aca4-26d876a6ef78" />

In the UI, there is an infinite loader, and the content can't be loaded because of the issue

<img width="1375" height="907" alt="Image" src="https://github.com/user-attachments/assets/db1de020-00be-4a7a-999a-d72e56e47fc2" />

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11
  Available memory (MB): 65281
  Available CPU cores: 24
Binaries:
  Node: 22.21.0
  npm: 10.9.4
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 16.0.4
  react: 19.2.0
  react-dom: 19.2.0
  typescript: 5.9.3
  swagger-ui-react: 5.30.3
Next.js Config:
  output: standalone

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

Turbopack

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

next dev (local), next build (local)

Additional context

The only fix that I found for now is to use --webpack in the scripts. Example: next dev --webpack. With Webpack, it's working fine.

extent analysis

TL;DR

  • Using the --webpack flag with next dev and next build may resolve the Turbopack compilation issue with Swagger UI React.

Guidance

  • Try running next dev --webpack and next build --webpack to see if the issue is resolved, as this has been reported to work.
  • Verify that the Swagger UI is correctly rendered and functional after applying the workaround.
  • If the issue persists, consider checking for any updates or issues with the swagger-ui-react package that may be related to Turbopack compatibility.
  • Review the Next.js configuration and version to ensure it is compatible with Turbopack and the swagger-ui-react package.

Example

No specific code changes are suggested at this time, as the workaround involves using the --webpack flag.

Notes

  • The root cause of the issue appears to be related to Turbopack compatibility with the swagger-ui-react package.
  • Using the --webpack flag may be a temporary workaround until a more permanent solution is found.

Recommendation

  • Apply workaround: Using the --webpack flag is a viable temporary solution until a more permanent fix is available, as it allows the application to function correctly with Swagger UI React.

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