Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tmm1 opened this issue Dec 21, 2024 · 2 comments
Open

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

tmm1 opened this issue Dec 21, 2024 · 2 comments

Comments

@tmm1
Copy link

tmm1 commented Dec 21, 2024

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:

export class Prebuildify extends NativeModule {
async usesTool(): Promise<boolean> {
const packageName = await this.findPackageInDependencies('prebuildify', 'devDependencies');

const prebuildsDir = path.join(this.modulePath, 'prebuilds');

could something similar be added for napi-rs?

@MarshallOfSound
Copy link
Member

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

@tmm1
Copy link
Author

tmm1 commented Dec 22, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants