Skip to content

fix: use temporal-polyfill via npm overrides to resolve JSBI issues#442

Merged
jens-maus merged 1 commit intojens-maus:masterfrom
KristjanESPERANTO:fix/temporal-polyfill-bigint
Feb 3, 2026
Merged

fix: use temporal-polyfill via npm overrides to resolve JSBI issues#442
jens-maus merged 1 commit intojens-maus:masterfrom
KristjanESPERANTO:fix/temporal-polyfill-bigint

Conversation

@KristjanESPERANTO
Copy link
Contributor

@KristjanESPERANTO KristjanESPERANTO commented Feb 3, 2026

Fixes #441

Problem

Users cannot upgrade from v0.22.1 to v0.23+ when using Next.js with Turbopack due to bundler errors:

Error: e.BigInt is not a function

The issue occurs because rrule-temporal depends on @js-temporal/polyfill, which uses the JSBI library to polyfill BigInt. Modern bundlers like Turbopack and Webpack fail to properly tree-shake or optimize JSBI's emulation code.

Solution

This PR uses npm overrides to replace @js-temporal/polyfill with temporal-polyfill, which uses native BigInt instead of JSBI. Both polyfills implement the same Temporal API and are compatible via duck-typing.

Changes:

  • Added npm override in package.json to redirect @js-temporal/polyfill to temporal-polyfill@^0.3.0
  • Added tests to verify JSBI is removed and correct polyfill is loaded

Why npm overrides?

This isn't the ideal solution, but it seems the most pragmatic approach because:

  1. The rrule-temporal maintainer does not intend to switch to temporal-polyfill (see rrule-temporal/issue #94).
  2. @js-temporal/polyfill PR #167, which would allow users to choose between JSBI and native BigInt, has not been merged and is stalled for a long time.
  3. Once Node.js ships native Temporal support, all polyfills become obsolete anyway

Impact

  • Works with Next.js Turbopack and Webpack
  • Smaller bundle size
  • Native BigInt operations instead of JSBI emulation
  • Better tree-shaking in modern bundlers

Summary by CodeRabbit

  • Chores

    • Updated Temporal polyfill dependency to use an alternative package implementation.
  • Tests

    • Added test suite to verify Temporal polyfill dependency resolution and module loading behavior.

Fixes jens-maus#441

Resolves BigInt/JSBI compatibility issues with bundlers like
Next.js Turbopack and Webpack by using npm overrides to replace
@js-temporal/polyfill with temporal-polyfill (FullCalendar).

Note: While npm overrides is not the ideal solution, this approach is
acceptable as a temporary measure because:
- rrule-temporal maintainer declined switching to temporal-polyfill
  (see ggaabe/rrule-temporal#94)
- The polyfill will be removed entirely once Node.js ships native
  Temporal support (planned for future Node.js versions)
- This provides immediate relief for users hitting the JSBI bundler bug

Changes:
- Add npm overrides to redirect @js-temporal/polyfill → temporal-polyfill
- Add tests to ensure temporal-polyfill is used and JSBI is not installed

Benefits:
- Eliminates JSBI dependency completely -> smaller bundle size
- Better compatibility with Next.js, Turbopack, and Webpack
- Uses native BigInt instead of polyfill (Node 18+ has native support)

The npm overrides feature ensures that rrule-temporal's transitive
dependency on @js-temporal/polyfill is replaced with temporal-polyfill,
avoiding the 'e.BigInt is not a function' error that occurs when JSBI
fails to load correctly in certain build environments.

See also:
- js-temporal/temporal-polyfill#231
- ggaabe/rrule-temporal#94
- https://github.com/fullcalendar/temporal-polyfill
@coderabbitai
Copy link

coderabbitai bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

This pull request switches the temporal polyfill from @js-temporal/polyfill to npm:temporal-polyfill@^0.3.0 using npm overrides, and adds tests to verify correct polyfill resolution. A lint rule is disabled to accommodate the dependency configuration.

Changes

Cohort / File(s) Summary
Dependency Configuration
package.json
Removed direct @js-temporal/polyfill dependency; added npm overrides to map it to temporal-polyfill@^0.3.0. Added import-x/no-extraneous-dependencies lint rule disable.
Polyfill Verification Tests
test/polyfill-check.test.js
New test suite verifying JSBI is not installed, @js-temporal/polyfill resolves to temporal-polyfill, and runtime module loading confirms correct package name.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A BigInt bug brought tears to the day,
But a polyfill swap saved the way!
Temporal flows through temporal-polyfill's embrace,
Tests now ensure we're in the right place. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: replacing @js-temporal/polyfill with temporal-polyfill via npm overrides to fix JSBI-related issues.
Linked Issues check ✅ Passed The PR directly addresses issue #441 by implementing a solution to replace the JSBI-based @js-temporal/polyfill with temporal-polyfill, which resolves the 'e.BigInt is not a function' error in Next.js with Turbopack.
Out of Scope Changes check ✅ Passed All changes are scoped to resolving the JSBI issue: package.json dependency override, lint rule addition, and verification tests. No unrelated changes detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jens-maus jens-maus merged commit 3bba517 into jens-maus:master Feb 3, 2026
16 checks passed
@KristjanESPERANTO KristjanESPERANTO deleted the fix/temporal-polyfill-bigint branch February 3, 2026 20:09
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.

Can't update from 0.22.1 - e.BigInt is not a function

2 participants