NewsWorld
PredictionsDigestsScorecardTimelinesArticles
NewsWorld
HomePredictionsDigestsScorecardTimelinesArticlesWorldTechnologyPoliticsBusiness
AI-powered predictive news aggregation© 2026 NewsWorld. All rights reserved.
Trending
IranIranianMilitaryIsraeliPricesStrikesCrisisRegionalOperationsMilitiasMarketsLaunchGulfConflictStatesHormuzMarchEscalationTimelineTargetsStraitDigestPowerProxy
IranIranianMilitaryIsraeliPricesStrikesCrisisRegionalOperationsMilitiasMarketsLaunchGulfConflictStatesHormuzMarchEscalationTimelineTargetsStraitDigestPowerProxy
All Articles
Packaging a Gleam app into a single executable
Hacker News
Published about 3 hours ago

Packaging a Gleam app into a single executable

Hacker News · Mar 2, 2026 · Collected from RSS

Summary

Article URL: https://www.dhzdhd.dev/blog/gleam-executable Comments URL: https://news.ycombinator.com/item?id=47220020 Points: 12 # Comments: 0

Full Article

Table of Contents About Creating a gleam project Methods of creating an executable Erlang target Gleescript (requires system Erlang) Steps Burrito JavaScript target Deno compile Steps Node SEA Steps Bun build —compile Steps Nexe Conclusion About Gleam is a new-ish functional programming language that compiles to Erlang and JavaScript. It features a familiar Rust like syntax while being similar to Elm in complexity and in general is a lot of fun to work with. The problem however is that Gleam does not natively support creating executables. This note/guide explains how to create a Gleam executable in various ways, along with their advantages and caveats. I will be using my WIP project to demonstrate the process of creating an executable throughout the guide. Creating a gleam project Install gleam by following the instructions here Create a new project with gleam new <project_name> Build the project with gleam build --target=erlang|javascript The target is important as it determines the generated output of the build command and hence, the way of packaging the code into an executable. Methods of creating an executable Erlang target Gleescript (requires system Erlang) Gleescript is a tool that allows you to create a single executable from a Gleam project. It uses the Erlang escript stdlib module to create the escript which can then be run on the Erlang VM. The caveat is that it requires the Erlang VM to be installed on the target machine. As quoted by the official docs - The escript can run on any computer that has the Erlang VM installed. Older versions of the virtual machine may not support the newer bytecode contained in the escript. Typically being within a couple major versions of the version used to build the escript is safe. Steps Add gleescript as a dependency using gleam add gleescript Build the project with gleam build --target erlang Create the escript with gleam run -m gleescript Run the executable ./your_project Burrito Burrito is a tool to wrap Elixir applications in a BEAM burrito so as to speak. Unlike gleescript, it does not require the host machine to have the Erlang VM installed. As quoted from the official docs - Builds a self-extracting archive for a Mix project, targeting Windows, MacOS, and Linux, containing: Your compiled BEAM code The required ERTS for your project Compilation artifacts for any elixir-make based NIFs used by the project I have not experimented enough with Burrito to get it working with Gleam but it definitely is worth a try considering it supports Elixir and Erlang projects. Perhaps a project can be converted into an escript and then wrapped with Burrito to create a self-contained executable. JavaScript target Deno compile Deno compile is a command built into Deno that allows you to compile a JavaScript file into a single executable. It bundles a lightweight Deno runtime into the executable, so it can run on any system without requiring Deno to be installed. You still have to bundle the generated Gleam code into a single file using a bundler like Webpack/Parcel/Rollup/Esbuild. Deno used to support bundling applications with deno bundle but it has been deprecated in favor of other bundlers stated before. Steps Build the Gleam project with gleam build --target=javascript Bundle the generated JavaScript files into a single file using a bundler (I am using ESbuild here) esbuild build/dev/javascript/<project_name>/<project_name>.mjs --platform=node --minify-whitespace --minify-syntax --bundle --outfile=bundle.cjs --format=cjs --footer:js=\"main();\" Specify the entrypoint to the Gleam project as the first argument. Next specify the platform as node as my specific project is using Node.js API’s internally (Gleam simplifile package) Minify the output to reduce the size of the executable. Notice that I have minified only the whitespace and syntax and left the identifiers as is which is required for the last step. Specify bundle because we obviously want to bundle the code into a single file. Specify the output file as bundle.cjs and the format as cjs (CommonJS). This was a result of me trying out Node SEA first (the next method) but ESM probably works here too as Deno does not have any explicit declaration that it only supports CommonJS. Specify a footer that calls the main method in the generated file as we are not using the bundled file as a module. Usually the footer is used for adding comments and there might be a better way of doing this that I am not aware of. This however serves the purpose very well. Compile the bundled file into a single executable using deno compile --target=<target_architecture> --output <executable_name> bundle.cjs A lot more flags can be included which are described in the docs Permissions should also be added if the executable needs to access the file system or network. They can be found here Node SEA Node Single Executable Applications (SEA) is an experimental Node v23+ feature that allows the distribution of a Node.js application to a system that does not have Node.js installed. The caveat with this method is that it supports only CommonJS files and you will have to bundle the generated Gleam JavaScript files into a single file using a bundler like Webpack/Parcel/Rollup/Esbuild. Steps Build the Gleam project with gleam build --target=javascript Bundle the generated JavaScript files into a single file using a bundler (I am using ESbuild here) esbuild build/dev/javascript/<project_name>/<project_name>.mjs --platform=node --minify-whitespace --minify-syntax --bundle --outfile=bundle.cjs --format=cjs --footer:js=\"main();\" Specify the entrypoint to the Gleam project as the first argument. Next specify the platform as node as my specific project is using Node.js API’s internally (Gleam simplifile package) Minify the output to reduce the size of the executable. Notice that I have minified only the whitespace and syntax and left the identifiers as is which is required for the last step. Specify bundle because we obviously want to bundle the code into a single file. Specify the output file as bundle.cjs and the format as cjs (CommonJS). This is required for Node SEA. Specify a footer that calls the main method in the generated file as we are not using the bundled file as a module. Usually the footer is used for adding comments and there might be a better way of doing this that I am not aware of. This however serves the purpose very well. The next steps are a lot more complicated that Deno and you can find them here. For my project however, they are - Create a sea-config.json and populate as per instructions in the docs. The main and output are the important fields here. Generate the blob to be injected into the copied Node.js binary using node --experimental-sea-config sea-config.json Create a copy of the Node executable using cp $(command -v node) executable_name Remove the binary signature by following instructions in the docs. Inject the blob into the copied Node.js binary using npx postject executable_name NODE_SEA_BLOB <output>.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 Sign the binary if required Run the binary using ./executable_name Following the steps above resulted in a segfault for me and I am not sure why. I will update this section once I study SEA in more detail. It is clear however that Deno is way simpler to use compared to Node SEA. Bun build —compile Bun build with the compile flag is a Bun feature to bundle a bunch of JS files and then compile them into a single executable. It is similar to Deno compile but does not require a separate bundler. All imported files and packages are bundled into the executable, along with a copy of the Bun runtime. All built-in Bun and Node.js APIs are supported. Steps Build the Gleam project with gleam build --target=javascript bun build --compile --outfile=bundle build/dev/javascript/<project_name>/<project_name>.mjs --footer="main();" That’s it. Bun is incredibly convinient and crazy fast compared to Deno or Node or any of the methods mentioned so far. Nexe Nexe is a command-line utility that compiles your Node.js application into a single executable file. Like Burrito, I have not played around with Nexe enough to get it working with my project but it should be way more straightforward than making Burrito work with Gleam. Conclusion Out of all the tools/libraries that I used, I found Bun to be incredibly fast and also very easy to use. The only problem with Bun and Deno is that due to them bundling their own runtimes, the executables are large, usually exceeding 100MB. I personally do not mind this as I am not using the executables in production but it is something to keep in mind.


