[lexical-headless] Feature: @lexical/headless/dom module for easier SSR#7833
Merged
etrepum merged 8 commits intofacebook:mainfrom Sep 24, 2025
Merged
[lexical-headless] Feature: @lexical/headless/dom module for easier SSR#7833etrepum merged 8 commits intofacebook:mainfrom
etrepum merged 8 commits intofacebook:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
ivailop7
previously approved these changes
Sep 22, 2025
Collaborator
Author
|
I will wait to merge this until after #7706 to avoid approval and merge conflict churn on that larger PR |
Collaborator
Author
|
@ivailop7 this needs a re-approval after fixing the merge conflict |
ivailop7
approved these changes
Sep 24, 2025
Collaborator
Done! |
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.
Description
This adds a new entrypoint to
@lexical/headlessat@lexical/headless/domthat uses conditional exports so that importing it from node brings in a happy-dom implementation ofwithDOMand importing it from the browser brings in a trivialwithDOM = (f) => f(window)implementation. This is using the same sort of trick that react-dom uses to have separate implementations for react-server and everything else.RE #4960 - Not closing this one because it could use examples and maybe some framework support. Could even implement hydration either with JSON (like react with some json blob on the page) or HTML (if the user is careful to have an exportDOM/importDOM that round-trips). A react-server conditional export somewhere in @lexical/react would possibly make sense for that use case.
Closes #3616
Test plan
Adds unit tests. Manually tested that adding withDOM to the playground brings in the trivial browser version.
Follow-up work would be to add examples and more usage, but those are a lot easier to write once there is a version published to npm (at least a nightly).