-
-
Notifications
You must be signed in to change notification settings - Fork 735
docs(transformer/styled-components): add comments about CSSMinifier
#12197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
graphite-app
merged 1 commit into
main
from
07-10-docs_transformer_styled-components_add_comments_about_cssminifier
Jul 10, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What makes it true that "template literal has ensured that
quasisalways has one more element thanexpressions"? How is that ensured?If in some other transform, I do
expressions.push(...)without correspondingquasis.push(...)by accident, this invariant is broken, andquasis.set_len(expressions.len() + 1)is UB. Safety invariants should be local and provable. "SAFETY: There are no bugs in the rest of the codebase" isn't very convincing!debug_assert!notassert!. That's no good as a safety guarantee.assert!, it's too late. We's already invoke UB before we get to that.truncatewould be fine - it might panic if some other code has broken the rule, but won't cause UB.Or we could add an assertion at top of the function
assert!(quasis.len() == expressions.len() + 1), and then use unsafeset_len.But... this PR is mainly about adding comments. Let's leave it as is here, and address it in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I'd quite like to make this a type system invariant by changing
TemplateLiteralto:Then we can stop worrying about this! Rust will prevent us making mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Dunqing Ping just to make sure you see this. I had to mark it as "resolved" to merge the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new type looks good, the current one is probably to align with the
ESTree. I will add that assertion later.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#12213