Parametric packaging? (e.g., replicating `@iconify-json/<icon-set>` from Iconify's NPM packages)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 1.3k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 189
Description
Description
Not quite an issue, more-so a feature request. I'm in the middle of porting https://github.com/iconify/icon-sets to Typst so we can have our pick of SVG icons (without needing them as fonts 🎉)!
Iconify has a really slick layout (mostly for tree-shaking, if I understand correctly) where users can install an icon-set's JSON to support it (rather than having to install all 150+ icon sets, which turns in to something like 200K+ icons).
I'm not sure that Typst has/needs tree-shaking the way that web-oriented projects do, but the full package I've built (https://github.com/jmuchovej/typst-iconify) is north of 1GB because it has almost all the icons included.
There's two packaging strategies I can think of for the typst-iconify project:
typst-iconifyjust packages up the entire Iconify library (200K+ icons, relevant JSON/SVGs is ~950MB as of 15 Oct 2024).typst-iconifyhas some kind setup like...@preview/iconify(core library) and users can add@preview/iconify-{iconset}where{iconset}might beacademicons,carbon,catppuccin,fa(font awesome), etc.
(1) is by far the most straightforward, but it introduces some critical problems:
- Installation requires downloading ~950MB (or more, in the future) worth of SVGS, most of which will go unused.
- Once
typst-iconifyis stable, I suspect that the icon sets will update far more frequently than the core package code – having some way to separate these concerns would be ideal – however I'm not sure how. (It appears that@iconify-json/{iconset}essentially installs the correspondingJSONfile in a shared directory that other@iconify/...tools know how to access. (If Typst supports similarly, I'd be more than happy to explore that, I just don't know where/if that's possible.)
In the current packaging approach, where everything is namedspaced under @preview/... I don't think this avoids the patch-version explosion (though it could still cause significant version explosion because the icon sets appear to be upgraded pretty regularly).
So, this leads me to my questions:
- Is there a way to support something like the following – where line 2 essentially adds the
academiconsJSON files that@preview/iconifyknows how to parse to some shared location?1 | #import "@preview/iconify:0.1.0": icon 2 | #import "@preview/iconify-academicons:1.2.8" 3 | 4 | #icon("academicon:arxiv") - If ☝️ is possible, how would I achieve this? Particularly, this introduces a second set of problems:
- Can Typst, functionally, write temporary files (or similar)? (i.e., If
@preview/iconifydynamically loads SVG data, the packaged code in@preview/iconify-academiconswill be an SVG string, butimagerequires a file-path. - Is it possible to essentially write to a cache in this manner, or would it be "more typst-ian" to recompute all this data upon initial compilation? (i.e., if someone closes a doc, then reopens it later.)
- Can Typst, functionally, write temporary files (or similar)? (i.e., If
- How concerned are Typst with "patch bloat" from packages? (e.g., the split-package route I've described/favored would introduce over 150 packages, each with their own versioning/etc. I'd have them configured to auto-update, but I don't want these to end up back-logging other package updates, since they're definitely low priority. 😅)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the package repository's documentation and package-loading behavior for the proposed @preview/iconify and per-icon-set packages. Investigate whether packages can share data, write temporary files, or use a cache, and how package versions are managed. Done would require a decided packaging approach and documented support or limitations for the requested workflow.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100