#4936·lucide

@lucide/svelte: export per-icon __iconData (follow-up to #4644 / #4761)

Author: ruizdiazeverCreated Sep 30, 2026Updated Sep 30, 2026

Problem

Follow-up to #4644, closed by #4761. That PR gave lucide-preact, lucide-solid and lucide-react-native the same per-icon data export that lucide-react and lucide-vue-next already had:

javascript
export { __iconData, PanelLeft as default };

@lucide/svelte was not included and is still the only framework package with no way to read an icon's geometry. Libraries that interpolate between icons (morphing, path animation, custom renderers) need the IconNode upfront, so a compiled component is useless to them, and they still have to install core lucide alongside @lucide/svelte — the exact duplication #4644 describes.

Verified on @lucide/[email protected]

dist/icons/panel-left.js only re-exports the component:

javascript
export { default } from "./panel-left.svelte";

The geometry exists but stays private inside the generated component:

svelte
<script lang="ts">
  import Icon from '../Icon.svelte';
  let props = $props();
  const iconData = { "name": "panel-left", "size": 24, "node": [...], "aliases": ["sidebar"] };
</script>
  • grep -r "__iconData\|__iconNode" @lucide/svelte/dist → no matches
  • the shipped dist/icons/panel-left.svelte.d.ts exports only default
  • LucideIconData is exported as a type from the package root, but no value of that type is reachable

Compare with the same version of the other packages:

[email protected]  dist/esm/icons/panel-left.mjs  ->  export { __iconData, PanelLeft as default };
[email protected] dist/esm/icons/panel-left.mjs  ->  export { __iconData, PanelLeft as default };

So the natural consumer import simply has nothing to import:

typescript
import PanelLeft, { __iconData } from '@lucide/svelte/icons/panel-left'; // no exported member '__iconData'

Root cause

Two places, both narrow:

  1. packages/svelte/scripts/exportTemplate.mts never emits a data export — it only renders const iconData: LucideIconData = {...} privately, in the instance script.
  2. tools/build-icons/building/generateIconFiles.ts hardcodes the separate icon shim for every icon:
typescript
const output = `export { default } from "./${iconName}${iconFileExtension}";\n`;

So even adding export const __iconData to the .svelte file would not reach dist/icons/*.js. @lucide/svelte is currently the only package using separateIconFileExport, so this needs care rather than a blanket change.

Proposal

Match the other packages: export the icon data per icon.

typescript
import PanelLeft, { __iconData } from '@lucide/svelte/icons/panel-left';
// __iconData: LucideIconData -> { name, size, node, aliases }

Sketch for the template (module script, so it is a real module export and stays tree-shakeable):

svelte
<script module lang="ts">
  import type { LucideIconData } from '../types.js';

  export const __iconData: LucideIconData = {...};
</script>

Plus either make the shim re-export it, e.g. export { default, __iconData } from "./panel-left.svelte";, or add a dedicated data subpath — happy to defer to whatever fits the build best.

TODO

  • Export __iconData (and, if we want parity with lucide-react, a deprecated __iconNode = __iconData.node) from the per-icon module in packages/svelte/scripts/exportTemplate.mts.
  • Make the separate icon file shim in tools/build-icons re-export those named exports instead of only default, without changing output for packages that only need the default.
  • Keep @lucide/svelte/icons/* tree-shakeable and add no data to the barrel, since the current barrel ships no geometry.
  • Add a test in packages/svelte/tests asserting __iconData is present and matches the icon's nodes, and that the component still renders after the template change.
  • Document the per-icon data import in the Svelte package guide.

Happy to open the PR if someone points me at the preferred shape (template export vs separate data subpath).