Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bun's Roadmap #159

Open
Jarred-Sumner opened this issue May 6, 2022 · 96 comments
Open

Bun's Roadmap #159

Jarred-Sumner opened this issue May 6, 2022 · 96 comments
Labels
tracking An umbrella issue for tracking big features

Comments

@Jarred-Sumner
Copy link
Collaborator

Jarred-Sumner commented May 6, 2022

this has not been updated post Bun 1.0, we will update it soon.

This tracks the current near-term plans for Bun.

Edge bundling

With bundle-time functions, static analysis goes dynamic. Objects returned by functions executed at bundle-time are injected into the AST. This makes dead-code elimination work a lot better.

I expect this to spawn a new generation of bundle-time JavaScript frameworks.

But first, a lot more needs to be built.

Main blockers

JavaScript minifier

  • Minify JavaScript identifier names
  • Compress JavaScript syntax (this is partially implemented)
  • Constant folding
  • Dead code elimination (this is partially implemented)
  • Read "sideEffects" from package.json

Web Bundler (production-focused, instead of development-focused)):

  • Tree-shaking
  • Source maps
    • Source maps for JavaScript (exists today without bundling)
    • Source maps for CSS
    • Input source maps
  • Code splitting (esm)
  • Link-time optimizations
    • const TypeScript enum support
    • cross-module inlining for bundle-time known objects
  • Optional concurrency. In the CI-scenario, it needs to work great in parallel and in the edge runtime scenario, it needs to work great potentially running single-threaded.
  • Multiple output formats
    • IIFE (immediately invoked function expressions)
    • CommonJS
    • ES Modules
  • Continue supporting Hot Module Reloading after these changes

CSS parser:

  • CSS Minifier
  • CSS Lexer
  • CSS Parser/AST
  • CSS Auto-prefixer
  • Bun.Transpiler support for CSS
  • Support for parsing css inside of JavaScript
    • <style jsx> support

Once complete, the next step is integration with the HTTP server and other Bun APIs

Efficient bundling format

Cache builds into a binary archive format with metadata designed for fast random access, splice(), and sendfile() support. Outside of the edge runtime, these will work as a single-file JavaScript executable internally holding many files.

Instances of Bun will need to know what bundle(s) they're serving. From there, instead of going through a filesystem, we can serve static requests directly from the bundle and dynamic requests will bundle on-demand, potentially importing code from statically-bundled code.

  • Bundle API (not finalized yet)

    • Bundle.prototype.resolve(path): string API
    • Bundle.prototype.build(entryPoint, context): Response API
    • Bundle.prototype.generate(entryPoints, options): Promise<Bundle> API
  • JSNode AST API

    • Receive context/env data from the HTTP server and/or Bundle
    • Support generated functions
    • Support generated classes
    • Support generated objects
    • Support injecting imports

Server-side rendering

  • Support Next.js (partial support right now)
  • Support Remix (partial support right now)
  • Support SvelteKit
  • Support Nuxt.js
  • Support Vite
  • Experiment with React-specific optimizations
    • Stringify static React elements into raw HTML at bundle-time, handling encoding and escaping correctly
  • Support a fast path for generating ETags
  • Integrate with Bundle, JSNode, and other Bun APIs

Runtime

  • Foreign function interface (FFI) to support loading native code
  • Module loader hooks to enable .vue, .svelte, .scss imports and more.
    • Implement esbuild's onLoad API in bun.js
    • Implement esbuild's onResolve API in bun.js
    • Support when building for bun.js
    • Support when building for web
    • A way to configure which hooks to load before bun starts, likely in bunfig.toml
    • onLoad plugins from native libraries
    • onResolve plugins from native libraries
  • Fastest SQLite client available in JavaScript
  • Fastest PostgreSQL client available in JavaScript
    • Explore a socket-based implementation
    • Explore a libpq-based implementation
  • Fastest MySQL client available in JavaScript
    • Explore a socket-based implementation
    • Explore a libmysqlclient-based implementation
  • TCP sockets API with TLS 1.3, likely based on uSockets
  • DNS resolution API, probably using c-ares
  • Support https: and http: imports. This includes a disk cache possibly integrated into the bundling format.
  • Support data: imports
  • Support blob: imports & URLs (URL.createObjectURL, URL.revokeObjectURL)
  • Reliably unload JavaScript VMs without memory leaks and without restarting bun's process
  • Rewrite the JavaScript event loop implementation to be more efficient

Edge Runtime

Slimmer, linux-only build of bun.js:

  • Only loads prebundled code
  • Design for starting as fast as possible
    • No tsconfig.json parsing
    • No package.json parsing
    • No bunfig.toml parsing
    • No node_module resolver
    • Use binary bundling format
    • Potentially disable NAPI and FFI
  • Spawn a new JSGlobalObject per HTTP request and suspend it after response is sent/fully queued
  • No bun install
  • No other subcommands

