fix: enable React Compiler for slate/ directory#2403
Open
christianhg wants to merge 2 commits intomainfrom
Open
fix: enable React Compiler for slate/ directory#2403christianhg wants to merge 2 commits intomainfrom
christianhg wants to merge 2 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: d136d23 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📦 Bundle Stats —
|
| Metric | Value | vs main (055bdb1) |
|---|---|---|
| Internal (raw) | 763.1 KB | +8.1 KB, +1.1% |
| Internal (gzip) | 144.2 KB | +2.2 KB, +1.6% |
| Bundled (raw) | 1.37 MB | +8.1 KB, +0.6% |
| Bundled (gzip) | 307.0 KB | +2.2 KB, +0.7% |
| Import time | 99ms | +1ms, +0.8% |
@portabletext/editor/behaviors
| Metric | Value | vs main (055bdb1) |
|---|---|---|
| Internal (raw) | 467 B | - |
| Internal (gzip) | 207 B | - |
| Bundled (raw) | 424 B | - |
| Bundled (gzip) | 171 B | - |
| Import time | 6ms | -0ms, -0.8% |
@portabletext/editor/plugins
| Metric | Value | vs main (055bdb1) |
|---|---|---|
| Internal (raw) | 2.5 KB | - |
| Internal (gzip) | 910 B | - |
| Bundled (raw) | 2.3 KB | - |
| Bundled (gzip) | 839 B | - |
| Import time | 12ms | -0ms, -0.6% |
@portabletext/editor/selectors
| Metric | Value | vs main (055bdb1) |
|---|---|---|
| Internal (raw) | 60.2 KB | - |
| Internal (gzip) | 9.4 KB | - |
| Bundled (raw) | 56.7 KB | - |
| Bundled (gzip) | 8.6 KB | - |
| Import time | 10ms | +0ms, +0.3% |
@portabletext/editor/utils
| Metric | Value | vs main (055bdb1) |
|---|---|---|
| Internal (raw) | 24.2 KB | - |
| Internal (gzip) | 4.7 KB | - |
| Bundled (raw) | 22.2 KB | - |
| Bundled (gzip) | 4.4 KB | - |
| Import time | 9ms | +0ms, +0.7% |
🗺️ . · ./behaviors · ./plugins · ./selectors · ./utils · Artifacts
Details
- Import time regressions over 10% are flagged with
⚠️ - Sizes shown as raw / gzip 🗜️. Internal bytes = own code only. Total bytes = with all dependencies. Import time = Node.js cold-start median.
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.
The React Compiler has been enabled for the editor package but the entire
slate/directory was excluded via asourcesfilter inpackage.config.ts. PR #2387 removed the biggest blocker (all WeakMap-based DOM mapping), so the remaining violations are smaller and more mechanical.This PR fixes the remaining React Compiler violations in
slate/and removes the exclusion filter, bringing the vendored Slate layer under compiler optimization.The critical fixes are render-time mutations of the editor singleton (
editor.isNodeMapDirty,editor.readOnly,editor.forceRender) that have been moved intouseIsomorphicLayoutEffect. Thestate.hasMarkPlaceholderfield, which was mutated on auseMemo'd object during render, is now computed as a local variable and synced to a ref via a layout effect for the DOM selection sync to read.The
useDecorationsByChildhelper inuse-children.tsxused a ref-as-memoization-cache pattern that mutateduseRef().currentduring render. This has been replaced with auseMemothat compares against a previous-value ref updated only in layout effects.Three hooks use
'use no memo'as an escape hatch:useGenericSelector(the selector system core, same ref-during-render pattern as react-redux'suseSelector),useDecorations(intentionally creates a new selector closure every render), andTextString(layout effect with no deps that must run on every render to sync DOM text content).useIsMountedwas rewritten from a ref-read-during-render pattern touseState.