temporal-polyfill

A lightweight, spec-compliant polyfill for the JavaScript Temporal API, the modern successor to Date.

Library
npm
v1.0.4
772stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
79/100Good
Development Activity84
Maintenance84
Community48
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
81/100Excellent
Architecture82
Code Quality85
Innovation80
Learning Curve75

temporal-polyfill brings the TC39 Temporal proposal to environments that don’t yet support it natively, giving developers a spec-compliant Temporal global (or side-effect-free ponyfill) years before every target browser and Node.js version ships it built in. It supports all time zones and, through its /full/ entrypoints, an expanded set of calendar systems including Buddhist, Chinese, Hebrew, Islamic, and Japanese calendars, alongside the default ISO 8601 and Gregorian calendars covered by the smaller default build.

What sets it apart from other Temporal polyfills is its size and flexibility: at roughly 19.5 kB minified and gzipped, it is well under half the footprint of @js-temporal/polyfill, and it ships an additional tree-shakeable function API (temporal-polyfill/fns/*) for teams that want to import only the specific date/time operations they use. A companion codemod package can later rewrite function-API call sites back into native Temporal.* method calls once a project’s runtime environments no longer need the polyfill, making adoption a two-way door rather than a permanent dependency.

What You Get

  • Global, ponyfill, and shim installation modes for the full Temporal class API
  • A side-effect-free, tree-shakeable function API under temporal-polyfill/fns/* for bundle-size-sensitive consumers
  • Extended calendar-system coverage (Buddhist, Chinese, Hebrew, Islamic, Japanese, Persian, and more) via /full/ entrypoints
  • Prebuilt CDN bundles for both the basic and full calendar builds
  • TypeScript type overrides so globalThis.Temporal is correctly typed after a global install
  • A companion codemod package that rewrites function-API calls back into native Temporal.* syntax once native support lands

Common Use Cases

  • Shipping calendar, scheduling, or booking UI features today while waiting for universal native Temporal support
  • Building component libraries (date pickers, schedulers) around the tree-shakeable function API as a deletable peer dependency
  • Running Node.js services on older LTS versions (16-20) that predate native Temporal support
  • Serving users who need non-Gregorian calendar systems such as Hijri, Hebrew, or Japanese calendars

Under The Hood

Architecture The repository is a pnpm-workspace monorepo with four packages — polyfill (the published library), utils, spec, and codemod. Inside polyfill, a pure calculation engine (src/internal/* — ISO calendar math, field parsing/refinement, rounding, diffing, time zone parsing) is shared by two public surface layers: a class-based API mirroring the spec’s Temporal.* classes (src/classApi/basic and src/classApi/full, using a branding/slots pattern defined in src/apiHelpers/branding.ts and src/internal/slots.ts) and a tree-shakeable function API operating on plain records (src/funcApi/*). The basic and full class-API trees are structurally parallel, differing only in which calendar implementations from src/exoticCalendars/* they wire in, letting bundlers exclude unused calendar code. Because both API layers depend on the same internal slot/branding representation, changing that core module would ripple through the entire public surface.

Tech Stack The codebase is almost entirely TypeScript (94.5%), built with tsc for declarations and Rollup (@rollup/plugin-node-resolve, rollup-plugin-dts, @rollup/plugin-terser) for bundling, with a pluggable minification step supporting either Terser or SWC. Package management uses pnpm workspaces, and Biome (pinned to a specific version to avoid a known regression) replaces ESLint/Prettier for linting and formatting. Hand-written Node build scripts (scripts/bundle.js, scripts/manifest.js, scripts/minify.js) drive the many package.json exports subpaths the library ships.

Code Quality Tests are colocated *.test.ts files run through Vitest, including dedicated coverage suites that verify every function-API type mapping is exercised (fns-api-coverage.test.ts, fns-direct-coverage.test.ts, fns-nondirect-coverage.test.ts, fns-type-coverage.test.ts). Beyond unit tests, the project runs the official test262 spec-conformance suite against both the basic and full builds in CI, maintaining a small, explicitly documented list of intentional deviations. CI matrices across six Node.js versions and multiple minifiers, running lint, build, and the full test suite on every push to main.

API Design The standout design choice is offering two parallel APIs over the same engine: a class-based API matching the official Temporal proposal’s shape one-for-one, for near-zero migration friction, and a tree-shakeable function API for bundle-conscious consumers, with a codemod bridging the two. Naming follows the TC39 Temporal proposal’s own conventions closely, minimizing the learning curve for anyone familiar with the spec or MDN docs. Getting started requires a single import with no configuration for the common case, though pre-6.0 TypeScript users need one extra type-only import — a small, well-documented piece of friction. Documentation is thorough, with every entrypoint demonstrated in the README and a dedicated docs/fns/ tree covering the function API type by type.

Used by 6 apps in this directory

TypeScript
94%
AGPL 3.0

Element Web

Team Chat · Collaboration

13,437

A polished, self-hostable Matrix client for secure, decentralized messaging and collaboration that puts your organization in full control of its data.

View details
96
Repo Health
83
Technical
65
Dependency
Built with
TypeScript94%
Updated yesterday
TypeScript
65%
Other

Epicenter

Knowledge Management · Note Taking · Developer Tools

4,790

A local-first monorepo led by Whispering, an open-source speech-to-text app, built on an MIT toolkit that turns your data into plain Markdown and SQLite files you own instead of a database you rent.

View details
88
Repo Health
90
Technical
68
Dependency
Built with
TypeScript65%
Svelte13%
HTML12%
Updated yesterday
JavaScript
47%
MIT

Ghost

CMS · Blogging

55,191

Open source headless Node.js CMS for professional publishing, paid memberships, and newsletters with a fully owned audience.

View details
96
Repo Health
85
Technical
67
Dependency
Built with
JavaScript47%
TypeScript47%
Updated yesterday
TypeScript
88%
Apache 2.0

Medplum

Developer Tools · Databases · Authentication

2,657

An open-source, FHIR-native healthcare platform that gives developers a compliant backend, authentication, a React component library, and serverless bots to build clinical applications in weeks instead of years.

View details
93
Repo Health
90
Technical
72
Dependency
Built with
TypeScript88%
MDX10%
Updated yesterday
TypeScript
88%
MIT

Plasmic

CMS · Low Code Platforms · No Code Platforms

6,993

The open-source visual builder that lets teams design React apps and websites with drag-and-drop while integrating seamlessly with your codebase.

View details
81
Repo Health
78
Technical
64
Dependency
Built with
TypeScript88%
Updated yesterday
TypeScript
80%
Other

twenty

CRM

56,361

The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.

View details
92
Repo Health
82
Technical
64
Dependency
Built with
TypeScript80%
MDX17%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search