Skip to content

Commit

Permalink
Update swc_core to v0.83.12 (#5923)
Browse files Browse the repository at this point in the history
### Description


### Testing Instructions


Let's look at the CI result of
vercel/next.js#55216

Closes WEB-1533
  • Loading branch information
kdy1 committed Sep 15, 2023
1 parent 15abc25 commit 6de62cf
Show file tree
Hide file tree
Showing 14 changed files with 683 additions and 526 deletions.
1,150 changes: 658 additions & 492 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 8 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,17 @@ async-recursion = "1.0.2"
# Keep consistent with preset_env_base through swc_core
browserslist-rs = { version = "0.12.2" }

# Temporarily downgrading these to avoid breaking changes stemming from using
# lightning_css in later versions styled_jsx >= 0.37.0
mdxjs = "=0.1.14"
modularize_imports = { version = "=0.33.0" }
styled_components = { version = "=0.60.0" }
styled_jsx = { version = "=0.37.0" }
swc_core = { version = "=0.79.55", features = [
mdxjs = "0.1.16"
modularize_imports = { version = "0.45.0" }
styled_components = { version = "0.72.0" }
styled_jsx = { version = "0.49.0" }
swc_core = { version = "0.83.12", features = [
"ecma_loader_lru",
"ecma_loader_parking_lot",
] }
swc_emotion = { version = "=0.36.0" }
swc_relay = { version = "=0.8.0" }
testing = { version = "0.33.21" }
swc_emotion = { version = "0.48.0" }
swc_relay = { version = "0.20.0" }
testing = { version = "0.34.1" }

auto-hash-map = { path = "crates/turbo-tasks-auto-hash-map" }
node-file-trace = { path = "crates/node-file-trace", default-features = false }
Expand Down
1 change: 0 additions & 1 deletion crates/turbo-tasks/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::{
any::Provider,
error::Error as StdError,
fmt::{Debug, Display},
future::Future,
Expand Down
5 changes: 1 addition & 4 deletions crates/turbopack-build/src/ecmascript/minify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,7 @@ fn print_program(
)))) as Box<dyn WriteJs>;

let mut emitter = Emitter {
cfg: swc_core::ecma::codegen::Config {
minify: true,
..Default::default()
},
cfg: swc_core::ecma::codegen::Config::default().with_minify(true),
comments: None,
cm: cm.clone(),
wr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn create_proxy_module(transition_name: &str, target_import: &str) -> Progra
})],
src: Box::new(target_import.into()),
type_only: false,
asserts: Some(Box::new(ObjectLit {
with: Some(Box::new(ObjectLit {
span: DUMMY_SP,
props: vec![PropOrSpread::Prop(Box::new(Prop::KeyValue(KeyValueProp {
key: PropName::Ident(Ident::new(TURBOPACK_HELPER.into(), DUMMY_SP)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ impl CustomTransformer for StyledJsxTransformer {
ctx.source_map.clone(),
// styled_jsx don't really use that in a relevant way
FileName::Anon,
styled_jsx::visitor::Config {
use_lightningcss: false,
},
));

Ok(())
Expand Down
4 changes: 1 addition & 3 deletions crates/turbopack-ecmascript/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,7 @@ async fn gen_content_with_visitors(
let comments = comments.consumable();

let mut emitter = Emitter {
cfg: swc_core::ecma::codegen::Config {
..Default::default()
},
cfg: swc_core::ecma::codegen::Config::default(),
cm: source_map.clone(),
comments: Some(&comments),
wr: JsWriter::new(source_map.clone(), "\n", &mut bytes, Some(&mut srcmap)),
Expand Down
4 changes: 2 additions & 2 deletions crates/turbopack-ecmascript/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ async fn parse_content(
decorators: true,
decorators_before_export: true,
export_default_from: true,
import_assertions: true,
import_attributes: true,
allow_super_outside_method: true,
allow_return_outside_function: true,
auto_accessors: true,
using_decl: true,
explicit_resource_management: true,
}),
EcmascriptModuleAssetType::Typescript
| EcmascriptModuleAssetType::TypescriptWithTypes => {
Expand Down
5 changes: 1 addition & 4 deletions crates/turbopack-ecmascript/src/path_visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,7 @@ mod tests {
fn to_js(m: &Module, cm: &Arc<SourceMap>) -> String {
let mut bytes = Vec::new();
let mut emitter = Emitter {
cfg: swc_core::ecma::codegen::Config {
minify: true,
..Default::default()
},
cfg: swc_core::ecma::codegen::Config::default().with_minify(true),
cm: cm.clone(),
comments: None,
wr: JsWriter::new(cm.clone(), "\n", &mut bytes, None),
Expand Down
2 changes: 1 addition & 1 deletion crates/turbopack-ecmascript/src/references/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2602,7 +2602,7 @@ pub struct AstPath(#[turbo_tasks(trace_ignore)] Vec<AstParentKind>);
pub static TURBOPACK_HELPER: &str = "__turbopackHelper";

pub fn is_turbopack_helper_import(import: &ImportDecl) -> bool {
import.asserts.as_ref().map_or(false, |asserts| {
import.with.as_ref().map_or(false, |asserts| {
asserts.props.iter().any(|assert| {
assert
.as_prop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,7 @@ impl EcmascriptChunkItem for RequireContextChunkItem {
let source_map: Arc<swc_core::common::SourceMap> = Default::default();
let mut bytes: Vec<u8> = vec![];
let mut emitter = Emitter {
cfg: swc_core::ecma::codegen::Config {
..Default::default()
},
cfg: swc_core::ecma::codegen::Config::default(),
cm: source_map.clone(),
comments: None,
wr: JsWriter::new(source_map, "\n", &mut bytes, None),
Expand Down
6 changes: 3 additions & 3 deletions crates/turbopack-ecmascript/src/tree_shake/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ impl DepGraph {
specifiers,
src: Box::new(uri_of_module.clone().into()),
type_only: false,
asserts: Some(Box::new(create_turbopack_chunk_id_assert(dep))),
with: Some(Box::new(create_turbopack_chunk_id_assert(dep))),
})));
}

Expand Down Expand Up @@ -334,7 +334,7 @@ impl DepGraph {
)],
src: None,
type_only: false,
asserts: Some(Box::new(ObjectLit {
with: Some(Box::new(ObjectLit {
span: DUMMY_SP,
props: vec![assertion_prop],
})),
Expand Down Expand Up @@ -787,7 +787,7 @@ impl DepGraph {
})],
src: None,
type_only: false,
asserts: None,
with: None,
})),
export: Some(export.clone()),
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion crates/turbopack-ecmascript/src/tree_shake/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ where
// Try to prepend the content of module

let part_id = import
.asserts
.with
.as_deref()
.and_then(find_turbopack_chunk_id_in_asserts);

Expand Down
3 changes: 2 additions & 1 deletion crates/turbopack-ecmascript/src/tree_shake/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ fn print<N: swc_core::ecma::codegen::Node>(cm: &Arc<SourceMap>, nodes: &[&N]) ->

{
let mut emitter = swc_core::ecma::codegen::Emitter {
cfg: Default::default(),
cfg: swc_core::ecma::codegen::Config::default()
.with_emit_assert_for_import_attributes(true),
cm: cm.clone(),
comments: None,
wr: Box::new(JsWriter::new(cm.clone(), "\n", &mut buf, None)),
Expand Down

0 comments on commit 6de62cf

Please sign in to comment.