seek-oss / capsize

Flipping how we define typography in CSS.
https://seek-oss.github.io/capsize/
MIT License
1.48k stars 37 forks source link

@capsizecss/unpack fontkit module import error #169

Closed josephniet closed 3 months ago

josephniet commented 4 months ago

I'm getting an error when trying to import unpack. Tested using a fresh vite deployment

main.ts `import './style.css' import { fromFile } from '@capsizecss/unpack'; import font from './font.woff2';

const metrics = await fromFile(font); console.log('font metrics', metrics)`

package.json { "name": "capsize", "private": true, "version": "0.0.0", "type": "module", "scripts": { "dev": "vite", "build": "tsc && vite build", "preview": "vite preview" }, "devDependencies": { "typescript": "^5.2.2", "vite": "^5.1.0" }, "dependencies": { "@capsizecss/unpack": "^1.0.0" } }

Error ` VITE v5.1.1 ready in 194 ms

➜ Local: http://localhost:5173/ ➜ Network: use --host to expose ➜ press h + enter to show help X [ERROR] No matching export in "node_modules/fontkit/dist/browser-module.mjs" for import "default"

node_modules/@capsizecss/unpack/dist/capsizecss-unpack.browser.esm.js:3:7:
  3 │ import fontkit from 'fontkit';`

PS - Awesome project! I ended up using the GH site to upload fonts & then lift the metrics from there & they worked absolutely perfectly.

michaeltaranto commented 4 months ago

Hey mate, we have just merged a bit of an overhaul to how we build and manage package entry points (https://github.com/seek-oss/capsize/pull/168)

We have one more thing to merge before cutting the release, but keen to have your feedback on the following snapshot if you have time:

@capsizecss/unpack@0.0.0-master-20240214212615
josephniet commented 4 months ago

image pretty busy atm but I updated the package & re-run quickly & this is what I get. When I run via await fromUrl instead I get a different error: Uncaught ReferenceError: Buffer is not defined onLoadEnd index.js:17 blobToBuffer2 index.js:20 fromBlob index.mjs:75 fromBlob index.mjs:74 fromUrl index.mjs:93 async* main.ts:7 There's always a chance it's just something screwed up on my end...I do spend most of my life bashing away with things I don't understand :)

michaeltaranto commented 4 months ago

If you have a repro you can share that'll help. In the mean time we have cut the release now, so any further testing can be against latest published versions.

michaeltaranto commented 3 months ago

Closing due to inactivity. Feel free to re-open if you find an issue in the latest version