Skip to content

feat(react): adopt selective WebAPI DOM types [Codex] - #1

Open
jderochervlk wants to merge 13 commits into
masterfrom
feat/webapi-dom-profile
Open

jderochervlk wants to merge 13 commits into
masterfrom
feat/webapi-dom-profile

Conversation

@jderochervlk

@jderochervlk jderochervlk commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Migrate React's DOM and data bindings to WebAPI types. The current selection is DOMTree, History, Location, Touch, DataTransfer, and FormData: 27 WebAPI + 9 React = 36 source modules, pinned to WebAPI 691bc3f20dc5d621d22f5bf9931b4ec086542d5f from #416, stacked on #415. Nullable event targets/views and clipboard data use options; touch getters return TouchList. ReactDOM.FormData.t shares WebAPI.FormData.t's identity while its existing helpers and boxed String/File return variants remain intact. JsxDOM ownership remains the separate PR #2.

A separate cleaned-up migration candidate is proposed upstream in rescript-lang#165. That branch contains migration documentation, nullable DOM helper fixes, and packed-consumer checks, but no benchmark files. It remains draft until the required WebAPI features are published.

This branch retains the benchmarking tools and results. The separate 30-run comparison below measures unchanged upstream bb34644 on ReScript 12.3.1 and 13.0.0-alpha.7 against the hardened candidate 5010c94 on v13. The candidate's later test-only commit dbd1f13 leaves measured sources/configuration unchanged.

Current narrow-data integration (10 runs)

Fresh same-session medians in milliseconds, ten samples per mode. Except for the explicit v12 row, every case uses ReScript 13.0.0-alpha.7. Both unchanged baselines have identical pre-migration sources and no WebAPI dependency.

Case WebAPI modules Clean Cached no-op Single-file rebuild
Unchanged React, ReScript 12.3.1 0 133.04 44.60 76.93
Unchanged React, ReScript 13.0.0-alpha.7 0 86.29 42.13 64.86
Previous core-backed selection, data placeholders retained 15 129.04 48.00 74.06
Current PR #1, narrow data features 27 127.57 48.31 69.89
Same migrated sources, broad UIEvents + Fetch 102 206.83 55.09 74.34
PR #2, JsxDOM removed on this base 27 175.80 48.86 108.16

Narrow27 and broad102 have identical React source hashes and WebAPI inputs; only feature selection differs. The prior 15 control and narrow27 have overlapping ranges; this does not establish that adding APIs speeds up builds. Both remain slower than unchanged v13 React. PR #2's clean and edited medians remain higher than this PR's.

Recorded 2026-11-17, 07:21:06–07:21:36 UTC−05:00 (block-start timestamps), two five-run blocks with reversed order. The broad clean block medians varied from 184.43 to 256.99 ms; these laptop results are not precise general performance claims. Current report, all 180 samples, source revisions, ranges, and reproduction commands.

The new integration and its measurements are separate from the hardened upstream candidate below. That candidate and its 30-run report were preserved without rewriting their results. The optional FileList feature remains out of scope; migration notes describe the public type changes.

Separate hardened-candidate comparison (30 runs)

Median milliseconds, 30 runs per configuration per mode, with randomized configuration order within each round:

Configuration Clean Cached no-op Single-file rebuild
Unchanged upstream, ReScript 12.3.1 131.12 45.54 79.04
Unchanged upstream, ReScript 13.0.0-alpha.7 88.78 43.62 64.38
Hardened migration, ReScript 13.0.0-alpha.7 127.56 47.51 70.33

Against unchanged v13, the migration's medians are 43.7%, 8.9%, and 9.2% higher, respectively. This is an interoperability/type-safety change, not a build-speed improvement. The migrated configuration requires v13; it was not measured on v12.

See the focused report, reproduction runner, and all 270 raw samples. The report includes observed ranges, bootstrap intervals, exact source revisions, and limitations; OS caches and machine power/background activity were not controlled.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T12:32:42.424099Z 7aa9356 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jderochervlk jderochervlk changed the title refactor(react): migrate DOM bindings and profile builds [Codex] perf(react): migrate DOM bindings and profile six-module builds [Codex] Nov 16, 2026
@jderochervlk jderochervlk changed the title perf(react): migrate DOM bindings and profile six-module builds [Codex] perf(react): migrate DOM bindings with selective WebAPI features [Codex] Nov 17, 2026
jderochervlk added a commit to rescript-lang/experimental-rescript-webapi that referenced this pull request Nov 17, 2026
React's DOM bindings need element, history, and location types, but
History and Location currently belong to the Window feature. Selecting
those types therefore also compiles the broader Window dependency graph.

Add independent `WebAPI.History` and `WebAPI.Location` features and move
their source files into their own directories. History depends only on
the standard library; Location depends on core DOM. Window includes both
features, preserving existing module names and type identities.

