Update swc (#36535)
This PR updates swc to a72f436148
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.
This commit is contained in:
parent
0b0b5ca75c
commit
38aa6d7140
10 changed files with 68 additions and 50 deletions
33
packages/next-swc/Cargo.lock
generated
33
packages/next-swc/Cargo.lock
generated
|
@ -940,7 +940,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "modularize_imports"
|
||||
version = "0.1.1"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"handlebars",
|
||||
"once_cell",
|
||||
|
@ -1794,7 +1794,7 @@ checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
|
|||
|
||||
[[package]]
|
||||
name = "styled_components"
|
||||
version = "0.26.0"
|
||||
version = "0.28.0"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"once_cell",
|
||||
|
@ -1811,7 +1811,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "styled_jsx"
|
||||
version = "0.1.1"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"easy-error",
|
||||
"swc_common",
|
||||
|
@ -1853,9 +1853,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "swc"
|
||||
version = "0.172.1"
|
||||
version = "0.172.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4e29e879868284573c7d2edb014a6dde86a4a5b0dc060648c77ac2ac9ffccf0"
|
||||
checksum = "a76b9b1ae60c451c7510d48382a4d00118c0c9f8b11dbfd19f2e31f43b61234e"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"anyhow",
|
||||
|
@ -2197,9 +2197,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "swc_ecma_minifier"
|
||||
version = "0.107.0"
|
||||
version = "0.107.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee95fc1f92a21048d05ad6072dee0bdba3eb1dc35dbf487b13f2565633a889a7"
|
||||
checksum = "63849757c8b868b0ff7cd0fededd16e239a227863b9ec1aeade95a5839927fd6"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"arrayvec",
|
||||
|
@ -2229,9 +2229,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "swc_ecma_parser"
|
||||
version = "0.102.8"
|
||||
version = "0.102.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d82e92a57b370b3d59c1d613b3f68cf37d7f6960c36b349484b9ccd09b881d43"
|
||||
checksum = "aac5c37aa7bf93679d30d9d787ff985fca528fe4b15cf40321389a506aec10b3"
|
||||
dependencies = [
|
||||
"either",
|
||||
"enum_kind",
|
||||
|
@ -2249,9 +2249,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "swc_ecma_preset_env"
|
||||
version = "0.123.0"
|
||||
version = "0.123.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44db6900807c2792c07169dcc174b089c3b2c58efca6df9e1b80b927da60e3fd"
|
||||
checksum = "2ecd6f2e476981e127706792bf6f6d086bab33c6156a473a1fb7eb36931308ba"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"anyhow",
|
||||
|
@ -2294,13 +2294,14 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "swc_ecma_transforms_base"
|
||||
version = "0.80.0"
|
||||
version = "0.80.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba127853a1cf7e0b0411de93e67265934445f693c7420c67195fdab3e5d5335f"
|
||||
checksum = "01241a65b5919ea63f0e1f81bd35c91d39999835a3bf1140529086dff4fcee82"
|
||||
dependencies = [
|
||||
"better_scoped_tls",
|
||||
"once_cell",
|
||||
"phf",
|
||||
"rustc-hash",
|
||||
"serde",
|
||||
"smallvec",
|
||||
"swc_atoms",
|
||||
|
@ -2328,9 +2329,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "swc_ecma_transforms_compat"
|
||||
version = "0.94.0"
|
||||
version = "0.94.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24ac08ad78a45a5e41d2f6fa1f1085ed4500b56346ce4cbedac08528a779bdd9"
|
||||
checksum = "f9ca54cf58110c2c4ceeb71d35decdd8f7798edf8aa4bfc553748f12c0fbfe96"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"arrayvec",
|
||||
|
@ -2540,7 +2541,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "swc_emotion"
|
||||
version = "0.2.1"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"base64 0.13.0",
|
||||
"byteorder",
|
||||
|
|
|
@ -140,7 +140,12 @@ pub fn custom_before_pass<'a, C: Comments + 'a>(
|
|||
|
||||
Either::Left(chain!(
|
||||
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 => {
|
||||
|
|
|
@ -4,34 +4,34 @@ function b(c, a) {
|
|||
return d;
|
||||
}
|
||||
import a from "other";
|
||||
(function(c, b) {
|
||||
return function(c) {
|
||||
if (Array.isArray(c)) return c;
|
||||
}(c) || function(c, b) {
|
||||
var d, e, a = null == c ? null : "undefined" != typeof Symbol && c[Symbol.iterator] || c["@@iterator"];
|
||||
(function(a, c) {
|
||||
return function(a) {
|
||||
if (Array.isArray(a)) return a;
|
||||
}(a) || function(b, e) {
|
||||
var f, g, a = null == b ? null : "undefined" != typeof Symbol && b[Symbol.iterator] || b["@@iterator"];
|
||||
if (null != a) {
|
||||
var b = [], c = !0, f = !1;
|
||||
var c = [], d = !0, h = !1;
|
||||
try {
|
||||
for(a = a.call(c); !(c = (d = a.next()).done) && (b.push(d.value), !b || b.length !== b); c = !0);
|
||||
} catch (g) {
|
||||
f = !0, e = g;
|
||||
for(a = a.call(b); !(d = (f = a.next()).done) && (c.push(f.value), !e || c.length !== e); d = !0);
|
||||
} catch (i) {
|
||||
h = !0, g = i;
|
||||
} finally{
|
||||
try {
|
||||
c || null == a.return || a.return();
|
||||
d || null == a.return || a.return();
|
||||
} 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 ("string" == typeof a) return b(a, d);
|
||||
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 ("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.");
|
||||
}();
|
||||
})(a, 1)[0];
|
||||
|
|
|
@ -5,7 +5,7 @@ description = "AST Transforms for emotion"
|
|||
license = "Apache-2.0"
|
||||
name = "swc_emotion"
|
||||
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
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ edition = "2018"
|
|||
license = "Apache-2.0"
|
||||
name = "modularize_imports"
|
||||
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
|
||||
|
||||
|
|
|
@ -2,10 +2,11 @@
|
|||
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
|
||||
description = "AST Transforms for styled-components"
|
||||
edition = "2018"
|
||||
include = ["Cargo.toml", "src/**/*.rs"]
|
||||
license = "Apache-2.0"
|
||||
name = "styled_components"
|
||||
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
|
||||
|
||||
|
@ -15,12 +16,12 @@ once_cell = "1.10.0"
|
|||
regex = {version = "1.5.4", features = ["std", "perf"], default-features = false}
|
||||
serde = {version = "1.0.130", features = ["derive"]}
|
||||
swc_atoms = "0.2.11"
|
||||
swc_common = { version = "0.17.25", features = ["concurrent"] }
|
||||
swc_ecmascript = { version = "0.150.0", features = ["utils", "visit"] }
|
||||
swc_common = {version = "0.17.25", features = ["concurrent"]}
|
||||
swc_ecmascript = {version = "0.150.0", features = ["utils", "visit"]}
|
||||
tracing = "0.1.32"
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1"
|
||||
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"
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#![deny(unused)]
|
||||
|
||||
pub use crate::{
|
||||
utils::{analyze, analyzer, State},
|
||||
visitors::{
|
||||
|
@ -5,9 +7,9 @@ pub use crate::{
|
|||
},
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use std::{cell::RefCell, rc::Rc, sync::Arc};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
use swc_atoms::JsWord;
|
||||
use swc_common::{chain, SourceFile};
|
||||
use swc_common::{chain, FileName};
|
||||
use swc_ecmascript::visit::{Fold, VisitMut};
|
||||
|
||||
mod css;
|
||||
|
@ -58,13 +60,17 @@ impl Config {
|
|||
/// NOTE: **This is not complete**.
|
||||
///
|
||||
/// 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 config = Rc::new(config);
|
||||
|
||||
chain!(
|
||||
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()
|
||||
)
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ use crate::{
|
|||
};
|
||||
use once_cell::sync::Lazy;
|
||||
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_common::{util::take::Take, FileName, SourceFile, DUMMY_SP};
|
||||
use swc_common::{util::take::Take, FileName, DUMMY_SP};
|
||||
use swc_ecmascript::{
|
||||
ast::*,
|
||||
utils::{quote_ident, ExprFactory},
|
||||
|
@ -15,12 +15,15 @@ use swc_ecmascript::{
|
|||
use tracing::{debug, span, trace, Level};
|
||||
|
||||
pub fn display_name_and_id(
|
||||
file: Arc<SourceFile>,
|
||||
file_name: FileName,
|
||||
src_file_hash: u128,
|
||||
config: Rc<Config>,
|
||||
state: Rc<RefCell<State>>,
|
||||
) -> impl Fold + VisitMut {
|
||||
as_folder(DisplayNameAndId {
|
||||
file,
|
||||
file_name,
|
||||
src_file_hash,
|
||||
|
||||
config,
|
||||
state,
|
||||
cur_display_name: Default::default(),
|
||||
|
@ -33,7 +36,9 @@ static DISPLAY_NAME_REGEX: Lazy<Regex> =
|
|||
|
||||
#[derive(Debug)]
|
||||
struct DisplayNameAndId {
|
||||
file: Arc<SourceFile>,
|
||||
file_name: FileName,
|
||||
src_file_hash: u128,
|
||||
|
||||
config: Rc<Config>,
|
||||
state: Rc<RefCell<State>>,
|
||||
|
||||
|
@ -59,7 +64,7 @@ impl DisplayNameAndId {
|
|||
fn get_display_name(&mut self, _: &Expr) -> JsWord {
|
||||
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 => {
|
||||
let block_name = self.get_block_name(f);
|
||||
|
||||
|
@ -91,7 +96,7 @@ impl DisplayNameAndId {
|
|||
let next_id = self.next_id();
|
||||
|
||||
let hash = {
|
||||
let base = self.file.src_hash;
|
||||
let base = self.src_file_hash;
|
||||
let base = base.to_be_bytes();
|
||||
let a = u32::from_be_bytes(base[0..4].try_into().unwrap());
|
||||
let b = u32::from_be_bytes(base[4..8].try_into().unwrap());
|
||||
|
|
|
@ -27,7 +27,7 @@ fn fixture(input: PathBuf) {
|
|||
|
||||
chain!(
|
||||
resolver(Mark::new(), Mark::new(), false),
|
||||
styled_components(fm, config.clone())
|
||||
styled_components(fm.name.clone(), fm.src_hash, config.clone())
|
||||
)
|
||||
},
|
||||
&input,
|
||||
|
|
|
@ -5,7 +5,7 @@ edition = "2018"
|
|||
license = "Apache-2.0"
|
||||
name = "styled_jsx"
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue