nextjs - 💡(How to fix) Fix Turbopack: panic on `**` (exponentiation) operator in node_modules when `compiler.styledComponents` is enabled [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#92090Fetched 2026-04-08 01:51:59
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
closed ×1

Error Message

  1. Open http://localhost:3000 — the page returns a 500 error Current: Turbopack panics with a Rust todo!() and returns a 500 error:
  • pimlicolabs/permissionless.js#499 — same error reported on the library repo (wrong place; the bug is in SWC/Turbopack)

Root Cause

Caused by:

  • not yet implemented: right-associative binary expression

Code Example

thread 'tokio-runtime-worker' panicked at
  swc_ecma_compat_es2015/src/generator.rs:507:21:
  not yet implemented: right-associative binary expression

---

failed to analyze ecmascript module
  '[project]/node_modules/permissionless/_esm/actions/pimlico/estimateErc20PaymasterCost.js [client] (ecmascript)'

Caused by:
- not yet implemented: right-associative binary expression

Debug info:
- Execution of <ModuleAssetContext as AssetContext>::process_resolve_result failed
- Execution of *EcmascriptExports::split_locals_and_reexports failed
- Execution of analyze_ecmascript_module failed
- Execution of <EcmascriptModuleAsset as EcmascriptParsable>::failsafe_parse failed
- Execution of parse failed
- not yet implemented: right-associative binary expression

---

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0
  Available memory (MB): 24576
  Available CPU cores: 10
Binaries:
  Node: 20.20.0
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: 10.24.0
Relevant Packages:
  next: 16.1.6
  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/mhdsdt/turbopack-bigint-exponentiation-repro

To Reproduce

  1. Clone the reproduction: git clone https://github.com/mhdsdt/turbopack-bigint-exponentiation-repro
  2. npm install
  3. npm run dev (runs next dev --turbopack)
  4. Open http://localhost:3000 — the page returns a 500 error

The reproduction requires three conditions to trigger:

  1. compiler: { styledComponents: true } in next.config.ts
  2. styled-components installed as a dependency
  3. Any code in node_modules that uses the ** (exponentiation) operator — in this case, [email protected] uses 10n ** 18n

Switching to webpack (next dev without --turbopack) works fine.

Current vs. Expected behavior

Current: Turbopack panics with a Rust todo!() and returns a 500 error:

thread 'tokio-runtime-worker' panicked at
  swc_ecma_compat_es2015/src/generator.rs:507:21:
  not yet implemented: right-associative binary expression

The full debug trace:

failed to analyze ecmascript module
  '[project]/node_modules/permissionless/_esm/actions/pimlico/estimateErc20PaymasterCost.js [client] (ecmascript)'

Caused by:
- not yet implemented: right-associative binary expression

Debug info:
- Execution of <ModuleAssetContext as AssetContext>::process_resolve_result failed
- Execution of *EcmascriptExports::split_locals_and_reexports failed
- Execution of analyze_ecmascript_module failed
- Execution of <EcmascriptModuleAsset as EcmascriptParsable>::failsafe_parse failed
- Execution of parse failed
- not yet implemented: right-associative binary expression

Expected: The page should compile and render successfully. The ** operator is standard ES2016 JavaScript and has been supported in all modern browsers since 2016. The SWC generator transform should handle it rather than panicking.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0
  Available memory (MB): 24576
  Available CPU cores: 10
Binaries:
  Node: 20.20.0
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: 10.24.0
Relevant Packages:
  next: 16.1.6
  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?

Turbopack, SWC

Which stage(s) are affected?

next dev (local), next build (local)

Additional context

Root cause: The ** operator is the only right-associative binary operator in JavaScript. In SWC's ES2015 generator transform (swc_ecma_compat_es2015/src/generator.rs), all binary expressions are handled via visit_left_associative_bin_expr(), but ** is explicitly marked as todo!("right-associative binary expression") at line 507. When Turbopack's module analysis triggers this code path (via the styledComponents compiler option), it panics.

Confirmed on canary: Tested on [email protected] — the bug still exists (the todo!() is at the same location in swc_ecma_compat_es2015-42.0.0).

Real-world impact: This blocks Turbopack adoption for any project using styled-components alongside Web3/crypto libraries. Affected packages include:

  • permissionless (uses 10n ** 18n)
  • @noble/curves (uses _2n ** BigInt(254) extensively — foundational crypto library)
  • @walletconnect/utils (bundles noble-curves code)

Related:

extent analysis

Fix Plan

To fix the issue, we need to update the swc_ecma_compat_es2015 crate to handle the right-associative binary expression **.

  • Update swc_ecma_compat_es2015 to the latest version.
  • If the issue still exists, we need to manually patch the swc_ecma_compat_es2015 crate.

Here is an example of how to patch the visit_bin_expr function in generator.rs:

// Patched visit_bin_expr function
fn visit_bin_expr(&mut self, expr: &BinExpr) {
    match expr.op {
        // ...
        BinOp::Exp(_) => {
            // Handle the ** operator
            self.visit_exp_expr(expr);
        }
        // ...
    }
}

// New visit_exp_expr function
fn visit_exp_expr(&mut self, expr: &BinExpr) {
    // Handle the right-associative binary expression **
    // ...
}

Note: The above code is a simplified example and may not be the actual implementation.

Verification

To verify that the fix worked, run the following commands:

  • npm run dev (runs next dev --turbopack)
  • Open http://localhost:3000 in the browser. The page should compile and render successfully.

Extra Tips

  • Make sure to update all dependencies to the latest version.
  • If the issue still exists after updating, try to manually patch the swc_ecma_compat_es2015 crate.
  • Consider opening an issue in the swc repository to report the problem and get an official fix.

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

nextjs - 💡(How to fix) Fix Turbopack: panic on `**` (exponentiation) operator in node_modules when `compiler.styledComponents` is enabled [1 participants]