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

fix: copy .eot, .otf, .ttf, .woff, and woff2 font files when bundling #12439

Merged
merged 7 commits into from
Jul 6, 2024

Conversation

eltigerchino
Copy link
Member

@eltigerchino eltigerchino commented Jul 5, 2024

closes #11219
fixes #11220

Copies .ttf and .woff font files when bundling edge functions since those are the most common font files included with packages. Alternatively, we could use the same list of assets as Vite.


Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Edits

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@eltigerchino eltigerchino changed the title fix: copy font files when bundling with esbuild fix: copy .ttf and .woff files when bundling with esbuild Jul 5, 2024
@benmccann
Copy link
Member

do we also need to update here?

'.wasm': 'copy'

Copy link

changeset-bot bot commented Jul 5, 2024

🦋 Changeset detected

Latest commit: 53ab3fa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@sveltejs/adapter-cloudflare-workers Patch
@sveltejs/adapter-cloudflare Patch
@sveltejs/adapter-netlify Patch
@sveltejs/adapter-vercel Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@eltigerchino
Copy link
Member Author

eltigerchino commented Jul 5, 2024

do we also need to update here?

'.wasm': 'copy'

Yes, that's being updated. It's one of the steps required to get @vercel/og working since that includes a .woff fallback font in its package.

@eltigerchino eltigerchino changed the title fix: copy .ttf and .woff files when bundling with esbuild fix: copy .ttf, .woff, and .woff2 files when bundling with esbuild Jul 5, 2024
@@ -97,7 +97,10 @@ export default function ({ config = 'wrangler.toml', platformProxy = {} } = {})
alias: Object.fromEntries(compatible_node_modules.map((id) => [id, `node:${id}`])),
format: 'esm',
loader: {
'.wasm': 'copy'
'.wasm': 'copy',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like eot and otf are the other two coming up in my searches

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I've added .eot and .otf too. Just curious, what kind of search are you conducting?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd done a good search for "esbuild loader font" or something like that

@vercel vercel bot temporarily deployed to Preview – kit-svelte-dev July 5, 2024 18:02 Inactive
@vercel vercel bot temporarily deployed to Preview – kit-default-template July 5, 2024 18:03 Inactive
@benmccann benmccann changed the title fix: copy .ttf, .woff, and .woff2 files when bundling with esbuild fix: copy .eot, .otf, .ttf, .woff, and woff2 font files when bundling Jul 6, 2024
@benmccann benmccann merged commit c75e878 into main Jul 6, 2024
12 of 13 checks passed
@benmccann benmccann deleted the fix-adapter-bundle-assets branch July 6, 2024 15:07
@github-actions github-actions bot mentioned this pull request Jul 6, 2024
@eltigerchino
Copy link
Member Author

eltigerchino commented Jul 14, 2024

So apparently this won't do anything until evanw/esbuild#795 is resolved.
Currently, there's no way to have esbuild detect when we're using fonts:

  • Importing fonts without Vite's help causes a reference error (you can't import fonts as modules in JS).
  • Importing fonts with Vite's help will transform it into a constant URL string before esbuild's bundling. In the end, esbuild will never copy it since it only looks for imports.

@benmccann
Copy link
Member

Should we revert this or just leave it?

@eltigerchino
Copy link
Member Author

I might have to look at how the manoco editor is referencing their font because it seems esbuild picks it up, which caused the "no loader" error in #11220 we should check to see if the reproducible works after upgrading the adapter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No loader is configured for ".ttf" files.
2 participants