Skip to content

fix: add types/import/require conditions to ./icons/* exports so per-icon imports resolve - #299

Merged
wootsbot merged 2 commits into
icons-pack:mainfrom
huuyafwww:fix/icons-exports-conditions
Aug 16, 2026
Merged

wootsbot merged 2 commits into
icons-pack:mainfrom
huuyafwww:fix/icons-exports-conditions

Conversation

@huuyafwww

Copy link
Copy Markdown
Contributor

Thanks for maintaining this package — we use it in production and it has served us well.

Extensionless per-icon imports don't resolve today:

import SiGithub from '@icons-pack/react-simple-icons/icons/SiGithub';

The ./icons/* export is a plain passthrough, so TypeScript reports TS2307 (no types condition, SiGithub.d.ts is never found) and Node ESM throws ERR_MODULE_NOT_FOUND (./icons/SiGithub isn't a real file). Writing the extension manually works at runtime but has no typings, since there's no .d.mts next 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 tsc from 3,414 files to 12.

This PR maps the conditions explicitly:

"./icons/*.mjs": "./icons/*.mjs",
"./icons/*.cjs": "./icons/*.cjs",
"./icons/*": {
  "types": "./icons/*.d.ts",
  "import": "./icons/*.mjs",
  "require": "./icons/*.cjs"
}

The two passthrough lines keep existing explicit-extension imports like .../icons/SiGithub.mjs working — with only the conditional entry they would resolve to SiGithub.mjs.mjs and break. The barrel is untouched.

Would you be open to this change? Happy to adjust if you'd prefer a different shape.

@wootsbot

Copy link
Copy Markdown
Member

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! 🙌

@huuyafwww

Copy link
Copy Markdown
Contributor Author

@wootsbot
Thank you for reviewing the changes.
Currently, my project is temporarily applying the changes from this PR as a patch to work around Barrel Import, so
there’s no rush to release it.
Thank you for handling this maintenance despite your busy schedule.
Best regards

@wootsbot
wootsbot merged commit 32d0811 into icons-pack:main Aug 16, 2026
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants