Skip to content

Commit

Permalink
refactor(next-core): reduce duplicated decl
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Apr 25, 2023
1 parent e1d0367 commit f880918
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 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 @@ -65,6 +65,7 @@ pub async fn get_server_resolve_options_context(
get_next_server_import_map(project_path, ty, next_config, execution_context);
let foreign_code_context_condition = foreign_code_context_condition(next_config).await?;
let root_dir = project_path.root().resolve().await?;
let unsupported_modules_resolve_plugin = UnsupportedModulesResolvePluginVc::new(project_path);

Ok(match ty.into_value() {
ServerContextType::Pages { .. } | ServerContextType::PagesData { .. } => {
Expand All @@ -82,7 +83,7 @@ pub async fn get_server_resolve_options_context(
import_map: Some(next_server_import_map),
plugins: vec![
external_cjs_modules_plugin.into(),
UnsupportedModulesResolvePluginVc::new(project_path).into(),
unsupported_modules_resolve_plugin.into(),
],
..Default::default()
};
Expand All @@ -104,7 +105,7 @@ pub async fn get_server_resolve_options_context(
module: true,
custom_conditions: vec!["development".to_string()],
import_map: Some(next_server_import_map),
plugins: vec![UnsupportedModulesResolvePluginVc::new(project_path).into()],
plugins: vec![unsupported_modules_resolve_plugin.into()],
..Default::default()
};
ResolveOptionsContext {
Expand All @@ -125,7 +126,7 @@ pub async fn get_server_resolve_options_context(
module: true,
custom_conditions: vec!["development".to_string(), "react-server".to_string()],
import_map: Some(next_server_import_map),
plugins: vec![UnsupportedModulesResolvePluginVc::new(project_path).into()],
plugins: vec![unsupported_modules_resolve_plugin.into()],
..Default::default()
};
ResolveOptionsContext {
Expand All @@ -144,7 +145,7 @@ pub async fn get_server_resolve_options_context(
module: true,
custom_conditions: vec!["development".to_string()],
import_map: Some(next_server_import_map),
plugins: vec![UnsupportedModulesResolvePluginVc::new(project_path).into()],
plugins: vec![unsupported_modules_resolve_plugin.into()],
..Default::default()
};
ResolveOptionsContext {
Expand All @@ -163,7 +164,7 @@ pub async fn get_server_resolve_options_context(
enable_node_externals: true,
module: true,
custom_conditions: vec!["development".to_string()],
plugins: vec![UnsupportedModulesResolvePluginVc::new(project_path).into()],
plugins: vec![unsupported_modules_resolve_plugin.into()],
..Default::default()
};
ResolveOptionsContext {
Expand Down

0 comments on commit f880918

Please sign in to comment.