You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Does your feature request relate to a specific USWDS component?
No
What USWDS Version is this feature present in?
Not applicable
Is your feature request related to a problem? Please describe.
When you import one component from the library through tree shaking, it seems to import the entire library under the hood. Currently, the individual components don't seem to be exposed to the developer, and tree shaking is the only method of import. This is a problem when working with frameworks where bundle size is of importance, such as Next JS. See below examples:
As you can see, the bundle sizes for page1 and page2 are the same. This implies that importing one component imports the whole library. While this example was with a fresh app with nothing else in it, on a full project, that amount makes a big difference.
Describe the solution you'd like
Expose the ability to import one component from a specific file. Such as:
// Currentimport{Button,TextInput}from"@trussworks/react-uswds";// Single fileimportButtonfrom"@trussworks/react-uswds/components/Button";importTextInputfrom"@trussworks/react-uswds/components/TextInput";
This would reduce the bundle size by only importing the components and code necessary.
Describe alternatives you've considered
The only other alternative is to manually implement USWDS components in my project and allow imports this way, but that would be counter to the idea of this library.
Additional context
If this is already possible, and I just missed it, let me know. Thanks!
The text was updated successfully, but these errors were encountered:
Does your feature request relate to a specific USWDS component?
No
What USWDS Version is this feature present in?
Not applicable
Is your feature request related to a problem? Please describe.
When you import one component from the library through tree shaking, it seems to import the entire library under the hood. Currently, the individual components don't seem to be exposed to the developer, and tree shaking is the only method of import. This is a problem when working with frameworks where bundle size is of importance, such as Next JS. See below examples:
page1
page2
Build output
![Screenshot 2023-11-13 at 12 48 28 PM](https://private-user-images.githubusercontent.com/61305154/282573597-b46323b1-a928-4ce1-b5c6-07b046dc7c39.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA3MjcyNDUsIm5iZiI6MTcyMDcyNjk0NSwicGF0aCI6Ii82MTMwNTE1NC8yODI1NzM1OTctYjQ2MzIzYjEtYTkyOC00Y2UxLWI1YzYtMDdiMDQ2ZGM3YzM5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzExVDE5NDIyNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM5Y2Q3NDA5NWE5N2JlZWM5ZDM4NDZmYTM1ODcwNDNlMmVkOWNiNjQ2MDI1OTFhNzIwMTc0NDYxODNlYjFhZmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0._t9lwa0R6XizedIWgTFkjZPR8b2pTX9ivA_1hrGxrF8)
As you can see, the bundle sizes for page1 and page2 are the same. This implies that importing one component imports the whole library. While this example was with a fresh app with nothing else in it, on a full project, that amount makes a big difference.
Describe the solution you'd like
Expose the ability to import one component from a specific file. Such as:
This would reduce the bundle size by only importing the components and code necessary.
Describe alternatives you've considered
The only other alternative is to manually implement USWDS components in my project and allow imports this way, but that would be counter to the idea of this library.
Additional context
If this is already possible, and I just missed it, let me know. Thanks!
The text was updated successfully, but these errors were encountered: