Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
2c82615b
Unverified
Commit
2c82615b
authored
Sep 16, 2021
by
강동윤
Committed by
GitHub
Sep 16, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix transform of ` in styled-jsx (#29136)
parent
c7e187f8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
977 additions
and
924 deletions
+977
-924
Cargo.lock
packages/next/build/swc/Cargo.lock
+2
-2
mod.rs
packages/next/build/swc/src/styled_jsx/mod.rs
+658
-657
transform_css.rs
packages/next/build/swc/src/styled_jsx/transform_css.rs
+261
-263
fixture.rs
packages/next/build/swc/tests/fixture.rs
+2
-2
input.js
.../build/swc/tests/fixture/styled-jsx/tpl-escape-1/input.js
+14
-0
output.js
...build/swc/tests/fixture/styled-jsx/tpl-escape-1/output.js
+9
-0
input.js
.../build/swc/tests/fixture/styled-jsx/tpl-escape-2/input.js
+17
-0
output.js
...build/swc/tests/fixture/styled-jsx/tpl-escape-2/output.js
+14
-0
No files found.
packages/next/build/swc/Cargo.lock
View file @
2c82615b
...
@@ -1756,9 +1756,9 @@ dependencies = [
...
@@ -1756,9 +1756,9 @@ dependencies = [
[[package]]
[[package]]
name = "swc_ecma_codegen"
name = "swc_ecma_codegen"
version = "0.70.
2
"
version = "0.70.
3
"
source = "registry+https://github.com/rust-lang/crates.io-index"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "
7940bff62e5caf62fe6732ce4f07e52c3c208cb58cd9299f7f7c92dddab2bf72
"
checksum = "
bb2aca48c8369b19864bbf5ffb6a1e5e8784e451606c48c39f241a7da0751815
"
dependencies = [
dependencies = [
"bitflags",
"bitflags",
"num-bigint",
"num-bigint",
...
...
packages/next/build/swc/src/styled_jsx/mod.rs
View file @
2c82615b
...
@@ -583,7 +583,8 @@ fn get_style_expr(el: &JSXElement) -> &Expr {
...
@@ -583,7 +583,8 @@ fn get_style_expr(el: &JSXElement) -> &Expr {
.struct_span_err
(
.struct_span_err
(
el
.span
,
el
.span
,
&
format!
(
&
format!
(
"Expected one child under JSX style tag, but got {} (eg: <style jsx>{{`hi`}}</style>)"
,
"Expected one child under JSX style tag, but got {} (eg: <style
\
jsx>{{`hi`}}</style>)"
,
non_whitespace_children
.len
()
non_whitespace_children
.len
()
),
),
)
)
...
@@ -604,8 +605,8 @@ fn get_style_expr(el: &JSXElement) -> &Expr {
...
@@ -604,8 +605,8 @@ fn get_style_expr(el: &JSXElement) -> &Expr {
handler
handler
.struct_span_err
(
.struct_span_err
(
el
.span
,
el
.span
,
"Expected a single child of type JSXExpressionContainer under JSX Style tag (eg: <style
\
"Expected a single child of type JSXExpressionContainer under JSX Style tag (eg:
\
jsx>{{`hi`}}</style>)"
,
<style
jsx>{{`hi`}}</style>)"
,
)
)
.emit
()
.emit
()
});
});
...
...
packages/next/build/swc/src/styled_jsx/transform_css.rs
View file @
2c82615b
...
@@ -79,7 +79,7 @@ pub fn transform_css(
...
@@ -79,7 +79,7 @@ pub fn transform_css(
.map
(|
quasi
|
TplElement
{
.map
(|
quasi
|
TplElement
{
cooked
:
None
,
// ? Do we need cooked as well
cooked
:
None
,
// ? Do we need cooked as well
raw
:
Str
{
raw
:
Str
{
value
:
(
*
quasi
)
.into
(),
value
:
quasi
.replace
(
'`'
,
"
\\
`"
)
.into
(),
span
:
DUMMY_SP
,
span
:
DUMMY_SP
,
has_escape
:
false
,
has_escape
:
false
,
kind
:
StrKind
::
Synthesized
{},
kind
:
StrKind
::
Synthesized
{},
...
@@ -154,12 +154,10 @@ impl Namespacer {
...
@@ -154,12 +154,10 @@ impl Namespacer {
});
});
return
match
complex_selectors
{
return
match
complex_selectors
{
Ok
(
complex_selectors
)
=>
Ok
(
Ok
(
complex_selectors
)
=>
Ok
(
complex_selectors
[
0
]
.selectors
[
1
..
]
complex_selectors
[
0
]
.selectors
[
1
..
]
.iter
()
.iter
()
.cloned
()
.cloned
()
.collect
(),
.collect
()),
),
Err
(
_
)
=>
bail!
(
"Failed to transform one off global selector"
),
Err
(
_
)
=>
bail!
(
"Failed to transform one off global selector"
),
};
};
}
else
if
pseudo_index
.is_none
()
{
}
else
if
pseudo_index
.is_none
()
{
...
...
packages/next/build/swc/tests/fixture.rs
View file @
2c82615b
packages/next/build/swc/tests/fixture/styled-jsx/tpl-escape-1/input.js
0 → 100644
View file @
2c82615b
export
default
class
{
render
()
{
return
(
<
div
>
<
p
>
test
<
/p
>
<
style
jsx
>
{
`
p {
content: '\`'
}
`
}
<
/style
>
<
/div
>
)
}
}
packages/next/build/swc/tests/fixture/styled-jsx/tpl-escape-1/output.js
0 → 100644
View file @
2c82615b
import
_JSXStyle
from
"styled-jsx/style"
;
export
default
class
{
render
()
{
return
<
div
className
=
{
"jsx-1f6cef12199c3a8f"
}
>
<
p
className
=
{
"jsx-1f6cef12199c3a8f"
}
>
test
<
/p
>
<
_JSXStyle
id
=
{
"1f6cef12199c3a8f"
}
>
{
"p.jsx-1f6cef12199c3a8f {content:'`'}"
}
<
/_JSXStyle
>
<
/div>
;
}
}
\ No newline at end of file
packages/next/build/swc/tests/fixture/styled-jsx/tpl-escape-2/input.js
0 → 100644
View file @
2c82615b
export
default
function
Home
({
fontFamily
})
{
return
(
<
div
>
<
style
jsx
global
>
{
`
body {
font-family:
${
fontFamily
}
;
}
code:before,
code:after {
content: '\`';
}
`
}
<
/style
>
<
/div
>
)
}
\ No newline at end of file
packages/next/build/swc/tests/fixture/styled-jsx/tpl-escape-2/output.js
0 → 100644
View file @
2c82615b
import
_JSXStyle
from
"styled-jsx/style"
;
export
default
function
Home
({
fontFamily
})
{
return
<
div
className
=
{
_JSXStyle
.
dynamic
([
"2566fdd7bc25c35"
,
[
fontFamily
]
])}
>
<
_JSXStyle
id
=
{
"2566fdd7bc25c35"
}
dynamic
=
{[
fontFamily
]}
>
{
`body {font-family:
${
fontFamily
}
}
code:before, code:after {content:'\`'}`
}
<
/_JSXStyle
>
<
/div>
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment