-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: use ts build #970
Merged
Merged
feat: use ts build #970
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ReidyT
approved these changes
Jul 31, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, LGTM! 👾
pyphilia
approved these changes
Aug 5, 2024
Quality Gate passedIssues Measures |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this PR I convert the package to be built with Typescript only and not vite library mode.
Motivation
While vite library mode is very convenient to create a bundled package, it uses single file mode by default which makes the library code unable to be tree-shaked.
If we expose the library with preserved module structure, the library should be tree-shakable and the consumers should be able to reduce the size of their bundle by not including unused code.
Caveats
In my test, after exposing the Typescript build, the size of the consumer did not really decrease.
Possible reasons for this is that since I had to use the named imports of @mui/material instead of the second level default exports The bundle was still larger. This issue seems to not be on the fix list for the MUI team, as seems like a design issue on their behalf. If we wanted to really reduce our bundle size we should look at another component library that has better support for bundle size optimisation and tree-shaking. If looking at the analysis from https://arethetypeswrong.github.io/?p=@mui/[email protected] the issue lies in the fact that the second level imports are maskaraded in CJS exports. So it will not play nicely with the current ts + nodenext setup.
Other changes
I took the opportunity to do a bit of summer cleaning too:
lucide-icons
as possible to replace the mui iconstype
instead ofinterface
in all prop definitionsFC
in favour of(props: Props) => JSX.Element
index.ts
files in subfolders and directly export the components in the mainindex.ts
Questions
Should we use only named exports for components instead of having default exports that are then named ?
Downstream test PRs and bundle size comparison
Player:
graasp/graasp-player#825
2,312.19 kB -> 1,589.27 kB
31% shrink in bundle size
Builder
graasp/graasp-builder#1390
4,646.32 kB -> 4,379.26 kB
5% shrink in bundle size
Library
graasp/graasp-library#665
1.56Mb -> 1.45 Mb
7% shrink in bundle size
Analytics
graasp/graasp-analytics#419
2,257.06 kB -> 2,033.90 kB
9% shrink in bundle size
Account
graasp/client#315
1,660.81 kB -> 1,351.62 kB
18% shrink in bundle size
Auth
graasp/graasp-auth#442
1,599.91 kB -> 1,280.01 kB
19% shrink in bundle size