Skip to content

Easy-to-use, zero-configuration tool to create executables of your Node, Deno or Bun projects for all platforms and architectures.

License

Notifications You must be signed in to change notification settings

pigeonposse/binarium

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Binarium - Build node binaries with zero config

Web About Us Donate Github Twitter Instagram Medium

License Version

Zero-configuration node library and CLI for building executables for all platforms and architectures.

Index

πŸ“– Description

Package your Node.js project into an executable that can be run even on devices without Node.js installed.

The construction of the binary allows compilation on arm and x64 architecture.

If you compile on an x64 system it will not create the binaries for arm, but if you compile on arm it will create the binaries for both architectures.

This library works thanks to ncc, pkg and esbuild, which facilitate this process.

Using binarium is simple and will work in most cases, but that may not be the case. If so, we recommend using other alternatives such as pkg.

πŸ”‘ Installation

npm install binarium
# or pnpm
pnpm add binarium
# or yarn
yarn add binarium

πŸ“ˆ usage

Node example

import { build } from 'binarium'

await build( {
 input  : 'src/cli.js', // JS or TS file
 name   : 'app-name', // default is input filename
} )

CLI example

binarium --input=src/server.js --name=app-name

Options

All of these options are available with the binarium command by adding the suffix -- and followed by an = and its value.

type BuilderParams = {
 /**
  * The app server input file.
  *
  * The input can be provided without an extension. 
  * If the extension is omitted, the system will automatically look for the following extensions: `.ts`, `.js`, `.mjs`, `.mts`.
  */
 input: string, 
 /**
  * Binary name.
  */
 name?: string,
 /**
  * Directory for the output build.
  *
  * @default './build'
  */
 outDir?: string, 
 /**
  * Build only binary for your current OS.
  *
  * @default false
  */
 onlyOs?: boolean
 /**
  * The build type Result [all|cjs|bin].
  *
  * @default 'all'
  */
 type?: 'all'|'cjs'|'bin'
  /**
  * Config file path.
  * 
  * @default undefined
  */
 config?: string
}

Config File

For more advanced configuration you can use a configuration file. Supported formats are: .mjs, .js, .json, .yml, .yaml, .toml, .tml.

In the configuration file you can define your build options and configure advanced options of the build itself using the options key.

The options configuration is only recommended for cases that require a more advanced configuration.

Example

binarium  --config=binarium.config.js
// binarium.config.js
import { defineConfig } from 'binarium'

export default defineConfig( {
 name    : 'my-app-name',
 onlyOs  : true,
 options : { esbuild: { tsconfig: './tsconfig.builder.json' } },
} )

πŸ‘¨β€πŸ’» Development

binarium is an open-source project and its development is open to anyone who wants to participate.

Issues Pull requests Read more

β˜• Donate

Help us to develop more interesting things.

Donate

πŸ“œ License

This software is licensed with GPL-3.0.

Read more

🐦 About us

PigeonPosse is a ✨ code development collective ✨ focused on creating practical and interesting tools that help developers and users enjoy a more agile and comfortable experience. Our projects cover various programming sectors and we do not have a thematic limitation in terms of projects.

More

Collaborators

Name Role GitHub
Angelo Angelo Author & Development @Angelo
PigeonPosse PigeonPosse Collective @PigeonPosse

Web About Us Donate Github Twitter Instagram Medium