New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve tree shaking friendliness #224
Comments
Another option would be to put each component into its own file so that folks using tools that don't properly tree-shake or remove dead code get use only the icons they need: import Octicon from '@primer/octicons'
// by key
import GitHub from '@primer/octicons/mark-github'
// or by generated class name?
import GitHub from '@primer/octicons/MarkGithub' |
It sounds from this comment like webpack's problem is tree-shaking at the module level, as opposed to the file level; and that the solution is to ship each icon class as a separate file and re-export those from // dist/icons/X.js
export default function X() { /* ... */ }
// dist/index.js
export {default as X} from './icons/X' |
|
@josh and I discussed some of the more nuanced ways that we might be able to make
@github/octicons-react
more friendly to tree-shaking. One thing we could try is separating out theiconsByName
andgetIconByName()
symbols in a separate file, which would exclude the key/component mapping from the bundle altogether, making it possible for uglify to remove the unused components as dead code.The text was updated successfully, but these errors were encountered: