Skip to content

Commit

Permalink
Revert "Remove ServerDirectiveTransformer (#56496)"
Browse files Browse the repository at this point in the history
This reverts commit bfdb349.
  • Loading branch information
jridgewell committed Oct 25, 2023
1 parent a301eb6 commit 9c6b60a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
6 changes: 6 additions & 0 deletions packages/next-swc/crates/next-core/src/next_client/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use turbopack_binding::{
},
dev::{react_refresh::assert_can_resolve_react_refresh, DevChunkingContext},
ecmascript::chunk::EcmascriptChunkingContext,
ecmascript_plugin::transform::directives::server::ServerDirectiveTransformer,
node::execution_context::ExecutionContext,
turbopack::{
condition::ContextCondition,
Expand Down Expand Up @@ -243,6 +244,11 @@ pub async fn get_client_module_options_context(
*get_emotion_transform_plugin(next_config).await?,
*get_styled_components_transform_plugin(next_config).await?,
*get_styled_jsx_transform_plugin().await?,
Some(Vc::cell(Box::new(ServerDirectiveTransformer::new(
// ServerDirective is not implemented yet and always reports an issue.
// We don't have to pass a valid transition name yet, but the API is prepared.
&Vc::cell("TODO".to_string()),
)) as _)),
]
.into_iter()
.flatten()
Expand Down
23 changes: 17 additions & 6 deletions packages/next-swc/crates/next-core/src/next_server/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ use turbopack_binding::{
resolve::{parse::Request, pattern::Pattern},
},
ecmascript::TransformPlugin,
ecmascript_plugin::transform::directives::client::ClientDirectiveTransformer,
ecmascript_plugin::transform::directives::{
client::ClientDirectiveTransformer, server::ServerDirectiveTransformer,
},
node::execution_context::ExecutionContext,
turbopack::{
condition::ContextCondition,
Expand Down Expand Up @@ -289,6 +291,12 @@ pub async fn get_server_module_options_context(
let styled_components_transform_plugin =
*get_styled_components_transform_plugin(next_config).await?;
let styled_jsx_transform_plugin = *get_styled_jsx_transform_plugin().await?;
let server_directive_transform_plugin =
Some(Vc::cell(Box::new(ServerDirectiveTransformer::new(
// ServerDirective is not implemented yet and always reports an issue.
// We don't have to pass a valid transition name yet, but the API is prepared.
&Vc::cell("TODO".to_string()),
)) as _));

// ModuleOptionsContext related options
let tsconfig = get_typescript_transform_options(project_path);
Expand Down Expand Up @@ -387,6 +395,7 @@ pub async fn get_server_module_options_context(
let mut base_source_transforms: Vec<Vc<TransformPlugin>> = vec![
styled_components_transform_plugin,
styled_jsx_transform_plugin,
server_directive_transform_plugin,
]
.into_iter()
.flatten()
Expand Down Expand Up @@ -460,11 +469,13 @@ pub async fn get_server_module_options_context(
ecmascript_client_reference_transition_name,
..
} => {
let mut base_source_transforms: Vec<Vc<TransformPlugin>> =
vec![styled_components_transform_plugin]
.into_iter()
.flatten()
.collect();
let mut base_source_transforms: Vec<Vc<TransformPlugin>> = vec![
styled_components_transform_plugin,
server_directive_transform_plugin,
]
.into_iter()
.flatten()
.collect();

if let Some(ecmascript_client_reference_transition_name) =
ecmascript_client_reference_transition_name
Expand Down

0 comments on commit 9c6b60a

Please sign in to comment.