Skip to content

chore(app): replace core-js with local shims - #59007

Merged
kitlangton merged 1 commit into
devfrom
drop-core-js
Oct 25, 2026
Merged

kitlangton merged 1 commit into
devfrom
drop-core-js

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What it does

Drops the core-js dependency from the app. runtime/polyfills.ts pulled it in for three APIs (Map.groupBy, Promise.withResolvers, Promise.try); it now has small local shims instead.

How it works

  • Electron 44 ships a Chromium far newer than 128 (the first with Promise.try), so the desktop app never needs a polyfill.
  • The web app builds with target: "esnext" and has no browserslist, and it is served to Safari. Map.groupBy and Promise.withResolvers need Safari 17.4, Promise.try needs 18.2, and the app calls all three. So the polyfills can't be dropped outright.
  • Each shim installs only when the native API is missing, so Electron and current browsers run the native code.

Risk

Web app on Safari older than 18.2 only. The shims follow the spec for the cases the app uses (no iterable-edge-case shimming beyond that). The desktop app is unaffected.

Proof

  • bun test for src/runtime/polyfills.test.ts (removes the natives, loads the shims, checks grouping order and index, resolver settling, synchronous run and throw isolation): 3 pass.
  • bun typecheck in packages/app: clean.
  • bun script/lint-changed.ts origin/dev: 0 problems.

@opencode-agent opencode-agent Bot 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.

Looks good. core-js was only imported in runtime/polyfills.ts, so it can be dropped. Each shim only installs when the native API is missing, and for the ways the app calls them they behave like the native APIs: groups keep first-seen order and get the index, resolvers settle the promise, and Promise.try runs the callback synchronously and turns a throw into a rejection.

How I checked: the new polyfills.test.ts passes (3/3), and tsc -b in packages/app is clean. I couldn't test an older Safari end to end.

Public API: unchanged.

No concerns.

@kitlangton
kitlangton merged commit 798971c into dev Oct 25, 2026
21 checks passed
@kitlangton
kitlangton deleted the drop-core-js branch October 25, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant