Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upate swc to allow line comments in css #29943

Merged
merged 9 commits into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
103 changes: 55 additions & 48 deletions packages/next/build/swc/Cargo.lock

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

10 changes: 5 additions & 5 deletions packages/next/build/swc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ path-clean = "0.1"
regex = "1.5"
serde = "1"
serde_json = "1"
swc = "0.69.0"
swc = "0.70.0"
swc_atoms = "0.2.7"
swc_common = { version = "0.13.5", features = ["concurrent", "sourcemap"] }
swc_css = "0.16.0"
swc_ecmascript = { version = "0.75.0", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] }
swc_ecma_preset_env = "0.54.0"
swc_css = "0.18.0"
swc_ecmascript = { version = "0.76.0", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] }
swc_ecma_preset_env = "0.55.0"
swc_node_base = "0.4.0"
swc_stylis = "0.13.0"
swc_stylis = "0.15.0"
fxhash = "0.2.1"
retain_mut = "0.1.3"
pathdiff = "0.2.0"
Expand Down
3 changes: 3 additions & 0 deletions packages/next/build/swc/src/styled_jsx/transform_css.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub fn transform_css(
style_info.css_span.hi,
ParserConfig {
parse_values: false,
allow_wrong_line_comments: true,
},
// We ignore errors because we inject placeholders for expressions which is
// not a valid css.
Expand All @@ -44,6 +45,7 @@ pub fn transform_css(
style_info.css_span,
"Failed to parse css in styled jsx component",
)
.note(&format!("Input to the css parser is {}", style_info.css))
.emit()
});
bail!("Failed to parse css");
Expand Down Expand Up @@ -173,6 +175,7 @@ impl Namespacer {
&args,
ParserConfig {
parse_values: false,
allow_wrong_line_comments: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its not really "wrong", just not standardized in the spec. It works it some browsers.

I would call this allow_nonstandard_line_comments or allow_unofficial_line_comments 🙂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, nonstandard seems better.
Thasnk!

},
// TODO(kdy1): We might be able to report syntax errors.
&mut vec![],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default class {
render() {
return (
<div>
<p>test</p>
<style jsx>{`
//
p {
//
color: red;

//
}
`}</style>
</div>
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import _JSXStyle from "styled-jsx/style";
export default class {
render() {
return <div className={"jsx-1952086b0a5ae64c"}>

<p className={"jsx-1952086b0a5ae64c"}>test</p>

<_JSXStyle id={"1952086b0a5ae64c"}>{"p.jsx-1952086b0a5ae64c {color:red}"}</_JSXStyle>

</div>;
}
};