Skip to content

Commit

Permalink
fix styled-jsx alias (#55581)
Browse files Browse the repository at this point in the history
### What?

makes sure that styled-jsx is always bundled as it contains `react` and
it being external would break the react vendoring
  • Loading branch information
sokra authored Sep 19, 2023
1 parent 1a9b0f6 commit deb81cf
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/next-swc/crates/next-core/src/next_import_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,6 @@ async fn insert_next_server_special_aliases(
NextRuntime::Edge => request_to_import_mapping(context_dir, request),
NextRuntime::NodeJs => external_request_to_import_mapping(request),
};
let passthrough_external_if_node =
move |context_dir: Vc<FileSystemPath>, request: &str| match runtime {
NextRuntime::Edge => request_to_import_mapping(context_dir, request),
NextRuntime::NodeJs => ImportMapping::External(None).cell(),
};
match (mode, ty) {
(_, ServerContextType::Pages { pages_dir }) => {
import_map.insert_exact_alias(
Expand Down Expand Up @@ -441,11 +436,11 @@ async fn insert_next_server_special_aliases(
);
import_map.insert_exact_alias(
"styled-jsx",
passthrough_external_if_node(app_dir, "next/dist/compiled/styled-jsx"),
request_to_import_mapping(get_next_package(app_dir), "styled-jsx"),
);
import_map.insert_wildcard_alias(
"styled-jsx/",
passthrough_external_if_node(app_dir, "next/dist/compiled/styled-jsx/*"),
request_to_import_mapping(get_next_package(app_dir), "styled-jsx/*"),
);
import_map.insert_exact_alias(
"react/jsx-runtime",
Expand Down Expand Up @@ -561,6 +556,14 @@ async fn insert_next_server_special_aliases(
// @opentelemetry/api
request_to_import_mapping(app_dir, "next/dist/compiled/@opentelemetry/api"),
);
import_map.insert_exact_alias(
"styled-jsx",
request_to_import_mapping(get_next_package(app_dir), "styled-jsx"),
);
import_map.insert_wildcard_alias(
"styled-jsx/",
request_to_import_mapping(get_next_package(app_dir), "styled-jsx/*"),
);

import_map.insert_exact_alias(
"react/jsx-runtime",
Expand Down

0 comments on commit deb81cf

Please sign in to comment.