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

Update swc_core to v0.100.6 #68560

Merged
merged 32 commits into from
Aug 16, 2024
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
848 changes: 496 additions & 352 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 @@ -84,21 +84,21 @@ turbopack-trace-utils = { path = "turbopack/crates/turbopack-trace-utils" }
turbopack-wasm = { path = "turbopack/crates/turbopack-wasm" }

# SWC crates
swc_core = { version = "0.96.9", features = [
swc_core = { version = "0.100.6", features = [
"ecma_loader_lru",
"ecma_loader_parking_lot",
] }
testing = { version = "0.36.0" }
testing = { version = "0.39.0" }

# Keep consistent with preset_env_base through swc_core
browserslist-rs = { version = "0.16.0" }
miette = { version = "5.10.0", features = ["fancy"] }
mdxjs = "0.2.5"
modularize_imports = { version = "0.68.7" }
styled_components = { version = "0.96.6" }
styled_jsx = { version = "0.73.10" }
swc_emotion = { version = "0.72.6" }
swc_relay = { version = "0.44.5" }
modularize_imports = { version = "0.68.21" }
styled_components = { version = "0.96.20" }
styled_jsx = { version = "0.73.29" }
swc_emotion = { version = "0.72.19" }
swc_relay = { version = "0.44.22" }

# General Deps

Expand Down Expand Up @@ -198,7 +198,7 @@ smallvec = { version = "1.13.1", features = [
"union",
"const_new",
] }
sourcemap = "8.0.1"
sourcemap = "9.0.0"
syn = "1.0.107"
tempfile = "3.3.0"
thiserror = "1.0.48"
Expand Down
4 changes: 2 additions & 2 deletions crates/napi/src/minify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ enum MinifyTarget {
impl MinifyTarget {
fn to_file(&self, cm: Lrc<SourceMap>) -> Lrc<SourceFile> {
match self {
MinifyTarget::Single(code) => cm.new_source_file(FileName::Anon, code.clone()),
MinifyTarget::Single(code) => cm.new_source_file(FileName::Anon.into(), code.clone()),
MinifyTarget::Map(codes) => {
assert_eq!(
codes.len(),
Expand All @@ -69,7 +69,7 @@ impl MinifyTarget {

let (filename, code) = codes.iter().next().unwrap();

cm.new_source_file(FileName::Real(filename.clone().into()), code.clone())
cm.new_source_file(FileName::Real(filename.clone().into()).into(), code.clone())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/napi/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Task for ParseTask {
None
};
let fm =
c.cm.new_source_file(self.filename.clone(), self.src.clone());
c.cm.new_source_file(self.filename.clone().into(), self.src.clone());
let program = try_with_handler(
c.cm.clone(),
swc_core::base::HandlerOpts {
Expand Down
4 changes: 2 additions & 2 deletions crates/napi/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl Task for TransformTask {
FileName::Real(options.swc.filename.clone().into())
};

self.c.cm.new_source_file(filename, src.to_string())
self.c.cm.new_source_file(filename.into(), src.to_string())
}
Input::FromFilename => {
let filename = &options.swc.filename;
Expand All @@ -114,7 +114,7 @@ impl Task for TransformTask {
}

self.c.cm.new_source_file(
FileName::Real(filename.into()),
FileName::Real(filename.into()).into(),
read_to_string(filename).with_context(|| {
format!("Failed to read source code from {}", filename)
})?,
Expand Down
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.24.15"
remove_console = "0.25.15"
react_remove_properties = "0.24.17"
remove_console = "0.25.17"

auto-hash-map = { workspace = true }

Expand Down
2 changes: 1 addition & 1 deletion crates/next-core/src/app_segment_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::{bail, Result};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use swc_core::{
common::{source_map::Pos, Span, Spanned, GLOBALS},
common::{source_map::SmallPos, Span, Spanned, GLOBALS},
ecma::ast::{Decl, Expr, FnExpr, Ident, Program},
};
use turbo_tasks::{trace::TraceRawVcs, RcStr, TryJoinIterExt, ValueDefault, Vc};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl CustomTransformer for NextJsDynamic {
self.is_react_server_layer,
self.is_app_dir,
NextDynamicMode::Webpack,
FileName::Real(ctx.file_path_str.into()),
FileName::Real(ctx.file_path_str.into()).into(),
None,
));

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 @@ -56,8 +56,8 @@ swc_emotion = { workspace = true }
swc_relay = { workspace = true }
turbopack-ecmascript-plugins = { workspace = true, optional = true }

react_remove_properties = "0.24.15"
remove_console = "0.25.15"
react_remove_properties = "0.24.17"
remove_console = "0.25.17"
preset_env_base = "0.5.1"

[dev-dependencies]
Expand Down
6 changes: 3 additions & 3 deletions crates/next-custom-transforms/src/chain_transforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ where
if let Some(config) = &opts.relay {
Either::Left(swc_relay::relay(
Arc::new(config.clone()),
file.name.clone(),
(*file.name).clone(),
std::env::current_dir().unwrap(),
opts.pages_dir.clone(),
None,
Expand Down Expand Up @@ -160,7 +160,7 @@ where
let styled_jsx = if let Some(config) = opts.styled_jsx.to_option() {
Either::Left(styled_jsx::visitor::styled_jsx(
cm.clone(),
file.name.clone(),
(*file.name).clone(),
styled_jsx::visitor::Config {
use_lightningcss: config.use_lightningcss,
browsers: target_browsers,
Expand Down Expand Up @@ -266,7 +266,7 @@ where
if !config.enabled.unwrap_or(false) {
return None;
}
if let FileName::Real(path) = &file.name {
if let FileName::Real(path) = &*file.name {
path.to_str().map(|_| {
Either::Left(swc_emotion::EmotionTransformer::new(
config.clone(),
Expand Down
14 changes: 5 additions & 9 deletions crates/next-custom-transforms/src/transforms/amp_attributes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use swc_core::ecma::{
ast::{Ident, JSXAttr, JSXAttrName, JSXAttrOrSpread, JSXElementName, JSXOpeningElement},
ast::{
Ident, IdentName, JSXAttr, JSXAttrName, JSXAttrOrSpread, JSXElementName, JSXOpeningElement,
},
atoms::JsWord,
visit::Fold,
};
Expand All @@ -26,22 +28,16 @@ impl Fold for AmpAttributePatcher {
if sym.starts_with("amp-") {
for i in &mut attrs {
if let JSXAttrOrSpread::JSXAttr(JSXAttr {
name:
JSXAttrName::Ident(Ident {
sym,
span: s,
optional: o,
}),
name: JSXAttrName::Ident(IdentName { sym, span: s }),
span,
value,
}) = &i
{
if sym as &str == "className" {
*i = JSXAttrOrSpread::JSXAttr(JSXAttr {
name: JSXAttrName::Ident(Ident {
name: JSXAttrName::Ident(IdentName {
sym: JsWord::from("class"),
span: *s,
optional: *o,
}),
span: *span,
value: value.clone(),
Expand Down
17 changes: 9 additions & 8 deletions crates/next-custom-transforms/src/transforms/cjs_optimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use swc_core::{
common::{util::take::Take, SyntaxContext, DUMMY_SP},
ecma::{
ast::{
CallExpr, Callee, Decl, Expr, Id, Ident, Lit, MemberExpr, MemberProp, Module,
ModuleItem, Pat, Script, Stmt, VarDecl, VarDeclKind, VarDeclarator,
CallExpr, Callee, Decl, Expr, Id, Ident, IdentName, Lit, MemberExpr, MemberProp,
Module, ModuleItem, Pat, Script, Stmt, VarDecl, VarDeclKind, VarDeclarator,
},
atoms::{Atom, JsWord},
utils::{prepend_stmts, private_ident, ExprFactory, IdentRenamer},
Expand Down Expand Up @@ -114,18 +114,19 @@ impl VisitMut for CjsOptimizer {
span: DUMMY_SP,
callee: Ident::new(
"require".into(),
DUMMY_SP.with_ctxt(self.unresolved_ctxt),
DUMMY_SP,
self.unresolved_ctxt,
)
.as_callee(),
args: vec![Expr::Lit(Lit::Str(
renamed.clone().into(),
))
.as_arg()],
type_args: None,
..Default::default()
})),
prop: MemberProp::Ident(Ident::new(
prop: MemberProp::Ident(IdentName::new(
prop.sym.clone(),
DUMMY_SP.with_ctxt(self.unresolved_ctxt),
DUMMY_SP,
)),
}))),
definite: false,
Expand All @@ -142,8 +143,8 @@ impl VisitMut for CjsOptimizer {
Box::new(VarDecl {
span: DUMMY_SP,
kind: VarDeclKind::Const,
declare: false,
decls: vec![var],
..Default::default()
}),
)));
}
Expand Down Expand Up @@ -212,7 +213,7 @@ impl VisitMut for CjsOptimizer {
})) = n.init.as_deref()
{
if let Expr::Ident(ident) = &**callee {
if ident.span.ctxt == self.unresolved_ctxt && ident.sym == *"require" {
if ident.ctxt == self.unresolved_ctxt && ident.sym == *"require" {
if let Some(arg) = args.first() {
if let Expr::Lit(Lit::Str(v)) = &*arg.expr {
// TODO: Config
Expand Down
Loading
Loading