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

React-native bundle time increased from 30 seconds to 20 minutes. #167

Closed
herbertvuijk opened this issue Dec 3, 2023 · 1 comment
Closed

Comments

@herbertvuijk
Copy link

Describe the bug
After adding some icons into my project I found that the react-native build gets extremely slow

yarn react-native bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output ios/main.jsbundle --verbose

After 2 days of Googling and researching I realized that my built slowed down after adding RN FA. I waited it out, the bundling, and noticed that it had EVERY FA icon in the index.js. So the index.js became really big, and hence was slowing down a lot.

I changed to deep imports:

import { faCircle } from '@fortawesome/pro-thin-svg-icons/faCircle';
import { faCompass } from '@fortawesome/pro-thin-svg-icons/faCompass';
import { faUser } from '@fortawesome/pro-thin-svg-icons/faUser';

And that seemed to have speed up the build again. Obviously this is very frustrating behavior that lost me 2 days of work, before I understood what was going wrong.

Reproducible test case

  • New react-native project
    Import some icons like so:
    import { library } from '@fortawesome/fontawesome-svg-core'
    import {
    faList, faLocationSmile, faLightbulb, faCircleCheck, faLocationArrow,
    faLocationPin, faArrowUp, faThumbsDown, faCheck, faGauge, faLocationPlus,
    faTrash, faFaceFrown, faFaceMeh, faFaceSmileBeam, faArrowUpLong, faArrowsMaximize,
    faChevronsRight, faInboxOut, faInboxIn, faArrowUpFromLine, faPlaneDeparture,
    faArrowsLeftRight, faGaugeSimpleMax, faLifeRing, faUserPlus, faLocationDot, faRocket,
    faLocationCrosshairs, faPenToSquare, faCrown, faCamera, faChartBar, faArrowRight,
    faPen, faExclamationTriangle, faInfoCircle, faMagnifyingGlass, faSortUp, faSortDown,
    faCassetteTape, faTrophyStar, faBatteryBolt,
    faArrowRightArrowLeft, faPlus, faRectangleHistory, faUmbrellaBeach, faWind,
    faThermometerHalf, faBell, faUserFriends, faGear, faShareNodes, faCalendarDays,
    faArrowDown, faChevronRight, faWatch, faUserTie, faFilter, faTvRetro, faCircle,
    faCompass, faUser, faUsers, faPaperPlane, faBullseye, faBullhorn, faUserCrown, faStar,
    faClock, faXmark

} from '@fortawesome/pro-thin-svg-icons';

Expected behavior
My built should still work

@robmadole
Copy link
Member

Hi @herbertvuijk sorry you experienced frustration. But those deep imports exist for platforms that don't support tree-shaking. The way you solved this is exactly what we'd have recommended.

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

No branches or pull requests

2 participants