websockets / bufferutil

WebSocket buffer utils
MIT License
140 stars 42 forks source link

Make use of N-API #104

Closed sindilevich closed 6 years ago

sindilevich commented 6 years ago

New versions of Node.js have intorduced a new API for native packages: N -API.

Currently, there is a burden of supporting different versions of bufferutil for every Node ABI x platform x 32/64 bitness.

On of the huge disadvantages of the current native packages, is the requirement to either setup a compiler environment on the target machine, or have an access to Internet for downloading the prebuilt package from GitHub.

Some developers, however, work in standalone environments due to corporate policies, making upgrading bufferutil a non-trivial process. Such environments may make use of a proxying private repository tools, such as Artifactory or Nexus. Those tools allow caching public repositories from npmjs.org to be used locally, but do not allow access to sites like GitHub.

With N-API, there should be possible to have only one version for all the platforms. Which, in turn, makes it possible to include the prebuilt binary with the package itself and publish it on npmjs.org. The proxying private repository tools would then cache the new version of the package, and allow that work in standalone environments, use bufferutil more easily.

lpinca commented 6 years ago

There is already a napi version of this module published on npm but unfortunately there are no prebuilt binaries for it. You can install it with

npm install bufferutil@n-api

I'm fine with merging that branch to master, drop support for Node.js 4, use https://github.com/mafintosh/prebuildify-ci and cut a new major version.

I'm not sure when I can work on this though.

sindilevich commented 6 years ago

@lpinca, thank you for your quick reply! It'll be great to start using binaries, developed against N-API. Especially in those kinds of standalone environments I have mentioned: https://github.com/websockets/bufferutil/issues/104#issue-333543646.

Will be waiting to grab it when you finally make it the default implementation.

lpinca commented 6 years ago

Version 4.0.0 uses N-API and has prebuilt binaries included in the npm package. There are no prebuilt binaries for Linux 32 bit but they could be added if wanted.

Will do the same with utf-8-validate when I can.

sindilevich commented 6 years ago

Works like a charm for me. Thank you!