unplugin / unplugin-icons

🤹 Access thousands of icons as components on-demand universally.
https://www.npmjs.com/package/unplugin-icons
MIT License
4k stars 143 forks source link

🐞 Custom collection not work in `h()` by `collection:icon-name` #245

Closed chioio closed 1 year ago

chioio commented 1 year ago

Describe the bug

Custom collection: app File path: /assets/icons/trash.svg

Render function

export const renderIcon = (
  icon: string,
  props: Record<string, unknown> = { size: 20 }
) => h(Icon, { icon, width: props.size, height: props.size, ...props })

Error produce

const a = {
  icon: () => renderIcon('app:trash')
}

! But success using in template like <i-app:trash />

Reproduction

None

System Info

System:
    OS: macOS 12.6
    CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
    Memory: 1.37 GB / 8.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 14.19.2 - ~/Library/Caches/fnm_multishells/25267_1653168489651/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 6.14.17 - ~/Library/Caches/fnm_multishells/25267_1653168489651/bin/npm

Used Package Manager

pnpm

Validations

antfu commented 1 year ago

If you mean to use with unplugin-vue-components, it works by static replacement. Which your runtime approach would not work.