Entries
| Import | Gives you |
|---|---|
@munsonlabs/sigil | register, override, unregister, use, getIcon, getIconSync, subscribe, clear, sigil |
@munsonlabs/sigil/element | <ml-sigil-icon> - defined on import. ?defer to define it yourself |
@munsonlabs/sigil/vue | Sigil |
register loads the code for a library kind the first time you use it. Every file is around a kilobyte gzipped.
No import map. Everything is reached by relative path. With a bundler, unused kinds become lazy chunks. Self-hosting, serve dist/chunks/ next to the entries.
One registry per page. Two bundles carrying their own copy of the package share one instance through globalThis, so a third-party component's icons can be registered from your app. sigil.version says which copy created it.
One registry per process on the server. The same sharing makes the instance process-wide under SSR, across every request. Register libraries once in a server plugin; keep anything per request on a createSigil() of its own.
Failures are loud in development. An icon that can't be resolved - a 404, a non-SVG response, a resolver that throws - renders nothing and logs a console.warn in dev builds only.
Deferring the element
import { defineElements } from '@munsonlabs/sigil/element?defer'
register('fa', {
className: 'fa',
})
defineElements()
Mounted icons re-render on registration anyway, so this only avoids a first paint with empty icons.