nextjs - ✅(Solved) Fix verbatimModuleSyntax + type "circular dependency" cause ReferenceError in Turbopack (regression in 16.2.0-canary.94) [3 pull requests, 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#91906Fetched 2026-04-08 01:30:07
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
cross-referenced ×1issue_type_added ×1labeled ×1renamed ×1

Error Message

You will see the error.

PR fix notes

PR #90907: TURBOPACK: typescript transform support verbatimModuleSyntax

Description (problem / solution / changelog)

In utoo case, we need to support react classic jsx transform(To compitable with react 16 or above project).

We have a case like:

// index.ts
import React from 'react';

export const App = () => <div></div>;

Under the classic jsx transform, the jsx will be transformed as follows:

export const App = () => React.createElement("div", /***/);

But turbopack's jsx transform was behind typescript transform, so in the stage of typescript transform, the import of react will be deleted by the default config of swc typescript transform(which set verbatimmodulesyntax as false by default): https://swc.rs/docs/migrating-from-tsc#verbatimmodulesyntax-true

Then the output of classic jsx transform will get a runtime error like React was not found.

For solve the problem, this pr just support a config verbatimModuleSyntax for turbopack's typescript transform, it will not remove user's React import under classic jsx transform.

We test the case under utoopack in the following pr:

And Rspack also enable verbatimModuleSyntax to true by default under 2.0: https://github.com/web-infra-dev/rspack/discussions/9270#discussioncomment-13429924

Changed files

  • crates/next-core/src/transform_options.rs (modified, +31/-8)
  • turbopack/crates/turbopack-ecmascript/src/transform/mod.rs (modified, +7/-2)
  • turbopack/crates/turbopack/src/module_options/mod.rs (modified, +3/-1)
  • turbopack/crates/turbopack/src/module_options/module_options_context.rs (modified, +1/-0)

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 22.8.0
  npm: 11.6.1
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 16.2.0-canary.94 // There is a newer canary version (16.2.1-canary.7) available, please upgrade!
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/kevin-admoai/my-app

To Reproduce

Start application Load / You will see the error.

Current vs. Expected behavior

Cannot access 'x' before initialization.

This only happens after 16.2.0-canary.94. Versions before this are not impacted. The impacted code has lived in production for months before this.

This only happens when using turbopack. No issues when using --webpack.

This happens when using verbatimModuleSyntax: true in tsconfig. Removing this "fixes" the issue.

Maybe it is related to https://github.com/vercel/next.js/pull/90907?? This was included in the 16.2.0-canary.94 release! TURBOPACK: typescript transform support verbatimModuleSyntax

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 22.8.0
  npm: 11.6.1
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 16.2.0-canary.94 // There is a newer canary version (16.2.1-canary.7) available, please upgrade!
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.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)

Additional context

No response

extent analysis

Fix Plan

The fix involves updating the next version and adjusting the tsconfig settings.

  • Update next to the latest canary version (16.2.1-canary.7) by running:
npm install next@latest
  • Remove verbatimModuleSyntax: true from tsconfig.json or set it to false:
{
  "compilerOptions": {
    //... other options...
    "verbatimModuleSyntax": false
  }
}

Alternatively, you can keep verbatimModuleSyntax: true and update your code to avoid accessing variables before initialization.

Verification

After applying the fix, restart the development server with next dev and verify that the error is resolved.

Extra Tips

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