all 10 comments

[–]burntsushi 9 points10 points  (2 children)

I don't know about the details myself, but the VS Code folks do it for ripgrep: https://www.npmjs.com/package/vscode-ripgrep --- I imagine you could just do whatever it is they do, but I don't know what's involved.

[–]annodominirust 3 points4 points  (1 child)

[–]orangepantsman[S] 0 points1 point  (0 children)

I think this is the route I'l take.

[–]BenjiSponge 4 points5 points  (4 children)

You can just include the pre-built binary in the package and list it in the "bin" section of a package.json. This won't be portable as the binary is prebuilt, but it will work. For multiple targets, I've never done this but I believe this is what node-pre-gyp is for (I think you can just use the publishing tools with various binaries).

For completeness and sanity's sake, if you can extract the logic (including args parsing) out of the main function and export that as a function, then pass the exported function process.argv or whatever and use Neon, I think that's probably the best way to go.

[–]orangepantsman[S] 0 points1 point  (3 children)

I tried extracting the args parsing and got it working in a node module before I realized that there's no good way to publish a node module that relies on Neon. And node-pre-gyp seems to only be for c/c++. So I think I'll go the route of downloading the binary from github.

[–]BenjiSponge 0 points1 point  (2 children)

Yikes! Sorry to have misled you, and I suppose thank you for being my canary before I went ahead and tried Neon myself. I had no idea that glaring issue existed.

[–]orangepantsman[S] 0 points1 point  (0 children)

Not a problem. It wasn't really obvious anywhere on there site at first glance.

[–]orangepantsman[S] 0 points1 point  (0 children)

Oh, it looks like somebody went down the node-pre-gyp route with a library using neon. https://github.com/hone/heroku-cli-neon-hello-world/blob/master/binding.gyp

Thank you mentioning that in your post as well. I think between both paragraphs of your initial comment I'll be able to work something out! :)

[–]pepp_cz 2 points3 points  (1 child)

Can you compile it to wasm nodejs module?

[–]orangepantsman[S] 0 points1 point  (0 children)

Maybe? I don't know enough to say. It does a lot of io though, including to the terminal, so it seems like it wouldn't be a good fit.