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

Update swc (#36535)

This PR updates swc to https://github.com/swc-project/swc/commit/a72f436148db1aecfbfcbf64c902f926b44e9dbf


This PR applies

 - https://github.com/swc-project/swc/pull/4452
   - Fixes `yield*` of async generators in async generators.
   - Fixes name mangling of injected helpers.
     - Note: This only applies to tiny files which enables lots of helpers.
 - https://github.com/swc-project/swc/pull/4468
   - Fixes newer version of react.
parent 0b0b5ca7
...@@ -940,7 +940,7 @@ dependencies = [ ...@@ -940,7 +940,7 @@ dependencies = [
[[package]] [[package]]
name = "modularize_imports" name = "modularize_imports"
version = "0.1.1" version = "0.3.0"
dependencies = [ dependencies = [
"handlebars", "handlebars",
"once_cell", "once_cell",
...@@ -1794,7 +1794,7 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" ...@@ -1794,7 +1794,7 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
[[package]] [[package]]
name = "styled_components" name = "styled_components"
version = "0.26.0" version = "0.28.0"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"once_cell", "once_cell",
...@@ -1811,7 +1811,7 @@ dependencies = [ ...@@ -1811,7 +1811,7 @@ dependencies = [
[[package]] [[package]]
name = "styled_jsx" name = "styled_jsx"
version = "0.1.1" version = "0.3.0"
dependencies = [ dependencies = [
"easy-error", "easy-error",
"swc_common", "swc_common",
...@@ -1853,9 +1853,9 @@ dependencies = [ ...@@ -1853,9 +1853,9 @@ dependencies = [
[[package]] [[package]]
name = "swc" name = "swc"
version = "0.172.1" version = "0.172.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4e29e879868284573c7d2edb014a6dde86a4a5b0dc060648c77ac2ac9ffccf0" checksum = "a76b9b1ae60c451c7510d48382a4d00118c0c9f8b11dbfd19f2e31f43b61234e"
dependencies = [ dependencies = [
"ahash", "ahash",
"anyhow", "anyhow",
...@@ -2197,9 +2197,9 @@ dependencies = [ ...@@ -2197,9 +2197,9 @@ dependencies = [
[[package]] [[package]]
name = "swc_ecma_minifier" name = "swc_ecma_minifier"
version = "0.107.0" version = "0.107.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee95fc1f92a21048d05ad6072dee0bdba3eb1dc35dbf487b13f2565633a889a7" checksum = "63849757c8b868b0ff7cd0fededd16e239a227863b9ec1aeade95a5839927fd6"
dependencies = [ dependencies = [
"ahash", "ahash",
"arrayvec", "arrayvec",
...@@ -2229,9 +2229,9 @@ dependencies = [ ...@@ -2229,9 +2229,9 @@ dependencies = [
[[package]] [[package]]
name = "swc_ecma_parser" name = "swc_ecma_parser"
version = "0.102.8" version = "0.102.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d82e92a57b370b3d59c1d613b3f68cf37d7f6960c36b349484b9ccd09b881d43" checksum = "aac5c37aa7bf93679d30d9d787ff985fca528fe4b15cf40321389a506aec10b3"
dependencies = [ dependencies = [
"either", "either",
"enum_kind", "enum_kind",
...@@ -2249,9 +2249,9 @@ dependencies = [ ...@@ -2249,9 +2249,9 @@ dependencies = [
[[package]] [[package]]
name = "swc_ecma_preset_env" name = "swc_ecma_preset_env"
version = "0.123.0" version = "0.123.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44db6900807c2792c07169dcc174b089c3b2c58efca6df9e1b80b927da60e3fd" checksum = "2ecd6f2e476981e127706792bf6f6d086bab33c6156a473a1fb7eb36931308ba"
dependencies = [ dependencies = [
"ahash", "ahash",
"anyhow", "anyhow",
...@@ -2294,13 +2294,14 @@ dependencies = [ ...@@ -2294,13 +2294,14 @@ dependencies = [
[[package]] [[package]]
name = "swc_ecma_transforms_base" name = "swc_ecma_transforms_base"
version = "0.80.0" version = "0.80.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba127853a1cf7e0b0411de93e67265934445f693c7420c67195fdab3e5d5335f" checksum = "01241a65b5919ea63f0e1f81bd35c91d39999835a3bf1140529086dff4fcee82"
dependencies = [ dependencies = [
"better_scoped_tls", "better_scoped_tls",
"once_cell", "once_cell",
"phf", "phf",
"rustc-hash",
"serde", "serde",
"smallvec", "smallvec",
"swc_atoms", "swc_atoms",
...@@ -2328,9 +2329,9 @@ dependencies = [ ...@@ -2328,9 +2329,9 @@ dependencies = [
[[package]] [[package]]
name = "swc_ecma_transforms_compat" name = "swc_ecma_transforms_compat"
version = "0.94.0" version = "0.94.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24ac08ad78a45a5e41d2f6fa1f1085ed4500b56346ce4cbedac08528a779bdd9" checksum = "f9ca54cf58110c2c4ceeb71d35decdd8f7798edf8aa4bfc553748f12c0fbfe96"
dependencies = [ dependencies = [
"ahash", "ahash",
"arrayvec", "arrayvec",
...@@ -2540,7 +2541,7 @@ dependencies = [ ...@@ -2540,7 +2541,7 @@ dependencies = [
[[package]] [[package]]
name = "swc_emotion" name = "swc_emotion"
version = "0.2.1" version = "0.4.0"
dependencies = [ dependencies = [
"base64 0.13.0", "base64 0.13.0",
"byteorder", "byteorder",
......
...@@ -140,7 +140,12 @@ pub fn custom_before_pass<'a, C: Comments + 'a>( ...@@ -140,7 +140,12 @@ pub fn custom_before_pass<'a, C: Comments + 'a>(
Either::Left(chain!( Either::Left(chain!(
styled_components::analyzer(config.clone(), state.clone()), styled_components::analyzer(config.clone(), state.clone()),
styled_components::display_name_and_id(file.clone(), config, state) styled_components::display_name_and_id(
file.name.clone(),
file.src_hash,
config,
state
)
)) ))
} }
None => { None => {
......
...@@ -4,34 +4,34 @@ function b(c, a) { ...@@ -4,34 +4,34 @@ function b(c, a) {
return d; return d;
} }
import a from "other"; import a from "other";
(function(c, b) { (function(a, c) {
return function(c) { return function(a) {
if (Array.isArray(c)) return c; if (Array.isArray(a)) return a;
}(c) || function(c, b) { }(a) || function(b, e) {
var d, e, a = null == c ? null : "undefined" != typeof Symbol && c[Symbol.iterator] || c["@@iterator"]; var f, g, a = null == b ? null : "undefined" != typeof Symbol && b[Symbol.iterator] || b["@@iterator"];
if (null != a) { if (null != a) {
var b = [], c = !0, f = !1; var c = [], d = !0, h = !1;
try { try {
for(a = a.call(c); !(c = (d = a.next()).done) && (b.push(d.value), !b || b.length !== b); c = !0); for(a = a.call(b); !(d = (f = a.next()).done) && (c.push(f.value), !e || c.length !== e); d = !0);
} catch (g) { } catch (i) {
f = !0, e = g; h = !0, g = i;
} finally{ } finally{
try { try {
c || null == a.return || a.return(); d || null == a.return || a.return();
} finally{ } finally{
if (f) throw e; if (h) throw g;
} }
} }
return b; return c;
} }
}(c, b) || function(a, d) { }(a, c) || function(a, d) {
if (a) { if (a) {
if ("string" == typeof a) return b(a, d); if ("string" == typeof a) return b(a, d);
var c = Object.prototype.toString.call(a).slice(8, -1); var c = Object.prototype.toString.call(a).slice(8, -1);
if ("Object" === c && a.constructor && (c = a.constructor.name), "Map" === c || "Set" === c) return Array.from(c); if ("Object" === c && a.constructor && (c = a.constructor.name), "Map" === c || "Set" === c) return Array.from(c);
if ("Arguments" === c || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)) return b(a, d); if ("Arguments" === c || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(c)) return b(a, d);
} }
}(c, b) || function() { }(a, c) || function() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}(); }();
})(a, 1)[0]; })(a, 1)[0];
......
...@@ -5,7 +5,7 @@ description = "AST Transforms for emotion" ...@@ -5,7 +5,7 @@ description = "AST Transforms for emotion"
license = "Apache-2.0" license = "Apache-2.0"
name = "swc_emotion" name = "swc_emotion"
repository = "https://github.com/vercel/next.js.git" repository = "https://github.com/vercel/next.js.git"
version = "0.2.1" version = "0.4.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
......
...@@ -5,7 +5,7 @@ edition = "2018" ...@@ -5,7 +5,7 @@ edition = "2018"
license = "Apache-2.0" license = "Apache-2.0"
name = "modularize_imports" name = "modularize_imports"
repository = "https://github.com/vercel/next.js.git" repository = "https://github.com/vercel/next.js.git"
version = "0.1.1" version = "0.3.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
......
...@@ -2,10 +2,11 @@ ...@@ -2,10 +2,11 @@
authors = ["강동윤 <kdy1997.dev@gmail.com>"] authors = ["강동윤 <kdy1997.dev@gmail.com>"]
description = "AST Transforms for styled-components" description = "AST Transforms for styled-components"
edition = "2018" edition = "2018"
include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0" license = "Apache-2.0"
name = "styled_components" name = "styled_components"
repository = "https://github.com/vercel/next.js.git" repository = "https://github.com/vercel/next.js.git"
version = "0.26.0" version = "0.28.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
...@@ -15,12 +16,12 @@ once_cell = "1.10.0" ...@@ -15,12 +16,12 @@ once_cell = "1.10.0"
regex = {version = "1.5.4", features = ["std", "perf"], default-features = false} regex = {version = "1.5.4", features = ["std", "perf"], default-features = false}
serde = {version = "1.0.130", features = ["derive"]} serde = {version = "1.0.130", features = ["derive"]}
swc_atoms = "0.2.11" swc_atoms = "0.2.11"
swc_common = { version = "0.17.25", features = ["concurrent"] } swc_common = {version = "0.17.25", features = ["concurrent"]}
swc_ecmascript = { version = "0.150.0", features = ["utils", "visit"] } swc_ecmascript = {version = "0.150.0", features = ["utils", "visit"]}
tracing = "0.1.32" tracing = "0.1.32"
[dev-dependencies] [dev-dependencies]
serde_json = "1" serde_json = "1"
swc_ecma_transforms_testing = "0.82.0" swc_ecma_transforms_testing = "0.82.0"
swc_ecmascript = { version = "0.150.0", features = ["parser", "transforms"] } swc_ecmascript = {version = "0.150.0", features = ["parser", "transforms"]}
testing = "0.19.1" testing = "0.19.1"
#![deny(unused)]
pub use crate::{ pub use crate::{
utils::{analyze, analyzer, State}, utils::{analyze, analyzer, State},
visitors::{ visitors::{
...@@ -5,9 +7,9 @@ pub use crate::{ ...@@ -5,9 +7,9 @@ pub use crate::{
}, },
}; };
use serde::Deserialize; use serde::Deserialize;
use std::{cell::RefCell, rc::Rc, sync::Arc}; use std::{cell::RefCell, rc::Rc};
use swc_atoms::JsWord; use swc_atoms::JsWord;
use swc_common::{chain, SourceFile}; use swc_common::{chain, FileName};
use swc_ecmascript::visit::{Fold, VisitMut}; use swc_ecmascript::visit::{Fold, VisitMut};
mod css; mod css;
...@@ -58,13 +60,17 @@ impl Config { ...@@ -58,13 +60,17 @@ impl Config {
/// NOTE: **This is not complete**. /// NOTE: **This is not complete**.
/// ///
/// Only [analyzer] and [display_name_and_id] is implemented. /// Only [analyzer] and [display_name_and_id] is implemented.
pub fn styled_components(file: Arc<SourceFile>, config: Config) -> impl Fold + VisitMut { pub fn styled_components(
file_name: FileName,
src_file_hash: u128,
config: Config,
) -> impl Fold + VisitMut {
let state: Rc<RefCell<State>> = Default::default(); let state: Rc<RefCell<State>> = Default::default();
let config = Rc::new(config); let config = Rc::new(config);
chain!( chain!(
analyzer(config.clone(), state.clone()), analyzer(config.clone(), state.clone()),
display_name_and_id(file, config, state), display_name_and_id(file_name, src_file_hash, config, state),
transpile_css_prop() transpile_css_prop()
) )
} }
...@@ -4,9 +4,9 @@ use crate::{ ...@@ -4,9 +4,9 @@ use crate::{
}; };
use once_cell::sync::Lazy; use once_cell::sync::Lazy;
use regex::Regex; use regex::Regex;
use std::{cell::RefCell, convert::TryInto, path::Path, rc::Rc, sync::Arc}; use std::{cell::RefCell, convert::TryInto, path::Path, rc::Rc};
use swc_atoms::{js_word, JsWord}; use swc_atoms::{js_word, JsWord};
use swc_common::{util::take::Take, FileName, SourceFile, DUMMY_SP}; use swc_common::{util::take::Take, FileName, DUMMY_SP};
use swc_ecmascript::{ use swc_ecmascript::{
ast::*, ast::*,
utils::{quote_ident, ExprFactory}, utils::{quote_ident, ExprFactory},
...@@ -15,12 +15,15 @@ use swc_ecmascript::{ ...@@ -15,12 +15,15 @@ use swc_ecmascript::{
use tracing::{debug, span, trace, Level}; use tracing::{debug, span, trace, Level};
pub fn display_name_and_id( pub fn display_name_and_id(
file: Arc<SourceFile>, file_name: FileName,
src_file_hash: u128,
config: Rc<Config>, config: Rc<Config>,
state: Rc<RefCell<State>>, state: Rc<RefCell<State>>,
) -> impl Fold + VisitMut { ) -> impl Fold + VisitMut {
as_folder(DisplayNameAndId { as_folder(DisplayNameAndId {
file, file_name,
src_file_hash,
config, config,
state, state,
cur_display_name: Default::default(), cur_display_name: Default::default(),
...@@ -33,7 +36,9 @@ static DISPLAY_NAME_REGEX: Lazy<Regex> = ...@@ -33,7 +36,9 @@ static DISPLAY_NAME_REGEX: Lazy<Regex> =
#[derive(Debug)] #[derive(Debug)]
struct DisplayNameAndId { struct DisplayNameAndId {
file: Arc<SourceFile>, file_name: FileName,
src_file_hash: u128,
config: Rc<Config>, config: Rc<Config>,
state: Rc<RefCell<State>>, state: Rc<RefCell<State>>,
...@@ -59,7 +64,7 @@ impl DisplayNameAndId { ...@@ -59,7 +64,7 @@ impl DisplayNameAndId {
fn get_display_name(&mut self, _: &Expr) -> JsWord { fn get_display_name(&mut self, _: &Expr) -> JsWord {
let component_name = self.cur_display_name.clone().unwrap_or(js_word!("")); let component_name = self.cur_display_name.clone().unwrap_or(js_word!(""));
match &self.file.name { match &self.file_name {
FileName::Real(f) if self.config.file_name => { FileName::Real(f) if self.config.file_name => {
let block_name = self.get_block_name(f); let block_name = self.get_block_name(f);
...@@ -91,7 +96,7 @@ impl DisplayNameAndId { ...@@ -91,7 +96,7 @@ impl DisplayNameAndId {
let next_id = self.next_id(); let next_id = self.next_id();
let hash = { let hash = {
let base = self.file.src_hash; let base = self.src_file_hash;
let base = base.to_be_bytes(); let base = base.to_be_bytes();
let a = u32::from_be_bytes(base[0..4].try_into().unwrap()); let a = u32::from_be_bytes(base[0..4].try_into().unwrap());
let b = u32::from_be_bytes(base[4..8].try_into().unwrap()); let b = u32::from_be_bytes(base[4..8].try_into().unwrap());
......
...@@ -27,7 +27,7 @@ fn fixture(input: PathBuf) { ...@@ -27,7 +27,7 @@ fn fixture(input: PathBuf) {
chain!( chain!(
resolver(Mark::new(), Mark::new(), false), resolver(Mark::new(), Mark::new(), false),
styled_components(fm, config.clone()) styled_components(fm.name.clone(), fm.src_hash, config.clone())
) )
}, },
&input, &input,
......
...@@ -5,7 +5,7 @@ edition = "2018" ...@@ -5,7 +5,7 @@ edition = "2018"
license = "Apache-2.0" license = "Apache-2.0"
name = "styled_jsx" name = "styled_jsx"
repository = "https://github.com/vercel/next.js.git" repository = "https://github.com/vercel/next.js.git"
version = "0.1.1" version = "0.3.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
......
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