Skip to content

Commit c53ac3e

Browse files
authored
build: Update swc_core to v16.0.0 (#76414)
### What? Update `swc_core` to `v16.0.0`. This is a Wasm-breaking change, and changelog is at swc-project/swc@[email protected][email protected] ### Why? To apply various fixes.
1 parent be05184 commit c53ac3e

File tree

20 files changed

+251
-233
lines changed

20 files changed

+251
-233
lines changed

Cargo.lock

+166-148
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+8-8
Original file line numberDiff line numberDiff line change
@@ -299,21 +299,21 @@ turbopack-trace-utils = { path = "turbopack/crates/turbopack-trace-utils" }
299299
turbopack-wasm = { path = "turbopack/crates/turbopack-wasm" }
300300

301301
# SWC crates
302-
swc_core = { version = "14.0.1", features = [
302+
swc_core = { version = "16.0.0", features = [
303303
"ecma_loader_lru",
304304
"ecma_loader_parking_lot",
305305
] }
306-
testing = { version = "7.0.0" }
306+
testing = { version = "8.0.0" }
307307

308308
# Keep consistent with preset_env_base through swc_core
309309
browserslist-rs = { version = "0.17.0" }
310310
miette = { version = "5.10.0", features = ["fancy"] }
311311
mdxjs = "0.3"
312-
modularize_imports = { version = "0.77.0" }
313-
styled_components = { version = "0.105.0" }
314-
styled_jsx = { version = "0.81.0" }
315-
swc_emotion = { version = "0.81.0" }
316-
swc_relay = { version = "0.51.0" }
312+
modularize_imports = { version = "0.79.0" }
313+
styled_components = { version = "0.107.0" }
314+
styled_jsx = { version = "0.83.0" }
315+
swc_emotion = { version = "0.83.0" }
316+
swc_relay = { version = "0.53.0" }
317317

318318
# General Deps
319319
chromiumoxide = { version = "0.5.4", features = [
@@ -435,4 +435,4 @@ wasmer-cache = { git = "https://github.com/kdy1/wasmer", branch = "build-deps" }
435435
wasmer-compiler-cranelift = { git = "https://github.com/kdy1/wasmer", branch = "build-deps" }
436436
wasmer-wasix = { git = "https://github.com/kdy1/wasmer", branch = "build-deps" }
437437

438-
mdxjs={git="https://github.com/kdy1/mdxjs-rs.git",branch = "swc-core-14"}
438+
mdxjs = { git="https://github.com/kdy1/mdxjs-rs.git", branch = "swc-core-15" }

crates/next-core/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ lazy_static = { workspace = true }
3232
thiserror = { workspace = true }
3333
tracing = { workspace = true }
3434
rustc-hash = { workspace = true }
35-
react_remove_properties = "0.31.0"
36-
remove_console = "0.32.0"
35+
react_remove_properties = "0.33.0"
36+
remove_console = "0.34.0"
3737

3838
auto-hash-map = { workspace = true }
3939

crates/next-core/src/next_shared/transforms/next_font.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use anyhow::Result;
22
use async_trait::async_trait;
33
use next_custom_transforms::transforms::fonts::*;
4-
use swc_core::ecma::{ast::Program, atoms::JsWord, visit::VisitMutWith};
4+
use swc_core::ecma::{ast::Program, atoms::Atom, visit::VisitMutWith};
55
use turbo_tasks::ResolvedVc;
66
use turbopack::module_options::{ModuleRule, ModuleRuleEffect};
77
use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext};
@@ -33,7 +33,7 @@ pub fn get_next_font_transform_rule(enable_mdx_rs: bool) -> ModuleRule {
3333

3434
#[derive(Debug)]
3535
struct NextJsFont {
36-
font_loaders: Vec<JsWord>,
36+
font_loaders: Vec<Atom>,
3737
}
3838

3939
#[async_trait]

crates/next-custom-transforms/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ swc_relay = { workspace = true }
6060
turbopack-ecmascript-plugins = { workspace = true, optional = true }
6161
turbo-rcstr = { workspace = true }
6262

63-
react_remove_properties = "0.31.0"
64-
remove_console = "0.32.0"
63+
react_remove_properties = "0.33.0"
64+
remove_console = "0.34.0"
6565
preset_env_base = "2.0.1"
6666

6767
[dev-dependencies]

crates/next-custom-transforms/src/transforms/amp_attributes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use swc_core::ecma::{
33
Ident, IdentName, JSXAttr, JSXAttrName, JSXAttrOrSpread, JSXElementName, JSXOpeningElement,
44
Pass,
55
},
6-
atoms::JsWord,
6+
atoms::Atom,
77
visit::{fold_pass, Fold},
88
};
99

@@ -37,7 +37,7 @@ impl Fold for AmpAttributePatcher {
3737
if sym as &str == "className" {
3838
*i = JSXAttrOrSpread::JSXAttr(JSXAttr {
3939
name: JSXAttrName::Ident(IdentName {
40-
sym: JsWord::from("class"),
40+
sym: Atom::from("class"),
4141
span: *s,
4242
}),
4343
span: *span,

crates/next-custom-transforms/src/transforms/fonts/font_functions_collector.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ use swc_core::{
22
common::errors::HANDLER,
33
ecma::{
44
ast::*,
5-
atoms::JsWord,
5+
atoms::Atom,
66
visit::{noop_visit_type, Visit},
77
},
88
};
99

1010
pub struct FontFunctionsCollector<'a> {
11-
pub font_loaders: &'a [JsWord],
11+
pub font_loaders: &'a [Atom],
1212
pub state: &'a mut super::State,
1313
}
1414

crates/next-custom-transforms/src/transforms/fonts/font_imports_generator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use swc_core::{
33
common::{errors::HANDLER, Spanned, DUMMY_SP},
44
ecma::{
55
ast::*,
6-
atoms::JsWord,
6+
atoms::Atom,
77
visit::{noop_visit_type, Visit},
88
},
99
};
@@ -66,7 +66,7 @@ impl FontImportsGenerator<'_> {
6666

6767
return Some(ImportDecl {
6868
src: Box::new(Str {
69-
value: JsWord::from(format!(
69+
value: Atom::from(format!(
7070
"{}/target.css?{}",
7171
font_function.loader, query_json
7272
)),

crates/next-custom-transforms/src/transforms/fonts/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use swc_core::{
44
common::{BytePos, Spanned},
55
ecma::{
66
ast::{Id, ModuleItem, Pass},
7-
atoms::JsWord,
7+
atoms::Atom,
88
visit::{noop_visit_mut_type, visit_mut_pass, VisitMut, VisitWith},
99
},
1010
};
@@ -16,8 +16,8 @@ mod font_imports_generator;
1616
#[derive(Clone, Debug, Deserialize)]
1717
#[serde(deny_unknown_fields, rename_all = "camelCase")]
1818
pub struct Config {
19-
pub font_loaders: Vec<JsWord>,
20-
pub relative_file_path_from_root: JsWord,
19+
pub font_loaders: Vec<Atom>,
20+
pub relative_file_path_from_root: Atom,
2121
}
2222

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

3232
#[derive(Debug)]
3333
pub struct FontFunction {
34-
loader: JsWord,
35-
function_name: Option<JsWord>,
34+
loader: Atom,
35+
function_name: Option<Atom>,
3636
}
3737
#[derive(Debug, Default)]
3838
pub struct State {

crates/next-custom-transforms/src/transforms/import_analyzer.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc_hash::{FxHashMap, FxHashSet};
22
use swc_core::{
3-
atoms::JsWord,
3+
atoms::Atom,
44
ecma::{
55
ast::{
66
Expr, Id, ImportDecl, ImportNamedSpecifier, ImportSpecifier, MemberExpr, MemberProp,
@@ -13,16 +13,16 @@ use swc_core::{
1313
#[derive(Debug, Default)]
1414
pub(crate) struct ImportMap {
1515
/// Map from module name to (module path, exported symbol)
16-
imports: FxHashMap<Id, (JsWord, JsWord)>,
16+
imports: FxHashMap<Id, (Atom, Atom)>,
1717

18-
namespace_imports: FxHashMap<Id, JsWord>,
18+
namespace_imports: FxHashMap<Id, Atom>,
1919

20-
imported_modules: FxHashSet<JsWord>,
20+
imported_modules: FxHashSet<Atom>,
2121
}
2222

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

@@ -96,7 +96,7 @@ impl Visit for Analyzer<'_> {
9696
}
9797
}
9898

99-
fn orig_name(n: &ModuleExportName) -> JsWord {
99+
fn orig_name(n: &ModuleExportName) -> Atom {
100100
match n {
101101
ModuleExportName::Ident(v) => v.sym.clone(),
102102
ModuleExportName::Str(v) => v.value.clone(),

crates/next-custom-transforms/src/transforms/shake_exports.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ use swc_core::{
33
common::Mark,
44
ecma::{
55
ast::*,
6-
atoms::{js_word, JsWord},
6+
atoms::{atom, Atom},
77
transforms::optimization::simplify::dce::{dce, Config as DCEConfig},
88
visit::{fold_pass, Fold, FoldWith, VisitMutWith},
99
},
1010
};
1111

1212
#[derive(Clone, Debug, Deserialize)]
1313
pub struct Config {
14-
pub ignore: Vec<JsWord>,
14+
pub ignore: Vec<Atom>,
1515
}
1616

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

2424
#[derive(Debug, Default)]
2525
struct ExportShaker {
26-
ignore: Vec<JsWord>,
26+
ignore: Vec<Atom>,
2727
remove_export: bool,
2828
}
2929

@@ -108,14 +108,14 @@ impl Fold for ExportShaker {
108108
}
109109

110110
fn fold_export_default_decl(&mut self, decl: ExportDefaultDecl) -> ExportDefaultDecl {
111-
if !self.ignore.contains(&js_word!("default")) {
111+
if !self.ignore.contains(&atom!("default")) {
112112
self.remove_export = true
113113
}
114114
decl
115115
}
116116

117117
fn fold_export_default_expr(&mut self, expr: ExportDefaultExpr) -> ExportDefaultExpr {
118-
if !self.ignore.contains(&js_word!("default")) {
118+
if !self.ignore.contains(&atom!("default")) {
119119
self.remove_export = true
120120
}
121121
expr

turbopack/crates/turbopack-ecmascript-plugins/src/transform/styled_components.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::Result;
22
use async_trait::async_trait;
33
use swc_core::{
44
common::comments::NoopComments,
5-
ecma::{ast::Program, atoms::JsWord},
5+
ecma::{ast::Program, atoms::Atom},
66
};
77
use turbo_tasks::{ValueDefault, Vc};
88
use turbopack_ecmascript::{CustomTransformer, TransformContext};
@@ -71,7 +71,7 @@ impl StyledComponentsTransformer {
7171
if !top_level_import_paths.is_empty() {
7272
options.top_level_import_paths = top_level_import_paths
7373
.iter()
74-
.map(|s| JsWord::from(s.clone()))
74+
.map(|s| Atom::from(s.clone()))
7575
.collect();
7676
}
7777
let meaningless_file_names = &config.meaningless_file_names;

turbopack/crates/turbopack-ecmascript/src/analyzer/builtin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::mem::take;
22

3-
use swc_core::ecma::atoms::js_word;
3+
use swc_core::ecma::atoms::atom;
44

55
use super::{ConstantNumber, ConstantValue, JsValue, LogicalOperator, LogicalProperty, ObjectPart};
66
use crate::analyzer::JsValueUrlKind;
@@ -303,7 +303,7 @@ pub fn replace_builtin(value: &mut JsValue) -> bool {
303303
}
304304
}
305305
if potential_values.is_empty() {
306-
*value = JsValue::FreeVar(js_word!("undefined"));
306+
*value = JsValue::FreeVar(atom!("undefined"));
307307
} else {
308308
*value = potential_values_to_alternatives(
309309
potential_values,

turbopack/crates/turbopack-ecmascript/src/analyzer/graph.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use swc_core::{
99
common::{comments::Comments, pass::AstNodePath, Mark, Span, Spanned, SyntaxContext, GLOBALS},
1010
ecma::{
1111
ast::*,
12-
atoms::js_word,
12+
atoms::atom,
1313
utils::contains_ident_ref,
1414
visit::{fields::*, *},
1515
},
@@ -658,7 +658,7 @@ impl EvalContext {
658658
}
659659
let args = args.iter().map(|arg| self.eval(&arg.expr)).collect();
660660

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

663663
JsValue::call(callee, args)
664664
}
@@ -673,7 +673,7 @@ impl EvalContext {
673673
.iter()
674674
.map(|e| match e {
675675
Some(e) => self.eval(&e.expr),
676-
_ => JsValue::FreeVar(js_word!("undefined")),
676+
_ => JsValue::FreeVar(atom!("undefined")),
677677
})
678678
.collect();
679679
JsValue::array(arr)
@@ -1127,7 +1127,7 @@ impl Analyzer<'_> {
11271127
match callee {
11281128
Callee::Import(_) => {
11291129
self.add_effect(Effect::Call {
1130-
func: Box::new(JsValue::FreeVar(js_word!("import"))),
1130+
func: Box::new(JsValue::FreeVar(atom!("import"))),
11311131
args,
11321132
ast_path: as_parent_path(ast_path),
11331133
span,
@@ -1213,7 +1213,7 @@ impl Analyzer<'_> {
12131213
let values = self.cur_fn_return_values.take().unwrap();
12141214

12151215
Box::new(match values.len() {
1216-
0 => JsValue::FreeVar(js_word!("undefined")),
1216+
0 => JsValue::FreeVar(atom!("undefined")),
12171217
1 => values.into_iter().next().unwrap(),
12181218
_ => JsValue::alternatives(values),
12191219
})
@@ -1793,7 +1793,7 @@ impl VisitAstPath for Analyzer<'_> {
17931793
.arg
17941794
.as_deref()
17951795
.map(|e| self.eval_context.eval(e))
1796-
.unwrap_or(JsValue::FreeVar(js_word!("undefined")));
1796+
.unwrap_or(JsValue::FreeVar(atom!("undefined")));
17971797

17981798
values.push(return_value);
17991799
}

0 commit comments

Comments
 (0)