Skip to content

Commit

Permalink
make sure server component externals only apply to files resolvable b…
Browse files Browse the repository at this point in the history
…y node
  • Loading branch information
ForsakenHarmony committed May 3, 2023
1 parent c546847 commit d315f5f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/next-swc/crates/next-core/src/next_import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,14 @@ pub async fn get_next_server_import_map(

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);

// only mark as external if it's an extension supported by node.js
import_map.insert_wildcard_alias_with_suffix(format!("{name}/"), ".cjs", external);
import_map.insert_wildcard_alias_with_suffix(format!("{name}/"), ".js", external);
import_map.insert_wildcard_alias_with_suffix(format!("{name}/"), ".node", external);
import_map.insert_wildcard_alias_with_suffix(format!("{name}/"), ".json", external);
}

// The sandbox can't be bundled and needs to be external
import_map.insert_exact_alias("next/dist/server/web/sandbox", external);
}
Expand Down

0 comments on commit d315f5f

Please sign in to comment.