Unverified Commit a3fcebc3 authored by Donny/강동윤's avatar Donny/강동윤 Committed by GitHub

Update swc (#29969)

Co-authored-by: 's avatarkdy1 <kdy1@users.noreply.github.com>
parent dff6a71e
...@@ -581,9 +581,9 @@ dependencies = [ ...@@ -581,9 +581,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.103" version = "0.2.104"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6" checksum = "7b2f96d100e1cf1929e7719b7edb3b90ab5298072638fccd77be9ce942ecdfce"
[[package]] [[package]]
name = "lock_api" name = "lock_api"
...@@ -1809,9 +1809,9 @@ dependencies = [ ...@@ -1809,9 +1809,9 @@ dependencies = [
[[package]] [[package]]
name = "swc_ecma_ast" name = "swc_ecma_ast"
version = "0.54.3" version = "0.54.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eae24a6603262822de50069ff72394b0d208267e5bd5298678ba6a79f670c40f" checksum = "83ea102b5cd8a48adf11cc62d58c84add7a419999b219211e2a837e748787c9d"
dependencies = [ dependencies = [
"is-macro", "is-macro",
"num-bigint", "num-bigint",
...@@ -1893,9 +1893,9 @@ dependencies = [ ...@@ -1893,9 +1893,9 @@ dependencies = [
[[package]] [[package]]
name = "swc_ecma_minifier" name = "swc_ecma_minifier"
version = "0.40.0" version = "0.40.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de20e3de59fa9515a441fd89da583adddd92b9da1a3576ccd0b3fdf605a34d8a" checksum = "8ae16e558981277b544d9cda017f37627c7961fbb2098d628da5484669dc4b65"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"once_cell", "once_cell",
...@@ -1920,9 +1920,9 @@ dependencies = [ ...@@ -1920,9 +1920,9 @@ dependencies = [
[[package]] [[package]]
name = "swc_ecma_parser" name = "swc_ecma_parser"
version = "0.73.13" version = "0.73.14"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb14098c8e2c9678e2ec4324183a0e2508b26fcead24bfd7b1ee3c7a2af36cc7" checksum = "da32f08bd41b37190ce08110bee5d1d6c88ae94ecbfb6d4d3c4a13fe4769a182"
dependencies = [ dependencies = [
"either", "either",
"enum_kind", "enum_kind",
...@@ -1987,9 +1987,9 @@ dependencies = [ ...@@ -1987,9 +1987,9 @@ dependencies = [
[[package]] [[package]]
name = "swc_ecma_transforms_base" name = "swc_ecma_transforms_base"
version = "0.38.0" version = "0.38.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce2937a415e5aaeb584cf3228c045a5fb66241a5d08a5799545e7172e7aba30e" checksum = "644f7941823e8368ffd7fcedcebcd9e605adee6c91dd4a40f1de2495e453a7ec"
dependencies = [ dependencies = [
"once_cell", "once_cell",
"phf", "phf",
...@@ -2019,9 +2019,9 @@ dependencies = [ ...@@ -2019,9 +2019,9 @@ dependencies = [
[[package]] [[package]]
name = "swc_ecma_transforms_compat" name = "swc_ecma_transforms_compat"
version = "0.43.1" version = "0.43.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d77f5d1b842f96d6f8dacf8c3909b80722b647a93960bdbd99f54a5f07f3cccc" checksum = "66677d5e4f617f499642db61e11de86b103ce1e47d1f9971860b8be333471a57"
dependencies = [ dependencies = [
"ahash", "ahash",
"arrayvec", "arrayvec",
...@@ -2120,9 +2120,9 @@ dependencies = [ ...@@ -2120,9 +2120,9 @@ dependencies = [
[[package]] [[package]]
name = "swc_ecma_transforms_react" name = "swc_ecma_transforms_react"
version = "0.50.0" version = "0.50.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1e4c27b30d35af65882de3bbdeb14a5d9805c35cf0383f2bd91048134384381" checksum = "570111bf9fe7f7b8d49a686e7fe94bec0e89c192b9c69cd9f37f60c29fc42b50"
dependencies = [ dependencies = [
"ahash", "ahash",
"base64 0.13.0", "base64 0.13.0",
......
...@@ -66,11 +66,11 @@ pub struct TransformOptions { ...@@ -66,11 +66,11 @@ pub struct TransformOptions {
pub fn custom_before_pass(name: &FileName, opts: &TransformOptions) -> impl Fold { pub fn custom_before_pass(name: &FileName, opts: &TransformOptions) -> impl Fold {
chain!( chain!(
styled_jsx::styled_jsx(),
hook_optimizer::hook_optimizer(), hook_optimizer::hook_optimizer(),
Optional::new(next_ssg::next_ssg(), !opts.disable_next_ssg), Optional::new(next_ssg::next_ssg(), !opts.disable_next_ssg),
amp_attributes::amp_attributes(), amp_attributes::amp_attributes(),
next_dynamic::next_dynamic(name.clone(), opts.pages_dir.clone()), next_dynamic::next_dynamic(name.clone(), opts.pages_dir.clone()),
styled_jsx::styled_jsx()
) )
} }
......
...@@ -8,12 +8,12 @@ use swc_ecmascript::minifier::{ ...@@ -8,12 +8,12 @@ use swc_ecmascript::minifier::{
eval::{EvalResult, Evaluator}, eval::{EvalResult, Evaluator},
marks::Marks, marks::Marks,
}; };
use swc_ecmascript::utils::private_ident;
use swc_ecmascript::utils::{ use swc_ecmascript::utils::{
collect_decls, collect_decls,
ident::{Id, IdentLike}, ident::{Id, IdentLike},
prepend, HANDLER, prepend, HANDLER,
}; };
use swc_ecmascript::utils::{drop_span, private_ident};
use swc_ecmascript::visit::{Fold, FoldWith}; use swc_ecmascript::visit::{Fold, FoldWith};
//use external::external_styles; //use external::external_styles;
...@@ -413,7 +413,7 @@ impl StyledJSXTransformer { ...@@ -413,7 +413,7 @@ impl StyledJSXTransformer {
css_span = span.clone(); css_span = span.clone();
is_dynamic = false; is_dynamic = false;
} else { } else {
expr.clone().hash(&mut hasher); drop_span(expr.clone()).hash(&mut hasher);
let mut s = String::new(); let mut s = String::new();
for i in 0..quasis.len() { for i in 0..quasis.len() {
let placeholder = if i == quasis.len() - 1 { let placeholder = if i == quasis.len() - 1 {
......
use std::collections::hash_map::DefaultHasher; use std::collections::hash_map::DefaultHasher;
use std::hash::Hasher; use std::hash::Hasher;
use swc_common::DUMMY_SP; use swc_common::DUMMY_SP;
use swc_ecmascript::ast::*; use swc_ecmascript::{ast::*, utils::drop_span};
use super::{ExternalStyle, JSXStyle, LocalStyle}; use super::{ExternalStyle, JSXStyle, LocalStyle};
...@@ -39,7 +39,7 @@ pub fn compute_class_names( ...@@ -39,7 +39,7 @@ pub fn compute_class_names(
} }
JSXStyle::External(external) => { JSXStyle::External(external) => {
if !external.is_global { if !external.is_global {
external_styles.push(external.expr.clone()); external_styles.push(drop_span(external.expr.clone()));
} }
} }
} }
......
...@@ -31,9 +31,12 @@ use crate::{ ...@@ -31,9 +31,12 @@ use crate::{
util::{CtxtExt, MapErr}, util::{CtxtExt, MapErr},
TransformOptions, TransformOptions,
}; };
use anyhow::{Context as _, Error}; use anyhow::{anyhow, Context as _, Error};
use napi::{CallContext, Env, JsBoolean, JsObject, JsString, Task}; use napi::{CallContext, Env, JsBoolean, JsObject, JsString, Status, Task};
use std::sync::Arc; use std::{
panic::{catch_unwind, AssertUnwindSafe},
sync::Arc,
};
use swc::{try_with_handler, Compiler, TransformOutput}; use swc::{try_with_handler, Compiler, TransformOutput};
use swc_common::{FileName, SourceFile}; use swc_common::{FileName, SourceFile};
use swc_ecmascript::ast::Program; use swc_ecmascript::ast::Program;
...@@ -57,6 +60,7 @@ impl Task for TransformTask { ...@@ -57,6 +60,7 @@ impl Task for TransformTask {
type JsValue = JsObject; type JsValue = JsObject;
fn compute(&mut self) -> napi::Result<Self::Output> { fn compute(&mut self) -> napi::Result<Self::Output> {
let res = catch_unwind(AssertUnwindSafe(|| {
try_with_handler(self.c.cm.clone(), |handler| { try_with_handler(self.c.cm.clone(), |handler| {
self.c.run(|| match self.input { self.c.run(|| match self.input {
Input::Source(ref s) => { Input::Source(ref s) => {
...@@ -71,7 +75,22 @@ impl Task for TransformTask { ...@@ -71,7 +75,22 @@ impl Task for TransformTask {
} }
}) })
}) })
.convert_err() }))
.map_err(|err| {
if let Some(s) = err.downcast_ref::<String>() {
anyhow!("failed to process {}", s)
} else {
anyhow!("failed to process")
}
});
match res {
Ok(res) => res.convert_err(),
Err(err) => Err(napi::Error::new(
Status::GenericFailure,
format!("{:?}", err),
)),
}
} }
fn resolve(self, env: Env, result: Self::Output) -> napi::Result<Self::JsValue> { fn resolve(self, env: Env, result: Self::Output) -> napi::Result<Self::JsValue> {
......
...@@ -3,11 +3,12 @@ use next_swc::{ ...@@ -3,11 +3,12 @@ use next_swc::{
styled_jsx::styled_jsx, styled_jsx::styled_jsx,
}; };
use std::path::PathBuf; use std::path::PathBuf;
use swc_common::{chain, comments::SingleThreadedComments, FileName, Mark}; use swc_common::{chain, comments::SingleThreadedComments, FileName, Mark, Span, DUMMY_SP};
use swc_ecma_transforms_testing::{test, test_fixture}; use swc_ecma_transforms_testing::{test, test_fixture};
use swc_ecmascript::{ use swc_ecmascript::{
parser::{EsConfig, Syntax}, parser::{EsConfig, Syntax},
transforms::react::jsx, transforms::react::jsx,
visit::as_folder,
}; };
use testing::fixture; use testing::fixture;
...@@ -77,3 +78,22 @@ fn styled_jsx_fixture(input: PathBuf) { ...@@ -77,3 +78,22 @@ fn styled_jsx_fixture(input: PathBuf) {
let output = input.parent().unwrap().join("output.js"); let output = input.parent().unwrap().join("output.js");
test_fixture(syntax(), &|_tr| styled_jsx(), &input, &output); test_fixture(syntax(), &|_tr| styled_jsx(), &input, &output);
} }
pub struct DropSpan;
impl swc_ecmascript::visit::VisitMut for DropSpan {
fn visit_mut_span(&mut self, span: &mut Span) {
*span = DUMMY_SP
}
}
/// Hash of styled-jsx should not depend on the span of expressions.
#[fixture("tests/fixture/styled-jsx/**/input.js")]
fn styled_jsx_span_should_not_affect_hash(input: PathBuf) {
let output = input.parent().unwrap().join("output.js");
test_fixture(
syntax(),
&|_tr| chain!(as_folder(DropSpan), styled_jsx()),
&input,
&output,
);
}
...@@ -2,109 +2,137 @@ import _JSXStyle from "styled-jsx/style"; ...@@ -2,109 +2,137 @@ import _JSXStyle from "styled-jsx/style";
import styles from "./styles"; import styles from "./styles";
const styles2 = require("./styles2"); const styles2 = require("./styles2");
export const Test1 = ()=><div className={`jsx-${styles2.__hash} jsx-${styles.__hash}`}> export const Test1 = ()=><div className={`jsx-${styles2.__hash} jsx-${styles.__hash}`}>
<p className={`jsx-${styles2.__hash} jsx-${styles.__hash}`}>external only</p> <p className={`jsx-${styles2.__hash} jsx-${styles.__hash}`}>external only</p>
<_JSXStyle id={styles.__hash}>{styles}</_JSXStyle> <_JSXStyle id={styles.__hash}>{styles}</_JSXStyle>
<_JSXStyle id={styles2.__hash}>{styles2}</_JSXStyle> <_JSXStyle id={styles2.__hash}>{styles2}</_JSXStyle>
</div> </div>
; ;
export const Test2 = ()=><div className={"jsx-81a68341e430a972 " + `jsx-${styles.__hash}`}> export const Test2 = ()=><div className={"jsx-81a68341e430a972 " + `jsx-${styles.__hash}`}>
<p className={"jsx-81a68341e430a972 " + `jsx-${styles.__hash}`}>external and static</p> <p className={"jsx-81a68341e430a972 " + `jsx-${styles.__hash}`}>external and static</p>
<_JSXStyle id={"81a68341e430a972"}>{"p.jsx-81a68341e430a972 {color:red}"}</_JSXStyle> <_JSXStyle id={"81a68341e430a972"}>{"p.jsx-81a68341e430a972 {color:red}"}</_JSXStyle>
<_JSXStyle id={styles.__hash}>{styles}</_JSXStyle> <_JSXStyle id={styles.__hash}>{styles}</_JSXStyle>
</div> </div>
; ;
export const Test3 = ({ color })=><div className={`jsx-${styles.__hash}` + " " + _JSXStyle.dynamic([ export const Test3 = ({ color })=><div className={`jsx-${styles.__hash}` + " " + _JSXStyle.dynamic([
[ [
"26b457d3bc475235", "5cadd6714ea141b4",
[ [
color color
] ]
] ]
])}> ])}>
<p className={`jsx-${styles.__hash}` + " " + _JSXStyle.dynamic([ <p className={`jsx-${styles.__hash}` + " " + _JSXStyle.dynamic([
[ [
"26b457d3bc475235", "5cadd6714ea141b4",
[ [
color color
] ]
] ]
])}>external and dynamic</p> ])}>external and dynamic</p>
<_JSXStyle id={"26b457d3bc475235"} dynamic={[
<_JSXStyle id={"5cadd6714ea141b4"} dynamic={[
color color
]}>{`p.__jsx-style-dynamic-selector {color:${color}}`}</_JSXStyle> ]}>{`p.__jsx-style-dynamic-selector {color:${color}}`}</_JSXStyle>
<_JSXStyle id={styles.__hash}>{styles}</_JSXStyle> <_JSXStyle id={styles.__hash}>{styles}</_JSXStyle>
</div> </div>
; ;
export const Test4 = ({ color })=><div className={`jsx-${styles.__hash}` + " jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([ export const Test4 = ({ color })=><div className={`jsx-${styles.__hash}` + " jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([
[ [
"e6cca97eb9ca1a15", "8f336bc49da94d3f",
[ [
color color
] ]
] ]
])}> ])}>
<p className={`jsx-${styles.__hash}` + " jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([ <p className={`jsx-${styles.__hash}` + " jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([
[ [
"e6cca97eb9ca1a15", "8f336bc49da94d3f",
[ [
color color
] ]
] ]
])}>external, static and dynamic</p> ])}>external, static and dynamic</p>
<_JSXStyle id={"ceba8c9ce34e3d0c"}>{"p.jsx-ceba8c9ce34e3d0c {display:inline-block}"}</_JSXStyle> <_JSXStyle id={"ceba8c9ce34e3d0c"}>{"p.jsx-ceba8c9ce34e3d0c {display:inline-block}"}</_JSXStyle>
<_JSXStyle id={"c86b0d7e7328204f"} dynamic={[
<_JSXStyle id={"5cadd6714ea141b4"} dynamic={[
color color
]}>{`p.__jsx-style-dynamic-selector {color:${color}}`}</_JSXStyle> ]}>{`p.__jsx-style-dynamic-selector {color:${color}}`}</_JSXStyle>
<_JSXStyle id={styles.__hash}>{styles}</_JSXStyle> <_JSXStyle id={styles.__hash}>{styles}</_JSXStyle>
</div> </div>
; ;
export const Test5 = ()=><div className={"jsx-df0159ebd3f9fb6f"}> export const Test5 = ()=><div className={"jsx-df0159ebd3f9fb6f"}>
<p className={"jsx-df0159ebd3f9fb6f"}>static only</p> <p className={"jsx-df0159ebd3f9fb6f"}>static only</p>
<_JSXStyle id={"ceba8c9ce34e3d0c"}>{"p.jsx-df0159ebd3f9fb6f {display:inline-block}"}</_JSXStyle> <_JSXStyle id={"ceba8c9ce34e3d0c"}>{"p.jsx-df0159ebd3f9fb6f {display:inline-block}"}</_JSXStyle>
<_JSXStyle id={"81a68341e430a972"}>{"p.jsx-df0159ebd3f9fb6f {color:red}"}</_JSXStyle> <_JSXStyle id={"81a68341e430a972"}>{"p.jsx-df0159ebd3f9fb6f {color:red}"}</_JSXStyle>
</div> </div>
; ;
export const Test6 = ({ color })=><div className={"jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([ export const Test6 = ({ color })=><div className={"jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([
[ [
"a55f0611581d64ca", "8f336bc49da94d3f",
[ [
color color
] ]
] ]
])}> ])}>
<p className={"jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([ <p className={"jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([
[ [
"a55f0611581d64ca", "8f336bc49da94d3f",
[ [
color color
] ]
] ]
])}>static and dynamic</p> ])}>static and dynamic</p>
<_JSXStyle id={"ceba8c9ce34e3d0c"}>{"p.jsx-ceba8c9ce34e3d0c {display:inline-block}"}</_JSXStyle> <_JSXStyle id={"ceba8c9ce34e3d0c"}>{"p.jsx-ceba8c9ce34e3d0c {display:inline-block}"}</_JSXStyle>
<_JSXStyle id={"f0677f918e6b5a01"} dynamic={[
<_JSXStyle id={"5cadd6714ea141b4"} dynamic={[
color color
]}>{`p.__jsx-style-dynamic-selector {color:${color}}`}</_JSXStyle> ]}>{`p.__jsx-style-dynamic-selector {color:${color}}`}</_JSXStyle>
</div> </div>
; ;
export const Test7 = ({ color })=><div className={_JSXStyle.dynamic([ export const Test7 = ({ color })=><div className={_JSXStyle.dynamic([
[ [
"4adc07771eb3723", "5cadd6714ea141b4",
[ [
color color
] ]
] ]
])}> ])}>
<p className={_JSXStyle.dynamic([ <p className={_JSXStyle.dynamic([
[ [
"4adc07771eb3723", "5cadd6714ea141b4",
[ [
color color
] ]
] ]
])}>dynamic only</p> ])}>dynamic only</p>
<_JSXStyle id={"4adc07771eb3723"} dynamic={[
<_JSXStyle id={"5cadd6714ea141b4"} dynamic={[
color color
]}>{`p.__jsx-style-dynamic-selector {color:${color}}`}</_JSXStyle> ]}>{`p.__jsx-style-dynamic-selector {color:${color}}`}</_JSXStyle>
</div> </div>
; ;
export const Test8 = ({ color })=>{ export const Test8 = ({ color })=>{
...@@ -114,23 +142,26 @@ export const Test8 = ({ color })=>{ ...@@ -114,23 +142,26 @@ export const Test8 = ({ color })=>{
}; };
return <div className={_JSXStyle.dynamic([ return <div className={_JSXStyle.dynamic([
[ [
"a552a4a765a9ca4e", "6e7028e37f6f2a1c",
[ [
innerProps.color innerProps.color
] ]
] ]
])}> ])}>
<p className={_JSXStyle.dynamic([ <p className={_JSXStyle.dynamic([
[ [
"a552a4a765a9ca4e", "6e7028e37f6f2a1c",
[ [
innerProps.color innerProps.color
] ]
] ]
])}>dynamic with scoped compound variable</p> ])}>dynamic with scoped compound variable</p>
<_JSXStyle id={"a552a4a765a9ca4e"} dynamic={[
<_JSXStyle id={"6e7028e37f6f2a1c"} dynamic={[
innerProps.color innerProps.color
]}>{`p.__jsx-style-dynamic-selector {color:${innerProps.color}}`}</_JSXStyle> ]}>{`p.__jsx-style-dynamic-selector {color:${innerProps.color}}`}</_JSXStyle>
</div>; </div>;
} }
}; };
...@@ -140,29 +171,35 @@ export const Test9 = ({ color })=>{ ...@@ -140,29 +171,35 @@ export const Test9 = ({ color })=>{
}; };
return <div className={_JSXStyle.dynamic([ return <div className={_JSXStyle.dynamic([
[ [
"7ef39e3312c80ead", "33344a45c20c74fe",
[ [
innerProps.color innerProps.color
] ]
] ]
])}> ])}>
<p className={_JSXStyle.dynamic([ <p className={_JSXStyle.dynamic([
[ [
"7ef39e3312c80ead", "33344a45c20c74fe",
[ [
innerProps.color innerProps.color
] ]
] ]
])}>dynamic with compound variable</p> ])}>dynamic with compound variable</p>
<_JSXStyle id={"7ef39e3312c80ead"} dynamic={[
<_JSXStyle id={"33344a45c20c74fe"} dynamic={[
innerProps.color innerProps.color
]}>{`p.__jsx-style-dynamic-selector {color:${innerProps.color}}`}</_JSXStyle> ]}>{`p.__jsx-style-dynamic-selector {color:${innerProps.color}}`}</_JSXStyle>
</div>; </div>;
}; };
const foo = "red"; const foo = "red";
export const Test10 = ()=><div className={"jsx-688a08f9e73a5653"}> export const Test10 = ()=><div className={"jsx-e993bec5c22e1b75"}>
<p className={"jsx-688a08f9e73a5653"}>dynamic with constant variable</p>
<_JSXStyle id={"688a08f9e73a5653"}>{`p.jsx-688a08f9e73a5653 {color:${foo}}`}</_JSXStyle> <p className={"jsx-e993bec5c22e1b75"}>dynamic with constant variable</p>
<_JSXStyle id={"e993bec5c22e1b75"}>{`p.jsx-e993bec5c22e1b75 {color:${foo}}`}</_JSXStyle>
</div> </div>
; ;
export const Test11 = ({ color })=>{ export const Test11 = ({ color })=>{
...@@ -170,16 +207,19 @@ export const Test11 = ({ color })=>{ ...@@ -170,16 +207,19 @@ export const Test11 = ({ color })=>{
length: 5 length: 5
}).map((item, i)=><li key={i} className={_JSXStyle.dynamic([ }).map((item, i)=><li key={i} className={_JSXStyle.dynamic([
[ [
"ebe03db0369a2939", "5dc7166977a4514",
[ [
color color
] ]
] ]
]) + " " + "item"}> ]) + " " + "item"}>
<_JSXStyle id={"ebe03db0369a2939"} dynamic={[
<_JSXStyle id={"5dc7166977a4514"} dynamic={[
color color
]}>{`.item.__jsx-style-dynamic-selector {color:${color}}`}</_JSXStyle> ]}>{`.item.__jsx-style-dynamic-selector {color:${color}}`}</_JSXStyle>
Item #{i + 1} Item #{i + 1}
</li> </li>
); );
return <ul className="items">{items}</ul>; return <ul className="items">{items}</ul>;
......
import _JSXStyle from "styled-jsx/style"; import _JSXStyle from "styled-jsx/style";
const color = "red"; const color = "red";
const otherColor = "green"; const otherColor = "green";
const A = ()=><div className={"jsx-706d62168f5e52dc"}> const A = ()=><div className={"jsx-f44d626e14f3cfbc"}>
<p className={"jsx-706d62168f5e52dc"}>test</p>
<_JSXStyle id={"706d62168f5e52dc"}>{`p.jsx-706d62168f5e52dc {color:${color}}`}</_JSXStyle> <p className={"jsx-f44d626e14f3cfbc"}>test</p>
<_JSXStyle id={"f44d626e14f3cfbc"}>{`p.jsx-f44d626e14f3cfbc {color:${color}}`}</_JSXStyle>
</div> </div>
; ;
const B = ()=><div className={"jsx-d698fce2ff7d98bb"}> const B = ()=><div className={"jsx-9db1df72abe82640"}>
<p className={"jsx-d698fce2ff7d98bb"}>test</p>
<_JSXStyle id={"d698fce2ff7d98bb"}>{`p.jsx-d698fce2ff7d98bb {color:${otherColor}}`}</_JSXStyle> <p className={"jsx-9db1df72abe82640"}>test</p>
<_JSXStyle id={"9db1df72abe82640"}>{`p.jsx-9db1df72abe82640 {color:${otherColor}}`}</_JSXStyle>
</div> </div>
; ;
export default (()=><div > export default (()=><div >
<A /> <A />
<B /> <B />
</div> </div>
); );
...@@ -9,73 +9,91 @@ const animationName = "my-cool-animation"; ...@@ -9,73 +9,91 @@ const animationName = "my-cool-animation";
const obj = { const obj = {
display: "block" display: "block"
}; };
export default (({ display })=><div className={"jsx-802e359ee0ab20c4 " + _JSXStyle.dynamic([ export default (({ display })=><div className={"jsx-843124768056a74c " + _JSXStyle.dynamic([
[ [
"76aa3eae4e21e4ca", "a124d516c2c0707d",
[ [
display ? "block" : "none" display ? "block" : "none"
] ]
], ],
[ [
"5ba905f763f40220", "108a316873f1c6fc",
[ [
darken(color) + 2 darken(color) + 2
] ]
], ],
[ [
"c4bb394aae9bd00b", "785cf5e120672da8",
[ [
darken(color) darken(color)
] ]
] ]
])}> ])}>
<p className={"jsx-802e359ee0ab20c4 " + _JSXStyle.dynamic([
<p className={"jsx-843124768056a74c " + _JSXStyle.dynamic([
[ [
"76aa3eae4e21e4ca", "a124d516c2c0707d",
[ [
display ? "block" : "none" display ? "block" : "none"
] ]
], ],
[ [
"5ba905f763f40220", "108a316873f1c6fc",
[ [
darken(color) + 2 darken(color) + 2
] ]
], ],
[ [
"c4bb394aae9bd00b", "785cf5e120672da8",
[ [
darken(color) darken(color)
] ]
] ]
])}>test</p> ])}>test</p>
<_JSXStyle id={"f3d3af42197b4734"}>{`p.${color}.jsx-802e359ee0ab20c4 {color:${otherColor};
<_JSXStyle id={"5df43f2861c900e6"}>{`p.${color}.jsx-843124768056a74c {color:${otherColor};
display:${obj.display}}`}</_JSXStyle> display:${obj.display}}`}</_JSXStyle>
<_JSXStyle id={"94239b6d6b42c9b5"}>{"p.jsx-802e359ee0ab20c4 {color:red}"}</_JSXStyle>
<_JSXStyle id={"32d670fe91cc2fa1"}>{`body {background:${color}}`}</_JSXStyle> <_JSXStyle id={"94239b6d6b42c9b5"}>{"p.jsx-843124768056a74c {color:red}"}</_JSXStyle>
<_JSXStyle id={"3134af19d5bf663e"}>{`body {background:${color}}`}</_JSXStyle>
<_JSXStyle id={"a971cf00393d41be"}>{`body {background:${color}}`}</_JSXStyle>
<_JSXStyle id={"a971cf00393d41be"}>{`body {background:${color}}`}</_JSXStyle>
// TODO: the next two should have the same hash // TODO: the next two should have the same hash
<_JSXStyle id={"8e512e75f8a7c096"}>{`p.jsx-802e359ee0ab20c4 {color:${color}}`}</_JSXStyle>
<_JSXStyle id={"c25992945d0883cd"}>{`p.jsx-802e359ee0ab20c4 {color:${color}}`}</_JSXStyle> <_JSXStyle id={"5cadd6714ea141b4"}>{`p.jsx-843124768056a74c {color:${color}}`}</_JSXStyle>
<_JSXStyle id={"2f77c12736da5e9e"} dynamic={[
<_JSXStyle id={"5cadd6714ea141b4"}>{`p.jsx-843124768056a74c {color:${color}}`}</_JSXStyle>
<_JSXStyle id={"6b2c0e0cad82feb7"} dynamic={[
darken(color) darken(color)
]}>{`p.__jsx-style-dynamic-selector {color:${darken(color)}}`}</_JSXStyle> ]}>{`p.__jsx-style-dynamic-selector {color:${darken(color)}}`}</_JSXStyle>
<_JSXStyle id={"10454d61c818c6eb"} dynamic={[
<_JSXStyle id={"6468493b508fe311"} dynamic={[
darken(color) + 2 darken(color) + 2
]}>{`p.__jsx-style-dynamic-selector {color:${darken(color) + 2}}`}</_JSXStyle> ]}>{`p.__jsx-style-dynamic-selector {color:${darken(color) + 2}}`}</_JSXStyle>
<_JSXStyle id={"281f7ed4d9150bac"}>{`@media (min-width:${mediumScreen}) {p.jsx-802e359ee0ab20c4 {color:green}
p.jsx-802e359ee0ab20c4 {color:${`red`}}} <_JSXStyle id={"bb5a8a5ee5cd36db"}>{`@media (min-width:${mediumScreen}) {p.jsx-843124768056a74c {color:green}
p.jsx-802e359ee0ab20c4 {color:red}`}</_JSXStyle> p.jsx-843124768056a74c {color:${`red`}}}
<_JSXStyle id={"d8950943ae4cf3dc"}>{`p.jsx-802e359ee0ab20c4 {-webkit-animation-duration:${animationDuration}; p.jsx-843124768056a74c {color:red}`}</_JSXStyle>
<_JSXStyle id={"99746edba785c617"}>{`p.jsx-843124768056a74c {-webkit-animation-duration:${animationDuration};
animation-duration:${animationDuration}}`}</_JSXStyle> animation-duration:${animationDuration}}`}</_JSXStyle>
<_JSXStyle id={"1ee00865f92bdbe7"}>{`p.jsx-802e359ee0ab20c4 {-webkit-animation:${animationDuration} forwards ${animationName};
<_JSXStyle id={"62d69d091a270e9d"}>{`p.jsx-843124768056a74c {-webkit-animation:${animationDuration} forwards ${animationName};
animation:${animationDuration} forwards ${animationName}} animation:${animationDuration} forwards ${animationName}}
div.jsx-802e359ee0ab20c4 {background:${color}}`}</_JSXStyle> div.jsx-843124768056a74c {background:${color}}`}</_JSXStyle>
<_JSXStyle id={"4925b8e0a7ab752a"} dynamic={[
<_JSXStyle id={"50cfd39d2a258beb"} dynamic={[
display ? "block" : "none" display ? "block" : "none"
]}>{`span.__jsx-style-dynamic-selector {display:${display ? "block" : "none"}}`}</_JSXStyle> ]}>{`span.__jsx-style-dynamic-selector {display:${display ? "block" : "none"}}`}</_JSXStyle>
// TODO: causes bad syntax // TODO: causes bad syntax
{} {}
</div> </div>
); );
...@@ -6,18 +6,18 @@ bar.__hash = "aaed0341accea8f"; ...@@ -6,18 +6,18 @@ bar.__hash = "aaed0341accea8f";
const baz = new String("div {font-size:3em}"); const baz = new String("div {font-size:3em}");
baz.__hash = "aaed0341accea8f"; baz.__hash = "aaed0341accea8f";
const a = new String(`div {font-size:${size}em}`); const a = new String(`div {font-size:${size}em}`);
a.__hash = "611c3773b76f8ea3"; a.__hash = "f14cced97c082d2c";
export const uh = bar; export const uh = bar;
export const foo = new String(`div.jsx-e46da79e05d23fff {color:${color}}`); export const foo = new String(`div.jsx-a0d126276b085021 {color:${color}}`);
foo.__hash = "e46da79e05d23fff"; foo.__hash = "a0d126276b085021";
({ ({
styles: <_JSXStyle id={"12e2c41a8d37fe78"} dynamic={[ styles: <_JSXStyle id={"47e08c293b53f262"} dynamic={[
colors.green.light colors.green.light
]}>{`div.__jsx-style-dynamic-selector {color:${colors.green.light}} ]}>{`div.__jsx-style-dynamic-selector {color:${colors.green.light}}
a.__jsx-style-dynamic-selector {color:red}`}</_JSXStyle>, a.__jsx-style-dynamic-selector {color:red}`}</_JSXStyle>,
className: _JSXStyle.dynamic([ className: _JSXStyle.dynamic([
[ [
"12e2c41a8d37fe78", "47e08c293b53f262",
[ [
colors.green.light colors.green.light
] ]
...@@ -25,13 +25,13 @@ a.__jsx-style-dynamic-selector {color:red}`}</_JSXStyle>, ...@@ -25,13 +25,13 @@ a.__jsx-style-dynamic-selector {color:red}`}</_JSXStyle>,
]) ])
}); });
const b = { const b = {
styles: <_JSXStyle id={"d5617758481f82cd"} dynamic={[ styles: <_JSXStyle id={"47e08c293b53f262"} dynamic={[
colors.green.light colors.green.light
]}>{`div.__jsx-style-dynamic-selector {color:${colors.green.light}} ]}>{`div.__jsx-style-dynamic-selector {color:${colors.green.light}}
a.__jsx-style-dynamic-selector {color:red}`}</_JSXStyle>, a.__jsx-style-dynamic-selector {color:red}`}</_JSXStyle>,
className: _JSXStyle.dynamic([ className: _JSXStyle.dynamic([
[ [
"d5617758481f82cd", "47e08c293b53f262",
[ [
colors.green.light colors.green.light
] ]
...@@ -40,13 +40,13 @@ a.__jsx-style-dynamic-selector {color:red}`}</_JSXStyle>, ...@@ -40,13 +40,13 @@ a.__jsx-style-dynamic-selector {color:red}`}</_JSXStyle>,
}; };
const dynamic = (colors)=>{ const dynamic = (colors)=>{
const b = { const b = {
styles: <_JSXStyle id={"a7ac579c753e9d90"} dynamic={[ styles: <_JSXStyle id={"79d79305fa1611e"} dynamic={[
colors.green.light colors.green.light
]}>{`div.__jsx-style-dynamic-selector {color:${colors.green.light}} ]}>{`div.__jsx-style-dynamic-selector {color:${colors.green.light}}
a.__jsx-style-dynamic-selector {color:red}`}</_JSXStyle>, a.__jsx-style-dynamic-selector {color:red}`}</_JSXStyle>,
className: _JSXStyle.dynamic([ className: _JSXStyle.dynamic([
[ [
"a7ac579c753e9d90", "79d79305fa1611e",
[ [
colors.green.light colors.green.light
] ]
...@@ -55,7 +55,7 @@ a.__jsx-style-dynamic-selector {color:red}`}</_JSXStyle>, ...@@ -55,7 +55,7 @@ a.__jsx-style-dynamic-selector {color:red}`}</_JSXStyle>,
}; };
}; };
export default { export default {
styles: <_JSXStyle id={"e4642e4164827181"}>{`div.jsx-e4642e4164827181 {font-size:3em} styles: <_JSXStyle id={"d9cea503e39c5315"}>{`div.jsx-d9cea503e39c5315 {font-size:3em}
p.jsx-e4642e4164827181 {color:${color}}`}</_JSXStyle>, p.jsx-d9cea503e39c5315 {color:${color}}`}</_JSXStyle>,
className: "jsx-e4642e4164827181" className: "jsx-d9cea503e39c5315"
}; };
...@@ -2,7 +2,7 @@ import _JSXStyle from "styled-jsx/style"; ...@@ -2,7 +2,7 @@ import _JSXStyle from "styled-jsx/style";
export const Red = ({ Component ="button" })=>{ export const Red = ({ Component ="button" })=>{
return <Component className={_JSXStyle.dynamic([ return <Component className={_JSXStyle.dynamic([
[ [
"ff8ee675a24f28ee", "ab280f80c0d19763",
[ [
e1, e1,
e2, e2,
...@@ -23,8 +23,11 @@ export const Red = ({ Component ="button" })=>{ ...@@ -23,8 +23,11 @@ export const Red = ({ Component ="button" })=>{
] ]
])}> ])}>
{} {}
<_JSXStyle id={"ff8ee675a24f28ee"} dynamic={[
<_JSXStyle id={"ab280f80c0d19763"} dynamic={[
e1, e1,
e2, e2,
e3, e3,
...@@ -55,5 +58,6 @@ export const Red = ({ Component ="button" })=>{ ...@@ -55,5 +58,6 @@ export const Red = ({ Component ="button" })=>{
--button-13:${e13}; --button-13:${e13};
--button-14:${e14}; --button-14:${e14};
--button-15:${e15}}`}</_JSXStyle> --button-15:${e15}}`}</_JSXStyle>
</Component>; </Component>;
}; };
...@@ -2,15 +2,17 @@ import _JSXStyle from "styled-jsx/style"; ...@@ -2,15 +2,17 @@ import _JSXStyle from "styled-jsx/style";
export default function Home({ fontFamily }) { export default function Home({ fontFamily }) {
return <div className={_JSXStyle.dynamic([ return <div className={_JSXStyle.dynamic([
[ [
"2566fdd7bc25c35", "d64fed44dbc5d8df",
[ [
fontFamily fontFamily
] ]
] ]
])}> ])}>
<_JSXStyle id={"2566fdd7bc25c35"} dynamic={[
<_JSXStyle id={"d64fed44dbc5d8df"} dynamic={[
fontFamily fontFamily
]}>{`body {font-family:${fontFamily}} ]}>{`body {font-family:${fontFamily}}
code:before, code:after {content:'\`'}`}</_JSXStyle> code:before, code:after {content:'\`'}`}</_JSXStyle>
</div>; </div>;
} };
\ No newline at end of file
...@@ -3,23 +3,26 @@ export default class { ...@@ -3,23 +3,26 @@ export default class {
render() { render() {
return <div className={_JSXStyle.dynamic([ return <div className={_JSXStyle.dynamic([
[ [
"8b268cf2c0a3f89b", "8c1103276226be14",
[ [
inputSize ? "height: calc(2 * var(--a)) !important;" : "" inputSize ? "height: calc(2 * var(--a)) !important;" : ""
] ]
] ]
])}> ])}>
<p className={_JSXStyle.dynamic([ <p className={_JSXStyle.dynamic([
[ [
"8b268cf2c0a3f89b", "8c1103276226be14",
[ [
inputSize ? "height: calc(2 * var(--a)) !important;" : "" inputSize ? "height: calc(2 * var(--a)) !important;" : ""
] ]
] ]
])}>test</p> ])}>test</p>
<_JSXStyle id={"8b268cf2c0a3f89b"} dynamic={[
<_JSXStyle id={"8c1103276226be14"} dynamic={[
inputSize ? "height: calc(2 * var(--a)) !important;" : "" inputSize ? "height: calc(2 * var(--a)) !important;" : ""
]}>{`@media only screen {a.__jsx-style-dynamic-selector {${inputSize ? "height: calc(2 * var(--a)) !important;" : ""} }}`}</_JSXStyle> ]}>{`@media only screen {a.__jsx-style-dynamic-selector {${inputSize ? "height: calc(2 * var(--a)) !important;" : ""} }}`}</_JSXStyle>
</div>; </div>;
} }
} };
\ No newline at end of file
...@@ -3,7 +3,7 @@ export default class { ...@@ -3,7 +3,7 @@ export default class {
render() { render() {
return <div className={_JSXStyle.dynamic([ return <div className={_JSXStyle.dynamic([
[ [
"4dca1c13af6604d3", "1a8c0e5c60018729",
[ [
a[b], a[b],
-1 * (c || 0), -1 * (c || 0),
...@@ -14,7 +14,7 @@ export default class { ...@@ -14,7 +14,7 @@ export default class {
<p className={_JSXStyle.dynamic([ <p className={_JSXStyle.dynamic([
[ [
"4dca1c13af6604d3", "1a8c0e5c60018729",
[ [
a[b], a[b],
-1 * (c || 0), -1 * (c || 0),
...@@ -23,7 +23,7 @@ export default class { ...@@ -23,7 +23,7 @@ export default class {
] ]
])}>test</p> ])}>test</p>
<_JSXStyle id={"4dca1c13af6604d3"} dynamic={[ <_JSXStyle id={"1a8c0e5c60018729"} dynamic={[
a[b], a[b],
-1 * (c || 0), -1 * (c || 0),
d d
......
...@@ -3,23 +3,26 @@ export default class { ...@@ -3,23 +3,26 @@ export default class {
render() { render() {
return <div className={_JSXStyle.dynamic([ return <div className={_JSXStyle.dynamic([
[ [
"1c633742f7a13f60", "1dd34a5c235f087f",
[ [
a a
] ]
] ]
])}> ])}>
<p className={_JSXStyle.dynamic([ <p className={_JSXStyle.dynamic([
[ [
"1c633742f7a13f60", "1dd34a5c235f087f",
[ [
a a
] ]
] ]
])}>test</p> ])}>test</p>
<_JSXStyle id={"1c633742f7a13f60"} dynamic={[
<_JSXStyle id={"1dd34a5c235f087f"} dynamic={[
a a
]}>{`@media only screen {a.__jsx-style-dynamic-selector {color:${a}}}`}</_JSXStyle> ]}>{`@media only screen {a.__jsx-style-dynamic-selector {color:${a}}}`}</_JSXStyle>
</div>; </div>;
} }
} };
...@@ -3,7 +3,7 @@ export default class { ...@@ -3,7 +3,7 @@ export default class {
render() { render() {
return <div className={_JSXStyle.dynamic([ return <div className={_JSXStyle.dynamic([
[ [
"eb1d88515aa07b6b", "35bb702eb335aa6f",
[ [
a || "var(--c)", a || "var(--c)",
b || "inherit" b || "inherit"
...@@ -13,7 +13,7 @@ export default class { ...@@ -13,7 +13,7 @@ export default class {
<p className={_JSXStyle.dynamic([ <p className={_JSXStyle.dynamic([
[ [
"eb1d88515aa07b6b", "35bb702eb335aa6f",
[ [
a || "var(--c)", a || "var(--c)",
b || "inherit" b || "inherit"
...@@ -21,7 +21,7 @@ export default class { ...@@ -21,7 +21,7 @@ export default class {
] ]
])}>test</p> ])}>test</p>
<_JSXStyle id={"eb1d88515aa07b6b"} dynamic={[ <_JSXStyle id={"35bb702eb335aa6f"} dynamic={[
a || "var(--c)", a || "var(--c)",
b || "inherit" b || "inherit"
]}>{`.a:hover .b.__jsx-style-dynamic-selector {display:inline-block; ]}>{`.a:hover .b.__jsx-style-dynamic-selector {display:inline-block;
......
...@@ -3,27 +3,30 @@ export default class { ...@@ -3,27 +3,30 @@ export default class {
render() { render() {
return <div className={_JSXStyle.dynamic([ return <div className={_JSXStyle.dynamic([
[ [
"e9f85ed5d171a7cb", "21ae2868f133bbf6",
[ [
a ? "100%" : "200px", a ? "100%" : "200px",
b ? "0" : "8px 20px" b ? "0" : "8px 20px"
] ]
] ]
])}> ])}>
<p className={_JSXStyle.dynamic([ <p className={_JSXStyle.dynamic([
[ [
"e9f85ed5d171a7cb", "21ae2868f133bbf6",
[ [
a ? "100%" : "200px", a ? "100%" : "200px",
b ? "0" : "8px 20px" b ? "0" : "8px 20px"
] ]
] ]
])}>test</p> ])}>test</p>
<_JSXStyle id={"e9f85ed5d171a7cb"} dynamic={[
<_JSXStyle id={"21ae2868f133bbf6"} dynamic={[
a ? "100%" : "200px", a ? "100%" : "200px",
b ? "0" : "8px 20px" b ? "0" : "8px 20px"
]}>{`.item.__jsx-style-dynamic-selector {max-width:${a ? "100%" : "200px"}; ]}>{`.item.__jsx-style-dynamic-selector {max-width:${a ? "100%" : "200px"};
padding:${b ? "0" : "8px 20px"}}`}</_JSXStyle> padding:${b ? "0" : "8px 20px"}}`}</_JSXStyle>
</div>; </div>;
} }
} };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment