Skip to content

Commit

Permalink
Ensure process.env.TURBOPACK is always set (#6116)
Browse files Browse the repository at this point in the history
### Description

Related to vercel/next.js#56496. Server Actions
currently shows an error as it seems to use the react-dom-webpack
version instead of react-dom-turbopack. This seems to be caused by the
changes in vercel/next.js#56438 which checks for
`process.env.TURBOPACK` which is not always set currently, unlike
`process.turbopack`. This PR adds it in the other places where
`process.turbopack` is set.

<!--
  ✍️ Write a short summary of your work.
  If necessary, include relevant screenshots.
-->

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->
  • Loading branch information
timneutkens committed Oct 6, 2023
1 parent dbc78d7 commit e97565e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions crates/turbopack-cli/src/contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ pub fn get_client_asset_context(
fn client_defines(node_env: &NodeEnv) -> Vc<CompileTimeDefines> {
compile_time_defines!(
process.turbopack = true,
process.env.TURBOPACK = true,
process.env.NODE_ENV = node_env.to_string()
)
.cell()
Expand Down
1 change: 1 addition & 0 deletions crates/turbopack-tests/tests/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ async fn run_test(resource: String) -> Result<Vc<RunTestResult>> {
.defines(
compile_time_defines!(
process.turbopack = true,
process.env.TURBOPACK = true,
process.env.NODE_ENV = "development",
)
.cell(),
Expand Down
1 change: 1 addition & 0 deletions crates/turbopack-tests/tests/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ async fn run_test(resource: String) -> Result<Vc<FileSystemPath>> {

let defines = compile_time_defines!(
process.turbopack = true,
process.env.TURBOPACK = true,
process.env.NODE_ENV = "development",
DEFINED_VALUE = "value",
DEFINED_TRUE = true,
Expand Down
8 changes: 6 additions & 2 deletions crates/turbopack/src/evaluate_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,12 @@ pub async fn node_evaluate_asset_context(
transitions.unwrap_or_else(|| Vc::cell(Default::default())),
CompileTimeInfo::builder(node_build_environment())
.defines(
compile_time_defines!(process.turbopack = true, process.env.NODE_ENV = node_env,)
.cell(),
compile_time_defines!(
process.turbopack = true,
process.env.NODE_ENV = node_env,
process.env.TURBOPACK = true
)
.cell(),
)
.cell(),
ModuleOptionsContext {
Expand Down

0 comments on commit e97565e

Please sign in to comment.