brechtsanders / xlsxio

XLSX I/O - C library for reading and writing .xlsx files
MIT License
417 stars 112 forks source link

Support binding.gyp compilation for Node.js Addon Use #35

Open webern opened 6 years ago

webern commented 6 years ago

Sadly, Node.js does not use cmake for native code addons, instead it uses gyp and the equivilant of a CmakeLists.txt file is binding.gyp. Including a binding.gyp and testing its validity in continuous integration could boost popularity of the library.

brechtsanders commented 6 years ago

I'm not familiar with how C/C++ integrates with Node.js. Note however XLSX I/O also comes with a Makefile that you can run without CMake. DOesn't that work?

webern commented 6 years ago

I don't think so. It's a sad state of affairs, I wouldn't expect you to be the person to implement this.

brechtsanders commented 6 years ago

Can you help me understand how/why a C library like this can be used from Node.js? I though that was a JavaScript engine.

webern commented 6 years ago

This may help https://nodejs.org/api/addons.html

Typically in cases where JavaScript isn't performant enough, you can write C++ code and link it into Node.js like a plugin. Then you can call your native code from the JavaScript runtime and pass data into and receive data back from your native code.

In my case I couldn't find a JavaScript library that could handle the large sizes of my xlsx files. Maybe one exists, but we tried the most popular JS library and it was a memory explosion.

elominp commented 5 years ago

Hi everyone, If you're interested I started to write a N-API wrapper of this library here : https://github.com/elominp/jsxlsxio

It's doing the bare minimum, I still need to write a readme to document and mention your library and improve the binding.gyp to build cleanly, especially for Windows (on MacOS and Linux distributions it should already be ok but on Windows I'm building your library and it's dependencies manually instead of using your DLLs)