unplugin/unplugin-icons

Support for Yarn PnP

bmulholland opened this issue · 6 comments

Describe the bug

When using Yarn PnP (and possibly with pnpm without some forms of hoisting?), there's no node_modules directory. In this case, the icons from an iconify pack aren't imported. With the vite example from the examples dir, with default yarn settings, I get "Internal server error: Icon mdi/alarm-off not found"

This may be an issue with a dependency (iconify?). It may also be expected behaviour -- in which case, maybe there's a less "magic" way to configure the imported icons. If so, could just document that.

I'm happy to dig into this myself, if I can get some pointers of where to look. Right now I'm not even sure if this is the right project to report this too -- a lot of magic is going on!

Reproduction

Repro'd with example from examples dir. Just take files, add yarn berry with default settings, and try yarn dev

System Info

yarn 4.1.1, latest macOS

Used Package Manager

yarn

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.

I don't have interests in supporting PnP, nor taking the complexity. Maybe we could expose an array where you can tell explicitly what collections are available?

Yeah I was thinking of something like that. It feels like there's likely just a bit of explicit configuration that could side-step the whole problem. That would be both acceptable (to the end-user dev) and way easier to maintain (for you). I'd be happy to poke at doing something like this -- sounds like you already have an idea of what/where? Could you point me in the right direction of where that array would go?

Just to drop in my initial thought: use the customCollections code to provide an explicit mapping. I don't know if that could work?

Sure, feel free to send a PR and we could discuss with the implementation

I guess I buried my question. I don't know where to start with the PR :). Could you kindly point me to where the magic resolution of collections happens? Any place I could start? Context that could help me? Even a file name or a sentence or two of context?

Like I say, I don't even know if the right code is in this repository. I don't have time to wrap my head around the multiple repos involved, but can certainly start something if I know the right place to look...

I was right to be suspicious of whether the fix was in this repo: turns out this is the root cause.

Nothing for this package, so closing out.