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

How can I tell electron-rebuild to ignore my library? #1055

Open
Julusian opened this issue Dec 8, 2022 · 4 comments
Open

How can I tell electron-rebuild to ignore my library? #1055

Julusian opened this issue Dec 8, 2022 · 4 comments

Comments

@Julusian
Copy link

Julusian commented Dec 8, 2022

I have some libraries which provide node-api prebuilds for all common platforms. This means that electron-rebuild should almost never need to rebuild my library.
Rebuilding it forces users to spend more time waiting for the rebuild to happen, and can require them to install some dependencies/tools for the rebuild to succeed. (In one, there is an optional tool that if available will produce a more performant binary).

So ultimately, the forced rebuild is hurting users, with little/no benefit.
Is there either:

  • A way I can mark my library as not needing to be rebuilt? Perhaps a flag I should be setting in the package.json?
  • A way that users can tell electron-rebuild to ignore my library? They could use --only to do this, but it would be much better to be able to ignore a specific dependency instead of having to name all but one explicitly
@MarshallOfSound
Copy link
Member

I think in general @electron/rebuild can be smarter around napi binaries. The problem is it's quite hardly to safely know if the native module is truly an napi module, I've seen some napi modules that still for whatever reason call nan or v8 methods directly 🙃

Do you have a ref to your module? Would probs help someone look into this with a "repro case"

@Julusian
Copy link
Author

Julusian commented Dec 8, 2022

Ideally I should be able to put something in my package.json which says 'Im node-api, trust me'. If I was to do that and still use nan or v8 or something, then its clearly a bug in my library.
But I am not sure if this will be good enough for platforms where I don't provide prebuilds, which could be an issue in some scenarios.

I think electron-builder approaches this by invoking the install script for the package (with some env variables set to tell it to run for another target), under the assumption that a library will need to use that script to ensure it has an appropriate binary.


This came out of https://github.com/Julusian/node-midi, from a user issue, which includes a reproduction https://github.com/navelpluisje/midi-electron-test.

On ubuntu/debian, building the module requires the libasound2-dev package to be installed.

Another example which I assume will also be rebuilt, (I haven't verified) is https://github.com/julusian/node-jpeg-turbo. Which uses a tool yasm to process some assembly as part of the compilation. If that tool was not found it will fallback to c implementations, costing performance.

@rosendolu
Copy link

I think in general @electron/rebuild can be smarter around napi binaries. The problem is it's quite hardly to safely know if the native module is truly an napi module, I've seen some napi modules that still for whatever reason call nan or v8 methods directly 🙃

Do you have a ref to your module? Would probs help someone look into this with a "repro case"

Yeah , such as level, It has prebuild binary, don`t need rebuild on pack;On my project , rebuild failed , Appreciate if you can take a look classic-level rebuild failed

@rosendolu
Copy link

I have some libraries which provide node-api prebuilds for all common platforms. This means that electron-rebuild should almost never need to rebuild my library. Rebuilding it forces users to spend more time waiting for the rebuild to happen, and can require them to install some dependencies/tools for the rebuild to succeed. (In one, there is an optional tool that if available will produce a more performant binary).

So ultimately, the forced rebuild is hurting users, with little/no benefit. Is there either:

  • A way I can mark my library as not needing to be rebuilt? Perhaps a flag I should be setting in the package.json?
  • A way that users can tell electron-rebuild to ignore my library? They could use --only to do this, but it would be much better to be able to ignore a specific dependency instead of having to name all but one explicitly

I checked the doc, maybe below can help. add below in forge.config.js

rebuildConfig: {
    onlyModules: [],
  },

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

3 participants