Skip to content

Polyfills cleanup - #2254

Merged
rymsha merged 1 commit into
masterfrom
2253-polyfills-cleanup
Aug 6, 2026
Merged

Polyfills cleanup#2254
rymsha merged 1 commit into
masterfrom
2253-polyfills-cleanup

Conversation

@rymsha

@rymsha rymsha commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Fixes #2253

XP 8 runs on GraalVM 25, which lets us drop most of the hand-rolled SSR polyfills:

  • TextEncoder: GraalJS provides native TextEncoder/TextDecoder via the js.text-encoding option (stable in GraalJS 25, default off). It is now enabled in EngineFactory, and the @sinonjs/text-encoding polyfill and dependency are removed. Bonus: SSR contexts also get a native TextDecoder, which the old polyfill never provided.
  • console: GraalJS provides a native console by default (js.console, stable, default on) with a fuller method set (log, debug, info, warn, error, assert, time, group, …) than the old print-based mapping — the shim in polyfillBasics.js was dead code.
  • polyfillBasics.js: with the console shim gone, only the minimal process shim remained — moved into nodePolyfills.ts and the file is deleted, so every SSR context loads one asset less.
  • timers: the ~70-line timers.ts (branded types, exported no-op functions, @ts-expect-error suppressions) is replaced with inline one-line ??= no-op shims in nodePolyfills.ts. Behavior preserved: setTimeout/setInterval still return 0, existing globals are never overwritten.
  • Also removed the now-unused @rollup/plugin-alias dependency and its stale @sinonjs/text-encoding alias from rollup.config.nodePolyfills.mjs.

Verification

  • ./gradlew test passes, including RendererTest.render_real_react_component_via_server_edge, which renders real React 19 through react-dom/server.edge against the production-compiled polyfill bundle — server.edge looks up TextEncoder at module-load time, so this exercises the native GraalJS implementation.
  • Jest (11/11), rollup polyfill build, and check:types:graal all pass.

🤖 Generated with Claude Code

XP 8 runs on GraalVM 25, which lets us drop most of the hand-rolled SSR
polyfills:

- TextEncoder: enable GraalJS's native TextEncoder/TextDecoder via the
  stable js.text-encoding option in EngineFactory; drop the
  @sinonjs/text-encoding polyfill and dependency.
- console: GraalJS provides a native console by default — the shim in
  polyfillBasics.js was dead code.
- polyfillBasics.js: move the remaining minimal process shim into
  nodePolyfills.ts and delete the file (one less asset to load into
  every SSR context).
- timers: replace timers.ts with inline one-line no-op shims in
  nodePolyfills.ts, preserving return values and the don't-overwrite
  guard.

Fixes #2253

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 22.85%. Comparing base (aef55db) to head (275030f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2254   +/-   ##
=======================================
  Coverage   22.85%   22.85%           
=======================================
  Files           1        1           
  Lines          35       35           
=======================================
  Hits            8        8           
  Misses         27       27           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rymsha
rymsha requested a review from anatol-sialitski August 6, 2026 07:16
@rymsha
rymsha merged commit 8f7942b into master Aug 6, 2026
5 checks passed
@rymsha
rymsha deleted the 2253-polyfills-cleanup branch August 6, 2026 07:20
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.

Polyfills cleanup

2 participants