Skip to content

Commit bfdb349

Browse files
Remove ServerDirectiveTransformer (#56496)
As discussed with @jridgewell this removes the hard error when using `"use server"` in Turbopack. <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent f954212 commit bfdb349

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

packages/next-swc/crates/next-core/src/next_client/context.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use turbopack_binding::{
1919
},
2020
dev::{react_refresh::assert_can_resolve_react_refresh, DevChunkingContext},
2121
ecmascript::chunk::EcmascriptChunkingContext,
22-
ecmascript_plugin::transform::directives::server::ServerDirectiveTransformer,
2322
node::execution_context::ExecutionContext,
2423
turbopack::{
2524
condition::ContextCondition,
@@ -232,11 +231,6 @@ pub async fn get_client_module_options_context(
232231
*get_emotion_transform_plugin(next_config).await?,
233232
*get_styled_components_transform_plugin(next_config).await?,
234233
*get_styled_jsx_transform_plugin().await?,
235-
Some(Vc::cell(Box::new(ServerDirectiveTransformer::new(
236-
// ServerDirective is not implemented yet and always reports an issue.
237-
// We don't have to pass a valid transition name yet, but the API is prepared.
238-
&Vc::cell("TODO".to_string()),
239-
)) as _)),
240234
]
241235
.into_iter()
242236
.flatten()

packages/next-swc/crates/next-core/src/next_import_map.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,20 @@ pub async fn get_next_server_import_map(
280280
"next/dist/build/webpack/loaders/next-flight-loader/action-proxy",
281281
),
282282
);
283+
import_map.insert_exact_alias(
284+
"private-next-rsc-action-client-wrapper",
285+
request_to_import_mapping(
286+
project_path,
287+
"next/dist/build/webpack/loaders/next-flight-loader/action-client-wrapper",
288+
),
289+
);
290+
import_map.insert_exact_alias(
291+
"private-next-rsc-action-validate",
292+
request_to_import_mapping(
293+
project_path,
294+
"next/dist/build/webpack/loaders/next-flight-loader/action-validate",
295+
),
296+
);
283297
import_map.insert_exact_alias(
284298
"next/head",
285299
request_to_import_mapping(project_path, "next/dist/client/components/noop-head"),

packages/next-swc/crates/next-core/src/next_server/context.rs

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ use turbopack_binding::{
1919
resolve::{parse::Request, pattern::Pattern},
2020
},
2121
ecmascript::TransformPlugin,
22-
ecmascript_plugin::transform::directives::{
23-
client::ClientDirectiveTransformer, server::ServerDirectiveTransformer,
24-
},
22+
ecmascript_plugin::transform::directives::client::ClientDirectiveTransformer,
2523
node::execution_context::ExecutionContext,
2624
turbopack::{
2725
condition::ContextCondition,
@@ -276,12 +274,6 @@ pub async fn get_server_module_options_context(
276274
let styled_components_transform_plugin =
277275
*get_styled_components_transform_plugin(next_config).await?;
278276
let styled_jsx_transform_plugin = *get_styled_jsx_transform_plugin().await?;
279-
let server_directive_transform_plugin =
280-
Some(Vc::cell(Box::new(ServerDirectiveTransformer::new(
281-
// ServerDirective is not implemented yet and always reports an issue.
282-
// We don't have to pass a valid transition name yet, but the API is prepared.
283-
&Vc::cell("TODO".to_string()),
284-
)) as _));
285277

286278
// ModuleOptionsContext related options
287279
let tsconfig = get_typescript_transform_options(project_path);
@@ -374,7 +366,6 @@ pub async fn get_server_module_options_context(
374366
let mut base_source_transforms: Vec<Vc<TransformPlugin>> = vec![
375367
styled_components_transform_plugin,
376368
styled_jsx_transform_plugin,
377-
server_directive_transform_plugin,
378369
]
379370
.into_iter()
380371
.flatten()
@@ -433,13 +424,11 @@ pub async fn get_server_module_options_context(
433424
ecmascript_client_reference_transition_name,
434425
..
435426
} => {
436-
let mut base_source_transforms: Vec<Vc<TransformPlugin>> = vec![
437-
styled_components_transform_plugin,
438-
server_directive_transform_plugin,
439-
]
440-
.into_iter()
441-
.flatten()
442-
.collect();
427+
let mut base_source_transforms: Vec<Vc<TransformPlugin>> =
428+
vec![styled_components_transform_plugin]
429+
.into_iter()
430+
.flatten()
431+
.collect();
443432

444433
if let Some(ecmascript_client_reference_transition_name) =
445434
ecmascript_client_reference_transition_name

0 commit comments

Comments
 (0)