Skip to content

Commit 3813b2c

Browse files
authored
perf: Update SWC plugins (#75324)
### What? Applies - swc-project/plugins#396 - swc-project/plugins#397 - swc-project/plugins#398 - swc-project/plugins#399 ### Why? To remove needless allocations.
1 parent 3d6a6cf commit 3813b2c

File tree

6 files changed

+22
-18
lines changed

6 files changed

+22
-18
lines changed

Cargo.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ testing = { version = "5.0.0" }
101101
browserslist-rs = { version = "0.16.0" }
102102
miette = { version = "5.10.0", features = ["fancy"] }
103103
mdxjs = "0.2.15"
104-
modularize_imports = { version = "0.71.0" }
105-
styled_components = { version = "0.99.0" }
104+
modularize_imports = { version = "0.72.0" }
105+
styled_components = { version = "0.100.1" }
106106
styled_jsx = { version = "0.76.0" }
107-
swc_emotion = { version = "0.75.0" }
107+
swc_emotion = { version = "0.76.0" }
108108
swc_relay = { version = "0.46.1" }
109109

110110
# General Deps

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::sync::Arc;
2+
13
use anyhow::Result;
24
use async_trait::async_trait;
35
use modularize_imports::{modularize_imports, Config, PackageConfig};
@@ -81,7 +83,7 @@ impl ModularizeImportsTransformer {
8183
.map(|(k, v)| {
8284
(
8385
k.clone(),
84-
PackageConfig {
86+
Arc::new(PackageConfig {
8587
transform: match &v.transform {
8688
Transform::String(s) => {
8789
modularize_imports::Transform::String(s.clone())
@@ -97,7 +99,7 @@ impl ModularizeImportsTransformer {
9799
skip_default_conversion: v.skip_default_conversion,
98100
handle_default_import: false,
99101
handle_namespace_import: false,
100-
},
102+
}),
101103
)
102104
})
103105
.collect(),

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ pub fn custom_before_pass<'a, C>(
131131
where
132132
C: Clone + Comments + 'a,
133133
{
134+
let file_path_str = file.name.to_string();
135+
134136
#[cfg(target_arch = "wasm32")]
135137
let relay_plugin = noop_pass();
136138

@@ -182,7 +184,7 @@ where
182184
fn_pass(move |program| {
183185
if let Some(config) = &opts.styled_components {
184186
program.mutate(styled_components::styled_components(
185-
&file.name,
187+
Some(&file_path_str),
186188
file.src_hash,
187189
config,
188190
NoopComments,

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::sync::Arc;
2+
13
use anyhow::Result;
24
use async_trait::async_trait;
35
use modularize_imports::{modularize_imports, Config, PackageConfig};
@@ -30,15 +32,15 @@ impl ModularizeImportsTransformer {
3032
.map(|(k, v)| {
3133
(
3234
k.clone(),
33-
PackageConfig {
35+
Arc::new(PackageConfig {
3436
transform: modularize_imports::Transform::String(
3537
v.transform.clone(),
3638
),
3739
prevent_full_import: v.prevent_full_import,
3840
skip_default_conversion: v.skip_default_conversion,
3941
handle_default_import: false,
4042
handle_namespace_import: false,
41-
},
43+
}),
4244
)
4345
})
4446
.collect(),

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
use std::path::PathBuf;
2-
31
use anyhow::Result;
42
use async_trait::async_trait;
53
use swc_core::{
6-
common::{comments::NoopComments, FileName},
4+
common::comments::NoopComments,
75
ecma::{ast::Program, atoms::JsWord},
86
};
97
use turbo_tasks::{ValueDefault, Vc};
@@ -92,7 +90,7 @@ impl CustomTransformer for StyledComponentsTransformer {
9290
#[tracing::instrument(level = tracing::Level::TRACE, name = "styled_components", skip_all)]
9391
async fn transform(&self, program: &mut Program, ctx: &TransformContext<'_>) -> Result<()> {
9492
program.mutate(styled_components::styled_components(
95-
&FileName::Real(PathBuf::from(ctx.file_path_str)),
93+
Some(ctx.file_path_str),
9694
ctx.file_name_hash,
9795
&self.config,
9896
NoopComments,

0 commit comments

Comments
 (0)