fix: add types/import/require conditions to ./icons/* exports so per-icon imports resolve - #299
Conversation
|
Hi @huuyafwww Thank you so much for this contribution and for the detailed analysis of the problem. It's great to hear you're using the package in production. Apologies for the delay in getting to this PR — we've been swamped with work lately and I hadn't been able to give it the attention it deserves. The change makes a lot of sense: mapping the conditions explicitly fixes both the typings issue and the Node ESM resolver, and the type-check cost improvement (from 3,414 files down to 12) is really valuable. I'll review it in detail this week. Thanks again for your patience and for the excellent work! 🙌 |
|
@wootsbot |
Thanks for maintaining this package — we use it in production and it has served us well.
Extensionless per-icon imports don't resolve today:
The
./icons/*export is a plain passthrough, so TypeScript reports TS2307 (notypescondition,SiGithub.d.tsis never found) and Node ESM throwsERR_MODULE_NOT_FOUND(./icons/SiGithubisn't a real file). Writing the extension manually works at runtime but has no typings, since there's no.d.mtsnext to the.mjs.That leaves the barrel as the only typed entry point, and it pulls 3,400+ declaration files into every consumer's type check even when only a few icons are used. Switching our app to per-icon imports dropped this package's cost in
tscfrom 3,414 files to 12.This PR maps the conditions explicitly:
The two passthrough lines keep existing explicit-extension imports like
.../icons/SiGithub.mjsworking — with only the conditional entry they would resolve toSiGithub.mjs.mjsand break. The barrel is untouched.Would you be open to this change? Happy to adjust if you'd prefer a different shape.