How holepunchto/bare works
Bare is an embeddable, modular JavaScript runtime for desktop and mobile. Its principal workflow is for an embedder or CLI user to start a process, load JavaScript modules, run or poll the event loop, and eventually tear down the process. Major runtime capabilities include CJS/ESM interoperability, native addons, lightweight threads, process context, and suspension/wakeup lifecycle controls. The README documents these capabilities; sampled source and the SOURCE INDEX support selected internal links, while unsampled call paths are omitted or marked unverified.
Main entry points: runtime.c Runtime and loop · addon.c Native addons · bare.js CJS / ESM modules · bare.h C embedding API
Components 16
Runtime entry
- Bare CLI
bin/bare.js - C embedding API
include/bare.h
Execution core
- Process setup
src/bare.c - Runtime and loop
src/runtime.c - JS engine
- Async event loop
- Suspend and wake
src/runtime.c
Modules and addons
- CJS / ESM modules
src/bare.js - File protocol
src/protocol.js - Native addons
src/addon.c - Addon API
src/addon.js - Module registration
include/bare/module.h
Threads and context
- Thread API
src/thread.js - Thread runtime
src/thread.c - Process context
src/context.c
Other components
- Embedder
Connections 19
- Embedder → C embedding API: configures process
README.md - Embedder → Bare CLI: starts runtime
- C embedding API → Process setup: sets up and loads
src/bare.c - Process setup → Runtime and loop: delegates runtime
- Runtime and loop → JS engine: executes JavaScript
README.md - Runtime and loop → Async event loop: drives I/O
README.md - CJS / ESM modules → File protocol: uses protocol
src/bare.js - CJS / ESM modules → Addon API: exposes addons
src/bare.js - CJS / ESM modules → Thread API: exposes threads
src/bare.js - File protocol → Native addons: resolves modules
- Addon API → Native addons: loads addons
- Native addons → Module registration: registers modules
include/bare/module.h - Thread API → Thread runtime: starts threads
README.md - Runtime and loop → Thread runtime: controls thread lifecycle
src/runtime.c - Runtime and loop → Native addons: tears down addons
src/runtime.c - Runtime and loop → Process context: tears down context
src/runtime.c - Process context → Native addons: checks addon seal and current process
src/context.c - C embedding API → Suspend and wake: requests lifecycle changes
README.md - Suspend and wake → Async event loop: blocks or resumes
README.md