Usability & Developer Experience

  • High-quality examples for getting started with bun. Right now, the examples are poor quality.
  • bun REPL with transpiler-enabled support for async/await, typescript and ES Modules (those are not supported by eval usually)
  • Public docs
  • Public landing page
  • Public github repo
  • bun subcommand for running npm packages or URLs that may not already be installed. Like npx
  • GitHub Actions for bun
  • @types/bun npm package

Ecosystem

  • Run Next.js apps in production with bun.js
  • Run Remix apps in production with bun.js
  • Run SvelteKit apps in production with bun.js
  • Use Prisma, Apollo, etc with bun.js
  • more frameworks
  • Investigate running Vite inside bun.js
  • Support running Bun from StackBlitz

Web Compatibility

note: after a little testing, performance of safari's web streams implementation is similar to deno and much faster than node 18. I expect the final result to be faster than deno because bun's TextEncoder/TextDecoder & Blob implementation seems generally faster than safari's

Security

  • Verify TLS certificates in fetch. Right now, it doesn't.
  • Investigate supporting Content Security Policy (CSP) in bun.js
    • This would mean limiting which domains are accessible to the runtime based on the script execution context and how/where code is loaded into the runtime.
    • If we decide to support this, we likely can use WebKit's implementation for most of it.

Windows support

  • The HTTP client needs a Windows implementation for the syscalls
  • Bun needs test coverage for Windows filepath handling
  • All of bun's dependencies need to compile on Windows
  • Building JavaScriptCore needs to work on Windows and the JIT tiers need to work. I don't know what the current status of this is. WebKit's bug tracker suggests it may not have JITs enabled which will likely need some patches to fix it.

Node.js Compatibility

  • Node-API support
  • child_process support
  • non-blocking "fs"
  • "net" module
  • "crypto" polyfill should use hardware-accelerated crypto for better performance
  • Finish "buffer" implementation
  • require implementation that natively supports ESM (rather than via transpiler). This would involve subclassing AbstractModuleRecord in JSC. This would better support lazy-loading CommonJS modules.

Reliability

  • Better fetch implementation:
    • HTTP Keep-Alive
    • TLS 1.3 0-RTT
    • HTTP Pipelining
    • Cookie Jar
    • HTTP/3 (QUIC)
  • Run Web Platform tests
  • Run Test262
  • Support ActiveDOMObject from WebKit so that all native objects can be suspended & terminated

Misc

@RnbWd
Copy link

RnbWd commented Jul 7, 2022

this seems like a lot of work... wow

@space7panda
Copy link

Can't wait for full npm-like config support. We are using our own npm registry, and the current build time is 40-60 minutes. If it will be at least 10 minutes this will be a game-changer!

@officialrajdeepsingh
Copy link

I am waiting for the stable version of the bun. What change bun in the javascript world.

@tipiirai
Copy link

Also waiting for the stable version. So exciting! I bet it's going to take a lot of time though. The scope of this project is much larger than what Node attempts to solve.

@matepaiva
Copy link

can someone confirm that right now I can't use the package mysql2? It throws me an error because it depends on TLS package and on NET package, and I think they were not implemented yet in Bun, but I am not sure.

@Kapsonfire-DE
Copy link
Contributor

still missing websocket server support

@GCSBOSS
Copy link

GCSBOSS commented Jul 12, 2022

Can a tinitiny docker image be placed somewhere in there? 👀

@MystPi
Copy link

MystPi commented Jul 14, 2022

Can't wait for Windows support... I'll be anxiously awaiting it until it's out. 😅

@JacobStraberg
Copy link

still missing websocket server support

Dito

@sodeprecated
Copy link

Are you planning to support http2?

@moderation
Copy link

Are you planning to support http2?

HTTP/3 is on #159 so I would say HTTP/2 will likely be added before that

@sodeprecated
Copy link

Are you planning to support http2?

HTTP/3 is on #159 so I would say HTTP/2 will likely be added before that

I would say that http3 on roadmap is more about quic protocol and there is no straight inheritance between http3 and http2, so maybe support of http2 needs to be marked explicitly.

@frodoe7
Copy link

frodoe7 commented Jul 19, 2022

Motivated to see a stable version ASAP

@LaurelineP
Copy link

Promising !
Any roadmap on a progressive translation ?

@Parvat-R
Copy link

When is the support for windows coming? Cant wait for it.

@jacoscaz
Copy link

I would say that http3 on roadmap is more about quic protocol and there is no straight inheritance between http3 and http2, so maybe support of http2 needs to be marked explicitly.

Another vote for HTTP/2 as it's a prerequisite to gRPC support.

