nuxt / icon

The <Icon> component, supporting Iconify, Emojis and custom components.
https://stackblitz.com/edit/nuxt-icon-playground?file=app.vue
MIT License
930 stars 51 forks source link

Invalid Icon filenames, as defined/validated by Iconify, are silently failing #257

Open Blackskyliner opened 1 week ago

Blackskyliner commented 1 week ago

While working on a new project with new developers we stumbled upon this silent failure. We had Icons exported from Figma in the format:

Which were then loaded as customCollection via NuxtConfig

icon: {
    customCollections: [
      {
        prefix: 'theme-icon',
        dir: './assets/icons'
      },
    ],
  },

The message upon restart was reassuring that all icons were loaded and should be accessible.

Nuxt Icon loaded local collection theme-icon with 43 icons.

But we could not access them, or better said, we could only access the ones which only were lowercase. So I digged down the whole integration with the following waypoints:

In words:


Suggested resolution: For better DX there should also be a name validation when loading the collection and it should warn about all icons not following the convention. I can craft the corresponding PR.


Did I miss something elsewhere or is my deduction of the error correct?

fahmifitu commented 1 week ago

I've concluded that this module is not production-ready due to numerous errors. The naming convention is poorly thought out, making it impractical for use. In particular, it forced me to manually rename every icon individually, which is highly inefficient and frustrating.

Blackskyliner commented 1 week ago

Okay, so lets fix that then. It won't get "production-ready" if no one addresses the problems and tries to fix them.

To address this specific problem and make it more robust, instead of just warning about it, we could theoretically, in this case, transparently transform invalid names to be valid for the underlying iconify library. Thus we won't have the same limitations and less manual labor to fix the naming convention. As file naming in usage and detection would be the same transformation of the name and thus, within our library, should be mostly error/side-effect free.