Skip to content

feat(core): move GMT onto temporal-polyfill (CORE-108, #460) - #464

Open
craig-o-curtis wants to merge 44 commits into
mainfrom
460-core-108-move-gmt-onto-temporal-polyfill
Open

craig-o-curtis wants to merge 44 commits into
mainfrom
460-core-108-move-gmt-onto-temporal-polyfill

Conversation

@craig-o-curtis

@craig-o-curtis craig-o-curtis commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #460

Summary

GMT now runs on temporal-polyfill 1.0.9 in place of @js-temporal/polyfill 0.5.1. Every measured import is smaller, month arithmetic takes bounded time for any amount, and the workarounds that 1.0.9 does not need are gone. The Persian leap-year bug that held this PR back (#465) is fixed in 1.0.9.

What Changed

1. Library

  • GMT imports Temporal from temporal-polyfill/full/implementation, pinned at exactly 1.0.9, through src/internal/temporal.ts. Temporal, Intl and toTemporalInstant are re-exported from it.
  • Helper types that temporal-spec does not export live in src/internal/temporalTypes.ts.
  • A month amount too large for any date in range throws a RangeError before any polyfill arithmetic runs (temporalCompat/monthRange.ts). The time this takes does not grow with the amount.

2. Removed workarounds

3. Persian leap years

4. Weekly upgrade check

  • The swap leg of temporal-oracle.yml runs GMT's suite on the newest published temporal-polyfill beside the pinned one, and reports what an upgrade would change. It never asks for an older version than the pin.

5. Sizes, lint and Dox

  • scripts/bundle-size.mjs measures GMT's source on temporal-polyfill, which the budgets gate, and GMT 1.21.0 on @js-temporal/polyfill as published, for comparison. Budgets are reset.
  • The lint restrictions name both polyfill packages. Dox takes Temporal from @northguild/gmt, and a lint rule rejects a direct import of either polyfill.
  • /bundle-size compares GMT on both polyfills. /upstream covers the reports filed on each and what 1.0.9 fixed. The guides, mistakes pages and migrate page name temporal-polyfill.

Sizes, minified and gzipped, from bundle-size.json:

Import GMT on temporal-polyfill 1.0.9 GMT 1.21.0 on @js-temporal/polyfill 0.5.1
Whole library (root) 151.9 kB 154.9 kB
Polyfill alone 23.3 kB 44.2 kB
isValidDate 23.5 kB 44.6 kB
formatDate 33.7 kB 45.7 kB
addBusinessDays 24.9 kB 46.0 kB
chargeableDays 28.8 kB 60.1 kB
dutyViolations 37.7 kB 69.9 kB

The left column is this branch's source, so it includes what GMT gained after 1.21.0.

Breaking changes

  • compareDurations returns 0 for two durations with the same fields, where 1.21 returned null when relativeTo was in a non-ISO calendar and adding them went past Temporal's date range.
  • smallestUnit in parseDuration and toStringSmallestUnit in DurationStringOptions no longer accept "minute" or "minutes" at the type level. Run-time behaviour is unchanged.
  • Some Temporal.* type names change. The changeset has the full table.

Validation

  • CI on 829f8f3 passed every check; the release pack dry run was skipped. That covers the GMT suite on Node 22, 24 and 26, the time zones on each, and the Dox browser tests in Chromium and WebKit.
  • fb5d309, the commit after it, only removes the pnpm release-age exclusion for 1.0.9. A frozen install passes the supply-chain check without it.
  • Story consistency fails on fb5d309 because of main. fix(dox): press the Sunshine inset frames at rest, and slim the Dox CI #595 added describe.skipIf in sound-peaks.browser.test.ts and zone-map-forced-colors.browser.test.ts, which scripts/test-markers.mjs rejects. This PR changes neither file. The check stops there, so its later steps did not run on this commit; they passed on 829f8f3.
  • Persian: Nowruz of every year from 1400 to 3100 AP matches native Temporal on 1.0.9. On 1.0.8, 78 of them were one day late.
  • Not run on 1.0.9: temporal-oracle.yml. Its last run on this branch was on 1.0.8 (5cfd1f2): the native suites passed in Chromium and Firefox and failed in Node and WebKit, and the polyfill swap legs were skipped.
  • Not verified: the removed workarounds in Firefox on the polyfill. Playwright Firefox does not launch on the local machine, and the PR checks have no Firefox job.

Risk / Impact

Medium. Every Temporal call in GMT now runs on a different implementation, and the diff touches about 600 files. Firefox is the open gap listed above.

Before merging

  • main passes Story consistency again.
  • temporal-oracle.yml runs on this branch with 1.0.9.
  • Close-out: the CORE-108 tracker row, and folding and deleting the two CORE-108 spec folders.

Release

.changeset/move-onto-temporal-polyfill.md, minor. Merging publishes nothing.

Release notes are reference, not a place to start, so the Changelog group
moves below Check. llms.txt lists its Changelog section last to match.
…ding

The landing has no sidebar, so a navigation to or from it used to cut the
sidebar away in one frame or pop it in. It now slides off to the left, or in
from the left, on the zone drawer's duration and sweep curve, with the same
band of ice light crossing it. The band moves to one shared token,
--gmt-sheen, that the drawer and the sidebar both read.

The sidebar's group also drops the backdrop-filter it took from the capture,
which left a sidebar-shaped blur over the hero after the sidebar had gone.
Reduced motion keeps the one-frame swap.
/why-gmt was the one Start here page on the splash template, so it had no
sidebar and no On this page list. It is now a normal doc page. The section
grid goes, the sections read top to bottom, and the Date bug section moves
up to follow the intro. Its heading is now a plain ## line in the page, so it
lists in On this page; WhyDateBug no longer draws one, and its card grid
answers to its own container instead of the grid cell.

Under the intro, a row of tiles gives the headline figures (tests, CI runs,
public functions, time zones, locales), each linked to its section. The
figures come from gmt-stats.json through why-gmt-figures.ts, which the page
and the Markdown twin both render.
The code blocks used Starlight's default Expressive Code themes, whose blues
blended into pages that are already mostly cyan. They now use a dark and a
light theme that code-themes.ts builds from the --gmt-syntax-* tokens when
the site builds: keywords purple, function names gold, strings green, numbers
and literals rose, types cyan, comments and punctuation dim ice. These are
the series colours the tools already use, through their -ink tokens.

Every token is held to the 7:1 code-frame floor in both themes. Starlight
still draws the frames, tabs and buttons. The widget call lines read the same
tokens, so they change colour with the code blocks.
The sidebar, the prev/next links and llms.txt now list install, core-rules, then the reasons
(why-gmt, compare, bundle-size) and upstream last. `astro.config.mjs` and `START_ORDER` change
together.
GMT now imports Temporal from `temporal-polyfill/full/implementation`, pinned at exactly 1.0.8,
through the one seam in `src/internal/temporal.ts`. Helper types that `temporal-spec` does not
export live in `src/internal/temporalTypes.ts`.

- A month amount too large for any date in range throws a RangeError before any polyfill
  arithmetic (`temporalCompat/monthRange.ts`), as the specification throws.
- Workarounds for `@js-temporal/polyfill` 0.5.1 that 1.0.8 does not need are removed, each after
  its repros passed on every engine: the clock, field search, fixed-day and non-ISO arithmetic,
  the Islamic era and ISO calendar readers, the zoned transition search, and the
  zoned-difference helpers.
- `ethiopic` and `coptic` compute in their own calendar, no longer through `ethioaa`.
- Year-month arithmetic calls `PlainYearMonth#add` and `#subtract` directly. The lowest
  year-month, -271821-04, throws even for a zero amount, as the specification says.
- The root devDependency `gmt-js-temporal-release` pins GMT 1.21.0, the last release on
  `@js-temporal/polyfill`, for the bundle-size comparison.
…CORE-108, #460)

Library code imports Temporal only from `internal/temporal`; a direct import of
`temporal-polyfill` or `@js-temporal/polyfill` is an error.
… (CORE-108, #460)

The swap leg of `temporal-oracle.yml` now runs GMT's suite on the newest published
`temporal-polyfill`, installed as `temporal-polyfill-candidate` beside the pinned 1.0.8, and
reports what would change on an upgrade. `scripts/swap-version.mjs` picks the version.

- The workaround registry, the compat snapshot and the canary reports follow the workarounds
  that remain on 1.0.8.
- D9 is retargeted: an out-of-range month amount must throw in time that does not grow with
  the amount.
`scripts/bundle-size.mjs` bundles two sets with the same esbuild settings: GMT's source on
`temporal-polyfill`, which the budgets gate, and GMT 1.21.0 on `@js-temporal/polyfill` as
published, which is reported only. `--json` writes both sets for the Dox `/bundle-size` page.
Budgets are reset to the new sizes.

The script also works when run from `apps/dox`, as the Dox build runs it: esbuild's input paths
are relative to the current directory.
Dox widgets import `Temporal` from `@northguild/gmt` and no longer depend on
`@js-temporal/polyfill`, so the site draws with the same polyfill the library ships. A lint rule
rejects a direct import of either polyfill package.
…#460)

Coptic no longer computes in `ethioaa`, so the row names what it checks: Amshir has 30 days.
Install is now first in Start here, so it closes with a short example: strings in and out, a calendar day across a clock change, and the fallback values in place of exceptions.
)

- `/bundle-size` charts and tabulates each polyfill alone and each single-function import, split
  into the polyfill and GMT's code, from the generated `bundle-size.json`. Green is
  `temporal-polyfill`, slate grey `@js-temporal/polyfill` as GMT 1.21.0 shipped it.
  `PolyfillCompare.astro` is the table and the charts' text alternative.
- The figures come from `bundle-size-figures.ts`, and the Markdown twin states the same values.
- The bar charts on /why-gmt and /bundle-size share `bar-chart-kit.ts`.
- `/upstream` lists the defects found in each polyfill, and the native-engine failures beside
  them.
- The install page names the polyfill each GMT version re-exports.
- The guides and the mistakes pages name `temporal-polyfill` 1.0.8 where they named
  `@js-temporal/polyfill` 0.5.1.
- The calendar-systems guide says GMT computes `ethiopic`, `ethioaa` and `coptic` each in its
  own calendar, and drops the section on runtime corrections that no longer exist.
- The reference corpus is regenerated from the library's JSDoc.
- AGENTS.md, the coding standards, the overviews and the audits name `temporal-polyfill`
  1.0.8 and the one import seam.
- The story file, the tracker row and the CORE-108 specs, which are folded into the story file
  when it closes.
- A first draft of the changeset (minor).
The two header buttons now show from the first paint in northguild.dev's
muted grey and turn cyan with their shine (`ng-shine-in`). Their colour
transition is off through the entrance so it cannot flash cyan early. The
hero entrance check counts every `ng-shine*` run as riding on a freeze.
…ecks

The group names already say Migrate and Checks, so the entries drop the
repeated words: `From Luxon`, `From native Temporal`, `Behaviour compared`,
`Canada 2026 clocks`. `/compare/` reads `GMT vs. the others`. Page titles
keep their full wording for headings and search.
…CORE-108, #460)

The Dox test rules keep class checks out of widget tests, so the check that a chart key sits inside `.not-content` moves to `content-list-rule.test.ts`, which already checks the CSS side of the same rule.
The sky's Sun, Moon and stars scaled only to the hero's viewport, not
to the Earth disc's size on screen, so zooming the globe grew the
disc without the sky moving to match: a Sun that sat at the rim at
rest could end up swallowed by a disc that had grown past it, or
read as hidden when the sky it's judged against never grew with it.
@craig-o-curtis craig-o-curtis added documentation Improvements or additions to documentation enhancement New feature or request gmt labels Nov 6, 2026
The sky drew stars out to 120 degrees from the point behind the Earth so the
hero corners are never bare, and the Sun and Moon used the same limit. A Sun
past 90 degrees is behind the reader, lighting the face they see, so drawing it
beyond the Earth put it below the horizon of every lit place on screen.

Also gives the hero-space test's globe stub the getZoom the sky now reads, and
lets the browser gate skip walk steps where the Sun is not drawn.
Reverts 7bfec9b and c7c38c1. Both now live on their own branch,
core-109-hero-sun-one-camera, with the rest of the hero Sun work.
… window (CORE-108, #460)

When a widget's mount threw, `renderWidget` kept its session open, so its
listener recorder stayed on `window` for every later file in the worker.
The leak guard then saw the recorder, not jsdom, as the caller of jsdom's
own selector listeners and failed `bundle-size-charts.test.ts` on Node 24
and 26.

- `renderWidget` ends the session and takes the recorder off when the load fails.
- The leak guard looks past the recorder's frame to find the caller.
- The leak guard names a file that leaves a listener method replaced.
- The leak guard tracks the targets it has wrapped, so it never wraps a test's own wrapper again.
@craig-o-curtis
craig-o-curtis marked this pull request as ready for review November 6, 2026 13:32
b50a60d moved the Changelog group to the end of the sidebar and of
llms.txt, but the built-site test still expected it after Start here.
The test only runs against a built site, so it failed in Story
consistency and not locally.

The tracker marks CORE-108 Done and adds CORE-109 (#467) at #45, so
the last cut ships CORE-109 to SPA-52 (#45–#49).
…sion (CORE-108, #460)

The Why this polyfill section takes its versions from the data only, so the wording names no release.
…108, #460)

The Tests job does not build `@northguild/gmt-oxlint`, so importing the Dox oxlint config failed
there. The guard now mocks the plugin's recommended rules, which never set
`no-restricted-imports`. Also formats `upstream-filings.json`.
@craig-o-curtis
craig-o-curtis marked this pull request as draft November 6, 2026 16:19
@craig-o-curtis

craig-o-curtis commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Back to draft until temporal-polyfill fixes two calendar bugs. The weekly check (#468) says when that happens.

No GMT release moves onto temporal-polyfill until releases fix both.

Every review thread so far has a reply. Once the fixes are out, this PR:

Then it goes back to ready for review.

@craig-o-curtis

Copy link
Copy Markdown
Contributor Author

Status on 27 November 2026: still parked. temporal-polyfill on npm is still 1.0.8.

Blockers

Found since the last update

  • Duration.compare with a plain relativeTo (Add only calendar units to a PlainDate relativeTo in Duration.compare fullcalendar/temporal-polyfill#130, open). The spec adds only the years, months and weeks to the date, but 1.0.8 adds the whole duration. So a large day or time amount throws "Out-of-bounds date" where the spec gives an answer, and compareDurations returns null. For example, PT3000000000H against P1Y from 2000-01-01 is 1 in native Temporal and throws on 1.0.8. A workaround, with a probe that turns it off once a release fixes it, is in progress on this branch.

This branch

The plan is the same as before. Once a release fixes Persian and Chinese and Dangi, this PR raises the pin, tests the first day of each affected year against native Temporal, updates the bundle-size figures and closes #465. Then it goes back to ready for review.

…as TC39 does (D35, CORE-108, #460)

temporal-polyfill 1.0.8 adds the whole duration to a plain relativeTo, so compareDurations
gave null where TC39 adds only the years, months and weeks and compares the days and time as
exact nanoseconds (fullcalendar/temporal-polyfill#130). PT3000000000H against P1Y from
2000-01-01 is 1, and -P1D against P1W from -271821-04-19 is -1.

- D35 workaround in internal/zonedDifference/plainCompare.ts: after the runtime throws a
  RangeError, with a plain relativeTo, a year, month or week on either side and the probe
  failing, compute DateDurationDays and Add24HourDaysToTimeDuration. It throws again where
  TC39 throws.
- Probe repros, isDurationCompareCompatNeeded, README row, trigger and removal step 35, the
  workarounds.mjs entry and the Dox compat row.
- A calendar-annotated plain relativeTo now resolves to a PlainDate, as Temporal does, so
  -271821-04-19[u-ca=gregory] no longer gives null.
- operations.ts loses dead code: the plain-context rounding path, compareAtLimit and the
  plain total and round helpers.
- The D22 and D35 removal steps name the functions to delete; fallow cannot report them.
…-onto-temporal-polyfill

- upstream-filings.json: main's synced fields, its new tc39/proposal-temporal#3343 entry and
  the outcome lines for fullcalendar/temporal-polyfill#127 and #132; this branch's gmtGuard and
  gmtNote values. #128 and #132 now name D33 as their guard, since temporal-polyfill keeps
  Chinese and Dangi on the host's Intl on purpose.
- sky-aim.test.ts and sky-names.test.ts, new on main, import Temporal from @northguild/gmt.
@craig-o-curtis

Copy link
Copy Markdown
Contributor Author

Status on 28 November 2026: still parked. temporal-polyfill on npm is still 1.0.8.

Blocker

No longer a blocker

Since the last update

This branch

The plan: once 1.0.9 is out, this PR raises the pin, tests the first day of each affected Persian year against native Temporal, retires D35, checks the PlainYearMonth.add change from fullcalendar/temporal-polyfill#129, updates the bundle-size figures and closes #465. Then it goes back to ready for review.

)

temporal-polyfill 1.0.9 ships the Persian leap-year fix (fullcalendar/temporal-polyfill#127, PR #131) and the `Duration.compare` fix from a plain `relativeTo` (#130), so GMT moves its pin from 1.0.8 to 1.0.9.

- Remove the D35 workaround: `plainCompare.ts`, its probe and repros, `isDurationCompareCompatNeeded`, the README rows, the `workarounds.mjs` entry and the Dox `WHAT_BREAKS` line. `durationCompare` calls `Temporal.Duration.compare` directly again.
- Regenerate the compat snapshot without D35 (17 groups, 0 removable on Node).
- Re-check every 1.0.8 claim in the source comments on 1.0.9; all hold. The D9 out-of-range timing is now about 3.5 s.
- Upstream filings: #127 released, #128 closed as working as intended (D33 stays), #134 fixed in 1.0.9, and contributor entries for #129 and #130.
- Docs: `/upstream/` Why this polyfill, the polyfill status table, the swap research, CORE-108 and the changeset size table.

pnpm-workspace.yaml carries a `minimumReleaseAgeExclude` for temporal-polyfill 1.0.9 and temporal-utils 1.0.5 until they are a day old; a follow-up commit removes it.
…ral-polyfill' into 460-core-108-move-gmt-onto-temporal-polyfill
…108, #460)

Checks 1 Farvardin of each year that follows one of the 78 Persian
years from 1502 to 2987 AP where the 33-year leap rule and ICU4X
disagree. The expected dates come from Node 26's built-in Temporal;
temporal-polyfill 1.0.8 gives each of them a day late, 1.0.9 matches.

Syncs the published test and run counts in gmt-stats.json, which
were stale after the D35 tests were removed.
…RE-108, #460)

temporal-polyfill 1.0.9 and temporal-utils 1.0.5 are more than a day
old, so pnpm accepts them without the exclusion. The frozen install
passes the supply-chain check without it.
@craig-o-curtis craig-o-curtis removed the parked Waiting on an upstream fix. Do not merge or review until the label is removed. label Nov 30, 2026
@craig-o-curtis
craig-o-curtis marked this pull request as ready for review November 30, 2026 17:52
@craig-o-curtis craig-o-curtis added ai skills Adds AI skills, commands, context, enhancements bug Something isn't working gmt monorepo pipes refactor labels Nov 30, 2026

@baldurpan baldurpan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-read what changed since I last reviewed at 11dbf6b: the PR's own seven commits, and the four merges of main, checked against the final tree. The move to temporal-polyfill 1.0.9 and the retirement of D35 hold up.

  • The Persian test has 78 rows. Each Nowruz date matches both Node's native Temporal and temporal-polyfill 1.0.9. The first day of every Persian year from 1 to 3500 AP also agrees between the two.
  • compareDurations gives the same answers as both runtimes on the range-edge and calendar-annotated relativeTo cases, and returns null where they throw.
  • tsc --noEmit is clean. The gmt vitest run passes, 78,184 tests in 1,034 files.
  • There are no conflict markers, and AGENTS.md and temporal-oracle.yml carry both main's calendar sweep and this PR's wording.

I did not run the Dox browser or chart tests locally, because they need the Dox build.

One nit is below.

`isTimeZoneEqualsCompatNeeded`, `timeZoneEquals`, `nowInstant`, `nowZonedDateTimeISO`, `nowPlainDateTimeISO`, `nowPlainDateISO` and `nowPlainTimeISO`, never the files behind them.
1. **Import surface.** `index.ts` is the only import surface. Call sites use `calendarDateAdd`,
`calendarDateUntil`, `calendarDateFromMonthCode`, `longestDayOfMonthCode`, `calendarFieldsOf`,
`assertMonthsInRange`, `MAX_MONTHS_IN_RANGE`, `isDurationCompareCompatNeeded`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isDurationCompareCompatNeeded went with D35 in bf98c65, but it is still listed here as part of the import surface. It is the only mention left in packages/gmt/src, so it can just be dropped from the list.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai skills Adds AI skills, commands, context, enhancements bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request gmt monorepo gmt pipes refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CORE-108 — Move GMT onto temporal-polyfill

2 participants