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

Reduces compiler-wasm binary file size #3780

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

malbarbo
Copy link

@malbarbo malbarbo commented Nov 2, 2024

Add the compiler-wasm feature reduce-bin-size which, when enabled, reduces the generated wasm file from 3.7 MB to 2.2 MB.

We achieved this by:

  • Adding the compiler-core feature disable-erlang, which disables erlang code generation
  • Replacing the use of regular expressions with iterator code
  • Adding the compiler-core feature disable-hide-internal, which disables hiding of internal methods, which requires the use of the globset crate, which in turn requires the use of the regex crate

Nothing changes by default, but when the compiler-wasm crate is built with the reduce-bin-size feature enabled, the compiler do it's magic and no code from the erlang backend and the globset and regex crates appears in the wasm file.

When enabled in compiler-wasm, this reduzes the wasm file from
3.7MB to 3.4MB.
When enabled in compiler-wasm, this removes the glob and regex
crates from the final wasm reducing size from 3.4MB to 2.2MB.
@malbarbo
Copy link
Author

malbarbo commented Nov 2, 2024

I'm incorporating the gleam compiler into a project, and the binary size is import.

I made this PR in case it's an interesting aspect for the gleam project. But if it's not desirable, no problem.

Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

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

Hello! Thank you for this, but this introduces a substantial maintenance overhead which I'm not in a position to support. Gleam is a community project and we about about 0.8 developers worth of money, so we have to be as efficient as possible with our time.

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