Share this story

Read Original at Hacker News

Related Articles

Hacker Newsabout 2 hours ago
Show HN: Govbase – Follow a bill from source text to news bias to social posts

Govbase tracks every bill, executive order, and federal regulation from official sources (Congress.gov, Federal Register, White House). An AI pipeline breaks each one down into plain-language summaries and shows who it impacts by demographic group. It also ties each policy directly to bias-rated news coverage and politician social posts on X, Bluesky, and Truth Social. You can follow a single bill from the official text to how media frames it to what your representatives are saying about it. Free on web, iOS, and Android. https://govbase.com I'd love feedback from the community, especially on the data pipeline or what policy areas/features you feel are missing. Comments URL: https://news.ycombinator.com/item?id=47220809 Points: 16 # Comments: 3

Hacker Newsabout 3 hours ago
Reflex (YC W23) Is Hiring Software Engineers – Python

Article URL: https://www.ycombinator.com/companies/reflex/jobs Comments URL: https://news.ycombinator.com/item?id=47220666 Points: 0 # Comments: 0

Hacker Newsabout 3 hours ago
Launch HN: OctaPulse (YC W26) – Robotics and computer vision for fish farming

Hi HN! My name is Rohan and, together with Paul, I’m the co-founder of OctaPulse (https://www.tryoctapulse.com/). We’re building a robotics layer for seafood production, starting with automated fish inspection. We are currently deployed at our first production site with the largest trout producer in North America. You might be wondering how the heck we got into this with no background in aquaculture or the ocean industry. We are both from coastal communities. I am from Goa, India and Paul is from Malta and Puerto Rico. Seafood is deeply tied to both our cultures and communities. We saw firsthand the damage being done to our oceans and how wild fish stocks are being fished to near extinction. We also learned that fish is the main protein source for almost 55% of the world's population. Despite it not being huge consumption in America it is massive globally. And then we found out that America imports 90% of its seafood. What? That felt absurd. That was the initial motivation for starting this company. Paul and I met at an entrepreneurship happy hour at CMU. We met to talk about ocean tech. It went on for three hours. I was drawn to building in the ocean because it is one of the hardest engineering domains out there. Paul had been researching aquaculture for months and kept finding the same thing: a $350B global industry with less data visibility than a warehouse. After that conversation we knew we wanted to work on this together. Hatcheries, the early stage on-land part of production, are full of labor intensive workflows that are perfect candidates for automation. Farmers need to measure their stock for feeding, breeding, and harvest decisions but fish are underwater and get stressed when handled. Most farms still sample manually. They net a few dozen fish, anesthetize them, place them on a table to measure one by one, and extrapolate to populations of hundreds of thousands. It takes about 5 minutes per fish and the data is sparse. When we saw this process we were ba

Hacker Newsabout 4 hours ago
Notes on Lagrange Interpolating Polynomials

Article URL: https://eli.thegreenplace.net/2026/notes-on-lagrange-interpolating-polynomials/ Comments URL: https://news.ycombinator.com/item?id=47219688 Points: 15 # Comments: 5

Hacker Newsabout 4 hours ago
Ask HN: Who is hiring? (March 2026)

Please state the location and include REMOTE for remote work, REMOTE (US) or similar if the country is restricted, and ONSITE when remote work is not an option. Please only post if you personally are part of the hiring company—no recruiting firms or job boards. One post per company. If it isn't a household name, explain what your company does. Please only post if you are actively filling a position and are committed to replying to applicants. Commenters: please don't reply to job posts to complain about something. It's off topic here. Readers: please only email if you are personally interested in the job. Searchers: try https://dheerajck.github.io/hnwhoishiring/, http://nchelluri.github.io/hnjobs/, https://hnresumetojobs.com, https://hnhired.fly.dev, https://kennytilton.github.io/whoishiring/, https://hnjobs.emilburzo.com, or this (unofficial) Chrome extension: https://chromewebstore.google.com/detail/hn-hiring-pro/mpfal.... Don't miss this other fine thread: Who wants to be hired? https://news.ycombinator.com/item?id=47219667 Comments URL: https://news.ycombinator.com/item?id=47219668 Points: 63 # Comments: 84

Hacker Newsabout 4 hours ago
Felix "fx" Lindner has died

Article URL: https://blog.recurity-labs.com/2026-03-02/Farewell_Felix Comments URL: https://news.ycombinator.com/item?id=47219558 Points: 45 # Comments: 3