core icon indicating copy to clipboard operation
core copied to clipboard

Using Node.js' JS implementation

Open james-pre opened this issue 7 months ago • 2 comments

One of the consistent problems has been compatibility with the node:fs API. While ZenFS strives for 100% compatibility, maintaining and working towards that is a massive amount of work.

Node.js already has the JS implementation.

In the future, I think ZenFS would benefit from using the Node.js implementation, then emulating the C++ bindings. This means we could have complete Node.js compatibility while maintaining the same powerful features.

This also significantly reduces maintainer workload.

Community feedback is welcome!

james-pre avatar May 20 '25 00:05 james-pre

Postponing this because importing the Node.js implementation will definitly not be possible for a long time, see https://github.com/nodejs/node/issues/58523.

james-pre avatar Jun 24 '25 17:06 james-pre

then emulating the C++ bindings

I think of nothing but pain and suffering when I think node C++ bindings. So idk.

However, I do have a litte good news for you. Deno has a node compatibility layer here where they basically port every node API to ESM (typescript actually). I know because, coincidentally, to get ZenFS working with deno I ported node globSync's implementation to deno (which is now merged!). It might work for stuff like globSync, but for stuff like read/write its polyfilled to Deno APIs rather than C++ APIs so might not be all that useful. Probably would at least be a good reference point if you do try porting nodejs code.

jeff-hykin avatar Jul 11 '25 12:07 jeff-hykin