Skip to content
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

icon-builder: build indexes for icons #1064

Closed
tony opened this issue Jul 8, 2015 · 3 comments
Closed

icon-builder: build indexes for icons #1064

tony opened this issue Jul 8, 2015 · 3 comments
Labels
package: icons Specific to @mui/icons

Comments

@tony
Copy link
Contributor

tony commented Jul 8, 2015

#1057 (comment)

Will have a PR this week for this. It will work for material-ui and user generated svg's.

@tony
Copy link
Contributor Author

tony commented Jul 8, 2015

@hai-cea / @jkruder I am not up to speed with how require works on web builds.

Is it true that adding an index.js to svg-icons folders (like we if we wanted to use mui.SvgIcon.Access.Accessibility would end up having all svg icons loaded ?

Is there anything that node / webpack / browserify does to optimize / allow lazy-evaluation of require's when inside of .index.js?

I believe the idea of index.js is great from a readability standpoint. Having to pick out and require icons one by one runs contrary to the fact we're prototyping to ship ASAP. However, the cost of having every svg pulled into builds makes this unfeasible.

@jkruder
Copy link
Contributor

jkruder commented Jul 8, 2015

@tony The src/index.js would not include the svg-icons explicitly. The index.js files would go under each directory within svg-icons so that folks can pull in a theme of icons and not the entire set of icons. If we had an index.js under svg-icons/navigation the require could look like:

let NavigationIcons = require('[relative path to node_modules]/node_modules/material-ui/lib/svg-icons/navigation/');
let { ArrowDown, ArrowUp } = NavigationIcons;

In this scenario only the Navigation icons have been pulled in. This is really only useful for folks who are consuming MUI. Internally we will still explicitly reference the icons we need so as not to pull in a large portion of the svg-icons.

In regards to how require's work, there are no dynamic requires using browserify (which this framework uses). So if there are 100 requires in an index, all 100 will be brought in regardless of how many are actually used.

@oliviertassinari
Copy link
Member

Resolved by #1959

@zannager zannager added the package: icons Specific to @mui/icons label Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: icons Specific to @mui/icons
Projects
None yet
Development

No branches or pull requests

4 participants