fix(ENG-4204): inline malachite fonts in the web component instead of loading files beside the script
From 2.134.1 (malachite#814) malachite ships each font as a woff2 file beside a wrapper that exports new URL("./<font>.woff2", import.meta.url). In webcomponent.js, Rollup rewrites import.meta.url to the script's own URL, and hub's IIFE build copies no font files. So once hub bumps malachite, every customer page that embeds the web component requests the fonts beside webcomponent.js and gets 404s. Chrome then falls back to malachite's inlined copies. Safari never does (fixed separately in malachite#822), so there the picker renders in the system font.
Ticket: ENG-4204.
This PR does not bump malachite. The lockfile stays on 2.79.0, where webcomponent.js builds byte-identical (1,284,708 bytes). It makes the web component safe for the bump.
Before and after
Hub's real <stackone-hub>, built against malachite 2.134.1 and served from /cdn/hub/webcomponent.js with a mocked hub API. Every response is delayed 250 ms. Each image shows the screenshot, a 3× zoom of the same rows, and the requests and console errors the browser recorded.
Safari (WebKit): before, 2 font 404s and Inter never loads. After, no font requests and Inter loads.

Chrome: before, 2 font 404s and 2 console errors on every load, then the fallback recovers. After, no font requests.

The change
scripts/inline-malachite-fonts.mjs: a Rollup plugin, used only by the web component build, that resolves each malachite*.woff2.jswrapper to its*.woff2.inline.jssibling (the same data URL malachite falls back to). The IIFE already carries those base64 copies, so nothing grows. A wrapper that loads a file with no inlined copy fails the build. A pre-2.134.1 wrapper, which is already a data URL, is left alone.scripts/verify-build.mjs(already in CI) fails ifwebcomponent.jsnames a font file in any form, or usesimport.meta.urlat all, which in the IIFE points at the script itself.scripts/inline-malachite-fonts.test.mjs: the lockfile never reaches the swap, so the plugin is tested by bundling a fake malachite package with Rollup.
| Build | webcomponent.js | verify:build |
|---|---|---|
| lockfile (malachite 2.79.0) | byte-identical | pass |
| malachite 2.134.1, this PR | 0 font URLs, 11 fonts inlined once | pass |
| malachite 2.134.1, plugin removed | 11 font URLs | fails, names both problems |
Local: npm test 52 passed, npm run lint and verify:build pass. With the swap removed, the plugin's main test fails.
Review
Four /code-review passes; the last found no correctness issue. Left as they are:
- A linked local malachite (
npm link) resolves outside@stackone/malachite/, so the plugin skips it.verify:buildstill fails on the result, and a published build never links. - Plugin order in
rollup.config.mjsis not covered by the plugin's own test. Moving it afterresolve()stops the swap, andverify:buildfails on the first malachite bump. - The plugin depends on malachite's dist layout (
*.woff2.inline.jsbeside each wrapper). If malachite renames those, the plugin fails the build rather than shipping 404s. A supported inline-fonts entry in malachite would be the deeper fix. - The CI step is still named "Test (format-vector conformance)" though
npm testnow also runs this plugin's tests.
Post-merge validation
- Path: library. release-please publishes
@stackone/hub. Customers pick upwebcomponent.json their next upgrade. - Scenario: after hub bumps malachite to 2.134.1 or later, load a page that serves
webcomponent.json its own and renders<stackone-hub>. - Signal it worked: no
*.woff2requests besidewebcomponent.js, and the picker renders in Inter in Safari and Chrome. - Regression signals:
verify:buildfailing on the bump PR; 404s on*.woff2next to the script; text in the system font.
🤖 Generated with Claude Code
Summary by cubic
Fixes the webcomponent.js build so fonts stay inlined once hub bumps @stackone/malachite past 2.134.1, when malachite starts shipping each font as a woff2 file beside the script. In the IIFE those file URLs resolve next to wherever the customer serves webcomponent.js, where no font exists, so every font face 404s; Chrome then falls back to malachite's inlined copies, but Safari renders the picker in the system font. Relates to ENG-4204.
- Adds a Rollup plugin that resolves each malachite font wrapper to its inlined
.woff2.inline.jscopy in the web component build only, failing the build when a wrapper has no inline copy. Wrappers that are already data URLs are left alone. verify:buildnow fails ifwebcomponent.jsnames any font file or usesimport.meta.url.- This PR bumps no dependencies; on the current lockfile (malachite 2.79.0) the bundle is byte-identical.