-
Notifications
You must be signed in to change notification settings - Fork 178
Description
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:
rebuild/src/module-type/prebuildify.ts
Lines 33 to 35 in 7b18a69
export class Prebuildify extends NativeModule { | |
async usesTool(): Promise<boolean> { | |
const packageName = await this.findPackageInDependencies('prebuildify', 'devDependencies'); |
rebuild/src/module-type/prebuildify.ts
Line 42 in 7b18a69
const prebuildsDir = path.join(this.modulePath, 'prebuilds'); |
could something similar be added for napi-rs?