mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-10 13:18:25 +00:00
* feat(svelte): export __iconData and __iconNode across per-icon modules (#4936) * Refactor imports in lucide-svelte.spec.ts Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * fix(build-icons): scope per-icon data re-exports behind exportIconData flag - Problem: generateAliasesFiles unconditionally re-exported __iconData and __iconNode for all packages using separateAliasesFile. Packages like @lucide/solid and @lucide/icons do not export these names from their templates, causing missing export errors in downstream bundlers (e.g. solid vite integration). - Solution: Add exportIconData flag (default false) to CLI, generateIconFiles, and generateAliasesFiles so named re-exports are opt-in and only emitted for packages that define them (@lucide/svelte). * refactor(svelte): remove tools/build-icons changes per maintainer review --------- Co-authored-by: Eric Fennis <eric.fennis@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
co-authored by
Eric Fennis
Copilot Autofix powered by AI
parent
0ab9c70d88
commit
02eb9161b5
@@ -9,14 +9,23 @@ export default defineExportTemplate(
|
||||
|
||||
return `\
|
||||
${getHTMLBanner()}
|
||||
<script module lang="ts">
|
||||
import type { LucideIconData, LucideIconNode } from '../types.js';
|
||||
|
||||
export const __iconData: LucideIconData = ${JSON.stringify(iconData)};
|
||||
|
||||
/**
|
||||
* @deprecated Access \`__iconData\` instead.
|
||||
*/
|
||||
export const __iconNode: LucideIconNode[] = __iconData.node;
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import Icon from '../Icon.svelte';
|
||||
import type { LucideProps, LucideIconData } from '../types.js';
|
||||
import type { LucideProps } from '../types.js';
|
||||
|
||||
let props: LucideProps = $props();
|
||||
|
||||
const iconData: LucideIconData = ${JSON.stringify(iconData)};
|
||||
|
||||
</script>
|
||||
|
||||
<!--
|
||||
@@ -29,7 +38,7 @@ Lucide SVG icon component, renders SVG Element with children.
|
||||
${deprecated ? `\n@deprecated ${deprecationReason}\n` : ''}\
|
||||
-->
|
||||
|
||||
<Icon {...props} icon={iconData} />
|
||||
<Icon {...props} icon={__iconData} />
|
||||
`;
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { describe, it, expect, afterEach } from 'vitest';
|
||||
import { render, cleanup } from '@testing-library/svelte';
|
||||
import { Smile, Pen, Edit2 } from '../src/lucide-svelte.js';
|
||||
import { __iconData, __iconNode } from '../src/icons/face-slightly-smiling.svelte';
|
||||
import TestSlots from './TestSlots.svelte';
|
||||
import ContextWrapper from './ContextWrapper.svelte';
|
||||
|
||||
@@ -132,3 +133,14 @@ describe('Icon Component Accessibility', () => {
|
||||
expect(container.firstChild).not.toHaveAttribute('aria-hidden');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Per-icon data export', () => {
|
||||
it('should export __iconData and __iconNode from the svelte component module', () => {
|
||||
expect(__iconData).toBeDefined();
|
||||
expect(__iconData.name).toBe('face-slightly-smiling');
|
||||
expect(__iconData.size).toBe(24);
|
||||
expect(Array.isArray(__iconData.node)).toBe(true);
|
||||
expect(__iconData.node.length).toBeGreaterThan(0);
|
||||
expect(__iconNode).toEqual(__iconData.node);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user