@DetachHead DetachHead mentioned this issue Aug 1, 2022
@dyaskur
Copy link

dyaskur commented Aug 4, 2022

Any plans to create a desktop app like electron?

@xHyroM
Copy link
Collaborator

xHyroM commented Aug 4, 2022

When is the support for windows coming? Cant wait for it.

#43 you can use WSL for now

@wakaztahir
Copy link

SolidJS uses JSX, Bun could support that...

@aralroca
Copy link
Contributor

aralroca commented Dec 4, 2023

SolidJS uses JSX, Bun could support that...

Is already supported

@CraigglesO
Copy link

this has not been updated post Bun 1.0, we will update it soon.

Considering I use this page as a way to keep up with Bun progress, would be nice if this issue got more attention from the main team.

@Ganitzsh
Copy link

Any plans around http2 server implementation? There are no updates about that in the main thread so I figured I'd check the roadmap but it does not mention anything.

@fralps
Copy link

fralps commented Jan 4, 2024

Any plans about official Bun Github Action Verified Creator?

@clare0987
Copy link

cluster, http2 🤔

@xHyroM
Copy link
Collaborator

xHyroM commented Jan 11, 2024

Any plans about official Bun Github Action Verified Creator?

oven-sh/setup-bun#25

@guest271314
Copy link
Contributor

Import maps https://github.com/WICG/import-maps

@gwleuverink
Copy link

Hi! is there any movement on the css loading front?

@RobinKnipe
Copy link

I've just tried to run storybook through bun, but it looks like node:zlib equivalent isn't available:

$ bunx --bun storybook dev
error: zlib.createBrotliDecompress is not implemented
      at node:zlib:2269:65
      at node_modules/@storybook/core-server/dist/presets/common-preset.js:12:32306
      at node:http:887:29

Will this be part of this roadmap at some point?

@hedaukartik
Copy link

When can we have CSS/SCSS parser feature?

@aralroca
Copy link
Contributor

When can we have CSS/SCSS parser feature?

Looking forward to the CSS parser too

@zx8086
Copy link

zx8086 commented Mar 15, 2024

I would say that http3 on roadmap is more about quic protocol and there is no straight inheritance between http3 and http2, so maybe support of http2 needs to be marked explicitly.

Another vote for HTTP/2 as it's a prerequisite to gRPC support.

Bump... really need this, game changer

@d4mr
Copy link

d4mr commented Mar 17, 2024

based on @Jarred-Sumner's answer here, where does Telemetry fit into the current roadmap?

@Confucian-e
Copy link

Please Fix this Bug ASAP
#5856

@yorunoken
Copy link

Please Fix this Bug ASAP #5856

Jarred has already said the bug will be fixed a little bit after v1.1 is finished. The development team is currently working on the Windows release.

@lsnow99
Copy link

lsnow99 commented Apr 1, 2024

Would love to help support work on #2704 as part of the Developer Experience roadmap

@TechKamleshSingh
Copy link

Thanks, #Bun for being a fast and easy-to-use JavaScript runtime! I appreciate your speed and compatibility with existing Node.js projects.

@olawalejuwonm
Copy link

olawalejuwonm commented Apr 7, 2024 via email

@Exitium-DEV
Copy link

+1 for TextDecoderStream
AuthJS relies on this and will be out soon (successor to NextAuth)

 ⨯ error: Attempt to export a nullable value for "TextDecoderStream"
      at defineProperties (file:///workspaces/dev-1/dashboard/node_modules/next/dist/compiled/edge-runtime/index.js:1:1)
      at addPrimitives (file:///workspaces/dev-1/dashboard/node_modules/next/dist/compiled/edge-runtime/index.js:13902:25)
      at extend (file:///workspaces/dev-1/dashboard/node_modules/next/dist/compiled/edge-runtime/index.js:13854:113)
      at new VM (file:///workspaces/dev-1/dashboard/node_modules/next/dist/compiled/edge-runtime/index.js:13946:88)
      at new EdgeVM (file:///workspaces/dev-1/dashboard/node_modules/next/dist/compiled/edge-runtime/index.js:13854:16)
      at file:///workspaces/dev-1/dashboard/node_modules/next/dist/server/web/sandbox/context.js:102:163

@001123
Copy link

001123 commented May 2, 2024

Is NextJS fully supported?
I test on my project it work well

@cotwitch
Copy link

cotwitch commented May 2, 2024

@001123 Do you use "Pages Router" or "App Router" ?

https://bun.sh/guides/ecosystem/nextjs

@001123
Copy link

001123 commented May 2, 2024

@001123 Do you use "Pages Router" or "App Router" ?

https://bun.sh/guides/ecosystem/nextjs

I'm just test on "Pages router"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tracking An umbrella issue for tracking big features
Projects
None yet
Development

No branches or pull requests