-
Notifications
You must be signed in to change notification settings - Fork 360
Description
Feature Overview
Feature Request: Add Support for Bun.js Runtime
Issue Type: Feature RequestRelevant Components: Runtime Support, JavaScript/Node.js Module
Summary
I would like to propose adding official support for Bun.js – a fast all-in-one JavaScript runtime built on top of JavaScriptCore – to Nginx Unit. Bun offers significant performance improvements and unique features that align well with Unit's goals of efficiency and seamless integration with modern web stacks.
Benefits of Bun.js Integration
- Performance Boost
-
Bun is 4x faster than Node.js for I/O-bound operations and up to 3x faster for CPU-bound tasks (source: Bun official benchmarks).
-
Native support for HTTP/3, WebSockets, and file system operations reduces latency.
- Simplified Ecosystem
-
Bun includes a bundler, test runner, and package manager out-of-the-box, eliminating the need for multiple tools.
-
Native support for TypeScript, JSX, and ES modules without additional configuration.
- Compatibility
- Bun is largely compatible with Node.js APIs and npm packages, making migration straightforward for existing applications.
- Alignment with Unit's Goals
- Bun's focus on speed and minimal overhead complements Unit's architecture, enabling faster request handling and lower resource usage.
Implementation Considerations
-
Runtime DetectionUnit could detect Bun.js via its unique process signature (
bun
instead ofnode
). -
Configuration ChangesMinimal changes would likely be needed to support Bun, as it shares many APIs with Node.js. However, specific settings for Bun's runtime (e.g.,
bun run
vs.node
) may need to be added. -
Example ConfigurationA sample Unit configuration for a Bun.js application might look like:
{
"listeners": {
"*:3000": {
"application": "bun-app"
}
},
"applications": {
"bun-app": {
"type": "javascript",
"processes": 4,
"executable": "bun", // Specify Bun runtime
"working_directory": "/path/to/app",
"script": "index.js"
}
}
}
Use Cases
-
High-performance Node.js/Bun.js applications requiring low latency.
-
Modern JavaScript frameworks (Next.js, Nuxt, etc.) that can leverage Bun's speed.
-
Microservices and APIs where every millisecond matters.
Community Interest
The Bun.js community is rapidly growing, with over 78k GitHub stars and increasing adoption in production environments. Adding support would attract developers exploring alternatives to Node.js and position Unit as a forward-looking runtime platform.
Proposed Next Steps
-
Feasibility Assessment: Determine if Bun.js can be supported with minimal changes to Unit's existing Node.js module.
-
Proof of Concept: A community-contributed PR or guide for running Bun.js apps on Unit could validate the approach.
-
Documentation: Update Unit's docs to include Bun.js support if implemented.
Additional Information
-
Bun.js Documentation: https://bun.sh/docs
-
Node.js Compatibility: https://bun.sh/docs/runtime/nodejs-apis
Some Framework for Bun
-
Elysia.js - Ergonomic Framework for Humans: https://github.com/elysiajs/elysia
-
Hono.js - Web framework built on Web Standards: https://github.com/honojs/hono
Would the maintainers be open to discussing this feature? I'd be happy to contribute to testing or documentation if needed.
Thank you for considering this request!
Best regards
Alternatives Considered
No response
Additional Context
No response