Skip to content

Commit

Permalink
add missing aliases for next/dynamic and next/head (#48871)
Browse files Browse the repository at this point in the history
### What?

missing aliases for app dir functionality

### Why?

### How?
  • Loading branch information
sokra committed Apr 26, 2023
1 parent 1274713 commit 6e896d3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/next-swc/crates/next-core/src/next_import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,15 @@ pub async fn get_next_server_import_map(
ServerContextType::AppSSR { .. }
| ServerContextType::AppRSC { .. }
| ServerContextType::AppRoute { .. } => {
import_map.insert_exact_alias(
"next/head",
request_to_import_mapping(project_path, "next/dist/client/components/noop-head"),
);
import_map.insert_exact_alias(
"next/dynamic",
request_to_import_mapping(project_path, "next/dist/shared/lib/app-dynamic"),
);

for name in next_config.server_component_externals().await?.iter() {
import_map.insert_exact_alias(name, external);
import_map.insert_wildcard_alias(format!("{name}/"), external);
Expand Down Expand Up @@ -251,6 +260,23 @@ pub async fn get_next_edge_import_map(

insert_next_server_special_aliases(&mut import_map, ty).await?;

match ty {
ServerContextType::Pages { .. } | ServerContextType::PagesData { .. } => {}
ServerContextType::AppSSR { .. }
| ServerContextType::AppRSC { .. }
| ServerContextType::AppRoute { .. } => {
import_map.insert_exact_alias(
"next/head",
request_to_import_mapping(project_path, "next/dist/client/components/noop-head"),
);
import_map.insert_exact_alias(
"next/dynamic",
request_to_import_mapping(project_path, "next/dist/shared/lib/app-dynamic"),
);
}
ServerContextType::Middleware => {}
}

Ok(import_map.cell())
}

Expand Down

0 comments on commit 6e896d3

Please sign in to comment.