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

feat: sdk bundle size opt methodology #722

Merged
merged 2 commits into from
Mar 1, 2024
Merged

feat: sdk bundle size opt methodology #722

merged 2 commits into from
Mar 1, 2024

Conversation

abretonc7s
Copy link
Collaborator

@abretonc7s abretonc7s commented Mar 1, 2024

Explanation

This PR introduces a series of optimizations to reduce the bundle sizes for the @metamask/sdk, @metamask/sdk-communication-layer, and @metamask/sdk-install-modal-web packages. Key changes include:

  • Updated Rollup configuration to enhance tree shaking.
  • Added automated bundle size tracking.
  • Use of size-limit to compute actual bundled size
    image

References

sdk git:(feat/bundle-size) ✗ yarn size
dist/browser/es/metamask-sdk.js: 1545.30 KB
dist/browser/umd/metamask-sdk.js: 1548.05 KB
dist/react-native/es/metamask-sdk.js: 570.76 KB
dist/node/cjs/metamask-sdk.js: 1231.80 KB
dist/node/es/metamask-sdk.js: 1229.21 KB
✔ Adding to empty webpack project
✔ Running JS in headless Chrome
  
  Time limit:   100 s
  Size:         292.54 kB with all dependencies, minified and brotlied
  Loading time: 5.8 s     on slow 3G
  Running time: 6.7 s     on Snapdragon 410
  Total time:   12.4 s
  
➜  sdk git:(feat/bundle-size) ✗ 

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@abretonc7s abretonc7s requested a review from a team as a code owner March 1, 2024 07:12
Copy link

socket-security bot commented Mar 1, 2024

Copy link

socket-security bot commented Mar 1, 2024

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package Note
Shell access npm/[email protected]

View full report↗︎

Next steps

What is shell access?

This module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.

Packages should avoid accessing the shell which can reduce portability, and make it easier for malicious shell access to be introduced.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/[email protected] or ignore all packages with @SocketSecurity ignore-all

@abretonc7s
Copy link
Collaborator Author

@SocketSecurity ignore

Copy link

codecov bot commented Mar 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.48%. Comparing base (bb0231d) to head (824ef27).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #722   +/-   ##
=======================================
  Coverage   81.48%   81.48%           
=======================================
  Files         173      173           
  Lines        3446     3446           
  Branches      805      805           
=======================================
  Hits         2808     2808           
  Misses        638      638           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

andreahaku
andreahaku previously approved these changes Mar 1, 2024
Copy link
Contributor

@andreahaku andreahaku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@andreahaku andreahaku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@abretonc7s abretonc7s merged commit a144f0b into main Mar 1, 2024
32 of 33 checks passed
@abretonc7s abretonc7s deleted the feat/bundle-size branch March 1, 2024 09:12
This was referenced Mar 4, 2024
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

Successfully merging this pull request may close these issues.

3 participants