nuxt / nuxt/icon

Custom collections aren't recognised

Open
#252 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.2k
Forks
96
Avg merge
8h 12m
Merged PRs (30d)
2

Description

Hi, hope you're all doing well!

I ran into an issue using @nuxt/ui which now uses @nuxt/icon under the hood (used to work when icon collection names could be specified as nuxt/ui module args even tho i had to add a ts-ignore as it wasn't referenced in the enum type), I am using a custom iconify collection i built which goes by

"@iconify-json/as": "npm:@my-org-name/my-icon-collection@^0.0.2",

in my package.json which isn't referenced in
https://github.com/nuxt/icon/blob/main/src/collection-names.ts
thus making it uncompatible with @nuxt/icon.
I think the issue comes from the usage of collectionNames there (as it seems we only values are only read if they are part of the underlying array):
https://github.com/nuxt/icon/blob/cc14fe49b19fce023ba6f049984317492043c9ab/src/collections.ts#L72-L73
Would it be possible further expand the compatibility to include custom collections? (and eventually check if these are installed print an error on the logger if it isn't the case)

NOTE: It seems to work when using this configuration (note SSR isn't set to false which is a constraint I have)

icon: {
  serverBundle: {
    collections: [
      'as'
    ]
  }
}

but it the specific project is using this piece of config

[...]
ssr: false, // SSR forced to false
icon: {
  provider: 'server', // Tried with and without this
  serverBundle: {
    collections: [
      'as'
    ]
  }
}

Sorry if it is a bit long, I tried my best to keep it pleasant to read though. Thank you in advance! :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/collection-names.ts and the collectionNames usage in src/collections.ts at the linked lines, then compare the working serverBundle.collections configuration in nuxt.config.ts with the failing SSR-disabled setup. Done means a custom installed collection such as “as” is recognised in the reported configuration, with any missing-collection behavior clarified.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, typescript
Domain
frontend, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.