Unverified Commit 26cdaa83 authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

create forked impl for Link component (#73019)

There's significant drift between how Link is implemented in pages vs app dir, and we're planning to make even more changes. (For example, we want to change the intersection observer prefetch behavior, but only in app router)

To simplify this drift in behavior, this will alias `next/link` to `client/app-dir/link.tsx` in app dir bundles. 

There is no change in behavior to the `link` component in this PR. The next PR in the stack will remove the current forked handling to remove things that are irrelevant to the router it's rendered in.
parent c8f96d50
......@@ -202,6 +202,10 @@ pub async fn get_next_client_import_map(
"next/dynamic",
request_to_import_mapping(project_path, "next/dist/shared/lib/app-dynamic"),
);
import_map.insert_exact_alias(
"next/link",
request_to_import_mapping(project_path, "next/dist/client/app-dir/link"),
);
}
ClientContextType::Fallback => {}
ClientContextType::Other => {}
......@@ -365,6 +369,10 @@ pub async fn get_next_server_import_map(
"next/dynamic",
request_to_import_mapping(project_path, "next/dist/shared/lib/app-dynamic"),
);
import_map.insert_exact_alias(
"next/link",
request_to_import_mapping(project_path, "next/dist/client/app-dir/link"),
)
}
ServerContextType::Middleware { .. } | ServerContextType::Instrumentation { .. } => {}
}
......@@ -469,6 +477,10 @@ pub async fn get_next_edge_import_map(
"next/dynamic",
request_to_import_mapping(project_path, "next/dist/shared/lib/app-dynamic"),
);
import_map.insert_exact_alias(
"next/link",
request_to_import_mapping(project_path, "next/dist/client/app-dir/link"),
)
}
}
......
......@@ -237,6 +237,7 @@ export function createAppRouterApiAliases(isServerOnlyLayer: boolean) {
const mapping: Record<string, string> = {
head: 'next/dist/client/components/noop-head',
dynamic: 'next/dist/api/app-dynamic',
link: 'next/dist/client/app-dir/link',
}
if (isServerOnlyLayer) {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment