Update swc_core
to v0.90.7
and update turbopack (#61662)
# Turbopack changes * https://github.com/vercel/turbo/pull/7342 <!-- OJ Kwon - docs(turbopack): build, deploy rustdocs --> * https://github.com/vercel/turbo/pull/7356 <!-- OJ Kwon - ci(workflow): remove doc deploy --> * https://github.com/vercel/turbo/pull/7272 <!-- Donny/강동윤 - build: Update `swc_core` to `v0.90.7` --> ### What? Update swc crates ### Why? - To apply https://github.com/swc-project/swc/pull/8532 and other bugfixes ### How? - Closes PACK-2389 - Closes PACK-2446 - Closes #61788
This commit is contained in:
parent
a4f46bc157
commit
42872bf423
8 changed files with 697 additions and 592 deletions
1029
Cargo.lock
generated
1029
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
10
Cargo.toml
10
Cargo.toml
|
@ -30,18 +30,18 @@ next-core = { path = "packages/next-swc/crates/next-core" }
|
|||
next-custom-transforms = { path = "packages/next-swc/crates/next-custom-transforms" }
|
||||
|
||||
# SWC crates
|
||||
swc_core = { version = "0.89.6", features = [
|
||||
swc_core = { version = "0.90.7", features = [
|
||||
"ecma_loader_lru",
|
||||
"ecma_loader_parking_lot",
|
||||
] }
|
||||
testing = { version = "0.35.16" }
|
||||
testing = { version = "0.35.18" }
|
||||
|
||||
# Turbo crates
|
||||
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240212.3" }
|
||||
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240213.2" }
|
||||
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
|
||||
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240212.3" }
|
||||
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240213.2" }
|
||||
# [TODO]: need to refactor embed_directory! macro usage in next-core
|
||||
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240212.3" }
|
||||
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-240213.2" }
|
||||
|
||||
# General Deps
|
||||
|
||||
|
|
|
@ -40,9 +40,9 @@ turbopack-binding = { workspace = true, features = [
|
|||
] }
|
||||
# To allow quote! macro works
|
||||
swc_core = { workspace = true, features = ["ecma_quote"]}
|
||||
react_remove_properties = "0.24.1"
|
||||
remove_console = "0.25.1"
|
||||
preset_env_base = "0.4.10"
|
||||
react_remove_properties = "0.24.5"
|
||||
remove_console = "0.25.5"
|
||||
preset_env_base = "0.4.11"
|
||||
|
||||
[dev-dependencies]
|
||||
turbopack-binding = { workspace = true, features = [
|
||||
|
|
|
@ -149,7 +149,7 @@ impl<C: Comments> ReactServerComponents<C> {
|
|||
span: DUMMY_SP,
|
||||
props: vec![ObjectPatProp::Assign(AssignPatProp {
|
||||
span: DUMMY_SP,
|
||||
key: proxy_ident,
|
||||
key: proxy_ident.into(),
|
||||
value: None,
|
||||
})],
|
||||
optional: false,
|
||||
|
@ -169,11 +169,12 @@ impl<C: Comments> ReactServerComponents<C> {
|
|||
span: DUMMY_SP,
|
||||
expr: Box::new(Expr::Assign(AssignExpr {
|
||||
span: DUMMY_SP,
|
||||
left: PatOrExpr::Expr(Box::new(Expr::Member(MemberExpr {
|
||||
left: MemberExpr {
|
||||
span: DUMMY_SP,
|
||||
obj: Box::new(Expr::Ident(quote_ident!("module"))),
|
||||
prop: MemberProp::Ident(quote_ident!("exports")),
|
||||
}))),
|
||||
}
|
||||
.into(),
|
||||
op: op!("="),
|
||||
right: Box::new(Expr::Call(CallExpr {
|
||||
span: DUMMY_SP,
|
||||
|
|
|
@ -1169,7 +1169,7 @@ fn attach_name_to_expr(ident: Ident, expr: Expr, extra_items: &mut Vec<ModuleIte
|
|||
span: DUMMY_SP,
|
||||
expr: Box::new(Expr::Assign(AssignExpr {
|
||||
span: DUMMY_SP,
|
||||
left: PatOrExpr::Pat(Box::new(Pat::Ident(ident.into()))),
|
||||
left: ident.into(),
|
||||
op: op!("="),
|
||||
right: Box::new(expr),
|
||||
})),
|
||||
|
|
|
@ -642,8 +642,74 @@ impl Repeated for NextSsg {
|
|||
///
|
||||
/// Note: We don't implement `fold_script` because next.js doesn't use it.
|
||||
impl Fold for NextSsg {
|
||||
// This is important for reducing binary sizes.
|
||||
noop_fold_type!();
|
||||
fn fold_array_pat(&mut self, mut arr: ArrayPat) -> ArrayPat {
|
||||
arr = arr.fold_children_with(self);
|
||||
|
||||
if !arr.elems.is_empty() {
|
||||
arr.elems.retain(|e| !matches!(e, Some(Pat::Invalid(..))));
|
||||
}
|
||||
|
||||
arr
|
||||
}
|
||||
|
||||
fn fold_assign_target_pat(&mut self, mut n: AssignTargetPat) -> AssignTargetPat {
|
||||
n = n.fold_children_with(self);
|
||||
|
||||
match &n {
|
||||
AssignTargetPat::Array(arr) => {
|
||||
if arr.elems.is_empty() {
|
||||
return AssignTargetPat::Invalid(Invalid { span: DUMMY_SP });
|
||||
}
|
||||
}
|
||||
AssignTargetPat::Object(obj) => {
|
||||
if obj.props.is_empty() {
|
||||
return AssignTargetPat::Invalid(Invalid { span: DUMMY_SP });
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
n
|
||||
}
|
||||
|
||||
fn fold_expr(&mut self, e: Expr) -> Expr {
|
||||
match e {
|
||||
Expr::Assign(assign_expr) => {
|
||||
let mut retain = true;
|
||||
let left =
|
||||
self.within_lhs_of_var(true, |this| assign_expr.left.clone().fold_with(this));
|
||||
|
||||
let right = self.within_lhs_of_var(false, |this| {
|
||||
match left {
|
||||
AssignTarget::Simple(SimpleAssignTarget::Invalid(..))
|
||||
| AssignTarget::Pat(AssignTargetPat::Invalid(..)) => {
|
||||
retain = false;
|
||||
this.mark_as_candidate(&assign_expr.right);
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
assign_expr.right.clone().fold_with(this)
|
||||
});
|
||||
|
||||
if retain {
|
||||
self.remove_expression = false;
|
||||
Expr::Assign(AssignExpr {
|
||||
left,
|
||||
right,
|
||||
..assign_expr
|
||||
})
|
||||
} else {
|
||||
self.remove_expression = true;
|
||||
*right
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
self.remove_expression = false;
|
||||
e.fold_children_with(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn fold_import_decl(&mut self, mut i: ImportDecl) -> ImportDecl {
|
||||
// Imports for side effects.
|
||||
|
@ -812,6 +878,43 @@ impl Fold for NextSsg {
|
|||
n
|
||||
}
|
||||
|
||||
fn fold_object_pat(&mut self, mut obj: ObjectPat) -> ObjectPat {
|
||||
obj = obj.fold_children_with(self);
|
||||
|
||||
if !obj.props.is_empty() {
|
||||
obj.props = take(&mut obj.props)
|
||||
.into_iter()
|
||||
.filter_map(|prop| match prop {
|
||||
ObjectPatProp::KeyValue(prop) => {
|
||||
if prop.value.is_invalid() {
|
||||
None
|
||||
} else {
|
||||
Some(ObjectPatProp::KeyValue(prop))
|
||||
}
|
||||
}
|
||||
ObjectPatProp::Assign(prop) => {
|
||||
if self.should_remove(&prop.key.to_id()) {
|
||||
self.mark_as_candidate(&prop.value);
|
||||
|
||||
None
|
||||
} else {
|
||||
Some(ObjectPatProp::Assign(prop))
|
||||
}
|
||||
}
|
||||
ObjectPatProp::Rest(prop) => {
|
||||
if prop.arg.is_invalid() {
|
||||
None
|
||||
} else {
|
||||
Some(ObjectPatProp::Rest(prop))
|
||||
}
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
|
||||
obj
|
||||
}
|
||||
|
||||
/// This methods returns [Pat::Invalid] if the pattern should be removed.
|
||||
fn fold_pat(&mut self, mut p: Pat) -> Pat {
|
||||
p = p.fold_children_with(self);
|
||||
|
@ -831,48 +934,13 @@ impl Fold for NextSsg {
|
|||
}
|
||||
}
|
||||
Pat::Array(arr) => {
|
||||
if !arr.elems.is_empty() {
|
||||
arr.elems.retain(|e| !matches!(e, Some(Pat::Invalid(..))));
|
||||
|
||||
if arr.elems.is_empty() {
|
||||
return Pat::Invalid(Invalid { span: DUMMY_SP });
|
||||
}
|
||||
if arr.elems.is_empty() {
|
||||
return Pat::Invalid(Invalid { span: DUMMY_SP });
|
||||
}
|
||||
}
|
||||
Pat::Object(obj) => {
|
||||
if !obj.props.is_empty() {
|
||||
obj.props = take(&mut obj.props)
|
||||
.into_iter()
|
||||
.filter_map(|prop| match prop {
|
||||
ObjectPatProp::KeyValue(prop) => {
|
||||
if prop.value.is_invalid() {
|
||||
None
|
||||
} else {
|
||||
Some(ObjectPatProp::KeyValue(prop))
|
||||
}
|
||||
}
|
||||
ObjectPatProp::Assign(prop) => {
|
||||
if self.should_remove(&prop.key.to_id()) {
|
||||
self.mark_as_candidate(&prop.value);
|
||||
|
||||
None
|
||||
} else {
|
||||
Some(ObjectPatProp::Assign(prop))
|
||||
}
|
||||
}
|
||||
ObjectPatProp::Rest(prop) => {
|
||||
if prop.arg.is_invalid() {
|
||||
None
|
||||
} else {
|
||||
Some(ObjectPatProp::Rest(prop))
|
||||
}
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
if obj.props.is_empty() {
|
||||
return Pat::Invalid(Invalid { span: DUMMY_SP });
|
||||
}
|
||||
if obj.props.is_empty() {
|
||||
return Pat::Invalid(Invalid { span: DUMMY_SP });
|
||||
}
|
||||
}
|
||||
Pat::Rest(rest) => {
|
||||
|
@ -904,6 +972,40 @@ impl Fold for NextSsg {
|
|||
p
|
||||
}
|
||||
|
||||
fn fold_simple_assign_target(&mut self, mut n: SimpleAssignTarget) -> SimpleAssignTarget {
|
||||
n = n.fold_children_with(self);
|
||||
|
||||
if let SimpleAssignTarget::Ident(name) = &n {
|
||||
if self.should_remove(&name.id.to_id()) {
|
||||
self.state.should_run_again = true;
|
||||
tracing::trace!(
|
||||
"Dropping var `{}{:?}` because it should be removed",
|
||||
name.id.sym,
|
||||
name.id.span.ctxt
|
||||
);
|
||||
|
||||
return SimpleAssignTarget::Invalid(Invalid { span: DUMMY_SP });
|
||||
}
|
||||
}
|
||||
|
||||
if let SimpleAssignTarget::Member(member_expr) = &n {
|
||||
if let Some(id) = find_member_root_id(member_expr) {
|
||||
if self.should_remove(&id) {
|
||||
self.state.should_run_again = true;
|
||||
tracing::trace!(
|
||||
"Dropping member expression object `{}{:?}` because it should be removed",
|
||||
id.0,
|
||||
id.1
|
||||
);
|
||||
|
||||
return SimpleAssignTarget::Invalid(Invalid { span: DUMMY_SP });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
n
|
||||
}
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
fn fold_stmt(&mut self, mut s: Stmt) -> Stmt {
|
||||
match s {
|
||||
|
@ -946,42 +1048,6 @@ impl Fold for NextSsg {
|
|||
s
|
||||
}
|
||||
|
||||
fn fold_expr(&mut self, e: Expr) -> Expr {
|
||||
match e {
|
||||
Expr::Assign(assign_expr) => {
|
||||
let mut retain = true;
|
||||
let left =
|
||||
self.within_lhs_of_var(true, |this| assign_expr.left.clone().fold_with(this));
|
||||
|
||||
let right = self.within_lhs_of_var(false, |this| {
|
||||
if let PatOrExpr::Pat(pat) = &left {
|
||||
if pat.is_invalid() {
|
||||
retain = false;
|
||||
this.mark_as_candidate(&assign_expr.right);
|
||||
}
|
||||
}
|
||||
assign_expr.right.clone().fold_with(this)
|
||||
});
|
||||
|
||||
if retain {
|
||||
self.remove_expression = false;
|
||||
Expr::Assign(AssignExpr {
|
||||
left,
|
||||
right,
|
||||
..assign_expr
|
||||
})
|
||||
} else {
|
||||
self.remove_expression = true;
|
||||
*right
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
self.remove_expression = false;
|
||||
e.fold_children_with(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// This method make `name` of [VarDeclarator] to [Pat::Invalid] if it
|
||||
/// should be removed.
|
||||
fn fold_var_declarator(&mut self, d: VarDeclarator) -> VarDeclarator {
|
||||
|
@ -1003,6 +1069,9 @@ impl Fold for NextSsg {
|
|||
|
||||
decls
|
||||
}
|
||||
|
||||
// This is important for reducing binary sizes.
|
||||
noop_fold_type!();
|
||||
}
|
||||
|
||||
/// Returns the root identifier of a member expression.
|
||||
|
|
|
@ -193,7 +193,7 @@
|
|||
"@types/ws": "8.2.0",
|
||||
"@vercel/ncc": "0.34.0",
|
||||
"@vercel/nft": "0.26.3",
|
||||
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240212.3",
|
||||
"@vercel/turbopack-ecmascript-runtime": "https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240213.2",
|
||||
"acorn": "8.5.0",
|
||||
"amphtml-validator": "1.0.35",
|
||||
"anser": "1.4.9",
|
||||
|
|
|
@ -1077,8 +1077,8 @@ importers:
|
|||
specifier: 0.26.3
|
||||
version: 0.26.3
|
||||
'@vercel/turbopack-ecmascript-runtime':
|
||||
specifier: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240212.3
|
||||
version: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240212.3(react-refresh@0.12.0)(webpack@5.90.0)'
|
||||
specifier: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240213.2
|
||||
version: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240213.2(react-refresh@0.12.0)(webpack@5.90.0)'
|
||||
acorn:
|
||||
specifier: 8.5.0
|
||||
version: 8.5.0
|
||||
|
@ -25655,9 +25655,9 @@ packages:
|
|||
/zwitch@2.0.4:
|
||||
resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
|
||||
|
||||
'@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240212.3(react-refresh@0.12.0)(webpack@5.90.0)':
|
||||
resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240212.3}
|
||||
id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240212.3'
|
||||
'@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240213.2(react-refresh@0.12.0)(webpack@5.90.0)':
|
||||
resolution: {tarball: https://gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240213.2}
|
||||
id: '@gitpkg-fork.vercel.sh/vercel/turbo/crates/turbopack-ecmascript-runtime/js?turbopack-240213.2'
|
||||
name: '@vercel/turbopack-ecmascript-runtime'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
|
|
Loading…
Reference in a new issue