rebuild icon indicating copy to clipboard operation
rebuild copied to clipboard

napi-rs prebuilds are not detected/downloaded using rebuild arch

Open tmm1 opened this issue 11 months ago • 2 comments

napi-rs uses a custom scheme for prebuilds:

The other problem is how to deliver prebuild binary to users. Downloading it in postinstall script is a common way that most packages do it right now. The problem with this solution is it introduced many other packages to download binary that has not been used by runtime codes. The other problem is some users may not easily download the binary from GitHub/CDN if they are behind a private network (But in most cases, they have a private NPM mirror).

In this package, we choose a better way to solve this problem. We release different npm packages for different platforms. And add it to optionalDependencies before releasing the Major package to npm.

NPM will choose which native package should download from registry automatically. You can see npm dir for details. And you can also run yarn add @napi-rs/package-template to see how it works.


currently @electron/rebuild has support for prebuildify-based layouts:

https://github.com/electron/rebuild/blob/7b18a69765c4ef27ae2b2988e0662c9104f185fd/src/module-type/prebuildify.ts#L33-L35

https://github.com/electron/rebuild/blob/7b18a69765c4ef27ae2b2988e0662c9104f185fd/src/module-type/prebuildify.ts#L42

could something similar be added for napi-rs?

tmm1 avatar Dec 21 '24 22:12 tmm1

PRs welcome. I dont see a problem adding support for these systems

MarshallOfSound avatar Dec 21 '24 23:12 MarshallOfSound

The @parcel/watcher package has a similar issue. That one doesn't use napi-rs, it actually uses prebuildify, but instead of publishing all the binaries in one package under the prebuilds folder they publish separate packages to npm registry

It seems like a more generic solution may be required to deal with split-npm-binary-packages which seem to be becoming more popular.

tmm1 avatar Dec 22 '24 03:12 tmm1