Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

components.d.ts path error if the name startswith prefix defined in collections #326

Open
5 tasks done
genffy opened this issue Nov 15, 2023 · 6 comments
Open
5 tasks done

Comments

@genffy
Copy link
Contributor

genffy commented Nov 15, 2023

Describe the bug

When use ViteComponents and IconsResolver, and if the component name include the string that is defined in colloections(default is icon-sets.json), and the components.d.ts file will get error path.

eg:
LayoutHeader => LayoutHeader: typeof import('~icons/la/yout-header')['default']
Circle: typeof import('~icons/ci/rcle')['default']
Because the la and ci are all both included by icon-sets prefix

The mini reproduction is a nuxt3 example.

Reproduction

https://stackblitz.com/edit/nuxt-starter-mrqmcy?file=components.d.ts

System Info

System:
    OS: macOS 14.0
    CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
    Memory: 21.04 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.17.0 - ~/.nvm/versions/node/v18.17.0/bin/node
    Yarn: 3.6.1 - ~/.nvm/versions/node/v18.17.0/bin/yarn
    npm: 9.6.7 - ~/.nvm/versions/node/v18.17.0/bin/npm
    pnpm: 8.6.7 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 118.0.5993.117
    Safari: 17.0

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
Copy link

stackblitz bot commented Nov 15, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@genffy genffy changed the title render icons path error with path includes prefix in collections components.d.ts path error if the name startswith prefix defined in collections Nov 15, 2023
@userquin
Copy link
Member

add prefix

@genffy
Copy link
Contributor Author

genffy commented Nov 15, 2023

add prefix

The option of componentPrefix was well worked for demo, but not suitable for real app.

@userquin
Copy link
Member

userquin commented Nov 15, 2023

componentPrefix is there to solve these type of problems, any ui library should add a prefix to avoid collisions, if you're removing that prefix when using this library, how do you expect us to be able to detect a collision here?

For example, if you add Vuetify and you use VXXX in your component names, it is not a Vuetify bug when using Vuetify resolver, change your component names (in this example the components have a fixed name, here, we expose componentPrefix to allow dynamic names/prefix from configuration).

Take a look at any ui resolver in unplugin-vue-components

@genffy
Copy link
Contributor Author

genffy commented Nov 15, 2023

@userquin the prefix cannot solve the this issue(nuxt3) scenario, especially the app with a large number of components, it can't exclude multiple icon-sets.

Actually the options of enabledCollections can worked, and set some of what you used icon prefix, but its should not be too simple like la, fa...

The another solution is add strict option, when set true to force strict matching with - suffix for all collections. The main change is on this https://github.com/unplugin/unplugin-icons/pull/327/files#diff-0d2f46f3b329944abf82b98bdebe5220e48742c8868011ed9b35b592f72b0fedR112

@userquin
Copy link
Member

userquin commented Nov 15, 2023

What do you mean? you only need to remember to not including components starting with I in your components folder.

If that's a problem, you can use UnoCSS Icons Preset, you don't need any vue component, just use css classes (you also have UnoCSS integration for Nuxt ).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants