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 v16.0.0 #76414

Merged
merged 5 commits into from
Feb 27, 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
314 changes: 166 additions & 148 deletions Cargo.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -299,21 +299,21 @@ turbopack-trace-utils = { path = "turbopack/crates/turbopack-trace-utils" }
turbopack-wasm = { path = "turbopack/crates/turbopack-wasm" }

# SWC crates
swc_core = { version = "14.0.1", features = [
swc_core = { version = "16.0.0", features = [
"ecma_loader_lru",
"ecma_loader_parking_lot",
] }
testing = { version = "7.0.0" }
testing = { version = "8.0.0" }

# Keep consistent with preset_env_base through swc_core
browserslist-rs = { version = "0.17.0" }
miette = { version = "5.10.0", features = ["fancy"] }
mdxjs = "0.3"
modularize_imports = { version = "0.77.0" }
styled_components = { version = "0.105.0" }
styled_jsx = { version = "0.81.0" }
swc_emotion = { version = "0.81.0" }
swc_relay = { version = "0.51.0" }
modularize_imports = { version = "0.79.0" }
styled_components = { version = "0.107.0" }
styled_jsx = { version = "0.83.0" }
swc_emotion = { version = "0.83.0" }
swc_relay = { version = "0.53.0" }

# General Deps
chromiumoxide = { version = "0.5.4", features = [
Expand Down Expand Up @@ -435,4 +435,4 @@ 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" }

mdxjs={git="https://github.com/kdy1/mdxjs-rs.git",branch = "swc-core-14"}
mdxjs = { git="https://github.com/kdy1/mdxjs-rs.git", branch = "swc-core-15" }
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.31.0"
remove_console = "0.32.0"
react_remove_properties = "0.33.0"
remove_console = "0.34.0"

auto-hash-map = { workspace = true }

Expand Down
4 changes: 2 additions & 2 deletions crates/next-core/src/next_shared/transforms/next_font.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use async_trait::async_trait;
use next_custom_transforms::transforms::fonts::*;
use swc_core::ecma::{ast::Program, atoms::JsWord, visit::VisitMutWith};
use swc_core::ecma::{ast::Program, atoms::Atom, visit::VisitMutWith};
use turbo_tasks::ResolvedVc;
use turbopack::module_options::{ModuleRule, ModuleRuleEffect};
use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext};
Expand Down Expand Up @@ -33,7 +33,7 @@ pub fn get_next_font_transform_rule(enable_mdx_rs: bool) -> ModuleRule {

#[derive(Debug)]
struct NextJsFont {
font_loaders: Vec<JsWord>,
font_loaders: Vec<Atom>,
}

#[async_trait]
Expand Down
4 changes: 2 additions & 2 deletions crates/next-custom-transforms/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ swc_relay = { workspace = true }
turbopack-ecmascript-plugins = { workspace = true, optional = true }
turbo-rcstr = { workspace = true }

react_remove_properties = "0.31.0"
remove_console = "0.32.0"
react_remove_properties = "0.33.0"
remove_console = "0.34.0"
preset_env_base = "2.0.1"

[dev-dependencies]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use swc_core::ecma::{
Ident, IdentName, JSXAttr, JSXAttrName, JSXAttrOrSpread, JSXElementName, JSXOpeningElement,
Pass,
},
atoms::JsWord,
atoms::Atom,
visit::{fold_pass, Fold},
};

Expand Down Expand Up @@ -37,7 +37,7 @@ impl Fold for AmpAttributePatcher {
if sym as &str == "className" {
*i = JSXAttrOrSpread::JSXAttr(JSXAttr {
name: JSXAttrName::Ident(IdentName {
sym: JsWord::from("class"),
sym: Atom::from("class"),
span: *s,
}),
span: *span,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use swc_core::{
common::errors::HANDLER,
ecma::{
ast::*,
atoms::JsWord,
atoms::Atom,
visit::{noop_visit_type, Visit},
},
};

pub struct FontFunctionsCollector<'a> {
pub font_loaders: &'a [JsWord],
pub font_loaders: &'a [Atom],
pub state: &'a mut super::State,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use swc_core::{
common::{errors::HANDLER, Spanned, DUMMY_SP},
ecma::{
ast::*,
atoms::JsWord,
atoms::Atom,
visit::{noop_visit_type, Visit},
},
};
Expand Down Expand Up @@ -66,7 +66,7 @@ impl FontImportsGenerator<'_> {

return Some(ImportDecl {
src: Box::new(Str {
value: JsWord::from(format!(
value: Atom::from(format!(
"{}/target.css?{}",
font_function.loader, query_json
)),
Expand Down
10 changes: 5 additions & 5 deletions crates/next-custom-transforms/src/transforms/fonts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use swc_core::{
common::{BytePos, Spanned},
ecma::{
ast::{Id, ModuleItem, Pass},
atoms::JsWord,
atoms::Atom,
visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitWith},
},
};
Expand All @@ -16,8 +16,8 @@ mod font_imports_generator;
#[derive(Clone, Debug, Deserialize)]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
pub struct Config {
pub font_loaders: Vec<JsWord>,
pub relative_file_path_from_root: JsWord,
pub font_loaders: Vec<Atom>,
pub relative_file_path_from_root: Atom,
}

pub fn next_font_loaders(config: Config) -> impl Pass + VisitMut {
Expand All @@ -31,8 +31,8 @@ pub fn next_font_loaders(config: Config) -> impl Pass + VisitMut {

#[derive(Debug)]
pub struct FontFunction {
loader: JsWord,
function_name: Option<JsWord>,
loader: Atom,
function_name: Option<Atom>,
}
#[derive(Debug, Default)]
pub struct State {
Expand Down
12 changes: 6 additions & 6 deletions crates/next-custom-transforms/src/transforms/import_analyzer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use rustc_hash::{FxHashMap, FxHashSet};
use swc_core::{
atoms::JsWord,
atoms::Atom,
ecma::{
ast::{
Expr, Id, ImportDecl, ImportNamedSpecifier, ImportSpecifier, MemberExpr, MemberProp,
Expand All @@ -13,16 +13,16 @@ use swc_core::{
#[derive(Debug, Default)]
pub(crate) struct ImportMap {
/// Map from module name to (module path, exported symbol)
imports: FxHashMap<Id, (JsWord, JsWord)>,
imports: FxHashMap<Id, (Atom, Atom)>,

namespace_imports: FxHashMap<Id, JsWord>,
namespace_imports: FxHashMap<Id, Atom>,

imported_modules: FxHashSet<JsWord>,
imported_modules: FxHashSet<Atom>,
}

#[allow(unused)]
impl ImportMap {
pub fn is_module_imported(&mut self, module: &JsWord) -> bool {
pub fn is_module_imported(&mut self, module: &Atom) -> bool {
self.imported_modules.contains(module)
}

Expand Down Expand Up @@ -96,7 +96,7 @@ impl Visit for Analyzer<'_> {
}
}

fn orig_name(n: &ModuleExportName) -> JsWord {
fn orig_name(n: &ModuleExportName) -> Atom {
match n {
ModuleExportName::Ident(v) => v.sym.clone(),
ModuleExportName::Str(v) => v.value.clone(),
Expand Down
10 changes: 5 additions & 5 deletions crates/next-custom-transforms/src/transforms/shake_exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ use swc_core::{
common::Mark,
ecma::{
ast::*,
atoms::{js_word, JsWord},
atoms::{atom, Atom},
transforms::optimization::simplify::dce::{dce, Config as DCEConfig},
visit::{fold_pass, Fold, FoldWith, VisitMutWith},
},
};

#[derive(Clone, Debug, Deserialize)]
pub struct Config {
pub ignore: Vec<JsWord>,
pub ignore: Vec<Atom>,
}

pub fn shake_exports(config: Config) -> impl Pass {
Expand All @@ -23,7 +23,7 @@ pub fn shake_exports(config: Config) -> impl Pass {

#[derive(Debug, Default)]
struct ExportShaker {
ignore: Vec<JsWord>,
ignore: Vec<Atom>,
remove_export: bool,
}

Expand Down Expand Up @@ -108,14 +108,14 @@ impl Fold for ExportShaker {
}

fn fold_export_default_decl(&mut self, decl: ExportDefaultDecl) -> ExportDefaultDecl {
if !self.ignore.contains(&js_word!("default")) {
if !self.ignore.contains(&atom!("default")) {
self.remove_export = true
}
decl
}

fn fold_export_default_expr(&mut self, expr: ExportDefaultExpr) -> ExportDefaultExpr {
if !self.ignore.contains(&js_word!("default")) {
if !self.ignore.contains(&atom!("default")) {
self.remove_export = true
}
expr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Result;
use async_trait::async_trait;
use swc_core::{
common::comments::NoopComments,
ecma::{ast::Program, atoms::JsWord},
ecma::{ast::Program, atoms::Atom},
};
use turbo_tasks::{ValueDefault, Vc};
use turbopack_ecmascript::{CustomTransformer, TransformContext};
Expand Down Expand Up @@ -71,7 +71,7 @@ impl StyledComponentsTransformer {
if !top_level_import_paths.is_empty() {
options.top_level_import_paths = top_level_import_paths
.iter()
.map(|s| JsWord::from(s.clone()))
.map(|s| Atom::from(s.clone()))
.collect();
}
let meaningless_file_names = &config.meaningless_file_names;
Expand Down
4 changes: 2 additions & 2 deletions turbopack/crates/turbopack-ecmascript/src/analyzer/builtin.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::mem::take;

use swc_core::ecma::atoms::js_word;
use swc_core::ecma::atoms::atom;

use super::{ConstantNumber, ConstantValue, JsValue, LogicalOperator, LogicalProperty, ObjectPart};
use crate::analyzer::JsValueUrlKind;
Expand Down Expand Up @@ -303,7 +303,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
}
}
if potential_values.is_empty() {
*value = JsValue::FreeVar(js_word!("undefined"));
*value = JsValue::FreeVar(atom!("undefined"));
} else {
*value = potential_values_to_alternatives(
potential_values,
Expand Down
12 changes: 6 additions & 6 deletions turbopack/crates/turbopack-ecmascript/src/analyzer/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use swc_core::{
common::{comments::Comments, pass::AstNodePath, Mark, Span, Spanned, SyntaxContext, GLOBALS},
ecma::{
ast::*,
atoms::js_word,
atoms::atom,
utils::contains_ident_ref,
visit::{fields::*, *},
},
Expand Down Expand Up @@ -658,7 +658,7 @@ impl EvalContext {
}
let args = args.iter().map(|arg| self.eval(&arg.expr)).collect();

let callee = Box::new(JsValue::FreeVar(js_word!("import")));
let callee = Box::new(JsValue::FreeVar(atom!("import")));

JsValue::call(callee, args)
}
Expand All @@ -673,7 +673,7 @@ impl EvalContext {
.iter()
.map(|e| match e {
Some(e) => self.eval(&e.expr),
_ => JsValue::FreeVar(js_word!("undefined")),
_ => JsValue::FreeVar(atom!("undefined")),
})
.collect();
JsValue::array(arr)
Expand Down Expand Up @@ -1127,7 +1127,7 @@ impl Analyzer<'_> {
match callee {
Callee::Import(_) => {
self.add_effect(Effect::Call {
func: Box::new(JsValue::FreeVar(js_word!("import"))),
func: Box::new(JsValue::FreeVar(atom!("import"))),
args,
ast_path: as_parent_path(ast_path),
span,
Expand Down Expand Up @@ -1213,7 +1213,7 @@ impl Analyzer<'_> {
let values = self.cur_fn_return_values.take().unwrap();

Box::new(match values.len() {
0 => JsValue::FreeVar(js_word!("undefined")),
0 => JsValue::FreeVar(atom!("undefined")),
1 => values.into_iter().next().unwrap(),
_ => JsValue::alternatives(values),
})
Expand Down Expand Up @@ -1793,7 +1793,7 @@ impl VisitAstPath for Analyzer<'_> {
.arg
.as_deref()
.map(|e| self.eval_context.eval(e))
.unwrap_or(JsValue::FreeVar(js_word!("undefined")));
.unwrap_or(JsValue::FreeVar(atom!("undefined")));

values.push(return_value);
}
Expand Down
Loading
Loading