unplugin / unplugin-icons

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

Support for Yarn PnP #358

Closed bmulholland closed 3 months ago

bmulholland commented 6 months ago

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

antfu commented 6 months ago

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?

bmulholland commented 6 months ago

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?

bmulholland commented 6 months ago

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

antfu commented 6 months ago

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

bmulholland commented 6 months ago

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...

bmulholland commented 3 months ago

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.