Repository navigation
refactor(react): own DOM props and remove JsxDOM [Codex] - #2
Open
jderochervlk wants to merge 13 commits into
Open
jderochervlk wants to merge 13 commits into
jderochervlk wants to merge 13 commits into
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1. Review against
feat/webapi-dom-profile; the DOM/WebAPI migration and profiling changes belong to that base PR.Define React's intrinsic DOM props and abstract ref type directly in rescript-react instead of aliasing
JsxDOM. Preserve the complete pinned alpha.7 prop surface, optionality, attribute mappings, and the publicReactDOM.domPropsname used by editor completion. All four JSX entry points accept the local record.The props use the existing React event/style modules and WebAPI-backed element/ref types. Add the missing
ReactEvent.Togglefamily with a nullable source getter typed asWebAPI.DOMTree.element, compatible with the base PR's selective 27-module dependency.The regression harness compiles a real consumer with
JsxDOMunavailable in a private runtime copy, checks full prop-surface parity, and covers JSX/SSR behavior and invalid prop/style/event/ref inputs. ExplicitJsxDOMannotations should migrate to the corresponding ReactDOM names.JsxDOMStyleandJsxEventaliases deliberately remain for later changes. This branch incorporates the updated base through ordinary merges, without force-pushing history. The incremental diff contains JsxDOM ownership changes, migration notes, regression checks, and the before/after measurements below.The latest base also supplies narrow clipboard, touch, and FormData types using 27 WebAPI source modules. This follow-up inherits those changes through ordinary merges, preserving boxed React form values and aligning Toggle's event contracts.
Refreshed build timings after JsxDOM removal
Same-session ReScript 13.0.0-alpha.7, same 27-module WebAPI snapshot, 10 samples per mode per version:
Both versions compile 27 WebAPI + 9 React sources. Clean and edited-build medians are higher after removal in both blocks; cached ranges overlap. This is a type-ownership change, not a demonstrated build-speed improvement.
Measured before source:
0e266a6496dbbf398001e1f9711b1c3a5e8a8b53; after:b35fa9d7de992e38333d58e8f164de223aa3a8e0; WebAPI:691bc3f20dc5d621d22f5bf9931b4ec086542d5f. Recorded on 2026-11-17 UTC−05:00: before blocks 07:21:13 and 07:21:29, after blocks 07:21:19 and 07:21:22. These identify block starts before warm-up, not individual sample timestamps.The current report includes ranges, raw timestamped results, unchanged v12/v13 controls, and reproduction commands. Installation/cleanup are excluded; clean means compiler artifacts, not OS caches. These are library-build timings, not application JSX compilation or runtime measurements. Earlier 15-module measurements remain historical evidence.