Skip to content

Optimize the size of standalone binaries#736

Open
yhatt wants to merge 2 commits into
mainfrom
optimized-standalone-binaries
Open

Optimize the size of standalone binaries#736
yhatt wants to merge 2 commits into
mainfrom
optimized-standalone-binaries

Conversation

@yhatt

@yhatt yhatt commented Jul 21, 2026

Copy link
Copy Markdown
Member

The size of the standalone binaries for Marp CLI is bloating at every releases. In version v4.5.0, we have switched the binary to Node.js SEA, and I noticed that only the size of Windows binary has been reduced compared to the previous version.

So I have thought the standalone binary for Linux and macOS also have some room for optimization. And finally, I found out the binary for all platforms can be reduced by improving bundled packages and the post/pre build process.

This PR introduces the standalone binary build for the current OS/arch with several optimizations.

The new process cannot cross-compile the binary for other OS/arch, but it's not a key problem because we have set up GitHub Actions to build the binary for primary platforms.

Done

Common

  • Ignore assets from bundle proactively. e.g. unused bundle module files, test codes, documentations, source maps, etc.
  • Stop using typescript package in the bundle: cosmiconfig is only dependency that requires typescript package for loading marp.config.ts with tsconfig.json configuration. The standalone binary uses the latest Node.js and it already can load TypeScript file directly, without any flags and configurations.

Linux

  • Strip unneeded symbols from the binary: strip --strip-unneeded

macOS

  • Strip debug symbols and local symbols from the binary: strip -S -x

Comparison

.tar.gz

OS/Arch v4.5.0 Upcoming Diff
Linux x64 66.84 MiB 46.74 MiB -20.11 MiB (-30.08%)
Linux arm64 67.07 MiB 46.44 MiB -20.63 MiB (-30.76%)
macOS arm64 63.94 MiB 44.67 MiB -19.27 MiB (-30.13%)
Windows x64 59.42 MiB 44.99 MiB -14.43 MiB (-24.28%)

Binary

OS/Arch v4.5.0 Upcoming Diff
Linux x64 165.07 MiB 119.32 MiB -45.75 MiB (-27.72%)
Linux arm64 165.32 MiB 117.32 MiB -48.00 MiB (-29.04%)
macOS arm64 160.90 MiB 111.38 MiB -49.52 MiB (-30.78%)
Windows x64 122.46 MiB 108.13 MiB -14.33 MiB (-11.70%)

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.

1 participant