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

build: Update `swc_core` to `v12.0.0` (#75327)

### What?

Update `swc_core` to the next version.

ChangeLog: https://github.com/swc-project/swc/compare/swc_core%40v10.5.0...swc_core%40v12.0.0

### Why?

To apply an enormous amount of performance patches.
parent 8ed8716c
This diff is collapsed.
...@@ -91,21 +91,21 @@ turbopack-trace-utils = { path = "turbopack/crates/turbopack-trace-utils" } ...@@ -91,21 +91,21 @@ turbopack-trace-utils = { path = "turbopack/crates/turbopack-trace-utils" }
turbopack-wasm = { path = "turbopack/crates/turbopack-wasm" } turbopack-wasm = { path = "turbopack/crates/turbopack-wasm" }
# SWC crates # SWC crates
swc_core = { version = "10.5.0", features = [ swc_core = { version = "12.0.0", features = [
"ecma_loader_lru", "ecma_loader_lru",
"ecma_loader_parking_lot", "ecma_loader_parking_lot",
] } ] }
testing = { version = "5.0.0" } testing = { version = "5.0.0" }
# Keep consistent with preset_env_base through swc_core # Keep consistent with preset_env_base through swc_core
browserslist-rs = { version = "0.16.0" } browserslist-rs = { version = "0.17.0" }
miette = { version = "5.10.0", features = ["fancy"] } miette = { version = "5.10.0", features = ["fancy"] }
mdxjs = "0.2.15" mdxjs = "0.2.15"
modularize_imports = { version = "0.72.0" } modularize_imports = { version = "0.74.0" }
styled_components = { version = "0.100.1" } styled_components = { version = "0.102.0" }
styled_jsx = { version = "0.76.0" } styled_jsx = { version = "0.78.0" }
swc_emotion = { version = "0.76.0" } swc_emotion = { version = "0.78.0" }
swc_relay = { version = "0.46.1" } swc_relay = { version = "0.48.0" }
# General Deps # General Deps
chromiumoxide = { version = "0.5.4", features = [ chromiumoxide = { version = "0.5.4", features = [
...@@ -224,3 +224,6 @@ wasmer = { git = "https://github.com/kdy1/wasmer", branch = "build-deps" } ...@@ -224,3 +224,6 @@ wasmer = { git = "https://github.com/kdy1/wasmer", branch = "build-deps" }
wasmer-cache = { git = "https://github.com/kdy1/wasmer", branch = "build-deps" } wasmer-cache = { git = "https://github.com/kdy1/wasmer", branch = "build-deps" }
wasmer-compiler-cranelift = { git = "https://github.com/kdy1/wasmer", branch = "build-deps" } wasmer-compiler-cranelift = { git = "https://github.com/kdy1/wasmer", branch = "build-deps" }
wasmer-wasix = { git = "https://github.com/kdy1/wasmer", branch = "build-deps" } wasmer-wasix = { git = "https://github.com/kdy1/wasmer", branch = "build-deps" }
# Remove this once https://github.com/wooorm/mdxjs-rs/pull/62 is merged and released
mdxjs = { git="https://github.com/kdy1/mdxjs-rs.git", branch="swc-core-11" }
...@@ -32,8 +32,8 @@ lazy_static = { workspace = true } ...@@ -32,8 +32,8 @@ lazy_static = { workspace = true }
thiserror = { workspace = true } thiserror = { workspace = true }
tracing = { workspace = true } tracing = { workspace = true }
rustc-hash = { workspace = true } rustc-hash = { workspace = true }
react_remove_properties = "0.26.1" react_remove_properties = "0.28.0"
remove_console = "0.27.1" remove_console = "0.29.0"
auto-hash-map = { workspace = true } auto-hash-map = { workspace = true }
......
...@@ -46,6 +46,7 @@ impl CustomTransformer for NextEdgeNodeApiAssert { ...@@ -46,6 +46,7 @@ impl CustomTransformer for NextEdgeNodeApiAssert {
is_unresolved_ref_safe: false, is_unresolved_ref_safe: false,
unresolved_ctxt: SyntaxContext::empty().apply_mark(ctx.unresolved_mark), unresolved_ctxt: SyntaxContext::empty().apply_mark(ctx.unresolved_mark),
in_strict: false, in_strict: false,
remaining_depth: 4,
}, },
self.should_error_for_node_apis, self.should_error_for_node_apis,
self.is_production, self.is_production,
......
...@@ -60,9 +60,9 @@ swc_relay = { workspace = true } ...@@ -60,9 +60,9 @@ swc_relay = { workspace = true }
turbopack-ecmascript-plugins = { workspace = true, optional = true } turbopack-ecmascript-plugins = { workspace = true, optional = true }
turbo-rcstr = { workspace = true } turbo-rcstr = { workspace = true }
react_remove_properties = "0.26.1" react_remove_properties = "0.28.0"
remove_console = "0.27.1" remove_console = "0.29.0"
preset_env_base = "1.0.0" preset_env_base = "2.0.0"
[dev-dependencies] [dev-dependencies]
swc_core = { workspace = true, features = ["testing_transform"]} swc_core = { workspace = true, features = ["testing_transform"]}
......
...@@ -170,7 +170,7 @@ where ...@@ -170,7 +170,7 @@ where
&file.name, &file.name,
&styled_jsx::visitor::Config { &styled_jsx::visitor::Config {
use_lightningcss: config.use_lightningcss, use_lightningcss: config.use_lightningcss,
browsers: target_browsers, browsers: *target_browsers,
}, },
&styled_jsx::visitor::NativeConfig { process_css: None }, &styled_jsx::visitor::NativeConfig { process_css: None },
)) ))
......
...@@ -37,6 +37,7 @@ impl CollectExportedConstVisitor { ...@@ -37,6 +37,7 @@ impl CollectExportedConstVisitor {
unresolved_ctxt: SyntaxContext::empty().apply_mark(Mark::new()), unresolved_ctxt: SyntaxContext::empty().apply_mark(Mark::new()),
is_unresolved_ref_safe: false, is_unresolved_ref_safe: false,
in_strict: false, in_strict: false,
remaining_depth: 4,
}, },
} }
} }
...@@ -61,7 +62,7 @@ impl Visit for CollectExportedConstVisitor { ...@@ -61,7 +62,7 @@ impl Visit for CollectExportedConstVisitor {
{ {
let id = id.sym.as_ref(); let id = id.sym.as_ref();
if let Some(prop) = self.properties.get_mut(id) { if let Some(prop) = self.properties.get_mut(id) {
*prop = extract_value(&self.expr_ctx, init, id.to_string()); *prop = extract_value(self.expr_ctx, init, id.to_string());
}; };
} }
} }
...@@ -74,7 +75,7 @@ impl Visit for CollectExportedConstVisitor { ...@@ -74,7 +75,7 @@ impl Visit for CollectExportedConstVisitor {
} }
/// Coerece the actual value of the given ast node. /// Coerece the actual value of the given ast node.
fn extract_value(ctx: &ExprCtx, init: &Expr, id: String) -> Option<Const> { fn extract_value(ctx: ExprCtx, init: &Expr, id: String) -> Option<Const> {
match init { match init {
init if init.is_undefined(ctx) => Some(Const::Value(Value::Null)), init if init.is_undefined(ctx) => Some(Const::Value(Value::Null)),
Expr::Ident(ident) => Some(Const::Unsupported(format!( Expr::Ident(ident) => Some(Const::Unsupported(format!(
......
...@@ -234,14 +234,14 @@ Learn more: https://nextjs.org/docs/api-reference/edge-runtime", ...@@ -234,14 +234,14 @@ Learn more: https://nextjs.org/docs/api-reference/edge-runtime",
Expr::Member(member) => { Expr::Member(member) => {
if member.prop.is_ident_with("NEXT_RUNTIME") { if member.prop.is_ident_with("NEXT_RUNTIME") {
if let Expr::Member(obj_member) = &*member.obj { if let Expr::Member(obj_member) = &*member.obj {
if obj_member.obj.is_global_ref_to(&self.ctx, "process") if obj_member.obj.is_global_ref_to(self.ctx, "process")
&& obj_member.prop.is_ident_with("env") && obj_member.prop.is_ident_with("env")
{ {
self.guarded_runtime = true; self.guarded_runtime = true;
} }
} }
} }
if member.obj.is_global_ref_to(&self.ctx, "process") { if member.obj.is_global_ref_to(self.ctx, "process") {
if let MemberProp::Ident(prop) = &member.prop { if let MemberProp::Ident(prop) = &member.prop {
self.guarded_process_props.push(prop.sym.clone()); self.guarded_process_props.push(prop.sym.clone());
} }
...@@ -364,7 +364,7 @@ impl Visit for WarnForEdgeRuntime { ...@@ -364,7 +364,7 @@ impl Visit for WarnForEdgeRuntime {
} }
fn visit_member_expr(&mut self, n: &MemberExpr) { fn visit_member_expr(&mut self, n: &MemberExpr) {
if n.obj.is_global_ref_to(&self.ctx, "process") { if n.obj.is_global_ref_to(self.ctx, "process") {
if let MemberProp::Ident(prop) = &n.prop { if let MemberProp::Ident(prop) = &n.prop {
self.warn_for_unsupported_process_api(n.span, prop); self.warn_for_unsupported_process_api(n.span, prop);
return; return;
......
...@@ -2,6 +2,7 @@ use std::{ ...@@ -2,6 +2,7 @@ use std::{
env::current_dir, env::current_dir,
iter::FromIterator, iter::FromIterator,
path::{Path, PathBuf}, path::{Path, PathBuf},
sync::Arc,
}; };
use next_custom_transforms::transforms::{ use next_custom_transforms::transforms::{
...@@ -363,8 +364,8 @@ fn next_ssg_fixture(input: PathBuf) { ...@@ -363,8 +364,8 @@ fn next_ssg_fixture(input: PathBuf) {
next: false.into(), next: false.into(),
runtime: None, runtime: None,
import_source: Some("".into()), import_source: Some("".into()),
pragma: Some("__jsx".into()), pragma: Some(Arc::new("__jsx".into())),
pragma_frag: Some("__jsxFrag".into()), pragma_frag: Some(Arc::new("__jsxFrag".into())),
throw_if_namespace: false.into(), throw_if_namespace: false.into(),
development: false.into(), development: false.into(),
refresh: Default::default(), refresh: Default::default(),
...@@ -777,8 +778,8 @@ fn run_stip_page_exports_test(input: &Path, output: &Path, mode: ExportFilter) { ...@@ -777,8 +778,8 @@ fn run_stip_page_exports_test(input: &Path, output: &Path, mode: ExportFilter) {
next: false.into(), next: false.into(),
runtime: None, runtime: None,
import_source: Some("".into()), import_source: Some("".into()),
pragma: Some("__jsx".into()), pragma: Some(Arc::new("__jsx".into())),
pragma_frag: Some("__jsxFrag".into()), pragma_frag: Some(Arc::new("__jsxFrag".into())),
throw_if_namespace: false.into(), throw_if_namespace: false.into(),
development: false.into(), development: false.into(),
..Default::default() ..Default::default()
...@@ -854,6 +855,7 @@ fn test_edge_assert(input: PathBuf) { ...@@ -854,6 +855,7 @@ fn test_edge_assert(input: PathBuf) {
is_unresolved_ref_safe: false, is_unresolved_ref_safe: false,
unresolved_ctxt: SyntaxContext::empty().apply_mark(unresolved_mark), unresolved_ctxt: SyntaxContext::empty().apply_mark(unresolved_mark),
in_strict: false, in_strict: false,
remaining_depth: 4,
}, },
true, true,
true, true,
......
...@@ -382,7 +382,7 @@ async fn parse_file_content( ...@@ -382,7 +382,7 @@ async fn parse_file_content(
source_map: source_map.clone(), source_map: source_map.clone(),
}); });
parsed_program.mutate(swc_core::ecma::lints::rules::lint_to_fold(rules)); parsed_program.mutate(swc_core::ecma::lints::rules::lint_pass(rules));
drop(span); drop(span);
parsed_program.mutate(swc_core::ecma::transforms::proposal::explicit_resource_management::explicit_resource_management()); parsed_program.mutate(swc_core::ecma::transforms::proposal::explicit_resource_management::explicit_resource_management());
......
...@@ -3,7 +3,7 @@ use std::{fmt::Debug, hash::Hash, sync::Arc}; ...@@ -3,7 +3,7 @@ use std::{fmt::Debug, hash::Hash, sync::Arc};
use anyhow::Result; use anyhow::Result;
use async_trait::async_trait; use async_trait::async_trait;
use swc_core::{ use swc_core::{
atoms::Atom, atoms::{atom, Atom},
base::SwcComments, base::SwcComments,
common::{collections::AHashMap, comments::Comments, util::take::Take, Mark, SourceMap}, common::{collections::AHashMap, comments::Comments, util::take::Take, Mark, SourceMap},
ecma::{ ecma::{
...@@ -164,11 +164,11 @@ impl EcmascriptInputTransform { ...@@ -164,11 +164,11 @@ impl EcmascriptInputTransform {
let config = Options { let config = Options {
runtime: Some(runtime), runtime: Some(runtime),
development: Some(*development), development: Some(*development),
import_source: import_source.await?.as_deref().map(ToString::to_string), import_source: import_source.await?.as_deref().map(Atom::from),
refresh: if *refresh { refresh: if *refresh {
Some(swc_core::ecma::transforms::react::RefreshOptions { Some(swc_core::ecma::transforms::react::RefreshOptions {
refresh_reg: "__turbopack_refresh__.register".to_string(), refresh_reg: atom!("__turbopack_refresh__.register"),
refresh_sig: "__turbopack_refresh__.signature".to_string(), refresh_sig: atom!("__turbopack_refresh__.signature"),
..Default::default() ..Default::default()
}) })
} else { } else {
......
...@@ -1246,10 +1246,11 @@ impl DepGraph { ...@@ -1246,10 +1246,11 @@ impl DepGraph {
let side_effects = !has_explicit_pure let side_effects = !has_explicit_pure
&& (vars.found_unresolved && (vars.found_unresolved
|| decl.init.as_deref().is_some_and(|e| { || decl.init.as_deref().is_some_and(|e| {
e.may_have_side_effects(&ExprCtx { e.may_have_side_effects(ExprCtx {
unresolved_ctxt, unresolved_ctxt,
is_unresolved_ref_safe: false, is_unresolved_ref_safe: false,
in_strict: false, in_strict: false,
remaining_depth: 4,
}) })
})); }));
......
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