Skip to content

Minified browser code in the packaged final app. #931

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

Merged
merged 1 commit into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions electron/build/template-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
"shelljs": "^0.8.3"
},
"scripts": {
"build": "yarn download:plugins && theia build --mode development && yarn patch",
"build:publish": "yarn download:plugins && theia build --mode production && yarn patch",
"build": "yarn download:plugins && theia build --mode production && yarn patch",
"rebuild": "yarn theia rebuild:electron",
"package": "cross-env DEBUG=* && electron-builder --publish=never",
"package:publish": "cross-env DEBUG=* && electron-builder --publish=always",
Expand Down
5 changes: 1 addition & 4 deletions electron/packager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
'Installing dependencies'
);
exec(
`yarn --network-timeout 1000000 --cwd ${path('..', 'build')} build${isElectronPublish ? ':publish' : ''
}`,
`yarn --network-timeout 1000000 --cwd ${path('..', 'build')} build`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice one @kittaakos. Just one thing: wouldn't it be better if we'd set isElectronPublish to true here?

That way we could still use yarn build to package the app in development mode when we need it. Does that make sense to you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here?

Thanks for pointing out why it did not work 👍

package the app in development mode when we need it

Good point, but when do we need a packaged app for dev mode? I could not come up with a single use-case. I think isElectronPublish makes the packager logic confusing.
If we still want to support a packaged dev app, we need to figure out when and how to set isElectronPublish to true. Any proposals?


I also collected a pros-cons list if we decide always to minify the code:

Pros:

  • Precisely the same will be released, which was built and verified previously,
  • Consistency: simplifies the packaging logic,
  • Can help with the (manual) performance measurements.

Cons:

  • Bundle time would take an additional 20 sec due to webpack the production mode (I only guessed here and did not measure) compared to the overall ~20min package time,
  • We have to deal with minified stack traces on the FE (Note: source maps work, I could debug the bunded app with minified code, but please verify. Thanks)

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I thought source maps wouldn't work in production mode. In that case, I guess the pros outweigh the cons.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

source maps wouldn't work in production mode.

Please double check if you can also debug the TS code in the bundled app. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

yup, everything seems to work for me. Thanks @kittaakos!

`Building the ${productName} application`
);
exec(
Expand Down Expand Up @@ -488,7 +487,6 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
)}.`
);
shell.exit(1);
process.exit(1);
}
if (expectedVersion) {
if (!versions.has(expectedVersion)) {
Expand All @@ -497,7 +495,6 @@ ${fs.readFileSync(path('..', 'build', 'package.json')).toString()}
}'.`
);
shell.exit(1);
process.exit(1);
}
}
}
Expand Down