[WIP] Refactor JSX to use intermediate representation#2976
Closed
karl wants to merge 1 commit intoprettier:masterfrom
Closed
[WIP] Refactor JSX to use intermediate representation#2976karl wants to merge 1 commit intoprettier:masterfrom
karl wants to merge 1 commit intoprettier:masterfrom
Conversation
2 tasks
Closed
Collaborator
|
@karl Is there anything I can do to help to go forward with this? :-) |
Collaborator
Author
|
Please feel free to take over from me as I’m afraid I just don’t have time to work on this at the moment. If you’d like to do that I’d be happy to take you through my thinking and help get you up to speed! |
Member
|
Closing this for now since we have #4753. Feel free to pick this up once that’s been merged! |
Collaborator
Author
|
Good call @j-f1 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This is a currently broken work in progress refactor of how we handle JSX. It aims to introduce an intermediate representation that will make it easier for us to output following different formatting rules.
This should make it possible to re-use the same code for JSX, HTML, and FBT (Facebook translations).
The basic idea I wanted to explore here was an intermediate representation format.
The idea is to have a collection of alternating children and separators (one of space, new line, or nothing).
From this intermediate representation we could then generate the output using one of 3 sets of rules:
When playing around with this the idea seemed to work OK, although if I recall correctly there are some edge cases that make it difficult to cleanly separate the
AST -> Intermediate -> Prettier docstages.