Skip to content

Commit 0de5f3a

Browse files
authored
refactor(styled-jsx): Allow legacy nesting syntax (#425)
I'm not sure if allowing non-standard stuff is a good idea. But I'm creating this PR for compatibility with the Babel version styled-jsx...
1 parent 8f85dac commit 0de5f3a

File tree

9 files changed

+48
-3
lines changed

9 files changed

+48
-3
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/styled-jsx/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @swc/plugin-styled-jsx
22

3+
## 7.0.1
4+
5+
### Patch Changes
6+
7+
- 95aecbc: Allow legacy nesting syntax
8+
39
## 7.0.0
410

511
### Major Changes

packages/styled-jsx/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
# @swc/plugin-styled-jsx
44

5+
## 7.0.1
6+
7+
### Patch Changes
8+
9+
- 95aecbc: Allow legacy nesting syntax
10+
511
## 7.0.0
612

713
### Major Changes

packages/styled-jsx/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@swc/plugin-styled-jsx",
3-
"version": "7.0.0",
3+
"version": "7.0.1",
44
"description": "SWC plugin for styled-jsx",
55
"main": "swc_plugin_styled_jsx.wasm",
66
"scripts": {

packages/styled-jsx/transform/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license = { workspace = true }
1010
name = "styled_jsx"
1111
repository = { workspace = true }
1212
rust-version = { workspace = true }
13-
version = "0.83.0"
13+
version = "0.83.1"
1414

1515

1616
[features]

packages/styled-jsx/transform/src/transform_css_swc.rs

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub fn transform_css(
5151
let config = ParserConfig {
5252
allow_wrong_line_comments: true,
5353
css_modules: false,
54+
legacy_nesting: true,
5455
..Default::default()
5556
};
5657
let lexer = Lexer::new(
@@ -264,6 +265,7 @@ impl Namespacer {
264265
ParserConfig {
265266
allow_wrong_line_comments: true,
266267
css_modules: true,
268+
legacy_nesting: true,
267269
..Default::default()
268270
},
269271
// TODO(kdy1): We might be able to report syntax errors.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export default () => (
2+
<div>
3+
<p>test</p>
4+
<p>woot</p>
5+
<p>woot</p>
6+
<style jsx>{`
7+
.container {
8+
color: blue;
9+
padding: 3rem;
10+
11+
.inner {
12+
color: yellow;
13+
}
14+
}
15+
`}</style>
16+
</div>
17+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import _JSXStyle from "styled-jsx/style";
2+
export default (()=><div className={"jsx-3b0234e9651851cb"}>
3+
<p className={"jsx-3b0234e9651851cb"}>test</p>
4+
<p className={"jsx-3b0234e9651851cb"}>woot</p>
5+
<p className={"jsx-3b0234e9651851cb"}>woot</p>
6+
<_JSXStyle id={"3b0234e9651851cb"}>{".container.jsx-3b0234e9651851cb{color:#00f;padding:3rem}.container.jsx-3b0234e9651851cb.jsx-3b0234e9651851cb .inner.jsx-3b0234e9651851cb{color:#ff0}"}</_JSXStyle>
7+
</div>);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import _JSXStyle from "styled-jsx/style";
2+
export default (()=><div className={"jsx-3b0234e9651851cb"}>
3+
<p className={"jsx-3b0234e9651851cb"}>test</p>
4+
<p className={"jsx-3b0234e9651851cb"}>woot</p>
5+
<p className={"jsx-3b0234e9651851cb"}>woot</p>
6+
<_JSXStyle id={"3b0234e9651851cb"}>{".container.jsx-3b0234e9651851cb{color:#00f;padding:3rem}.container.jsx-3b0234e9651851cb .inner.jsx-3b0234e9651851cb{color:#ff0}"}</_JSXStyle>
7+
</div>);

0 commit comments

Comments
 (0)