Перейти к содержимому

Эта страница ещё не переведена и показана на английском.

Elide for Bun users

Switching from Bun to Elide: what runs unchanged, which commands and APIs differ, benchmarks, strengths, weaknesses and the security model.

На этой странице

Elide runs the TypeScript, node:* modules and npm packages a Bun program uses; the Bun global is absent.

Run the same code

elide app.ts                    # or: elide run app.ts
elide install --ecosystems=npm  # dependencies from package.json
elide test                      # node:test files
  • TypeScript runs with no compile step and no tsconfig.json.
  • Built-ins load with or without the node: prefix.
  • A module that default-exports { fetch } serves when run, as in Bun.

See JavaScript and TypeScript, module status in the API Overview, and suite results in the Compatibility Matrix.

What changes

BunElide
bun app.tselide app.ts
bun installelide install --ecosystems=npm; plain elide install skips npm
bun.lockaube-lock.yaml
bun run buildelide run build
bunx toolelide run tool for a tool in node_modules/.bin; no download-and-run
bun test with expectelide test with node:test and node:assert; expect is unavailable
bun --inspect app.tselide run --debugger=cdp app.ts
bun --watch, bun --hotNo equivalent
.env loaded automaticallyCall process.loadEnvFile() in code
Bun.serve({ fetch })Elide.serve({ fetch })
bun:sqliteelide:sqlite; see SQLite
Bun.file, Bun.write, Bun.$node:fs and node:child_process
Web Workernode:worker_threads
bun build, bun build --compileNo equivalent

Benchmarks

Hello-world startup with hyperfine -N -w 10 -r 100 on a 24-core AMD Ryzen Threadripper PRO 9965WX Linux workstation:

RuntimeCommandMean
Bunbun hello.js1.63 ± 0.18 ms
Elideelide run hello.js1.43 ± 0.06 ms
Nodenode hello.js11.70 ± 0.90 ms
Denodeno run hello.js6.31 ± 0.30 ms

Hello-world serving with wrk -t12 -c256 -d10s --latency. Each server ran on the same 24 logical CPUs, wrk on 24 others.

RuntimeRequests/sp50 latencyp99 latency
Bun156,9741.60 ms1.80 ms
Elide635,5100.38 ms0.59 ms
Deno163,5111.54 ms1.58 ms

Each server used its defaults: Bun and Deno serve on one thread, Elide on several.

Versions, setup, and recordings: Benchmarks.

Strengths

  • elide serve --contexts=auto server.ts runs several copies of the app, sized from the CPU cores, on Linux.
  • Flags restrict filesystem, network and subprocess access and limit resources; see Security model.
  • The same binary runs WebAssembly, compiles and runs Java and Kotlin, and runs Python after elide setup python.

Weaknesses

  • Node-API compatibility is 86.8% and WinterTC 95.9% on their test suites.
  • node:http2, node:cluster, node:inspector and node:wasi throw ERR_UNKNOWN_BUILTIN_MODULE.
  • https.createServer throws ERR_HTTPS_SERVER_UNSUPPORTED, and there is no WebSocket global.
  • No macOS Intel build; macOS releases are Apple Silicon only.

Security model

Bun has no permission model. Elide allows everything too, until you pass a flag.

FlagEffect
--sandboxDeny filesystem access; network and subprocesses stay allowed.
--allow-read[=PATHS], --allow-write[=PATHS]Allow reads or writes, everywhere or at the listed paths.
--allow-net[=HOSTS]Allow network access, to every host or only the listed ones.
--allow-run[=CMDS]Allow subprocesses, any or only the listed commands.
--deny-net=HOSTS, --deny-run=CMDSDeny hosts or commands even when allowed.
--fs-auditLog each filesystem decision to stderr.
--limit=workers=N, --limit=fds=NLimit live workers and open node:fs handles.
--max-mem=SIZELimit the heap size.
--timeout=DURATIONStop the run after DURATION with exit 124.
elide --allow-read=. --allow-net=localhost --allow-run=git app.ts

A denied call names the flag to add:

TypeError: fetch to 'example.com:443' is not permitted; grant it with --allow-net=example.com

--sandbox=trusted is the only available profile. See Sandbox and Limits.

Next steps

Была ли эта страница полезной?