-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
What version of Bun is running?
1.3.10
What platform is your computer?
Linux 6.12.58+ x86_64
What steps can reproduce the bug?
- Create a project using
Bun.serve()with an HTML import:
// server.ts
import index from "./index.html";
Bun.serve({
development: true,
routes: { "/": index },
fetch(req) { /* ... */ },
});- In
index.html, reference a script that imports@fontsource-variable/roboto:
<script type="module" src="./app.tsx"></script>- In
app.tsx:
import "@fontsource-variable/roboto";- The fontsource package's
index.csscontains@font-facerules withunicode-rangevalues like:
@font-face {
font-family: "Roboto Variable";
src: url(./files/roboto-latin-wght-normal.woff2) format("woff2-variations");
unicode-range: U+0000-00FF,U+0131,U+0152-0153;
}- Load the page and inspect the CSS output served by Bun.
What is the expected behavior?
The unicode-range values should be preserved as-is:
unicode-range: U+0000-00FF,U+0131,U+0152-0153;What do you see instead?
Bun's CSS processor strips the + from U+ prefixes and sometimes inserts spaces, producing invalid unicode-range values:
unicode-range: U0000-00FF, U0131, U0152-0153;Some ranges also get mangled with spaces: U + A640-A69F instead of U+A640-A69F.
Because U0000-00FF is not valid CSS (the spec requires U+), browsers silently ignore the entire @font-face rule, causing fonts to not load at all.
Additional information
This affects any CSS with unicode-range processed by Bun's dev bundler (not just fontsource). The corruption occurs in Bun's built-in CSS minification/processing pipeline.
Workaround: Process font CSS via a custom [serve.static].plugins loader that reads the raw CSS and injects it via a <style> tag, bypassing Bun's CSS processing.