Consumers can select `WebAPI.DOMNodes`, `WebAPI.History`, and
`WebAPI.Location` without enabling Window. The feature-ownership checks
register both new source groups and guard missing features and duplicate
public-module ownership. The API guide documents the narrower selection.

The compiler upgrade has already landed in #414. This branch now
incorporates that main-branch update and retains its compiler checks,
documentation renderer, and typed-array fixture. The remaining diff is
limited to the History/Location feature split, its documentation, and
feature validation.

The further selective DOMTree/CSS layout is separate in #415; the React
profiling and dependent JSX work remain in
jderochervlk/rescript-react#1 and
jderochervlk/rescript-react#2.
@jderochervlk jderochervlk changed the title perf(react): migrate DOM bindings with selective WebAPI features [Codex] feat(react): adopt selective WebAPI DOM types [Codex] Nov 17, 2026
jderochervlk added a commit to rescript-lang/experimental-rescript-webapi that referenced this pull request Nov 17, 2026
React bindings need clipboard data, touch lists, and FormData types
without enabling the complete UIEvents and Fetch groups. Add four
independently selectable features while retaining the existing broad
features as compatibility umbrellas.

- **WebAPI.Touch** owns Touch and TouchList and depends only on DOM.
- **WebAPI.FormData** owns FormData and its unboxed entry-value union
and depends only on DOM.
- **WebAPI.FileEntries** moves the five existing legacy file-entry
modules intact, preserving the API needed by `webkitGetAsEntry` without
pulling in streams or modern filesystem handles.
- **WebAPI.DataTransfer** owns the transfer/item/list modules and
includes DOMTree and FileEntries, preserving `setDragImage` and
`webkitGetAsEntry` at their existing public paths.

Small representations now belong to the existing public API modules.
UiEventsTypes and FetchTypes retain representation/constructor
re-exports; file/blob signatures use their equal DOM types. Basic DOM is
unchanged. This adds no backing-holder modules and keeps existing public
operation names, privacy, nullability, and unboxed representations.

### Narrow dependency selection

With DOMTree + History + Location, adding Touch + DataTransfer +
FormData compiles **27 WebAPI source modules**, versus **102** with
broad UIEvents + Fetch. Standalone Touch and FormData each compile five
sources including DOM. These are compiler-inventory counts, not
build-speed claims. FileList operations remain an explicit broader File
opt-in; the optional separate FileList feature is not included.

The change includes narrow and packed-consumer fixtures, excluded-module
checks, source-inventory assertions, legacy type/constructor
interoperability, and native form-data/transfer/touch coverage. It does
not replace React's boxed form-value variant with WebAPI's unboxed
union.

### Prerequisite

Stacked on
#415.
The new branch was created from current `origin/main` at `20d11da1`
(including merged #413), then merged #415's prerequisite changes. This
PR targets #415's branch to keep its review diff limited to the
data-feature split; retarget to main after #415 merges.

Follow-on consumers are
jderochervlk/rescript-react#1 and
jderochervlk/rescript-react#2. Existing
profiling results are not measurements of this new integration.
jderochervlk added a commit to rescript-lang/experimental-rescript-webapi that referenced this pull request Nov 17, 2026
Stacked on
#413.
This replaces the earlier six-module consolidation with selective
feature boundaries.

Keep basic `DOM.res` and seven CSS declaration modules byte-for-byte
unchanged from the History/Location baseline. Add `WebAPI.DOMTree` for
the existing rich tree records and `WebAPI.CSSOMCore` for the CSS
modules those records need. DOMNodes and CSSOM continue to include their
required features, preserving their existing public APIs.

Move DOMStringMap alongside DOMTree and move only the small generic
HTMLCollection representation into DOMTree, retaining the public
collection alias and methods. CSS modules keep their original records
and operations together rather than introducing a large shared-record
layer. The existing fields, generic parameters, privacy, constructors,
and runtime behavior are preserved; all 338 existing modules emit
identical JavaScript to baseline.

React can select `WebAPI.DOMTree`, `WebAPI.History`, and
`WebAPI.Location`: 15 WebAPI source modules rather than 59. The
controlled comparison recorded a 122.27 ms median clean React build,
effectively tied with the earlier six-module version's 121.48 ms,
without enlarging basic DOM. The original 59-module selection measured
196.98 ms in that sample. Timings have substantial variance and are not
a universal performance guarantee.

The seven CSS modules' operations are intentionally included in
CSSOMCore. Element, Node, HTMLCollection, Event, geometry, Animation,
Window, and Document operations still require their respective features.
CSSOM does not select DOMTree.

The dependent React migration, full raw measurements, consumer costs,
and reproduction details are in
jderochervlk/rescript-react#1. Its separate
JsxDOM removal is jderochervlk/rescript-react#2.
Style-input and synthetic-event ownership changes remain outside this
PR.
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.

1 participant