Compiling LevelDb into Bun #14051
Replies: 1 comment
-
I guess this was a stupid question. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary:
I'm wondering if the Leveldown js wrapper used by PouchDb could be replaced with a C API for LevelDb to compile PouchDb into a Bun project?
(Attn: @Jarred-Sumner )
Details:
It was just announced in a blog post by Jarred Sumner that Bun can compile and run C in JavaScript. It does this using a C compiler called "TinyCC."
Near the end of the blog post reads, "You probably don't want to use this to compile large C projects like PostgresSQL or SQLite. TinyCC compiles to decently performant C, but it won't do advanced optimizations that Clang or GCC does like autovectorization or very specialized CPU instructions."
Still, I'm wondering if Bun's use of TinyCC would stand a chance at solving the following problem: Getting PouchDb to work with Bun.
PouchDb can be run with Node, using LevelDb (C++) as a backend store. To do this, PouchDb relies on Leveldown, which, as I understand it, uses NAPI, an API for native addons. "Native addons usually rely on a "postinstall" script to compile N-API addons with node-gyp. node-gyp depends on Python 3 and a recent C++ compiler."
Because of this need for a node-gyp/postinstall step, building a Node standalone exe (using either
pkg
or node's single executable application becomes problematic: they both choke on the node-gyp steps.SO, I'm wondering if the Leveldown js wrapper used by PouchDb could be replaced with a C API for LevelDb to compile PouchDb into a Bun project?
For example, instead of this
Leveldown.js
file that bridges js and C++, i.e., a sort of js header for the library; instead of that, use Bun's new C import capability to import the C (wrapper) headers and compile it with TinyCC.(With a side benefit being probably a smaller, faster exe.)
Beta Was this translation helpful? Give feedback.
All reactions