diff --git a/Cargo.lock b/Cargo.lock index c1a00d5e4..265afd0e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2153,7 +2153,7 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "styled_components" -version = "0.96.0" +version = "0.96.1" dependencies = [ "Inflector", "once_cell", diff --git a/packages/emotion/README.md b/packages/emotion/README.md index a92c3ab84..59165e343 100644 --- a/packages/emotion/README.md +++ b/packages/emotion/README.md @@ -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 diff --git a/packages/styled-components/CHANGELOG.md b/packages/styled-components/CHANGELOG.md index dd107d4b8..88fad7874 100644 --- a/packages/styled-components/CHANGELOG.md +++ b/packages/styled-components/CHANGELOG.md @@ -1,5 +1,11 @@ # @swc/plugin-styled-components +## 1.5.115 + +### Patch Changes + +- 34f9d21: Fix escaping issue + ## 1.5.114 ### Patch Changes diff --git a/packages/styled-components/README.md b/packages/styled-components/README.md index 789c6f798..ee9f229b6 100644 --- a/packages/styled-components/README.md +++ b/packages/styled-components/README.md @@ -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 diff --git a/packages/styled-components/package.json b/packages/styled-components/package.json index a66fc9520..e5cf824a6 100644 --- a/packages/styled-components/package.json +++ b/packages/styled-components/package.json @@ -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": { diff --git a/packages/styled-components/transform/Cargo.toml b/packages/styled-components/transform/Cargo.toml index 8fa242543..59c628243 100644 --- a/packages/styled-components/transform/Cargo.toml +++ b/packages/styled-components/transform/Cargo.toml @@ -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 diff --git a/packages/styled-components/transform/src/visitors/template_literals.rs b/packages/styled-components/transform/src/visitors/template_literals.rs index 2157ab785..cc15d84c8 100644 --- a/packages/styled-components/transform/src/visitors/template_literals.rs +++ b/packages/styled-components/transform/src/visitors/template_literals.rs @@ -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, })) }) diff --git a/packages/styled-components/transform/tests/fixtures/next-59805/code.js b/packages/styled-components/transform/tests/fixtures/next-59805/code.js new file mode 100644 index 000000000..70c0b0ce9 --- /dev/null +++ b/packages/styled-components/transform/tests/fixtures/next-59805/code.js @@ -0,0 +1,18 @@ +'use client'; + +import styled from 'styled-components'; + +const ReproElement = styled.p` + &::before { + content: '\\a9'; + } +`; + +export function ReproComponent(props) { + return ( + + This should be preceded by a copyright symbol and not backslash, + letter A, digit nine + + ); +} diff --git a/packages/styled-components/transform/tests/fixtures/next-59805/config.json b/packages/styled-components/transform/tests/fixtures/next-59805/config.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/packages/styled-components/transform/tests/fixtures/next-59805/config.json @@ -0,0 +1 @@ +{} diff --git a/packages/styled-components/transform/tests/fixtures/next-59805/output.js b/packages/styled-components/transform/tests/fixtures/next-59805/output.js new file mode 100644 index 000000000..3e17b137d --- /dev/null +++ b/packages/styled-components/transform/tests/fixtures/next-59805/output.js @@ -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 + + This should be preceded by a copyright symbol and not backslash, + + letter A, digit nine + + ; +} diff --git a/scripts/bump.sh b/scripts/bump.sh index 1b549a205..dbc42c2e2 100755 --- a/scripts/bump.sh +++ b/scripts/bump.sh @@ -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