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

Optimise CLI Webpack configuration #2175

Merged
merged 4 commits into from
Feb 9, 2024
Merged

Optimise CLI Webpack configuration #2175

merged 4 commits into from
Feb 9, 2024

Conversation

Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Feb 9, 2024

SWC was previously configured to output CJS, which means any imports would be transpiled to require. This means that any dependencies would also be loaded as CJS, even though an ESM version may be available. By changing SWC to output ES6 code and not transpiling any imports, Webpack loads potentially more ESM code which can be better optimised and tree-shaken.

Below are the old and new file sizes of the examples. For some examples, this change reduces the file size by 70%.

Before this change
272K    ./bip32/dist/bundle.js
344K    ./bip44/dist/bundle.js
312K    ./browserify-plugin/dist/bundle.js
136K    ./browserify/dist/bundle.js
104K    ./client-status/dist/bundle.js
152K    ./cronjobs/dist/bundle.js
156K    ./dialogs/dist/bundle.js
4.0K    ./errors/dist/bundle.js
108K    ./ethereum-provider/dist/bundle.js
1.1M    ./ethers-js/dist/bundle.js
200K    ./get-entropy/dist/bundle.js
104K    ./get-file/dist/bundle.js
152K    ./home-page/dist/bundle.js
164K    ./images/dist/bundle.js
104K    ./json-rpc/dist/bundle.js
152K    ./lifecycle-hooks/dist/bundle.js
108K    ./localization/dist/bundle.js
156K    ./manage-state/dist/bundle.js
4.0K    ./name-lookup/dist/bundle.js
104K    ./network-access/dist/bundle.js
152K    ./notifications/dist/bundle.js
104K    ./rollup-plugin/dist/bundle.js
156K    ./signature-insights/dist/bundle.js
152K    ./transaction-insights/dist/bundle.js
108K    ./wasm/dist/bundle.js
104K    ./webpack-plugin/dist/bundle.js
4.6M    total
After this change
256K    ./bip32/dist/bundle.js
324K    ./bip44/dist/bundle.js
312K    ./browserify-plugin/dist/bundle.js
136K    ./browserify/dist/bundle.js
104K    ./client-status/dist/bundle.js
136K    ./cronjobs/dist/bundle.js
136K    ./dialogs/dist/bundle.js
4.0K    ./errors/dist/bundle.js
108K    ./ethereum-provider/dist/bundle.js
300K    ./ethers-js/dist/bundle.js
176K    ./get-entropy/dist/bundle.js
104K    ./get-file/dist/bundle.js
 36K    ./home-page/dist/bundle.js
152K    ./images/dist/bundle.js
104K    ./json-rpc/dist/bundle.js
 36K    ./lifecycle-hooks/dist/bundle.js
104K    ./localization/dist/bundle.js
104K    ./manage-state/dist/bundle.js
4.0K    ./name-lookup/dist/bundle.js
104K    ./network-access/dist/bundle.js
104K    ./notifications/dist/bundle.js
104K    ./rollup-plugin/dist/bundle.js
 36K    ./signature-insights/dist/bundle.js
 36K    ./transaction-insights/dist/bundle.js
104K    ./wasm/dist/bundle.js
104K    ./webpack-plugin/dist/bundle.js
3.2M    total

@Mrtenz Mrtenz requested a review from a team as a code owner February 9, 2024 11:16
Copy link

codecov bot commented Feb 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (1ec9bf5) 96.54% compared to head (97d8a19) 96.54%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2175   +/-   ##
=======================================
  Coverage   96.54%   96.54%           
=======================================
  Files         331      331           
  Lines        7459     7459           
  Branches     1145     1145           
=======================================
  Hits         7201     7201           
  Misses        258      258           

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

@Mrtenz Mrtenz merged commit d844be7 into main Feb 9, 2024
147 checks passed
@Mrtenz Mrtenz deleted the mrtenz/cli-optimisation branch February 9, 2024 11:40
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.

2 participants