-
Notifications
You must be signed in to change notification settings - Fork 27.3k
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
Fix Emotion SWC transform escape sequence bugs (#40385, #38301) #40534
Closed
Closed
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d7b2605
fixed config-schema for esmExternals
rubytree33 39cf9bf
formatting
rubytree33 7faed2b
esmExternals config schema minor idiomatic edit
rubytree33 4f04fb7
Merge branch 'vercel:canary' into canary
rubytree33 e3bd19b
swc emotion prefer cooked tagged template (#40385)
rubytree33 a548c3f
revert pnpm-lock.yaml
rubytree33 be3be5b
cargo fmt fix
rubytree33 429efd7
Merge branch 'canary' into canary
rubytree33 de64a85
Merge branch 'canary' into canary
rubytree33 f4a5780
Merge branch 'canary' into canary
rubytree33 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
20 changes: 20 additions & 0 deletions
20
errors/invalid-escape-sequence-in-emotion-tagged-template.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Invalid escape sequence in Emotion tagged template | ||
|
||
#### Why This Error Occurred | ||
|
||
<!-- Explain why the error occurred. Ensure the description makes it clear why the warning/error exists --> | ||
|
||
One or more escape sequence in an Emotion tagged template was incorrect. This prevented correct parsing before transformations were applied. | ||
|
||
#### Possible Ways to Fix It | ||
|
||
<!-- Explain how to fix the warning/error, potentially by providing alternative approaches. Ensure this section is actionable by users --> | ||
|
||
Look for `\\` in the string to find the broken escape sequence(s). For example, `\\u` must be followed by four hex digits. | ||
|
||
### Useful Links | ||
|
||
<!-- Add links to relevant documentation --> | ||
|
||
- [Next.js compiler Emotion configuration](https://nextjs.org/docs/advanced-features/compiler#emotion) | ||
- [ECMAScript 2023 syntax for string literals](https://tc39.es/ecma262/multipage/ecmascript-language-lexical-grammar.html#sec-literals-string-literals) |
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
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
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.
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.
This is going to lead to more headaches than expected. CSS allows
\
to escape unicode chars without au
prefix, eg"\2022"
should render a•
, and"\0025a0"
should render a■
. Both of these are illegal escape sequences (they're legacy octal escapes in JS), but perfectly fine in CSS.Rather than use JS's cooking semantics, we can manually cook the raw strings using CSS semantics. We can pilfer SWC's escape parser to do this: https://github.com/swc-project/swc/blob/decebadff1686adb8ea30d0ef84d849061205c7c/crates/swc_css_parser/src/lexer/mod.rs#L892-L969