nextjs - 💡(How to fix) Fix Relay plugin imports generated files as modules in Turbopack only, causing errors [1 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#88662Fetched 2026-04-08 02:04:10
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
issue_type_added ×1labeled ×1

Code Example

{
  "fragment": {
    "argumentDefinitions": [],
    // rest of the document

---

{
  "default": {
    "fragment": {
      "argumentDefinitions": [],
      // rest of the document

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Wed Nov  5 21:33:58 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 22.20.0
  npm: 11.6.1
  Yarn: 1.22.19
  pnpm: 10.20.0
Relevant Packages:
  next: 16.1.1-canary.30 // Latest available version is detected (16.1.1-canary.30).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.6.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/wizardly-rain-g2v4s3

To Reproduce

  1. Load Codesandbox repo
  2. Load npm run dev (this will output the GraphQL document on the page)
  3. Change dev task to next dev --webpack and compare

Current vs. Expected behavior

Based on the previous issue https://github.com/vercel/next.js/issues/47239, eagerEsModules option should import the document (default export) from Relay-generated files. This works in Webpack, but Turbopack returns the module instead.

With Webpack enabled:

{
  "fragment": {
    "argumentDefinitions": [],
    // rest of the document

With Turbopack enabled:

{
  "default": {
    "fragment": {
      "argumentDefinitions": [],
      // rest of the document

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.6.0: Wed Nov  5 21:33:58 PST 2025; root:xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 22.20.0
  npm: 11.6.1
  Yarn: 1.22.19
  pnpm: 10.20.0
Relevant Packages:
  next: 16.1.1-canary.30 // Latest available version is detected (16.1.1-canary.30).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  typescript: 5.6.3
Next.js Config:
  output: N/A

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), next start (local)

Additional context

No response

extent analysis

TL;DR

  • The issue can be mitigated by adjusting the import behavior for Relay-generated files when using Turbopack.

Guidance

  • Verify that the eagerEsModules option is correctly configured in the Next.js setup to ensure it works as expected with Turbopack.
  • Compare the differences in how Webpack and Turbopack handle ES module imports to identify potential workarounds.
  • Check the Relay-generated files for any inconsistencies in their default exports that might affect how Turbopack imports them.
  • Consider adjusting the import statements in the affected files to directly reference the fragment instead of relying on the default export.

Example

No specific code example can be provided without modifying the original issue's context, but adjusting the import to directly access the fragment, like import { fragment } from './relayGeneratedFile';, might help bypass the issue with Turbopack.

Notes

The solution may depend on the specifics of the Relay-generated files and how they are being imported and used within the Next.js application. Further investigation into the differences between Webpack and Turbopack's handling of ES modules and default exports is necessary.

Recommendation

  • Apply workaround: Adjusting the import behavior or the configuration of eagerEsModules might provide a temporary solution until the underlying issue with Turbopack is resolved.

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