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" }
turbopack-wasm = { path = "turbopack/crates/turbopack-wasm" }
# SWC crates
swc_core = { version = "10.5.0", features = [
swc_core = { version = "12.0.0", features = [
"ecma_loader_lru",
"ecma_loader_parking_lot",
] }
testing = { version = "5.0.0" }
# 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"] }
mdxjs = "0.2.15"
modularize_imports = { version = "0.72.0" }
styled_components = { version = "0.100.1" }
styled_jsx = { version = "0.76.0" }
swc_emotion = { version = "0.76.0" }
swc_relay = { version = "0.46.1" }
modularize_imports = { version = "0.74.0" }
styled_components = { version = "0.102.0" }
styled_jsx = { version = "0.78.0" }
swc_emotion = { version = "0.78.0" }
swc_relay = { version = "0.48.0" }
# General Deps
chromiumoxide = { version = "0.5.4", features = [
......@@ -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-compiler-cranelift = { 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 }
thiserror = { workspace = true }
tracing = { workspace = true }
rustc-hash = { workspace = true }
react_remove_properties = "0.26.1"
remove_console = "0.27.1"
react_remove_properties = "0.28.0"
remove_console = "0.29.0"
auto-hash-map = { workspace = true }
......
......@@ -46,6 +46,7 @@ impl CustomTransformer for NextEdgeNodeApiAssert {
is_unresolved_ref_safe: false,
unresolved_ctxt: SyntaxContext::empty().apply_mark(ctx.unresolved_mark),
in_strict: false,
remaining_depth: 4,
},
self.should_error_for_node_apis,
self.is_production,
......
......@@ -60,9 +60,9 @@ swc_relay = { workspace = true }
turbopack-ecmascript-plugins = { workspace = true, optional = true }
turbo-rcstr = { workspace = true }
react_remove_properties = "0.26.1"
remove_console = "0.27.1"
preset_env_base = "1.0.0"
react_remove_properties = "0.28.0"
remove_console = "0.29.0"
preset_env_base = "2.0.0"
[dev-dependencies]
swc_core = { workspace = true, features = ["testing_transform"]}
......
......@@ -170,7 +170,7 @@ where
&file.name,
&styled_jsx::visitor::Config {
use_lightningcss: config.use_lightningcss,
browsers: target_browsers,
browsers: *target_browsers,
},
&styled_jsx::visitor::NativeConfig { process_css: None },
))
......
......@@ -37,6 +37,7 @@ impl CollectExportedConstVisitor {
unresolved_ctxt: SyntaxContext::empty().apply_mark(Mark::new()),
is_unresolved_ref_safe: false,
in_strict: false,
remaining_depth: 4,
},
}
}
......@@ -61,7 +62,7 @@ impl Visit for CollectExportedConstVisitor {
{
let id = id.sym.as_ref();
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 {
}
/// 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 {
init if init.is_undefined(ctx) => Some(Const::Value(Value::Null)),
Expr::Ident(ident) => Some(Const::Unsupported(format!(
......
......@@ -234,14 +234,14 @@ Learn more: https://nextjs.org/docs/api-reference/edge-runtime",
Expr::Member(member) => {
if member.prop.is_ident_with("NEXT_RUNTIME") {
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")
{
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 {
self.guarded_process_props.push(prop.sym.clone());
}
......@@ -364,7 +364,7 @@ impl Visit for WarnForEdgeRuntime {
}
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 {
self.warn_for_unsupported_process_api(n.span, prop);
return;
......
......@@ -2,6 +2,7 @@ use std::{
env::current_dir,
iter::FromIterator,
path::{Path, PathBuf},
sync::Arc,
};
use next_custom_transforms::transforms::{
......@@ -363,8 +364,8 @@ fn next_ssg_fixture(input: PathBuf) {
next: false.into(),
runtime: None,
import_source: Some("".into()),
pragma: Some("__jsx".into()),
pragma_frag: Some("__jsxFrag".into()),
pragma: Some(Arc::new("__jsx".into())),
pragma_frag: Some(Arc::new("__jsxFrag".into())),
throw_if_namespace: false.into(),
development: false.into(),
refresh: Default::default(),
......@@ -777,8 +778,8 @@ fn run_stip_page_exports_test(input: &Path, output: &Path, mode: ExportFilter) {
next: false.into(),
runtime: None,
import_source: Some("".into()),
pragma: Some("__jsx".into()),
pragma_frag: Some("__jsxFrag".into()),
pragma: Some(Arc::new("__jsx".into())),
pragma_frag: Some(Arc::new("__jsxFrag".into())),
throw_if_namespace: false.into(),
development: false.into(),
..Default::default()
......@@ -854,6 +855,7 @@ fn test_edge_assert(input: PathBuf) {
is_unresolved_ref_safe: false,
unresolved_ctxt: SyntaxContext::empty().apply_mark(unresolved_mark),
in_strict: false,
remaining_depth: 4,
},
true,
true,
......
......@@ -382,7 +382,7 @@ async fn parse_file_content(
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);
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};
use anyhow::Result;
use async_trait::async_trait;
use swc_core::{
atoms::Atom,
atoms::{atom, Atom},
base::SwcComments,
common::{collections::AHashMap, comments::Comments, util::take::Take, Mark, SourceMap},
ecma::{
......@@ -164,11 +164,11 @@ impl EcmascriptInputTransform {
let config = Options {
runtime: Some(runtime),
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 {
Some(swc_core::ecma::transforms::react::RefreshOptions {
refresh_reg: "__turbopack_refresh__.register".to_string(),
refresh_sig: "__turbopack_refresh__.signature".to_string(),
refresh_reg: atom!("__turbopack_refresh__.register"),
refresh_sig: atom!("__turbopack_refresh__.signature"),
..Default::default()
})
} else {
......
......@@ -1246,10 +1246,11 @@ impl DepGraph {
let side_effects = !has_explicit_pure
&& (vars.found_unresolved
|| decl.init.as_deref().is_some_and(|e| {
e.may_have_side_effects(&ExprCtx {
e.may_have_side_effects(ExprCtx {
unresolved_ctxt,
is_unresolved_ref_safe: 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