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

perf(turbopack): Use Pass API for styled-jsx SWC plugin #75271

Merged
merged 1 commit into from
Jan 24, 2025
Merged
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
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
use anyhow::Result;
use async_trait::async_trait;
use swc_core::{
common::{util::take::Take, FileName},
ecma::{
ast::{Module, Program},
preset_env::Versions,
visit::FoldWith,
},
common::FileName,
ecma::{ast::Program, preset_env::Versions},
};
use turbopack_ecmascript::{CustomTransformer, TransformContext};

Expand All @@ -25,8 +21,7 @@ impl StyledJsxTransformer {
impl CustomTransformer for StyledJsxTransformer {
#[tracing::instrument(level = tracing::Level::TRACE, name = "styled_jsx", skip_all)]
async fn transform(&self, program: &mut Program, ctx: &TransformContext<'_>) -> Result<()> {
let p = std::mem::replace(program, Program::Module(Module::dummy()));
*program = p.fold_with(&mut styled_jsx::visitor::styled_jsx(
program.mutate(styled_jsx::visitor::styled_jsx(
ctx.source_map.clone(),
// styled_jsx don't really use that in a relevant way
FileName::Anon,
Expand Down
Loading