Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preloading broken due to unreferenced fonts in Vite manifest #14244

Closed
7 tasks done
benmccann opened this issue Aug 30, 2023 · 3 comments · Fixed by #14297
Closed
7 tasks done

Preloading broken due to unreferenced fonts in Vite manifest #14244

benmccann opened this issue Aug 30, 2023 · 3 comments · Fixed by #14297
Labels
p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)

Comments

@benmccann
Copy link
Collaborator

benmccann commented Aug 30, 2023

Describe the bug

You can visit https://kit.svelte.dev/, which is supposed to render something like:

<link rel="preload" as="font" type="font/woff2" href="./_app/immutable/assets/overpass-latin-300.3782c01a.woff2" crossorigin>
<link rel="preload" as="font" type="font/woff2" href="./_app/immutable/assets/overpass-latin-600.0ca25556.woff2" crossorigin>
<link rel="preload" as="font" type="font/woff2" href="./_app/immutable/assets/fira-mono-latin-400.8d4e0c52.woff2" crossorigin>

You can see in the network tab that these are referenced from a CSS file in our project:
Screenshot from 2023-08-30 14-38-27

And you can open up that file to see the references:
Screenshot from 2023-08-30 14-38-12

But these files are orphaned in the Vite manifest and so SvelteKit doesn't know which pages it needs to preload them for.

Here's the import chain:

#11943 looks a bit similar, but was talking about workers, so I wasn't exactly sure if it was the same

Reproduction

https://github.com/sveltejs/kit/tree/master/sites/kit.svelte.dev

Steps to reproduce

git clone [email protected]:sveltejs/kit.git

Edit packages/kit/src/exports/vite/index.js to comment out these two lines:

					fs.unlinkSync(`${out}/client/${vite_config.build.manifest}`);
					fs.unlinkSync(`${out}/server/${vite_config.build.manifest}`);

Now run:

cd sites/kit.svelte.dev
pnpm install
pnpm build

Open .svelte-kit/output/client/vite-manifest.json. See that the .woff2 files have no references to them.

System Info

npmPackages:
    vite: ^4.4.9 => 4.4.9

Used Package Manager

pnpm

Logs

No response

Validations

@benmccann benmccann added bug p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) labels Aug 30, 2023
@sun0day
Copy link
Member

sun0day commented Sep 4, 2023

can't reproduce it , it works in my macos

image

@benmccann
Copy link
Collaborator Author

Thanks so much for taking a look @sun0day! That's what I see as well. Unfortunately it's not the expected behavior. The font files are in the manifest, but the manifest is not saying which files use those fonts. We need to know which pages use the fonts so that we know which pages need to preload them, but that information for some reason is missing.

I would expect the output to look something more like this:

  "_ThemeToggle.svelte_svelte_type_style_lang.0406e17e.js": {
    "assets": [
      "_app/immutable/assets/overpass-latin-300.3782c01a.woff2",
      "_app/immutable/assets/overpass-latin-600.0ca25556.woff2",
      "_app/immutable/assets/fira-mono-latin-400.8d4e0c52.woff2",
      "_app/immutable/assets/link.1a918426.svg"
    ],
    "css": [
      "_app/immutable/assets/ThemeToggle.ebee0a7d.css",
      "_app/immutable/assets/Icon.c25fd2f4.css"
    ],
    "file": "_app/immutable/chunks/ThemeToggle.svelte_svelte_type_style_lang.0406e17e.js",
    "imports": [
      "_scheduler.da650eeb.js",
      "_index.2e4dbd2f.js"
    ]
  },

@sun0day
Copy link
Member

sun0day commented Sep 5, 2023

Ah I see

@github-actions github-actions bot locked and limited conversation to collaborators Sep 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants