This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 660
Conversation
This file contains 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
✅ Deploy Preview for rometools ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
MichaReiser
changed the title
Empty File to create placeholder PR
refactor(rome_formatter): Comments
Sep 15, 2022
This was referenced Sep 15, 2022
MichaReiser
force-pushed
the
refactor/comments
branch
from
September 15, 2022 12:27
4946e49
to
8ce92f8
Compare
This was
linked to
issues
Sep 15, 2022
Closed
Comparing refactor(rome_formatter): Comments Snapshot #14 to median since last deploy of rome.tools.
1 page testedHomeBrowser previews
Most significant changes5 other significant changes: Number of Requests on iPhone, 4G LTE, Number of Requests on Motorola Moto G Power, 3G connection, Total Page Size in Bytes on Chrome Desktop, Total Page Size in Bytes on iPhone, 4G LTE, Total Page Size in Bytes on Motorola Moto G Power, 3G connection Calibre: Site dashboard | View this PR | Edit settings | View documentation |
This was referenced Sep 16, 2022
MichaReiser
force-pushed
the
refactor/comments
branch
from
September 16, 2022 14:58
68b96aa
to
301ba39
Compare
Parser conformance results on ubuntu-latestjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
!bench_formatter |
Formatter Benchmark Results
|
This PR removes the `FormatElement::Comment` element. It was used to this point because the `group` builder had to move `comments` outside of the start/end of the group. No such inspection is necessary after the refactor which is why the element can be deleted.
This PR moves the logic for formatting a node as `verbatim` to `rome_formatter` as it isn't JS specific
Comments Formatter integration
Co-authored-by: l3ops <leops@users.noreply.github.com>
MichaReiser
force-pushed
the
refactor/comments
branch
from
September 22, 2022 07:05
f4dbc00
to
6a430dc
Compare
!bench_formatter |
Formatter Benchmark Results
|
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.
Summary
This PR is empty for now but I want to use it to merge all comment-related PRs into it as the individual PRs may not compile on their own.
I split the whole refactory mainly on file boundaries to avoid having to deal with many merge conflicts between the different PRs. However, this means, that individual PRs won't compile nor will tests be passing.
This is what this PR is for. It ensures that all changes compile together and that there are no regressing tests. The main motivation of splitting this PR into multiple smaller PRs is to ease reviewing.
FormatElement::Comment
#3240rome_formatter
#3241Functionality
JSX Suppressions
It's now possible to suppress formatting of a JSX element or fragment by using
Fix instability issues
Fixes #2768
Formatting order
The comment formatting relied on the fact that tokens (and thus nodes) are formatted in the order they get written to the final document to be able to decide whether to insert a space before/after a comment. However, there is no enforcement of this constraint and ignoring it leads to very subtle spacing bugs that are hard to notice and track down. There are even situations where it's surprisingly hard, if not even impossible, to format the document in order if it is necessary to test if some other element will break that only gets written later.
This PR removes the constraint that tokens must be formatted in order (they still must be written in the correct order to the output buffer).
Performance
The overall performance is improving. The reasons for this are
FormatState
. TheFormatState
snapshot has a size of zero now, significantly reducing the cost of formatting statements.GroupElementsBuffer
added a level of indirection to everywrite
,state
,context
etc. calls. It also required to use a Boxed buffer snapshot to store itsempty
flagFxHashMap
s are fast :)Test Plan
cargo test