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

Update swc (#33201)

This PR is a bit big because AST definitions are modified recently because previous AST defs were too error-prone.
It will prevent plugin authors from making some common mistakes.


 - Closes #33088
 - Closes #31084
 - Closes #33283
parent 7db6aa2f
This diff is collapsed.
......@@ -14,21 +14,21 @@ fxhash = "0.2.1"
pathdiff = "0.2.0"
serde = "1"
serde_json = "1"
styled_components = "0.9.0"
swc = "0.110.0"
styled_components = "0.11.0"
swc = "0.114.0"
swc_atoms = "0.2.7"
swc_common = { version = "0.16.0", features = ["concurrent", "sourcemap"] }
swc_css = "0.45.0"
swc_ecma_loader = { version = "0.26.0", features = ["node", "lru"] }
swc_ecmascript = { version = "0.105.0", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] }
swc_common = { version = "0.17.0", features = ["concurrent", "sourcemap"] }
swc_css = "0.46.0"
swc_ecma_loader = { version = "0.27.0", features = ["node", "lru"] }
swc_ecmascript = { version = "0.108.1", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] }
swc_node_base = "0.5.1"
swc_stylis = "0.42.0"
swc_stylis = "0.43.0"
tracing = {version = "0.1.28", features = ["release_max_level_off"]}
regex = "1.5"
[dev-dependencies]
swc_ecma_transforms_testing = "0.56.0"
testing = "0.17.0"
swc_ecma_transforms_testing = "0.58.0"
testing = "0.18.0"
walkdir = "2.3.2"
......@@ -18,28 +18,20 @@ struct CjsFinder {
/// does not support changing configuration based on content of the file.
impl Visit for CjsFinder {
fn visit_member_expr(&mut self, e: &MemberExpr) {
if !e.computed {
match &e.obj {
ExprOrSuper::Super(_) => {}
ExprOrSuper::Expr(obj) => match &**obj {
Expr::Ident(obj) => match &*e.prop {
Expr::Ident(prop) => {
if &*obj.sym == "module" && &*prop.sym == "exports" {
self.found = true;
return;
}
}
_ => {}
},
_ => {}
},
}
match &*e.obj {
Expr::Ident(obj) => match &e.prop {
MemberProp::Ident(prop) => {
if &*obj.sym == "module" && &*prop.sym == "exports" {
self.found = true;
return;
}
}
_ => {}
},
_ => {}
}
e.obj.visit_with(self);
if e.computed {
e.prop.visit_with(self);
}
e.prop.visit_with(self);
}
}
use swc_atoms::JsWord;
use swc_common::DUMMY_SP;
use swc_ecmascript::ast::{
ArrayPat, Decl, Expr, ExprOrSuper, Ident, ImportDecl, ImportSpecifier, KeyValuePatProp, Number,
ObjectPat, ObjectPatProp, Pat, PropName, VarDecl, VarDeclarator,
ArrayPat, Callee, Decl, Expr, Ident, ImportDecl, ImportSpecifier, KeyValuePatProp, Number,
ObjectPat, ObjectPatProp, Pat, PropName, VarDecl, VarDeclarator,
};
use swc_ecmascript::visit::{Fold, FoldWith};
pub fn hook_optimizer() -> impl Fold {
HookOptimizer::default()
HookOptimizer::default()
}
#[derive(Debug, Default)]
struct HookOptimizer {
hooks: Vec<JsWord>,
hooks: Vec<JsWord>,
}
impl Fold for HookOptimizer {
// Find hooks imported from react/preact
fn fold_import_decl(&mut self, decl: ImportDecl) -> ImportDecl {
let ImportDecl {
ref src,
ref specifiers,
..
} = decl;
if &src.value == "react" || &src.value == "preact/hooks" {
for specifier in specifiers {
if let ImportSpecifier::Named(named_specifier) = specifier {
if named_specifier.local.sym.starts_with("use") {
self.hooks.push(named_specifier.local.sym.clone())
}
// Find hooks imported from react/preact
fn fold_import_decl(&mut self, decl: ImportDecl) -> ImportDecl {
let ImportDecl {
ref src,
ref specifiers,
..
} = decl;
if &src.value == "react" || &src.value == "preact/hooks" {
for specifier in specifiers {
if let ImportSpecifier::Named(named_specifier) = specifier {
if named_specifier.local.sym.starts_with("use") {
self.hooks.push(named_specifier.local.sym.clone())
}
}
}
}
}
decl
}
// Transform array desctructing to object destructuring for relevant hooks
fn fold_decl(&mut self, node: Decl) -> Decl {
let node = node.fold_children_with(self);
match node {
Decl::Var(VarDecl {
decls,
span,
kind,
declare,
}) => {
let mut new_decls = Vec::with_capacity(decls.len());
for decl in decls {
new_decls.push(self.get_decl(decl));
}
decl
}
// Transform array desctructing to object destructuring for relevant hooks
fn fold_decl(&mut self, node: Decl) -> Decl {
let node = node.fold_children_with(self);
match node {
Decl::Var(VarDecl {
decls,
span,
kind,
declare,
}) => {
let mut new_decls = Vec::with_capacity(decls.len());
for decl in decls {
new_decls.push(self.get_decl(decl));
Decl::Var(VarDecl {
decls: new_decls,
span,
kind,
declare,
})
}
_ => node,
}
Decl::Var(VarDecl {
decls: new_decls,
span,
kind,
declare,
})
}
_ => node,
}
}
}
impl HookOptimizer {
fn get_decl(&mut self, decl: VarDeclarator) -> VarDeclarator {
let VarDeclarator {
name,
init,
span,
definite,
} = &decl;
let init_clone = init.clone();
if let Pat::Array(a) = name {
if let Expr::Call(c) = &*init.as_deref().unwrap() {
if let ExprOrSuper::Expr(i) = &c.callee {
if let Expr::Ident(Ident { sym, .. }) = &**i {
if self.hooks.contains(&sym) {
let name = get_object_pattern(&a);
return VarDeclarator {
name,
init: init_clone,
span: *span,
definite: *definite,
};
fn get_decl(&mut self, decl: VarDeclarator) -> VarDeclarator {
let VarDeclarator {
name,
init,
span,
definite,
} = &decl;
let init_clone = init.clone();
if let Pat::Array(a) = name {
if let Expr::Call(c) = &*init.as_deref().unwrap() {
if let Callee::Expr(i) = &c.callee {
if let Expr::Ident(Ident { sym, .. }) = &**i {
if self.hooks.contains(&sym) {
let name = get_object_pattern(&a);
return VarDeclarator {
name,
init: init_clone,
span: *span,
definite: *definite,
};
}
}
}
}
}
}
}
}
return decl;
}
return decl;
}
}
fn get_object_pattern(array_pattern: &ArrayPat) -> Pat {
let props: Vec<ObjectPatProp> = array_pattern
.elems
.iter()
.enumerate()
.filter_map(|(i, elem)| match elem {
Some(elem) => Some(ObjectPatProp::KeyValue(KeyValuePatProp {
key: PropName::Num(Number {
value: i as f64,
span: DUMMY_SP,
}),
value: Box::new(elem.clone()),
})),
None => None,
})
.collect();
let props: Vec<ObjectPatProp> = array_pattern
.elems
.iter()
.enumerate()
.filter_map(|(i, elem)| match elem {
Some(elem) => Some(ObjectPatProp::KeyValue(KeyValuePatProp {
key: PropName::Num(Number {
value: i as f64,
span: DUMMY_SP,
}),
value: Box::new(elem.clone()),
})),
None => None,
})
.collect();
Pat::Object(ObjectPat {
props,
span: DUMMY_SP,
optional: false,
type_ann: None,
})
Pat::Object(ObjectPat {
props,
span: DUMMY_SP,
optional: false,
type_ann: None,
})
}
......@@ -4,9 +4,9 @@ use pathdiff::diff_paths;
use swc_atoms::js_word;
use swc_common::{FileName, DUMMY_SP};
use swc_ecmascript::ast::{
ArrayLit, ArrowExpr, BinExpr, BinaryOp, BlockStmtOrExpr, Bool, CallExpr, Expr, ExprOrSpread,
ExprOrSuper, Ident, ImportDecl, ImportSpecifier, KeyValueProp, Lit, MemberExpr, Null,
ObjectLit, Prop, PropName, PropOrSpread, Str, StrKind,
ArrayLit, ArrowExpr, BinExpr, BinaryOp, BlockStmtOrExpr, Bool, CallExpr, Callee, Expr,
ExprOrSpread, Ident, ImportDecl, ImportSpecifier, KeyValueProp, Lit, MemberExpr, MemberProp,
Null, ObjectLit, Prop, PropName, PropOrSpread, Str, StrKind,
};
use swc_ecmascript::utils::ExprFactory;
use swc_ecmascript::utils::{
......@@ -63,19 +63,15 @@ impl Fold for NextDynamicPatcher {
fn fold_call_expr(&mut self, expr: CallExpr) -> CallExpr {
if self.is_next_dynamic_first_arg {
if let ExprOrSuper::Expr(e) = &expr.callee {
if let Expr::Ident(Ident { sym, .. }) = &**e {
if sym == "import" {
if let Expr::Lit(Lit::Str(Str { value, .. })) = &*expr.args[0].expr {
self.dynamically_imported_specifier = Some(value.to_string());
}
}
if let Callee::Import(..) = &expr.callee {
if let Expr::Lit(Lit::Str(Str { value, .. })) = &*expr.args[0].expr {
self.dynamically_imported_specifier = Some(value.to_string());
}
}
return expr.fold_children_with(self);
}
let mut expr = expr.fold_children_with(self);
if let ExprOrSuper::Expr(i) = &expr.callee {
if let Callee::Expr(i) = &expr.callee {
if let Expr::Ident(identifier) = &**i {
if self.dynamic_bindings.contains(&identifier.to_id()) {
if expr.args.len() == 0 {
......@@ -182,21 +178,18 @@ impl Fold for NextDynamicPatcher {
body: BlockStmtOrExpr::Expr(Box::new(Expr::Array(ArrayLit {
elems: vec![Some(ExprOrSpread {
expr: Box::new(Expr::Call(CallExpr {
callee: ExprOrSuper::Expr(Box::new(Expr::Member(
callee: Callee::Expr(Box::new(Expr::Member(
MemberExpr {
obj: ExprOrSuper::Expr(Box::new(
Expr::Ident(Ident {
sym: js_word!("require"),
span: DUMMY_SP,
optional: false,
}),
)),
prop: Box::new(Expr::Ident(Ident {
sym: "resolveWeak".into(),
obj: Box::new(Expr::Ident(Ident {
sym: js_word!("require"),
span: DUMMY_SP,
optional: false,
})),
computed: false,
prop: MemberProp::Ident(Ident {
sym: "resolveWeak".into(),
span: DUMMY_SP,
optional: false,
}),
span: DUMMY_SP,
},
))),
......
......@@ -144,12 +144,8 @@ impl Fold for Analyzer<'_> {
fn fold_jsx_element(&mut self, jsx: JSXElement) -> JSXElement {
fn get_leftmost_id_member_expr(e: &JSXMemberExpr) -> Id {
match &e.obj {
JSXObject::Ident(i) => {
i.to_id()
}
JSXObject::JSXMemberExpr(e) => {
get_leftmost_id_member_expr(e)
}
JSXObject::Ident(i) => i.to_id(),
JSXObject::JSXMemberExpr(e) => get_leftmost_id_member_expr(e),
}
}
......@@ -202,16 +198,6 @@ impl Fold for Analyzer<'_> {
f
}
fn fold_member_expr(&mut self, mut e: MemberExpr) -> MemberExpr {
e.obj = e.obj.fold_with(self);
if e.computed {
e.prop = e.prop.fold_with(self);
}
e
}
/// Drops [ExportDecl] if all specifiers are removed.
fn fold_module_item(&mut self, s: ModuleItem) -> ModuleItem {
match s {
......
......@@ -50,7 +50,7 @@ impl RemoveConsole {
fn should_remove_call(&mut self, n: &CallExpr) -> bool {
let callee = &n.callee;
let member_expr = match callee {
ExprOrSuper::Expr(e) => match &**e {
Callee::Expr(e) => match &**e {
Expr::Member(m) => m,
_ => return false,
},
......@@ -58,24 +58,22 @@ impl RemoveConsole {
};
// Don't attempt to evaluate computed properties.
if member_expr.computed {
if matches!(&member_expr.prop, MemberProp::Computed(..)) {
return false;
}
// Only proceed if the object is the global `console` object.
match &member_expr.obj {
ExprOrSuper::Expr(e) => match &**e {
Expr::Ident(i) if self.is_global_console(i) => {}
_ => return false,
},
match &*member_expr.obj {
Expr::Ident(i) if self.is_global_console(i) => {}
_ => return false,
}
// Check if the property is requested to be excluded.
// Here we do an O(n) search on the list of excluded properties because the size
// should be small.
match &*member_expr.prop {
Expr::Ident(i) if self.exclude.iter().find(|x| **x == i.sym).is_none() => {}
match &member_expr.prop {
MemberProp::Ident(i) if self.exclude.iter().find(|x| **x == i.sym).is_none() => {}
_ => return false,
}
......
......@@ -227,8 +227,7 @@ impl Fold for StyledJSXTransformer {
}
}
Expr::Member(MemberExpr {
obj: ExprOrSuper::Expr(boxed_ident),
..
obj: boxed_ident, ..
}) => {
if let Expr::Ident(identifier) = &**boxed_ident {
if self.external_bindings.contains(&identifier.to_id()) {
......@@ -284,7 +283,7 @@ impl Fold for StyledJSXTransformer {
for stmt in block.stmts {
new_stmts.push(stmt.fold_children_with(self));
if let Some(add_hash) = self.add_hash.take() {
new_stmts.push(add_hash_statment(add_hash));
new_stmts.push(add_hash_statement(add_hash));
}
}
......@@ -317,14 +316,14 @@ impl Fold for StyledJSXTransformer {
}))));
self.add_default_decl = None;
if let Some(add_hash) = self.add_hash.take() {
new_items.push(ModuleItem::Stmt(add_hash_statment(add_hash)));
new_items.push(ModuleItem::Stmt(add_hash_statement(add_hash)));
}
}
if !is_styled_css_import(&new_item) {
new_items.push(new_item);
}
if let Some(add_hash) = self.add_hash.take() {
new_items.push(ModuleItem::Stmt(add_hash_statment(add_hash)));
new_items.push(ModuleItem::Stmt(add_hash_statement(add_hash)));
}
}
......@@ -489,13 +488,12 @@ impl StyledJSXTransformer {
StyleExpr::Ident(ident) => {
return JSXStyle::External(ExternalStyle {
expr: Expr::Member(MemberExpr {
obj: ExprOrSuper::Expr(Box::new(Expr::Ident(ident.clone()))),
prop: Box::new(Expr::Ident(Ident {
obj: Box::new(Expr::Ident(ident.clone())),
prop: MemberProp::Ident(Ident {
sym: "__hash".into(),
span: DUMMY_SP,
optional: false,
})),
computed: false,
}),
span: DUMMY_SP,
}),
identifier: ident.clone(),
......@@ -571,13 +569,10 @@ impl StyledJSXTransformer {
compute_class_names(&styles, &self.style_import_name.as_ref().unwrap());
let tag = match &*tagged_tpl.tag {
Expr::Ident(Ident { sym, .. }) => sym.to_string(),
Expr::Member(MemberExpr { prop, .. }) => {
if let Expr::Ident(Ident { sym, .. }) = &**prop {
sym.to_string()
} else {
String::from("not_styled_jsx_tag")
}
}
Expr::Member(MemberExpr {
prop: MemberProp::Ident(Ident { sym, .. }),
..
}) => sym.to_string(),
_ => String::from("not_styled_jsx_tag"),
};
let style = if let JSXStyle::Local(style) = &styles[0] {
......@@ -809,10 +804,9 @@ fn get_existing_class_name(el: &JSXOpeningElement) -> (Option<Expr>, Option<usiz
if valid_spread {
let member_dot_name = Expr::Member(MemberExpr {
obj: ExprOrSuper::Expr(Box::new(*expr.clone())),
prop: Box::new(Expr::Ident(ident("className"))),
obj: Box::new(*expr.clone()),
prop: MemberProp::Ident(ident("className")),
span: DUMMY_SP,
computed: false,
});
// `${name} && ${name}.className != null && ${name}.className`
spreads.push(and(
......@@ -869,22 +863,21 @@ fn join_spreads(spreads: Vec<Expr>) -> Expr {
new_expr
}
fn add_hash_statment((id, hash): (Id, String)) -> Stmt {
fn add_hash_statement((id, hash): (Id, String)) -> Stmt {
Stmt::Expr(ExprStmt {
expr: Box::new(Expr::Assign(AssignExpr {
left: PatOrExpr::Expr(Box::new(Expr::Member(MemberExpr {
obj: ExprOrSuper::Expr(Box::new(Expr::Ident(Ident {
obj: Box::new(Expr::Ident(Ident {
sym: id.0,
span: DUMMY_SP.with_ctxt(id.1),
optional: false,
}))),
prop: Box::new(Expr::Ident(Ident {
})),
prop: MemberProp::Ident(Ident {
sym: "__hash".into(),
span: DUMMY_SP,
optional: false,
})),
}),
span: DUMMY_SP,
computed: false,
}))),
right: Box::new(string_literal_expr(&hash)),
op: op!("="),
......
......@@ -68,19 +68,18 @@ pub fn compute_class_names(
let dynamic_class_name = match dynamic_styles.len() {
0 => None,
_ => Some(Expr::Call(CallExpr {
callee: ExprOrSuper::Expr(Box::new(Expr::Member(MemberExpr {
obj: ExprOrSuper::Expr(Box::new(Expr::Ident(Ident {
callee: Callee::Expr(Box::new(Expr::Member(MemberExpr {
obj: Box::new(Expr::Ident(Ident {
sym: style_import_name.into(),
span: DUMMY_SP,
optional: false,
}))),
prop: Box::new(Expr::Ident(Ident {
})),
prop: MemberProp::Ident(Ident {
sym: "dynamic".into(),
span: DUMMY_SP,
optional: false,
})),
}),
span: DUMMY_SP,
computed: false,
}))),
args: vec![ExprOrSpread {
expr: Box::new(Expr::Array(ArrayLit {
......
......@@ -23,7 +23,7 @@ export const Test2 = ()=><div className={"jsx-81a68341e430a972 " + `jsx-${styles
;
export const Test3 = ({ color })=><div className={`jsx-${styles.__hash}` + " " + _JSXStyle.dynamic([
[
"5cadd6714ea141b4",
"332b21af86b0ec6",
[
color
]
......@@ -32,14 +32,14 @@ export const Test3 = ({ color })=><div className={`jsx-${styles.__hash}` + " "
<p className={`jsx-${styles.__hash}` + " " + _JSXStyle.dynamic([
[
"5cadd6714ea141b4",
"332b21af86b0ec6",
[
color
]
]
])}>external and dynamic</p>
<_JSXStyle id={"5cadd6714ea141b4"} dynamic={[
<_JSXStyle id={"332b21af86b0ec6"} dynamic={[
color
]}>{`p.__jsx-style-dynamic-selector{color:${color}}`}</_JSXStyle>
......@@ -49,7 +49,7 @@ export const Test3 = ({ color })=><div className={`jsx-${styles.__hash}` + " "
;
export const Test4 = ({ color })=><div className={`jsx-${styles.__hash}` + " jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([
[
"8f336bc49da94d3f",
"ec8f36d08fa7aa2c",
[
color
]
......@@ -58,7 +58,7 @@ export const Test4 = ({ color })=><div className={`jsx-${styles.__hash}` + " js
<p className={`jsx-${styles.__hash}` + " jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([
[
"8f336bc49da94d3f",
"ec8f36d08fa7aa2c",
[
color
]
......@@ -67,7 +67,7 @@ export const Test4 = ({ color })=><div className={`jsx-${styles.__hash}` + " js
<_JSXStyle id={"ceba8c9ce34e3d0c"}>{"p.jsx-ceba8c9ce34e3d0c{display:inline-block}"}</_JSXStyle>
<_JSXStyle id={"8f336bc49da94d3f"} dynamic={[
<_JSXStyle id={"ec8f36d08fa7aa2c"} dynamic={[
color
]}>{`p.__jsx-style-dynamic-selector{color:${color}}`}</_JSXStyle>
......@@ -87,7 +87,7 @@ export const Test5 = ()=><div className={"jsx-df0159ebd3f9fb6f"}>
;
export const Test6 = ({ color })=><div className={"jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([
[
"8f336bc49da94d3f",
"ec8f36d08fa7aa2c",
[
color
]
......@@ -96,7 +96,7 @@ export const Test6 = ({ color })=><div className={"jsx-ceba8c9ce34e3d0c " + _JS
<p className={"jsx-ceba8c9ce34e3d0c " + _JSXStyle.dynamic([
[
"8f336bc49da94d3f",
"ec8f36d08fa7aa2c",
[
color
]
......@@ -105,7 +105,7 @@ export const Test6 = ({ color })=><div className={"jsx-ceba8c9ce34e3d0c " + _JS
<_JSXStyle id={"ceba8c9ce34e3d0c"}>{"p.jsx-ceba8c9ce34e3d0c{display:inline-block}"}</_JSXStyle>
<_JSXStyle id={"8f336bc49da94d3f"} dynamic={[
<_JSXStyle id={"ec8f36d08fa7aa2c"} dynamic={[
color
]}>{`p.__jsx-style-dynamic-selector{color:${color}}`}</_JSXStyle>
......@@ -113,7 +113,7 @@ export const Test6 = ({ color })=><div className={"jsx-ceba8c9ce34e3d0c " + _JS
;
export const Test7 = ({ color })=><div className={_JSXStyle.dynamic([
[
"5cadd6714ea141b4",
"332b21af86b0ec6",
[
color
]
......@@ -122,14 +122,14 @@ export const Test7 = ({ color })=><div className={_JSXStyle.dynamic([
<p className={_JSXStyle.dynamic([
[
"5cadd6714ea141b4",
"332b21af86b0ec6",
[
color
]
]
])}>dynamic only</p>
<_JSXStyle id={"5cadd6714ea141b4"} dynamic={[
<_JSXStyle id={"332b21af86b0ec6"} dynamic={[
color
]}>{`p.__jsx-style-dynamic-selector{color:${color}}`}</_JSXStyle>
......@@ -142,7 +142,7 @@ export const Test8 = ({ color })=>{
};
return <div className={_JSXStyle.dynamic([
[
"6e7028e37f6f2a1c",
"c37e7ca12a9fbc5b",
[
innerProps.color
]
......@@ -151,14 +151,14 @@ export const Test8 = ({ color })=>{
<p className={_JSXStyle.dynamic([
[
"6e7028e37f6f2a1c",
"c37e7ca12a9fbc5b",
[
innerProps.color
]
]
])}>dynamic with scoped compound variable</p>
<_JSXStyle id={"6e7028e37f6f2a1c"} dynamic={[
<_JSXStyle id={"c37e7ca12a9fbc5b"} dynamic={[
innerProps.color
]}>{`p.__jsx-style-dynamic-selector{color:${innerProps.color}}`}</_JSXStyle>
......@@ -171,7 +171,7 @@ export const Test9 = ({ color })=>{
};
return <div className={_JSXStyle.dynamic([
[
"33344a45c20c74fe",
"59d22b990ceca2d7",
[
innerProps.color
]
......@@ -180,25 +180,25 @@ export const Test9 = ({ color })=>{
<p className={_JSXStyle.dynamic([
[
"33344a45c20c74fe",
"59d22b990ceca2d7",
[
innerProps.color
]
]
])}>dynamic with compound variable</p>
<_JSXStyle id={"33344a45c20c74fe"} dynamic={[
<_JSXStyle id={"59d22b990ceca2d7"} dynamic={[
innerProps.color
]}>{`p.__jsx-style-dynamic-selector{color:${innerProps.color}}`}</_JSXStyle>
</div>;
};
const foo = "red";
export const Test10 = ()=><div className={"jsx-e993bec5c22e1b75"}>
export const Test10 = ()=><div className={"jsx-64eb0b4e09da0dd3"}>
<p className={"jsx-e993bec5c22e1b75"}>dynamic with constant variable</p>
<p className={"jsx-64eb0b4e09da0dd3"}>dynamic with constant variable</p>
<_JSXStyle id={"e993bec5c22e1b75"}>{`p.jsx-e993bec5c22e1b75{color:${foo}}`}</_JSXStyle>
<_JSXStyle id={"64eb0b4e09da0dd3"}>{`p.jsx-64eb0b4e09da0dd3{color:${foo}}`}</_JSXStyle>
</div>
;
......@@ -207,14 +207,14 @@ export const Test11 = ({ color })=>{
length: 5
}).map((item, i)=><li key={i} className={_JSXStyle.dynamic([
[
"5dc7166977a4514",
"93933d24284432d0",
[
color
]
]
]) + " " + "item"}>
<_JSXStyle id={"5dc7166977a4514"} dynamic={[
<_JSXStyle id={"93933d24284432d0"} dynamic={[
color
]}>{`.item.__jsx-style-dynamic-selector{color:${color}}`}</_JSXStyle>
......
import _JSXStyle from "styled-jsx/style";
const color = "red";
const otherColor = "green";
const A = ()=><div className={"jsx-f44d626e14f3cfbc"}>
const A = ()=><div className={"jsx-319ecfcffea32bfb"}>
<p className={"jsx-f44d626e14f3cfbc"}>test</p>
<p className={"jsx-319ecfcffea32bfb"}>test</p>
<_JSXStyle id={"f44d626e14f3cfbc"}>{`p.jsx-f44d626e14f3cfbc{color:${color}}`}</_JSXStyle>
<_JSXStyle id={"319ecfcffea32bfb"}>{`p.jsx-319ecfcffea32bfb{color:${color}}`}</_JSXStyle>
</div>
;
const B = ()=><div className={"jsx-9db1df72abe82640"}>
const B = ()=><div className={"jsx-8a19b9bd65b986e0"}>
<p className={"jsx-9db1df72abe82640"}>test</p>
<p className={"jsx-8a19b9bd65b986e0"}>test</p>
<_JSXStyle id={"9db1df72abe82640"}>{`p.jsx-9db1df72abe82640{color:${otherColor}}`}</_JSXStyle>
<_JSXStyle id={"8a19b9bd65b986e0"}>{`p.jsx-8a19b9bd65b986e0{color:${otherColor}}`}</_JSXStyle>
</div>
;
......
......@@ -9,85 +9,85 @@ const animationName = "my-cool-animation";
const obj = {
display: "block"
};
export default (({ display })=><div className={"jsx-843124768056a74c " + _JSXStyle.dynamic([
export default (({ display })=><div className={"jsx-1ada4ad4dab7822f " + _JSXStyle.dynamic([
[
"a124d516c2c0707d",
"183a75aa3877c18a",
[
display ? "block" : "none"
]
],
[
"108a316873f1c6fc",
"f07deae908c9294f",
[
darken(color) + 2
]
],
[
"785cf5e120672da8",
"50021e09364b96c8",
[
darken(color)
]
]
])}>
<p className={"jsx-843124768056a74c " + _JSXStyle.dynamic([
<p className={"jsx-1ada4ad4dab7822f " + _JSXStyle.dynamic([
[
"a124d516c2c0707d",
"183a75aa3877c18a",
[
display ? "block" : "none"
]
],
[
"108a316873f1c6fc",
"f07deae908c9294f",
[
darken(color) + 2
]
],
[
"785cf5e120672da8",
"50021e09364b96c8",
[
darken(color)
]
]
])}>test</p>
<_JSXStyle id={"5df43f2861c900e6"}>{`p.${color}.jsx-843124768056a74c{color:${otherColor};
<_JSXStyle id={"6116059e04f3bff7"}>{`p.${color}.jsx-1ada4ad4dab7822f{color:${otherColor};
display:${obj.display}}`}</_JSXStyle>
<_JSXStyle id={"94239b6d6b42c9b5"}>{"p.jsx-843124768056a74c{color:red}"}</_JSXStyle>
<_JSXStyle id={"94239b6d6b42c9b5"}>{"p.jsx-1ada4ad4dab7822f{color:red}"}</_JSXStyle>
<_JSXStyle id={"a971cf00393d41be"}>{`body{background:${color}}`}</_JSXStyle>
<_JSXStyle id={"171303fb0d7f788b"}>{`body{background:${color}}`}</_JSXStyle>
<_JSXStyle id={"a971cf00393d41be"}>{`body{background:${color}}`}</_JSXStyle>
<_JSXStyle id={"171303fb0d7f788b"}>{`body{background:${color}}`}</_JSXStyle>
// TODO: the next two should have the same hash
<_JSXStyle id={"5cadd6714ea141b4"}>{`p.jsx-843124768056a74c{color:${color}}`}</_JSXStyle>
<_JSXStyle id={"332b21af86b0ec6"}>{`p.jsx-1ada4ad4dab7822f{color:${color}}`}</_JSXStyle>
<_JSXStyle id={"5cadd6714ea141b4"}>{`p.jsx-843124768056a74c{color:${color}}`}</_JSXStyle>
<_JSXStyle id={"332b21af86b0ec6"}>{`p.jsx-1ada4ad4dab7822f{color:${color}}`}</_JSXStyle>
<_JSXStyle id={"785cf5e120672da8"} dynamic={[
<_JSXStyle id={"50021e09364b96c8"} dynamic={[
darken(color)
]}>{`p.__jsx-style-dynamic-selector{color:${darken(color)}}`}</_JSXStyle>
<_JSXStyle id={"108a316873f1c6fc"} dynamic={[
<_JSXStyle id={"f07deae908c9294f"} dynamic={[
darken(color) + 2
]}>{`p.__jsx-style-dynamic-selector{color:${darken(color) + 2}}`}</_JSXStyle>
<_JSXStyle id={"bb5a8a5ee5cd36db"}>{`@media (min-width:${mediumScreen}) {p.jsx-843124768056a74c{color:green}
p.jsx-843124768056a74c{color:${`red`}}}
p.jsx-843124768056a74c{color:red}`}</_JSXStyle>
<_JSXStyle id={"4e4be2da62837c76"}>{`@media (min-width:${mediumScreen}) {p.jsx-1ada4ad4dab7822f{color:green}
p.jsx-1ada4ad4dab7822f{color:${`red`}}}
p.jsx-1ada4ad4dab7822f{color:red}`}</_JSXStyle>
<_JSXStyle id={"99746edba785c617"}>{`p.jsx-843124768056a74c{-webkit-animation-duration:${animationDuration};
<_JSXStyle id={"27040f0829fb73d4"}>{`p.jsx-1ada4ad4dab7822f{-webkit-animation-duration:${animationDuration};
animation-duration:${animationDuration}}`}</_JSXStyle>
<_JSXStyle id={"62d69d091a270e9d"}>{`p.jsx-843124768056a74c{-webkit-animation:${animationDuration} forwards ${animationName};
<_JSXStyle id={"3e72d735e703a530"}>{`p.jsx-1ada4ad4dab7822f{-webkit-animation:${animationDuration} forwards ${animationName};
animation:${animationDuration} forwards ${animationName}}
div.jsx-843124768056a74c{background:${color}}`}</_JSXStyle>
div.jsx-1ada4ad4dab7822f{background:${color}}`}</_JSXStyle>
<_JSXStyle id={"a124d516c2c0707d"} dynamic={[
<_JSXStyle id={"183a75aa3877c18a"} dynamic={[
display ? "block" : "none"
]}>{`span.__jsx-style-dynamic-selector{display:${display ? "block" : "none"}}`}</_JSXStyle>
......
import _JSXStyle from "styled-jsx/style";
export default (({ breakPoint })=><div className={_JSXStyle.dynamic([
[
"6b843a9852a4be26",
"42a6f8ca08e1a043",
[
breakPoint
]
]
])}>
<_JSXStyle id={"6b843a9852a4be26"} dynamic={[
<_JSXStyle id={"42a6f8ca08e1a043"} dynamic={[
breakPoint
]}>{`@media (${breakPoint}) {}`}</_JSXStyle>
......
......@@ -3,7 +3,7 @@ export default class {
render() {
return <div className={_JSXStyle.dynamic([
[
"a876575397b32eda",
"5bbb77b0f67942dc",
[
Typography.base.size.default,
Typography.base.lineHeight,
......@@ -17,7 +17,7 @@ export default class {
<p className={_JSXStyle.dynamic([
[
"a876575397b32eda",
"5bbb77b0f67942dc",
[
Typography.base.size.default,
Typography.base.lineHeight,
......@@ -29,7 +29,7 @@ export default class {
]
])}>test</p>
<_JSXStyle id={"a876575397b32eda"} dynamic={[
<_JSXStyle id={"5bbb77b0f67942dc"} dynamic={[
Typography.base.size.default,
Typography.base.lineHeight,
Target.mediumPlus,
......
import _JSXStyle from "styled-jsx/style";
import Link from "next/link";
export default function IndexPage() {
return <div className={"jsx-bc8a8bae32099ce8"}>
return <div className={"jsx-b642661fd6426842"}>
Hello World.{" "}
<Link href="/about">
<a className={"jsx-bc8a8bae32099ce8"}>Abound</a>
<a className={"jsx-b642661fd6426842"}>Abound</a>
</Link>
<_JSXStyle id={"bc8a8bae32099ce8"}>{`a.jsx-bc8a8bae32099ce8{color:${"#abcdef"}12}`}</_JSXStyle>
<_JSXStyle id={"b642661fd6426842"}>{`a.jsx-b642661fd6426842{color:${"#abcdef"}12}`}</_JSXStyle>
</div>;
};
......@@ -6,29 +6,29 @@ bar.__hash = "aaed0341accea8f";
const baz = new String("div{font-size:3em}");
baz.__hash = "aaed0341accea8f";
const a = new String(`div{font-size:${size}em}`);
a.__hash = "f14cced97c082d2c";
a.__hash = "5ba1fcb8b8f3d807";
export const uh = bar;
export const foo = new String(`div.jsx-a0d126276b085021{color:${color}}`);
foo.__hash = "a0d126276b085021";
export const foo = new String(`div.jsx-945eaa83250ed332{color:${color}}`);
foo.__hash = "945eaa83250ed332";
({
styles: <_JSXStyle id={"47e08c293b53f262"}>{`div.jsx-47e08c293b53f262{color:${colors.green.light}}
a.jsx-47e08c293b53f262{color:red}`}</_JSXStyle>,
className: "jsx-47e08c293b53f262"
styles: <_JSXStyle id={"c107a919a5b2943d"}>{`div.jsx-c107a919a5b2943d{color:${colors.green.light}}
a.jsx-c107a919a5b2943d{color:red}`}</_JSXStyle>,
className: "jsx-c107a919a5b2943d"
});
const b = {
styles: <_JSXStyle id={"47e08c293b53f262"}>{`div.jsx-47e08c293b53f262{color:${colors.green.light}}
a.jsx-47e08c293b53f262{color:red}`}</_JSXStyle>,
className: "jsx-47e08c293b53f262"
styles: <_JSXStyle id={"c107a919a5b2943d"}>{`div.jsx-c107a919a5b2943d{color:${colors.green.light}}
a.jsx-c107a919a5b2943d{color:red}`}</_JSXStyle>,
className: "jsx-c107a919a5b2943d"
};
const dynamic = (colors1)=>{
const b = {
styles: <_JSXStyle id={"79d79305fa1611e"} dynamic={[
styles: <_JSXStyle id={"60132422fc87f1d1"} dynamic={[
colors1.green.light
]}>{`div.__jsx-style-dynamic-selector{color:${colors1.green.light}}
a.__jsx-style-dynamic-selector{color:red}`}</_JSXStyle>,
className: _JSXStyle.dynamic([
[
"79d79305fa1611e",
"60132422fc87f1d1",
[
colors1.green.light
]
......@@ -37,7 +37,7 @@ a.__jsx-style-dynamic-selector{color:red}`}</_JSXStyle>,
};
};
export default {
styles: <_JSXStyle id={"d9cea503e39c5315"}>{`div.jsx-d9cea503e39c5315{font-size:3em}
p.jsx-d9cea503e39c5315{color:${color}}`}</_JSXStyle>,
className: "jsx-d9cea503e39c5315"
styles: <_JSXStyle id={"e5da8dd7ff5c7f39"}>{`div.jsx-e5da8dd7ff5c7f39{font-size:3em}
p.jsx-e5da8dd7ff5c7f39{color:${color}}`}</_JSXStyle>,
className: "jsx-e5da8dd7ff5c7f39"
};
......@@ -2,7 +2,7 @@ import _JSXStyle from "styled-jsx/style";
export const Red = ({ Component ="button" })=>{
return <Component className={_JSXStyle.dynamic([
[
"ab280f80c0d19763",
"ca900d186ad0e495",
[
e1,
e2,
......@@ -27,7 +27,7 @@ export const Red = ({ Component ="button" })=>{
{}
<_JSXStyle id={"ab280f80c0d19763"} dynamic={[
<_JSXStyle id={"ca900d186ad0e495"} dynamic={[
e1,
e2,
e3,
......
......@@ -2,14 +2,14 @@ import _JSXStyle from "styled-jsx/style";
export default function Home({ fontFamily }) {
return <div className={_JSXStyle.dynamic([
[
"d64fed44dbc5d8df",
"f804e2f486b6ac13",
[
fontFamily
]
]
])}>
<_JSXStyle id={"d64fed44dbc5d8df"} dynamic={[
<_JSXStyle id={"f804e2f486b6ac13"} dynamic={[
fontFamily
]}>{`body{font-family:${fontFamily}}
code:before, code:after{content:'\`'}`}</_JSXStyle>
......
......@@ -3,7 +3,7 @@ export default class {
render() {
return <div className={_JSXStyle.dynamic([
[
"8c1103276226be14",
"e359801ddd3b3cb6",
[
inputSize ? "height: calc(2 * var(--a)) !important;" : ""
]
......@@ -12,14 +12,14 @@ export default class {
<p className={_JSXStyle.dynamic([
[
"8c1103276226be14",
"e359801ddd3b3cb6",
[
inputSize ? "height: calc(2 * var(--a)) !important;" : ""
]
]
])}>test</p>
<_JSXStyle id={"8c1103276226be14"} dynamic={[
<_JSXStyle id={"e359801ddd3b3cb6"} dynamic={[
inputSize ? "height: calc(2 * var(--a)) !important;" : ""
]}>{`@media only screen {a.__jsx-style-dynamic-selector{${inputSize ? "height: calc(2 * var(--a)) !important;" : ""}
}}`}</_JSXStyle>
......
......@@ -3,7 +3,7 @@ export default class {
render() {
return <div className={_JSXStyle.dynamic([
[
"1a8c0e5c60018729",
"1a799d9370a3a386",
[
a[b],
-1 * (c || 0),
......@@ -14,7 +14,7 @@ export default class {
<p className={_JSXStyle.dynamic([
[
"1a8c0e5c60018729",
"1a799d9370a3a386",
[
a[b],
-1 * (c || 0),
......@@ -23,7 +23,7 @@ export default class {
]
])}>test</p>
<_JSXStyle id={"1a8c0e5c60018729"} dynamic={[
<_JSXStyle id={"1a799d9370a3a386"} dynamic={[
a[b],
-1 * (c || 0),
d
......
......@@ -3,7 +3,7 @@ export default class {
render() {
return <div className={_JSXStyle.dynamic([
[
"1dd34a5c235f087f",
"4ca4ef3595473f53",
[
a
]
......@@ -12,14 +12,14 @@ export default class {
<p className={_JSXStyle.dynamic([
[
"1dd34a5c235f087f",
"4ca4ef3595473f53",
[
a
]
]
])}>test</p>
<_JSXStyle id={"1dd34a5c235f087f"} dynamic={[
<_JSXStyle id={"4ca4ef3595473f53"} dynamic={[
a
]}>{`@media only screen {a.__jsx-style-dynamic-selector{color:${a}}}`}</_JSXStyle>
......
......@@ -3,7 +3,7 @@ export default class {
render() {
return <div className={_JSXStyle.dynamic([
[
"35bb702eb335aa6f",
"97886c1e9511aafa",
[
a || "var(--c)",
b || "inherit"
......@@ -13,7 +13,7 @@ export default class {
<p className={_JSXStyle.dynamic([
[
"35bb702eb335aa6f",
"97886c1e9511aafa",
[
a || "var(--c)",
b || "inherit"
......@@ -21,7 +21,7 @@ export default class {
]
])}>test</p>
<_JSXStyle id={"35bb702eb335aa6f"} dynamic={[
<_JSXStyle id={"97886c1e9511aafa"} dynamic={[
a || "var(--c)",
b || "inherit"
]}>{`.a:hover .b.__jsx-style-dynamic-selector{display:inline-block;
......
......@@ -3,7 +3,7 @@ export default class {
render() {
return <div className={_JSXStyle.dynamic([
[
"21ae2868f133bbf6",
"bcc606c168bcd197",
[
a ? "100%" : "200px",
b ? "0" : "8px 20px"
......@@ -13,7 +13,7 @@ export default class {
<p className={_JSXStyle.dynamic([
[
"21ae2868f133bbf6",
"bcc606c168bcd197",
[
a ? "100%" : "200px",
b ? "0" : "8px 20px"
......@@ -21,7 +21,7 @@ export default class {
]
])}>test</p>
<_JSXStyle id={"21ae2868f133bbf6"} dynamic={[
<_JSXStyle id={"bcc606c168bcd197"} dynamic={[
a ? "100%" : "200px",
b ? "0" : "8px 20px"
]}>{`.item.__jsx-style-dynamic-selector{max-width:${a ? "100%" : "200px"};
......
......@@ -16,12 +16,12 @@ once_cell = "1.8.0"
serde = "1"
serde_json = "1"
next-swc = { version = "0.0.0", path = "../core" }
swc = "0.110.0"
swc = "0.114.0"
swc_atoms = "0.2.7"
swc_bundler = { version = "0.98.0", features = ["concurrent"] }
swc_common = { version = "0.16.0", features = ["concurrent", "sourcemap"] }
swc_ecma_loader = { version = "0.26.0", features = ["node", "lru"] }
swc_ecmascript = { version = "0.105.0", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] }
swc_bundler = { version = "0.101.0", features = ["concurrent"] }
swc_common = { version = "0.17.0", features = ["concurrent", "sourcemap"] }
swc_ecma_loader = { version = "0.27.0", features = ["node", "lru"] }
swc_ecmascript = { version = "0.108.1", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] }
swc_node_base = "0.5.1"
[build-dependencies]
......
......@@ -16,9 +16,9 @@ path-clean = "0.1"
serde = {version = "1", features = ["derive"]}
serde_json = "1"
next-swc = { version = "0.0.0", path = "../core" }
swc = "0.110.0"
swc_common = { version = "0.16.0", features = ["concurrent", "sourcemap"] }
swc_ecmascript = { version = "0.105.0", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] }
swc = "0.114.0"
swc_common = { version = "0.17.0", features = ["concurrent", "sourcemap"] }
swc_ecmascript = { version = "0.108.1", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] }
tracing = {version = "0.1.28", features = ["release_max_level_off"]}
wasm-bindgen = {version = "0.2", features = ["serde-serialize"]}
wasm-bindgen-futures = "0.4.8"
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