Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions crates/oxc_transformer/src/plugins/styled_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,9 +989,7 @@ fn minify_template_literal<'a>(lit: &mut TemplateLiteral<'a>, ast: AstBuilder<'a
continue;
}
b'n' | b'r' if string_quote == NOT_IN_STRING => {
if output.last().is_some_and(|&last| last != b' ') {
output.push(b' ');
}
insert_space_if_required(&mut output, quasi_index);
i += 2;
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions tasks/transform_conformance/snapshots/oxc.snap.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
commit: 41d96516

Passed: 185/308
Passed: 186/309

# All Passed:
* babel-plugin-transform-class-static-block
Expand Down Expand Up @@ -1612,7 +1612,7 @@ after transform: ["Function", "babelHelpers"]
rebuilt : ["babelHelpers", "dec"]


# plugin-styled-components (23/38)
# plugin-styled-components (24/39)
* minify-comments/input.js
Unresolved references mismatch:
after transform: ["x", "y", "z"]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import styled from 'styled-components';

// Leading or trailing line breaks
const A = styled.div`\r\ncolor: blue;\r\n`;

// Line breaks in removal position
const B = styled.div`
color:\r\nblue;
.a\r\n{\r\n}
`;

// Line breaks in non-removal position
const C = styled.div`thing\r\n:hover;`;

// Line breaks before and after interpolations
const D = styled.div`
foo\r\n${'blue'}\r\n:blah;
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"presets": [
[
"@babel/preset-env",
{
"modules": false,
"targets": "defaults"
}
]
],
"plugins": [
["styled-components", {
"ssr": false,
"displayName": false,
"transpileTemplateLiterals": false
}]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import styled from 'styled-components';
const A = styled.div`color:blue;`;
const B = styled.div`color:blue;.a{}`;
const C = styled.div`thing :hover;`;
const D = styled.div`foo ${'blue'} :blah;`;
Loading