Skip to content

Commit

Permalink
fix(styled-components): Fix escaping issue (#255)
Browse files Browse the repository at this point in the history
**Related issue:**

 - vercel/next.js#59805
  • Loading branch information
kdy1 authored Jan 24, 2024
1 parent 94d9e63 commit d592781
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/emotion/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ Source code for plugin itself (not transforms) are copied from https://github.co
# @swc/plugin-emotion
## 2.5.115
### Patch Changes
- 906b5dd: Fix panic when trying to unwrap None on setting the context for a function name
## 2.5.114
### Patch Changes
Expand Down
6 changes: 6 additions & 0 deletions packages/styled-components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @swc/plugin-styled-components

## 1.5.115

### Patch Changes

- 34f9d21: Fix escaping issue

## 1.5.114

### Patch Changes
Expand Down
6 changes: 6 additions & 0 deletions packages/styled-components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ Then update your `.swcrc` file like below:

# @swc/plugin-styled-components

## 1.5.115

### Patch Changes

- 34f9d21: Fix escaping issue

## 1.5.114

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/styled-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@swc/plugin-styled-components",
"version": "1.5.114",
"version": "1.5.115",
"description": "SWC plugin for styled-components",
"main": "swc_plugin_styled_components.wasm",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/styled-components/transform/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0"
name = "styled_components"
repository = "https://github.com/swc-project/plugins.git"
version = "0.96.0"
version = "0.96.1"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,21 @@ impl VisitMut for TemplateLiterals {
.quasis
.into_iter()
.map(|q| {
let value = q
.raw
.replace("\\`", "`")
.replace("\\$", "$")
.replace("\\b", "\u{0008}")
.replace("\\f", "\u{000C}")
.replace("\\n", "\n")
.replace("\\r", "\r")
.replace("\\t", "\t")
.replace("\\v", "\u{000B}")
.replace("\\\\", "\\");

Expr::Lit(Lit::Str(Str {
span: q.span,
value: q.cooked.unwrap_or(q.raw),
value: value.into(),
raw: None,
}))
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use client';

import styled from 'styled-components';

const ReproElement = styled.p`
&::before {
content: '\\a9';
}
`;

export function ReproComponent(props) {
return (
<ReproElement>
This should be preceded by a copyright symbol and <i>not</i> backslash,
letter A, digit nine
</ReproElement>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use client';
import styled from 'styled-components';
const ReproElement = styled.p.withConfig({
displayName: "code__ReproElement",
componentId: "sc-40762e0a-0"
})([
"&::before{content:'\\a9';}"
]);
export function ReproComponent(props) {
return <ReproElement>

This should be preceded by a copyright symbol and <i>not</i> backslash,

letter A, digit nine

</ReproElement>;
}
2 changes: 1 addition & 1 deletion scripts/bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ done

git commit -am "Merge CHANGELOG into README"

cargo set-version --workspace --bump minor
cargo set-version --workspace --bump patch
git commit -a -m "Bump crates" || true

0 comments on commit d592781

Please sign in to comment.