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

taint flag should enable experimental react in turbopack #57315

Merged
merged 4 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
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
8 changes: 0 additions & 8 deletions packages/next-swc/crates/next-api/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -830,10 +830,6 @@ impl AppEndpoint {
NextRuntime::Edge,
Vc::upcast(this.app_project.edge_rsc_module_context()),
Vc::upcast(chunking_context),
this.app_project
.project()
.next_config()
.enable_server_actions(),
)
.await?;
server_assets.push(manifest);
Expand Down Expand Up @@ -984,10 +980,6 @@ impl AppEndpoint {
NextRuntime::NodeJs,
Vc::upcast(this.app_project.rsc_module_context()),
Vc::upcast(this.app_project.project().server_chunking_context()),
this.app_project
.project()
.next_config()
.enable_server_actions(),
)
.await?;
server_assets.push(manifest);
Expand Down
17 changes: 0 additions & 17 deletions packages/next-swc/crates/next-api/src/server_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,10 @@ pub(crate) async fn create_server_actions_manifest(
runtime: NextRuntime,
asset_context: Vc<Box<dyn AssetContext>>,
chunking_context: Vc<Box<dyn EcmascriptChunkingContext>>,
enable_server_actions: Vc<bool>,
) -> Result<(
Option<Vc<Box<dyn EvaluatableAsset>>>,
Vc<Box<dyn OutputAsset>>,
)> {
// If actions aren't enabled, then there's no need to scan the module graph. We
// still need to generate an empty manifest so that the TS side can merge
// the manifest later on.
if !*enable_server_actions.await? {
let manifest = build_manifest(
node_root,
pathname,
page_name,
runtime,
ModuleActionMap::empty(),
Default::default(),
)
.await?;
return Ok((None, manifest));
}

let actions = get_actions(Vc::upcast(entry));
let loader = build_server_actions_loader(node_root, page_name, actions, asset_context).await?;
let Some(evaluable) = Vc::try_resolve_sidecast::<Box<dyn EvaluatableAsset>>(loader).await?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub async fn get_next_client_transforms_rules(
let mut rules = vec![];

let modularize_imports_config = &next_config.await?.modularize_imports;
let enable_server_actions = *next_config.enable_server_actions().await?;
if let Some(modularize_imports_config) = modularize_imports_config {
rules.push(get_next_modularize_imports_rule(modularize_imports_config));
}
Expand All @@ -39,9 +38,7 @@ pub async fn get_next_client_transforms_rules(
Some(pages_dir)
}
ClientContextType::App { .. } => {
if enable_server_actions {
rules.push(get_server_actions_transform_rule(ActionsTransform::Client));
}
rules.push(get_server_actions_transform_rule(ActionsTransform::Client));
None
}
ClientContextType::Fallback | ClientContextType::Other => None,
Expand Down
10 changes: 4 additions & 6 deletions packages/next-swc/crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,15 +743,13 @@ impl NextConfig {
}

#[turbo_tasks::function]
pub async fn enable_server_actions(self: Vc<Self>) -> Result<Vc<bool>> {
Ok(Vc::cell(
self.await?.experimental.server_actions.unwrap_or(false),
))
pub async fn enable_ppr(self: Vc<Self>) -> Result<Vc<bool>> {
Ok(Vc::cell(self.await?.experimental.ppr.unwrap_or(false)))
}

#[turbo_tasks::function]
pub async fn enable_ppr(self: Vc<Self>) -> Result<Vc<bool>> {
Ok(Vc::cell(self.await?.experimental.ppr.unwrap_or(false)))
pub async fn enable_taint(self: Vc<Self>) -> Result<Vc<bool>> {
Ok(Vc::cell(self.await?.experimental.taint.unwrap_or(false)))
}
}

Expand Down
21 changes: 8 additions & 13 deletions packages/next-swc/crates/next-core/src/next_import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,12 @@ pub async fn get_next_client_import_map(
);
}
ClientContextType::App { app_dir } => {
let react_flavor = if *next_config.enable_server_actions().await?
|| *next_config.enable_ppr().await?
{
"-experimental"
} else {
""
};
let react_flavor =
if *next_config.enable_ppr().await? || *next_config.enable_taint().await? {
"-experimental"
} else {
""
};

import_map.insert_exact_alias(
"react",
Expand Down Expand Up @@ -644,13 +643,9 @@ async fn rsc_aliases(
runtime: NextRuntime,
next_config: Vc<NextConfig>,
) -> Result<()> {
let server_actions = *next_config.enable_server_actions().await?;
let ppr = *next_config.enable_ppr().await?;
let react_channel = if server_actions || ppr {
"-experimental"
} else {
""
};
let taint = *next_config.enable_taint().await?;
let react_channel = if ppr || taint { "-experimental" } else { "" };

let mut alias = indexmap! {
"react" => format!("next/dist/compiled/react{react_channel}"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub async fn get_next_server_transforms_rules(
let mut rules = vec![];

let modularize_imports_config = &next_config.await?.modularize_imports;
let enable_server_actions = *next_config.enable_server_actions().await?;
if let Some(modularize_imports_config) = modularize_imports_config {
rules.push(get_next_modularize_imports_rule(modularize_imports_config));
}
Expand All @@ -40,17 +39,13 @@ pub async fn get_next_server_transforms_rules(
(false, Some(pages_dir))
}
ServerContextType::AppSSR { .. } => {
if enable_server_actions {
rules.push(get_server_actions_transform_rule(ActionsTransform::Server));
}
rules.push(get_server_actions_transform_rule(ActionsTransform::Server));
(false, None)
}
ServerContextType::AppRSC {
client_transition, ..
} => {
if enable_server_actions {
rules.push(get_server_actions_transform_rule(ActionsTransform::Server));
}
rules.push(get_server_actions_transform_rule(ActionsTransform::Server));
if let Some(client_transition) = client_transition {
rules.push(get_next_css_client_reference_transforms_rule(
client_transition,
Expand Down
Loading