Skip to content

Commit

Permalink
Merge dedf85b into dd05689
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Aug 24, 2023
2 parents dd05689 + dedf85b commit 642fd5a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion crates/turbopack/src/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl ContextCondition {
// False positive.
#[allow(clippy::manual_try_fold)]
stream::iter(conditions)
.fold(Ok(true), |acc, c| async move {
.fold(Ok(false), |acc, c| async move {
Ok(acc? || c.matches(path).await?)
})
.await
Expand Down
40 changes: 23 additions & 17 deletions crates/turbopack/src/evaluate_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ use turbopack_core::{
use turbopack_node::execution_context::ExecutionContext;

use crate::{
module_options::ModuleOptionsContext, resolve_options_context::ResolveOptionsContext,
transition::TransitionsByName, ModuleAssetContext,
condition::ContextCondition, module_options::ModuleOptionsContext,
resolve_options_context::ResolveOptionsContext, transition::TransitionsByName,
ModuleAssetContext,
};

#[turbo_tasks::function]
Expand Down Expand Up @@ -49,31 +50,36 @@ pub async fn node_evaluate_asset_context(
} else {
"development".to_string()
};
let resolve_options_context = ResolveOptionsContext {
enable_node_modules: Some(execution_context.project_path().root().resolve().await?),
enable_node_externals: true,
enable_node_native_modules: true,
custom_conditions: vec![node_env.clone(), "node".to_string()],
..Default::default()
};
let resolve_options_context = ResolveOptionsContext {
enable_typescript: true,
import_map: Some(import_map),
rules: vec![(
ContextCondition::InDirectory("node_modules".to_string()),
resolve_options_context.clone().cell(),
)],
..resolve_options_context
}
.cell();
Ok(Vc::upcast(ModuleAssetContext::new(
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.clone(),
)
.cell(),
compile_time_defines!(process.turbopack = true, process.env.NODE_ENV = node_env,)
.cell(),
)
.cell(),
ModuleOptionsContext {
enable_typescript_transform: Some(Default::default()),
..Default::default()
}
.cell(),
ResolveOptionsContext {
enable_typescript: true,
enable_node_modules: Some(execution_context.project_path().root().resolve().await?),
enable_node_externals: true,
enable_node_native_modules: true,
custom_conditions: vec![node_env, "node".to_string()],
import_map: Some(import_map),
..Default::default()
}
.cell(),
resolve_options_context,
)))
}

0 comments on commit 642fd5a

Please sign in to comment.