Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Update swc_core to v12.0.0 #75327

Merged
merged 9 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
206 changes: 103 additions & 103 deletions Cargo.lock

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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" }
4 changes: 2 additions & 2 deletions crates/next-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions crates/next-custom-transforms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}
Expand Down
2 changes: 1 addition & 1 deletion crates/next-custom-transforms/src/chain_transforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
}
Expand All @@ -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());
};
}
}
Expand All @@ -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!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 6 additions & 4 deletions crates/next-custom-transforms/tests/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use std::{
env::current_dir,
iter::FromIterator,
path::{Path, PathBuf},
sync::Arc,
};

use next_custom_transforms::transforms::{
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion turbopack/crates/turbopack-ecmascript/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
8 changes: 4 additions & 4 deletions turbopack/crates/turbopack-ecmascript/src/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}));

Expand Down
Loading