Thin wrapper over the ipk-loaded esbuild-wasm.

Synopsis

esbuild [options] <entry>

echo "code" | esbuild [options]

Description

Bundles or transforms JavaScript/TypeScript using whichever esbuild-wasm version is installed in the nearest node_modules via ipk (see man ipk). Local paths (./foo, /workspace/bar) read from the VFS. Bare specifiers (react, lodash/fp, ...) resolve from the nearest ipk-installed node_modules — there is no network fallback, so install missing deps first with ipk add <pkg>.

Modes

--bundle Bundle the entry and its imports into one output file.

--transform Single-file transform (default when --bundle is absent).

Output

--outfile <path> Write the bundled/transformed output to <path>.

--format=<iife|cjs|esm> Output format (default: esm).

--minify Enable all minification passes.

--sourcemap[=inline|external|linked|both] Emit source maps.

--target=<csv> Comma-separated target list (e.g. es2020,chrome100).

--loader=<loader> Force loader for stdin / single-file transform (js, ts, jsx, tsx, json, text, base64, dataurl).

Install

Inert until the backing package is installed:

$ ipk add esbuild-wasm

Then esbuild --version and the bundle/transform commands above work. There is no bundled binary and no CDN fallback.

Example — bundling a .jsh script that uses an npm dependency

This walks through making a .jsh script that depends on a small npm args-parser (mri) portable, so it runs without needing its own node_modules next to it.

$ mkdir -p /workspace/jsh-demo && cd /workspace/jsh-demo

$ ipk add mri

Installs mri into ./node_modules and records it in ./package.json.

$ cat > greet-src.jsh

const mri = require('mri');

const argv = mri(process.argv.slice(2), {
  boolean: ['shout'],
  alias: { n: 'name', s: 'shout' },
  default: { name: 'world' },
});

let msg = `Hello, ${argv.name}!`;
if (argv.shout) msg = msg.toUpperCase();
console.log(msg);

Write the source form. At this point greet-src already works as a shell command (per the .jsh auto-discovery rules in man jsh) as long as it stays next to its node_modules:

$ greet-src --name=Lars --shout

HELLO, LARS!

$ esbuild --bundle --format=esm --outfile=greet-bundled.jsh greet-src.jsh

Bundles mri's source directly into greet-bundled.jsh — no import resolution left at run time.

$ cp greet-bundled.jsh /anywhere/else/greet-bundled.jsh && cd /anywhere/else && greet-bundled --name=Isolated --shout

HELLO, ISOLATED! — runs correctly with no node_modules present, confirming the bundle is fully self-contained.

Notes

Bundling is the right move whenever a .jsh script needs to be copied somewhere else, shipped as part of a skill's scripts/ directory, or otherwise guaranteed to run without a sibling node_modules.jsh discovery (see man jsh) only cares about the file itself, so a bundled single-file script is the most portable form. For quick iteration in place, skip bundling and just require() the installed package directly; reach for esbuild --bundle once the script is ready to move or ship.

See Also

ipk, tsc, biome, jsh, node, commands