Skip to content

fix: avoid bigint exponentiation for Turbopack compatibility#504

Open
skyc1e wants to merge 1 commit into
pimlicolabs:mainfrom
skyc1e:fix/turbopack-bigint-exponentiation
Open

fix: avoid bigint exponentiation for Turbopack compatibility#504
skyc1e wants to merge 1 commit into
pimlicolabs:mainfrom
skyc1e:fix/turbopack-bigint-exponentiation

Conversation

@skyc1e
Copy link
Copy Markdown

@skyc1e skyc1e commented Apr 7, 2026

Replaces 10n ** 18n and BigInt(1e18) with 1_000_000_000_000_000_000n in estimateErc20PaymasterCost.

Two problems in the original code:

  • 10n ** 18n crashes Turbopack — it doesn't support the ** operator with bigint operands yet ("right-associative binary expression not yet implemented").
  • BigInt(1e18) on the adjacent line converts a Number to BigInt; 1e18 is at the edge of Number.MAX_SAFE_INTEGER and the pattern is imprecise in general.

A bigint literal avoids both issues. Low risk: replaces a bigint exponent expression and a Number-to-BigInt cast with an equivalent bigint literal, avoiding the Turbopack parser limitation without changing the computed value.

Closes #499

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 7, 2026

⚠️ No Changeset found

Latest commit: be651b5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@skyc1e skyc1e force-pushed the fix/turbopack-bigint-exponentiation branch from 92a791d to be651b5 Compare April 7, 2026 21:20
Replace `10n ** 18n` and `BigInt(1e18)` with `1_000_000_000_000_000_000n`
in estimateErc20PaymasterCost.

`10n ** 18n` crashes Turbopack ("right-associative binary expression
not yet implemented"). `BigInt(1e18)` passes through a Number first,
which is technically imprecise for values near MAX_SAFE_INTEGER.

A bigint literal avoids both problems.

Closes pimlicolabs#499
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Turbopack fails to analyze permissionless ESM module – "right-associative binary expression not yet implemented"

1 participant