-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Reduce desktop app size #7744
Reduce desktop app size #7744
Conversation
3869c29
to
7a9c564
Compare
Excluded
|
7a9c564
to
ff7da1b
Compare
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.
Added notes on some of the changes
config/electron.config.js
Outdated
target: [ | ||
{target: 'dmg', arch: ['x64', 'arm64', 'universal']}, | ||
], |
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.
We can drop the universal
target if we're not going to use it.
The idea is to give x64 to "old" mac users and arm64
for M1s
Universal works for both but is 2x the size (This was briefly touched on the issue as well: #6927 (comment))
BTW I have no problem running the x64 version on M1 - you can't really tell the difference
Sample build output for these targets:
I would like to review this once it's ready. A couple other suggestions that might be worth investigating to reduce bundle size: |
Default is `dist` and is used for temporary content while building We also use `dist` to bundle the js script there We should not use the same folder as in the end temp content (200MB) gets bundled in to the desktop app
Provide arguments through Webpack `env` CLI API 1. Have the base configuration setup for PROD 2. Have the dev configuration override it 3. Desktop use creates 2 configurations in parallel
ff7da1b
to
121a41a
Compare
This script is now getting bundled into `main.js` before `package.json` is modified by electron-builder But the build process sets the `process.env.ELECTRON_ENV` so it's not a problem to just remove these lines Note: updated return docs - the returned values are the lowercase names and not ['PROD', 'STG', 'DEV']
121a41a
to
b8cf68e
Compare
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.
@roryabraham
I've unified the 2 electron Builder configs and had to make changes to usages of ELECTRON_ENV. Particularly to ELECTRON_ENVIRONMENT.js
I think it serves the same purpose this way.
Added a few more notes as code review comments
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.
Looks pretty good to me. Just noticed a few things that could be improved in the readme.
✔️ Ready for Review |
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! Also, nice catch on renaming CONST/index.js
.
conflicts :( |
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.
LGTM and thanks for making all the revisions.
✔️ Conflict resolved |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by @roryabraham in version: 1.1.41-0 🚀
|
@kidroca I think this might have broken storybook builds: https://github.com/Expensify/App/runs/5380104817?check_suite_focus=true I am able to reproduce the error on main by running |
That's something I forgot to test, I'll try it and get back to you |
Yes definitely broke storybook with the changes to |
🚀 Deployed to staging by @roryabraham in version: 1.1.41-0 🚀
|
🚀 Deployed to production by @francoisl in version: 1.1.41-6 🚀
|
Details
electron-builder
usespackage.json
to determine whatnode_modules
needs to be packed inside the app (dependencies)Our root package contains many dependencies irrelevant to desktop (e.g. ios/android stuff) an existing pattern dealing with this is to create a 2nd package.json only for Electron (native) dependencies: https://www.electron.build/tutorials/two-package-structure. So this is what we decided to do here.
The webpack configuration is updated so that we don't use a
dist
folder external todesktop
We're also using webpack to bundle
main.js
(config inspired by https://github.com/electron-react-boilerplate/electron-react-boilerplate).It helps us by:
.env
to webpack andmain.js
files
list upto date each time we import something from../src
Added some notes in desktop/README
Excluded
package-lock
changes to have less PR changesnpm install
once this get reviewedFixed Issues
$ #6927
Tests
Run
npm install
before you startnpm run desktop
still works (with/without.env
file)build-desktop
andbuild-desktop-staging
should not publish unless the--publish
flag is used--publish
flag.Since the webpack configs for web were modified we should check those as well
npm run web
still worksnpm run build
builds the production web bundlenpm run build-staging
builds the staging web bundleiOS and Android should be unaffected
QA Steps
For each env do the following:
.dmg
and verify the size is close to 90 Mb instead of 334MbSample.check.desktop.app.sizes.mp4
Tested On
Screenshots
Web
Mobile Web
Desktop
DEV
STAGING
PROD
iOS
Android