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

docs: add back docs about asar archives #35563

Merged
merged 1 commit into from Sep 13, 2022
Merged

docs: add back docs about asar archives #35563

merged 1 commit into from Sep 13, 2022

Conversation

zcbenz
Copy link
Member

@zcbenz zcbenz commented Sep 2, 2022

Description of Change

Lots of informations about ASAR archives had been lost after #26239, this PR adds them back.

Release Notes

Notes: Add back documentations about asar archives.

@zcbenz zcbenz added documentation 📓 semver/none target/19-x-y target/21-x-y PR should also be added to the "21-x-y" branch. labels Sep 2, 2022
@zcbenz zcbenz requested a review from a team September 2, 2022 02:00
@electron-cation electron-cation bot added semver/patch backwards-compatible bug fixes new-pr 🌱 PR opened in the last 24 hours labels Sep 2, 2022
@malept
Copy link
Member

malept commented Sep 2, 2022

I think the idea was to put that info into the asar readme.

Copy link
Member

@BlackHole1 BlackHole1 left a comment

Choose a reason for hiding this comment

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

Content LGTM

Copy link
Member

@RaisinTen RaisinTen left a comment

Choose a reason for hiding this comment

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

Thanks! This is going to be very helpful for https://github.com/nodejs/single-executable. :)

After creating an [application distribution](application-distribution.md), the
app's source code are usually bundled into an [ASAR
archive](https://github.com/electron/asar), which is a simple extensive archive
format designed for Electron apps. By bundling the app we can mitigate issues
Copy link
Contributor

@Prinzhorn Prinzhorn Sep 3, 2022

Choose a reason for hiding this comment

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

The word "issues" was originally linked to nodejs/node-v0.x-archive#6960 . But hasn't this been fixed years ago (npm doesn't nest node_modules any longer)?

Electron also recommends bundling your code (https://www.electronjs.org/de/docs/latest/tutorial/performance#7-bundle-your-code), which also speeds up require (they're mostly gone) and "conceals" the source (by means of minification and mangling).

The reason why I'm bringing this up is that when I started with Electron I read this paragraph and couldn't find a single compelling reason to use ASAR (and I didn't), only problems (e.g. the Worker constructor didn't seem to be patched to add ASAR support).

Is there actually a real benefit of using ASAR? I'm curious if I'm missing out.

Summary:

  1. Long path names haven't been an issue since 2015 (?)
  2. There's no evidence linked that ASAR is faster than bundling (which is recommended anyway), maybe include a benchmark somewhere?
  3. "conceal your source code from cursory inspection" is a really weak argument, if at all

So maybe this could be rewritten for 2022?

Copy link
Member Author

Choose a reason for hiding this comment

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

Bundlers are not good at handling assets as far as I know. For example you can not bundle image files and then serve them via protocol module, or execute a bundled python script with child_process. Of course you can work around them if your app is designed to work with bundlers from start, but ASAR is designed to work with arbitrary apps and package them into one single file.

But still I agree ASAR does not provide a real benefit than bundling, and this documentation means to list the limitations of ASAR instead of promoting it.

Node.js is going to work on a similar thing https://github.com/nodejs/single-executable, and we might want to use it as the default format in the end.

Copy link
Contributor

@Prinzhorn Prinzhorn Sep 6, 2022

Choose a reason for hiding this comment

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

Thanks for clarifying. It sounds like you brought up some good points that should belong into the docs (maybe we could explicitly mention bundling and the pros and cons).

you can not bundle image files and then serve them via protocol module

For me they are bundled as part of the client bundle and I point @fastify/static (which is bundled in the server bundle) to the client/dist folder. But I understand not everyone is running an HTTP server. This works as expected for me:

import chromeProxySettings from '~/images/getting-started-chrome-proxy.png';
<img src={chromeProxySettings} alt="Chrome proxy settings" />

I don't see why the protocol module couldn't serve files from my client/dist folder as well.

or execute a bundled python script with child_process

I think ASAR makes that harder, not easier? Because depending on the circumstances you'd have to explicitly do something like asarUnpack (for electron-builder) for it to even work. I'm shipping a Python binary (via PyInstaller) with additional Python scripts and I don't have any problems so far using child_process.spawn.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah this document needs an update, and actually the original PR that removed it was planning to move the document to the asar repo but somehow the effort ended nowhere.

This PR means to bring back the deleted page since it contains important information that currently can not be found on Internet, we might delete it later after getting a renewed documentation in the asar repo.

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Sep 3, 2022
Copy link
Member

@erickzhao erickzhao left a comment

Choose a reason for hiding this comment

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

I think the idea was to put that info into the asar readme.

As @malept mentioned, I do think this was the case. Do we feel like this belongs better in the Electron docs?

@@ -68,6 +68,7 @@ an issue:
* [Mac App Store](tutorial/mac-app-store-submission-guide.md)
* [Windows Store](tutorial/windows-store-guide.md)
* [Snapcraft](tutorial/snapcraft.md)
* [ASAR Archives](tutorial/asar-archives.md)
Copy link
Member

Choose a reason for hiding this comment

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

Note: we don't really use this README on the website anymore at all!

@zcbenz
Copy link
Member Author

zcbenz commented Sep 7, 2022

As @malept mentioned, I do think this was the case. Do we feel like this belongs better in the Electron docs?

I agreed the docs should be moved to the asar repo, but somehow the effort ended no where. I would like to recover the docs first since it contains important information that can not be found on Internet anymore. We can delete this doc after having all necessary information in the asar repo.

Copy link
Member

@ckerr ckerr left a comment

Choose a reason for hiding this comment

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

I don't have an opinion on where the docs go, but if I'm understanding the discussion here the documentation currently isn't available at all! For that reason, whether or not e/e docs/ is the end goal, I'm 👍 on merging this to at least get it documented somewhere

@jkleinsc jkleinsc removed the semver/patch backwards-compatible bug fixes label Sep 13, 2022
@jkleinsc
Copy link
Contributor

Merging as CI failure unrelated to PR change.

@jkleinsc jkleinsc merged commit 748c6af into main Sep 13, 2022
@jkleinsc jkleinsc deleted the fix-asar-docs branch September 13, 2022 21:00
@release-clerk
Copy link

release-clerk bot commented Sep 13, 2022

Release Notes Persisted

Add back documentations about asar archives.

@trop
Copy link
Contributor

trop bot commented Sep 13, 2022

I have automatically backported this PR to "19-x-y", please check out #35665

@trop
Copy link
Contributor

trop bot commented Sep 13, 2022

I have automatically backported this PR to "20-x-y", please check out #35666

@trop
Copy link
Contributor

trop bot commented Sep 13, 2022

I have automatically backported this PR to "21-x-y", please check out #35667

@trop trop bot added in-flight/20-x-y merged/21-x-y PR was merged to the "21-x-y" branch. and removed target/20-x-y target/21-x-y PR should also be added to the "21-x-y" branch. labels Sep 13, 2022
khalwa pushed a commit to solarwindscloud/electron that referenced this pull request Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 📓 merged/21-x-y PR was merged to the "21-x-y" branch. semver/none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants