📈 usage
Below is a sample of the many ways to run binarium
.
📦 JS
Quickly compile your JS project into executables for all platforms and architectures
Automatically detects the JS runtime you are working in. Only accepts
node
,deno
,bun
import { build } from 'binarium'
await build( {
input : 'src/cli.js', // JS or TS file. You can add it without the extension
name : 'app-name', // default is input filename
} )
🟢 Node
Quickly compile your Node
project into executables for all platforms and architectures
import { buildNode } from 'binarium'
await buildNode( {
input : 'src/cli', // JS or TS file. You can add it without the extension
name : 'app-name', // default is input filename
} )
This function works thanks to ncc, pkg and esbuild, which facilitate this process.
Alternatively, if you are working in a node environment, you can do:
import { build } from 'binarium'
await build( {
input : 'src/cli', // JS or TS file. You can add it without the extension
name : 'app-name', // default is input filename
} )
🦕 Deno
Build Deno executables (deno compile
wrapper)
import { buildDeno } from 'binarium'
await buildDeno( {
input : 'src/cli', // JS or TS file. You can add it without the extension
name : 'app-name', // default is input filename
} )
🍞 Bun
Build Bun executables (bun build --compile
wrapper)
import { buildBun } from 'binarium'
await buildBun( {
input : 'src/cli', // JS or TS file. You can add it without the extension
name : 'app-name', // default is input filename
} )
💻 CLI
Use it from Cli.
binarium --input src/server.js --name app-name
binarium node --input src/node-server.js --name node-app-name
binarium deno --input src/deno-server.js --name deno-app-name
binarium bun --input src/bun-server.js --name bun-app-name
🛠️ With config file - advanced configuration
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 nodeOptions
|denoOptions
|bunOptions
key.
Node Example
binarium node --config binarium.config.js
// binarium.config.js
import { defineConfig } from 'binarium'
export default defineConfig( {
name : 'my-app-name',
onlyOs : true,
nodeOptions : { esbuild: { tsconfig: './tsconfig.builder.json' } },
} )
Deno Example
binarium deno -c binarium.config.js
// binarium.config.js
import { defineConfig } from 'binarium'
export default defineConfig( {
name : 'my-app-name',
onlyOs : true,
denoOptions : { flags: [ '--allow-all', '--no-npm' ] },
} )
Bun Example
binarium bun -c binarium.config.js
// binarium.config.js
import { defineConfig } from 'binarium'
export default defineConfig( {
name : 'my-app-name',
onlyOs : true,
bunOptions : { flags: [ '--packages external' ] },
} )