Skip to content

Commit

Permalink
feat(turbopack): Align behavior for link rel="preconnect" with webp…
Browse files Browse the repository at this point in the history
…ack mode (#64011)

### What?

Emit `<link data-next-font="size-adjust" rel="preconnect" href="/"
crossorigin="anonymous"/>` in more cases.

### Why?

To align with the default mode

### How?
  • Loading branch information
kdy1 committed Apr 8, 2024
1 parent 9a6db57 commit 697ae8a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/next-swc/crates/next-api/src/font.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub(crate) async fn create_font_manifest(

let has_fonts = !font_paths.is_empty();
let using_size_adjust = font_paths.iter().any(|path| path.contains("-s"));

let font_paths = font_paths
.into_iter()
.filter(|path| path.contains(".p."))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ impl NextFontGoogleReplacer {
async fn import_map_result(&self, query: String) -> Result<Vc<ImportMapResult>> {
let request_hash = get_request_hash(&query).await?;
let qstr = qstring::QString::from(query.as_str());

let query_vc = Vc::cell(query);

let font_data = load_font_data(self.project_path);
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/server/dev/turbopack-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ export async function handleRouteType({
} else {
manifestLoader.deleteMiddlewareManifest(serverKey)
}
await manifestLoader.loadFontManifest('/_app', 'pages')
await manifestLoader.loadFontManifest(page, 'pages')
await manifestLoader.loadLoadableManifest(page, 'pages')

Expand Down
5 changes: 3 additions & 2 deletions test/turbopack-dev-tests-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6616,9 +6616,10 @@
"passed": [
"next/font/google no preloads with _app without preload",
"next/font/google without-preloaded-fonts without _app without fonts",
"next/font/google without-preloaded-fonts without _app without preload"
"next/font/google without-preloaded-fonts without _app without preload",
"next/font/google no preloads with _app without fonts"
],
"failed": ["next/font/google no preloads with _app without fonts"],
"failed": [],
"pending": [],
"flakey": [],
"runtimeError": false
Expand Down

0 comments on commit 697ae8a

Please sign in to comment.