Skip to content

Commit

Permalink
perf: Update SWC plugins (#75324)
Browse files Browse the repository at this point in the history
### What?

Applies

 - swc-project/plugins#396
 - swc-project/plugins#397 
 - swc-project/plugins#398
 - swc-project/plugins#399

### Why?

To remove needless allocations.
  • Loading branch information
kdy1 authored Jan 27, 2025
1 parent 3d6a6cf commit 3813b2c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 18 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ testing = { version = "5.0.0" }
browserslist-rs = { version = "0.16.0" }
miette = { version = "5.10.0", features = ["fancy"] }
mdxjs = "0.2.15"
modularize_imports = { version = "0.71.0" }
styled_components = { version = "0.99.0" }
modularize_imports = { version = "0.72.0" }
styled_components = { version = "0.100.1" }
styled_jsx = { version = "0.76.0" }
swc_emotion = { version = "0.75.0" }
swc_emotion = { version = "0.76.0" }
swc_relay = { version = "0.46.1" }

# General Deps
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::sync::Arc;

use anyhow::Result;
use async_trait::async_trait;
use modularize_imports::{modularize_imports, Config, PackageConfig};
Expand Down Expand Up @@ -81,7 +83,7 @@ impl ModularizeImportsTransformer {
.map(|(k, v)| {
(
k.clone(),
PackageConfig {
Arc::new(PackageConfig {
transform: match &v.transform {
Transform::String(s) => {
modularize_imports::Transform::String(s.clone())
Expand All @@ -97,7 +99,7 @@ impl ModularizeImportsTransformer {
skip_default_conversion: v.skip_default_conversion,
handle_default_import: false,
handle_namespace_import: false,
},
}),
)
})
.collect(),
Expand Down
4 changes: 3 additions & 1 deletion crates/next-custom-transforms/src/chain_transforms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ pub fn custom_before_pass<'a, C>(
where
C: Clone + Comments + 'a,
{
let file_path_str = file.name.to_string();

#[cfg(target_arch = "wasm32")]
let relay_plugin = noop_pass();

Expand Down Expand Up @@ -182,7 +184,7 @@ where
fn_pass(move |program| {
if let Some(config) = &opts.styled_components {
program.mutate(styled_components::styled_components(
&file.name,
Some(&file_path_str),
file.src_hash,
config,
NoopComments,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::sync::Arc;

use anyhow::Result;
use async_trait::async_trait;
use modularize_imports::{modularize_imports, Config, PackageConfig};
Expand Down Expand Up @@ -30,15 +32,15 @@ impl ModularizeImportsTransformer {
.map(|(k, v)| {
(
k.clone(),
PackageConfig {
Arc::new(PackageConfig {
transform: modularize_imports::Transform::String(
v.transform.clone(),
),
prevent_full_import: v.prevent_full_import,
skip_default_conversion: v.skip_default_conversion,
handle_default_import: false,
handle_namespace_import: false,
},
}),
)
})
.collect(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::path::PathBuf;

use anyhow::Result;
use async_trait::async_trait;
use swc_core::{
common::{comments::NoopComments, FileName},
common::comments::NoopComments,
ecma::{ast::Program, atoms::JsWord},
};
use turbo_tasks::{ValueDefault, Vc};
Expand Down Expand Up @@ -92,7 +90,7 @@ impl CustomTransformer for StyledComponentsTransformer {
#[tracing::instrument(level = tracing::Level::TRACE, name = "styled_components", skip_all)]
async fn transform(&self, program: &mut Program, ctx: &TransformContext<'_>) -> Result<()> {
program.mutate(styled_components::styled_components(
&FileName::Real(PathBuf::from(ctx.file_path_str)),
Some(ctx.file_path_str),
ctx.file_name_hash,
&self.config,
NoopComments,
Expand Down

0 comments on commit 3813b2c

Please sign in to comment.