Skip to content

Commit 4caa808

Browse files
committed
fix(transformer/styled-components): fix block comment containing expression in CSS minification
1 parent 0b252d8 commit 4caa808

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

crates/oxc_transformer/src/plugins/styled_components.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,7 @@ fn minify_template_literal<'a>(lit: &mut TemplateLiteral<'a>, ast: AstBuilder<'a
928928
pos += 2;
929929
if pos == bytes.len() {
930930
// Comment ends at end of quasi
931+
comment_type = None;
931932
continue;
932933
}
933934

tasks/transform_conformance/snapshots/oxc.snap.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
commit: 41d96516
22

3-
Passed: 184/307
3+
Passed: 184/308
44

55
# All Passed:
66
* babel-plugin-transform-class-static-block
@@ -1612,7 +1612,12 @@ after transform: ["Function", "babelHelpers"]
16121612
rebuilt : ["babelHelpers", "dec"]
16131613

16141614

1615-
# plugin-styled-components (22/37)
1615+
# plugin-styled-components (22/38)
1616+
* minify-comments/input.js
1617+
Unresolved references mismatch:
1618+
after transform: ["x", "y", "z"]
1619+
rebuilt : ["x", "z"]
1620+
16161621
* styled-components/add-identifier-with-top-level-import-paths/input.js
16171622
x Output mismatch
16181623

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import styled from 'styled-components';
2+
3+
const Button = styled.div`${x}/* ${y} */${z}`;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"modules": false,
7+
"targets": "defaults"
8+
}
9+
]
10+
],
11+
"plugins": [
12+
["styled-components", {
13+
"ssr": false,
14+
"displayName": false,
15+
"transpileTemplateLiterals": false
16+
}]
17+
]
18+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import styled from 'styled-components';
2+
const Button = styled.div`${x}${z}`;

0 commit comments

Comments
 (0)