Skip to content

utils: $utils.date.format makes a new Intl.DateTimeFormat on each call #62

Closed

Description

@lukeed

$utils.date.format(value, options) in packages/bongo/src/utils/config.ts makes a new Intl.DateTimeFormat on each call that has options. Making a formatter is slow. On Bun 1.4.3 (M1 Max), 20,000 calls with { dateStyle: 'long' } take 570 ms. One shared formatter takes 10 ms for the same 20,000 dates.

A site that shows a date on each of its 10,000 pages, and again in its lists, pays this on each build. The bench site of #56 had the same pattern in its own $utils; one shared formatter saved about 0.4 s of its build.

Direction

Keep a formatter for each $site.lang and set of options. Make the key from the options with their keys sorted. Limit the cache size, because the options can come from content.

Acceptance

  • Each call returns the same text as before.
  • A test covers two calls with the same options in a different key order.

Activity

  1. added
    enhancement
    on Oct 15, 2026
  2. added 2 commits that reference this issue on Oct 15, 2026
    e076ca2
    1b2f1d4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions