-
Notifications
You must be signed in to change notification settings - Fork 74
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
Prebuilds for Electron and Atom #61
Comments
Good question. I've been wanting to add some |
+1, though im curious how it would work at install time for the user. For example, if I publish a electron build to github releases for my module, when the user runs |
Last night I was thinking about it in terms of having a given electron app have the propery binary fetch as a postinstall step to go ahead and grab the right version for the electron version. If there's some other way to get that out of the At least with
I'd like the flow to be simpler than that and you're right. When a user |
Hmm yea I think the best way would be to use some special property in package.json that the process spawned by the install script can use to decide what binary to download. {
"name": "a-native-module",
"scripts": {
"install": "prebuild --download"
},
"dependencies": {
"prebuild": "^2.3.0"
},
"prebuild-runtime": "electron"
} Would that work? That way everything else with prebuild stays that same, but if |
I certainly like the Wait a second though, wouldn't that belong in the downstream package? The native package should be agnostic of the runtime, it's the user that has a hard requirement on electron vs. raw node. What about the |
I should be aded to the downstream package i guess. |
You could have a Does that make sense? :) |
Makes sense to me, and
|
Guys, any proposals here? |
small piece: how to get electron's abi version: echo "console.log(process.versions.node);process.exit(0)" > /tmp/echo.js && ./node_modules/electron-prebuilt/cli.js --require /tmp/echo.js |
Nice one! |
@juliangruber wouldn't it be more simple if we ask electron (or electron-prebuilt) developers to add some way to get version with one simple command instead? |
@havenchyk sure, but this works for now |
I'm just looking at this discussion now and wondering: where is the difference between Node.js and Electron that requires custom binary packages for Electron? |
So the problem is that with Electron, you have a different binary compatibility requirement, but installing a module for Electron involves using your system npm (rather than the one bundled with electron). One possibly solution would be to add a new command-line option |
It's a good idea, but there's a problem doing this during the
If |
good point about electron not yet being installed, buuuut i think the solution then is to just read the package.json and see which version is to be installed. another extra step of work this takes is managing a map between electron versions and their abi |
We could have a map for that, buuuut we could also parse out the abi version in the same way we parse it out from node's headers ;) |
If we can nail this during the |
At least for me, I'm going to be packaging releases anyway instead of relying on users to install dependencies themselves if that helps. I do like making the |
@ralphtheninja I started looking into this more, and I'm concerned that it may not be possible to 'safely' do it during the install step. I drew this conclusion by looking at all of the ways people use Electron, and from what I can tell there are all sorts of ways people set up their projects where you might not even be aware that they are about to attempt to use electron. For example, on windows you can download Electron to its own folder, build your whole project using Node.js and NPM, then run electron.exe to startup that app. This disconnect between the installation of an app, and the execution using electron creates a problem where we might not actually know even during postinstall... I think we may need to solve this either through collaboration with Electron, in terms of bringing their 'standard practice' to something more electron-specific, or change prebuild's behaviour. |
It does dawn on me now though, how does node-gyp know what ABI to build against when doing |
It doesn't, it just relies on the current node. node-pre-gyp takes a |
So what is the behaviour if I
So the 'typical behaviour' for Electron is to do |
That's the current state of affairs, yep! |
You get the ABI mismatch error at runtime. |
@brett19 Aye, this is a tough nut to crack and it will take time to get right, since as you say there are so many different ways to do this. Maybe we should try to reduce the amount of ways to do this to make it easier, like document properly and clearly state how you should do it to make it work. Another thing that struck me, what if an electron app A depends on module B, which in turn depends on native module C (say B depends on leveldown) so it indirectly depends on a native module the A has to take measures to make sure C downloads its prebuilts (ugh). Unless C can walk upwards to find the correct version of This becomes hairy fairly quickly :) |
That's actually the situation I'm in right now. We rely on |
Ok, cool. So we can basically assume that this is the case, or rather we can't assume at all that A depends on B which is a native module. We have to come up with an approach that solves this generic use case, regardless of module depth, if this is going to work well. |
So far, I've come to the thinking that 'enforcing' that a user specifies P.S. We should start packaging something with prebuild that allows people to 'import' their modules in their code. For instance, when I use my native binary, I do P.S.S. If we make |
The idea of passing a variable down the whole This also means that an Oh, another idea: Patch electron's What do you think about the EDIT: This can also be useful for regular node projects, when you switch node versions using a tool like nvm and need to recompile stuff. I'll start working on a POC |
@juliangruber We can use command line arguments as well with npm since npm also makes them into environment variables, which we catch here https://github.com/mafintosh/prebuild/blob/master/rc.js#L4-L17 |
Def interesting to explore! |
Adding this for reference Level/electron-demo#13 |
For a while, everything was awesome with Electron's ABI matching node 6 releases. Now that it's diverged quite a bit, if we want to stay updated we'll need to think back on this again. |
As I think on this again, I think we could first support
Then in userland for install they have to run Thoughts? |
🙇 thanks all! |
Prebuilding across the nodejs versions as listed in targets is super easy! Thanks!
How do I handle builds against the electron headers?
The text was updated successfully, but these errors were encountered: