node-re2 icon indicating copy to clipboard operation
node-re2 copied to clipboard

A port that doesn't rely on node-gyp?

Open ffMathy opened this issue 6 years ago • 13 comments

Node-gyp can be quite a pain to use on Windows.

Is it possible to make it node-gyp independent?

ffMathy avatar Apr 11 '18 11:04 ffMathy

I am open to suggestions, and working pull requests.

uhop avatar Apr 11 '18 16:04 uhop

It looks like this question is more properly addressed to Node developers. There is so-called N-API, which may be better suited for Windows. It is deemed "stable", but only in the latest versions of Node.

uhop avatar May 28 '18 03:05 uhop

Now with Node 6 is out of LTS we are closer to implement re2 with N-API. The doc still has quite a few sections marked "Experimental" (for example, "Life Cycle") yet we can start exploring.

uhop avatar Sep 08 '19 17:09 uhop

What the state here now, since node v10 is out of lts?

viceice avatar May 23 '20 14:05 viceice

Not started yet.

uhop avatar May 24 '20 00:05 uhop

We can just use Wasm. This way, it will always be supported in Node.js and browsers will support it too. https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm

Richienb avatar Aug 14 '20 18:08 Richienb

All good ideas. Just keep in mind:

  • The existing code uses the only bindings available at the time of creation: C++ with Nan using node-gyp.
  • N-API is a C bindings, which requires rewriting the binding code.
    • Let me stress: it is not a matter of "recompile and it just works".
  • WASM is used to run programs compiled from other languages to a specific target.
    • re2 is a component, a class, not a complete runnable program.
    • There are no bindings to interface JavaScript objects or impersonate them.

I was assured that the proper WASM bindings are coming, but so far I didn't see them even in the alpha stage. Given that the main driving force behind WASM were Mozilla guys, I worry that their efforts will be delayed significantly by the recent Mozilla reorg.

Required reading:

But I love to be proven wrong, and, as always, patches are welcome!

uhop avatar Aug 14 '20 21:08 uhop

Another thing to throw in the pile of possible ports: deno support. It is supposed to provide a way to add extensions based on Rust (another Mozilla technology) and it should support WebAssembly in some form. So far nothing was made public, but it is clearly coming at some point.

uhop avatar Aug 14 '20 22:08 uhop

Yet another thought: the original premise ("Node-gyp can be quite a pain to use on Windows") is more-or-less obsolete now. Starting with 1.14 re2 pre-builds binaries for multiple platforms including Mac and Windows. It is conceivable to use re2 on Windows without installing Python and the C++ toolchain.

It makes the Deno support more interesting for a simple reason: it is a completely unsupported platform, while other ways to support Node are largely irrelevant for end users — after setting it up once there is no difference how re2 was compiled.

uhop avatar Aug 14 '20 22:08 uhop

@uhop Rust WASM supports those things and C++ simultaneously.

Richienb avatar Aug 15 '20 06:08 Richienb

What things exactly? Component bindings? I would love to see how.

uhop avatar Aug 15 '20 06:08 uhop

@uhop Most of the re2 binding logic has already been done in https://github.com/nickdesaulniers/rust-re2. All we need to do is add type declarations. https://rustwasm.github.io/docs/wasm-bindgen/contributing/design/exporting-rust-struct.html?highlight=exporting,struct#exporting-a-struct-to-js

Richienb avatar Aug 15 '20 06:08 Richienb

It is nice to know that somebody took care of things for me. I will be cheering for that projects on sidelines.

uhop avatar Aug 15 '20 06:08 uhop

It looks like alternative ways to build a binary extensions are more mature now. Specifically WASM looks like an interesting option.

Closing this issues for two reasons:

  • There are alternative projects based on WASM.
  • All chrome code that bridges RE2 with JS should be rewritten, which requires a new project.

uhop avatar Dec 19 '22 02:12 uhop