Skip to content

pantoken / renderers/web-components/src / buildRegisterContext

Function: buildRegisterContext()

buildRegisterContext(options, target, resolveIconSvg): RegisterContext

Alpha

Build the shared RegisterContext a register()-style call threads to every element's define. The icon resolver is injectable: register() always passes the real, @pantoken/icons-backed iconSvg (unchanged default behavior for every existing caller), while the per-element CDN build passes noopIconSvg for elements that never call it — @pantoken/icons/@pantoken/tokens is a multi-MB dependency, and since Rollup can't code-split iife/umd output, anything statically reachable from a bundle's entry ends up in the whole bundle, regardless of whether that specific element's code path ever invokes it. This module has no top-level side effects for exactly that reason — importing it (unlike importing ../index.ts, which auto-registers everything on import) never reaches iconSvg unless the caller passes it in.

Parameters

options

RegisterContextOptions

Same shape as register()'s options, minus only.

target

ElementRegistry

The registry to define into.

resolveIconSvg

(name) => string

The resolver wired into ctx.iconSvg — pass iconSvg for real icons or noopIconSvg when the caller's element set provably never renders one (see ICON_ELEMENTS in ./elements-meta.ts).

Returns

RegisterContext