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

Update swc (#29460)

parent 7bbaff74
This diff is collapsed.
...@@ -16,27 +16,28 @@ path-clean = "0.1" ...@@ -16,27 +16,28 @@ path-clean = "0.1"
regex = "1.5" regex = "1.5"
serde = "1" serde = "1"
serde_json = "1" serde_json = "1"
swc = "0.51" swc = "0.58.0"
swc_atoms = "0.2" swc_atoms = "0.2"
swc_common = { version = "0.12", features = ["tty-emitter", "sourcemap"] } swc_common = { version = "0.13.0", features = ["concurrent", "sourcemap"] }
swc_css = "0.6" swc_css = "0.8.0"
swc_css_codegen = "0.4" swc_css_codegen = "0.6.0"
swc_ecmascript = { version = "0.63", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] } swc_ecmascript = { version = "0.66.0", features = ["codegen", "minifier", "optimization", "parser", "react", "transforms", "typescript", "utils", "visit"] }
swc_ecma_preset_env = "0.42" swc_ecma_preset_env = "0.45.0"
swc_node_base = "0.3" swc_node_base = "0.3"
swc_stylis = "0.3" swc_stylis = "0.5.0"
fxhash = "0.2.1" fxhash = "0.2.1"
retain_mut = "0.1.3" retain_mut = "0.1.3"
log = {version="0.4.14", features = ["release_max_level_off"] }
pathdiff = "0.2.0" pathdiff = "0.2.0"
rustc-hash = "1.1.0"
tracing = { version = "0.1.28", features = ["release_max_level_off"] }
[build-dependencies] [build-dependencies]
napi-build = "1" napi-build = "1"
[dev-dependencies] [dev-dependencies]
swc_ecma_transforms_testing = "0.32" swc_ecma_transforms_testing = "0.34.0"
testing = "0.13" testing = "0.14.0"
[profile.release] [profile.release]
lto = true lto = true
...@@ -90,7 +90,7 @@ struct Analyzer<'a> { ...@@ -90,7 +90,7 @@ struct Analyzer<'a> {
impl Analyzer<'_> { impl Analyzer<'_> {
fn add_ref(&mut self, id: Id) { fn add_ref(&mut self, id: Id) {
log::trace!("add_ref({}{:?}, data = {})", id.0, id.1, self.in_data_fn); tracing::trace!("add_ref({}{:?}, data = {})", id.0, id.1, self.in_data_fn);
if self.in_data_fn { if self.in_data_fn {
self.state.refs_from_data_fn.insert(id); self.state.refs_from_data_fn.insert(id);
} else { } else {
...@@ -140,7 +140,7 @@ impl Fold for Analyzer<'_> { ...@@ -140,7 +140,7 @@ impl Fold for Analyzer<'_> {
self.state.cur_declaring.insert(f.ident.to_id()); self.state.cur_declaring.insert(f.ident.to_id());
self.in_data_fn |= self.state.is_data_identifier(&f.ident); self.in_data_fn |= self.state.is_data_identifier(&f.ident);
log::trace!( tracing::trace!(
"ssg: Handling `{}{:?}`; in_data_fn = {:?}", "ssg: Handling `{}{:?}`; in_data_fn = {:?}",
f.ident.sym, f.ident.sym,
f.ident.span.ctxt, f.ident.span.ctxt,
...@@ -282,7 +282,7 @@ impl NextSsg { ...@@ -282,7 +282,7 @@ impl NextSsg {
where where
N: for<'aa> FoldWith<Analyzer<'aa>>, N: for<'aa> FoldWith<Analyzer<'aa>>,
{ {
log::debug!("mark_as_candidate"); tracing::debug!("mark_as_candidate");
// Analyzer never change `in_data_fn` to false, so all identifiers in `n` will // Analyzer never change `in_data_fn` to false, so all identifiers in `n` will
// be marked as referenced from a data function. // be marked as referenced from a data function.
...@@ -329,7 +329,7 @@ impl Fold for NextSsg { ...@@ -329,7 +329,7 @@ impl Fold for NextSsg {
| ImportSpecifier::Default(ImportDefaultSpecifier { local, .. }) | ImportSpecifier::Default(ImportDefaultSpecifier { local, .. })
| ImportSpecifier::Namespace(ImportStarAsSpecifier { local, .. }) => { | ImportSpecifier::Namespace(ImportStarAsSpecifier { local, .. }) => {
if self.should_remove(local.to_id()) { if self.should_remove(local.to_id()) {
log::trace!( tracing::trace!(
"Dropping import `{}{:?}` because it should be removed", "Dropping import `{}{:?}` because it should be removed",
local.sym, local.sym,
local.span.ctxt local.span.ctxt
...@@ -347,7 +347,7 @@ impl Fold for NextSsg { ...@@ -347,7 +347,7 @@ impl Fold for NextSsg {
} }
fn fold_module(&mut self, mut m: Module) -> Module { fn fold_module(&mut self, mut m: Module) -> Module {
log::info!("ssg: Start"); tracing::info!("ssg: Start");
{ {
// Fill the state. // Fill the state.
let mut v = Analyzer { let mut v = Analyzer {
...@@ -481,7 +481,7 @@ impl Fold for NextSsg { ...@@ -481,7 +481,7 @@ impl Fold for NextSsg {
}; };
if !preserve { if !preserve {
log::trace!("Dropping a export specifier because it's a data identifier"); tracing::trace!("Dropping a export specifier because it's a data identifier");
match s { match s {
ExportSpecifier::Named(ExportNamedSpecifier { orig, .. }) => { ExportSpecifier::Named(ExportNamedSpecifier { orig, .. }) => {
...@@ -507,7 +507,7 @@ impl Fold for NextSsg { ...@@ -507,7 +507,7 @@ impl Fold for NextSsg {
Pat::Ident(name) => { Pat::Ident(name) => {
if self.should_remove(name.id.to_id()) { if self.should_remove(name.id.to_id()) {
self.state.should_run_again = true; self.state.should_run_again = true;
log::trace!( tracing::trace!(
"Dropping var `{}{:?}` because it should be removed", "Dropping var `{}{:?}` because it should be removed",
name.id.sym, name.id.sym,
name.id.span.ctxt name.id.span.ctxt
......
...@@ -26,6 +26,9 @@ pub fn transform_css( ...@@ -26,6 +26,9 @@ pub fn transform_css(
ParserConfig { ParserConfig {
parse_values: false, parse_values: false,
}, },
// We ignore errors because we inject placeholders for expressions which is
// not a valid css.
&mut vec![],
); );
let mut ss = match result { let mut ss = match result {
Ok(ss) => ss, Ok(ss) => ss,
...@@ -148,6 +151,8 @@ impl Namespacer { ...@@ -148,6 +151,8 @@ impl Namespacer {
ParserConfig { ParserConfig {
parse_values: false, parse_values: false,
}, },
// TODO(kdy1): We might be able to report syntax errors.
&mut vec![],
) )
.unwrap(); .unwrap();
return x; return x;
......
export default class {
render() {
return (
<div>
<p>test</p>
<style jsx>{`
@media only screen {
a {
${inputSize ? 'height: calc(2 * var(--a)) !important;' : ''}
}
}
`}</style>
</div>
)
}
}
\ No newline at end of file
import _JSXStyle from "styled-jsx/style";
export default class {
render() {
return <div className={_JSXStyle.dynamic([
[
"8b268cf2c0a3f89b",
[
inputSize ? "height: calc(2 * var(--a)) !important;" : ""
]
]
])}>
<p className={_JSXStyle.dynamic([
[
"8b268cf2c0a3f89b",
[
inputSize ? "height: calc(2 * var(--a)) !important;" : ""
]
]
])}>test</p>
<_JSXStyle id={"8b268cf2c0a3f89b"} dynamic={[
inputSize ? "height: calc(2 * var(--a)) !important;" : ""
]}>{`@media only screen {a.__jsx-style-dynamic-selector {${inputSize ? "height: calc(2 * var(--a)) !important;" : ""} }}`}</_JSXStyle>
</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