Skip to content

Commit

Permalink
Add the "node" condition to import resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
jridgewell committed May 18, 2023
1 parent 9e51169 commit f799f02
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/next-swc/crates/next-core/src/next_server/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub async fn get_server_resolve_options_context(
enable_node_externals: true,
enable_node_native_modules: true,
module: true,
custom_conditions: vec!["development".to_string()],
custom_conditions: vec!["development".to_string(), "node".to_string()],
import_map: Some(next_server_import_map),
plugins: vec![
external_cjs_modules_plugin.into(),
Expand All @@ -123,7 +123,7 @@ pub async fn get_server_resolve_options_context(
enable_node_externals: true,
enable_node_native_modules: true,
module: true,
custom_conditions: vec!["development".to_string()],
custom_conditions: vec!["development".to_string(), "node".to_string()],
import_map: Some(next_server_import_map),
plugins: vec![
server_component_externals_plugin.into(),
Expand All @@ -147,7 +147,11 @@ pub async fn get_server_resolve_options_context(
enable_node_externals: true,
enable_node_native_modules: true,
module: true,
custom_conditions: vec!["development".to_string(), "react-server".to_string()],
custom_conditions: vec![
"development".to_string(),
"react-server".to_string(),
"node".to_string(),
],
import_map: Some(next_server_import_map),
plugins: vec![
server_component_externals_plugin.into(),
Expand All @@ -169,7 +173,7 @@ pub async fn get_server_resolve_options_context(
let resolve_options_context = ResolveOptionsContext {
enable_node_modules: Some(root_dir),
module: true,
custom_conditions: vec!["development".to_string()],
custom_conditions: vec!["development".to_string(), "node".to_string()],
import_map: Some(next_server_import_map),
plugins: vec![
server_component_externals_plugin.into(),
Expand All @@ -192,7 +196,7 @@ pub async fn get_server_resolve_options_context(
enable_node_modules: Some(root_dir),
enable_node_externals: true,
module: true,
custom_conditions: vec!["development".to_string()],
custom_conditions: vec!["development".to_string(), "node".to_string()],
plugins: vec![unsupported_modules_resolve_plugin.into()],
..Default::default()
};
Expand Down

0 comments on commit f799f02

Please sign in to comment.