-
Notifications
You must be signed in to change notification settings - Fork 8
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
Devise a migration plan for native addons #4
Comments
I'll throw a wild idea here, but could we move to something like https://github.com/cmake-js/cmake-js for addons before migrating Node.js to the next thing? Having the native addons build toolchain decoupled from core has the advantage that we can replace things in core if necessary without breaking the ecosystem. |
Sure, at least we could recommend so -- the challenge will be getting buy in from the ecosystem. Also if someone has time to work on nodejs/node-gyp#1118 we can break node-gyp's dependence on core and allow migrating core and addons to occur on independent timeframes. |
There's absolutely nothing stopping module authors today from using something other than node-gyp (e.g. https://github.com/cmake-js/cmake-js) to build their addons -- the reason to pick node-gyp is that's what (almost) every other addon is using and npm (and yarn?) bundle node-gyp and autotmatically run it. Maybe a plan for addons could be:
We'd still need some sort of strategy for the vast number of existing modules out there that use node-gyp, some of which are no longer maintained. Unfortunately not being maintained doesn't mean they're not being used. |
Right, we would need to deprecate gyp and provide tooling for folks to migrate to new shiny thing. It won't be painless (no migration will), but it's a start.
I thought Node.js bundled it and npm/yarn would just use the Node.js gyp package. I defenitely will need to learn more on how this happens.
Right, having gyp out of tree might help with that as it'll be possible for consumers to install it via npm. |
No, for addons npm bundles node-gyp (which bundles its own copy of gyp) and we vendor-in npm (I don't know what yarn currently does but at one point it was attempting to locate the node-gyp that was bundled with npm). Addons don't see the copy of gyp we vendor into tools to build core. The whole gyp-next (i.e. the new upstream for gyp) came about because the versions of gyp in core and in node-gyp got out of step and we found it difficult syncing changes for things like the Python 3 enablement and fixes for Catalina. I'll reiterate for anyone not familiar that we have node-gyp, which is a JavaScript/Node.js wrapper around gyp/gyp-next (which it bundles) and gyp-next, which is the fork of (the unmaintained) gyp project written in Python. |
So any attempt to migrate out of gyp will need to be coordinated with npm and possibly other package managers 🤔 |
Here is the high-level current hook for the NPM side https://docs.npmjs.com/misc/scripts#default-values |
Oh, and it would be nice to sketch out some things like nodejs/node#30139 |
Thanks for the link. The idea is to deprecate and eventually discontinue gyp altogether, so we still would need to work with npm (and any other package manager that bundles gyp) to remove gyp from there.
IMO this is out of scope for this initiative, but if someone has the time and energy to work on it I won't object. |
It depends on what we do in terms of toolchain for Node.js core, but given that cmake is already an option for native addons at least for those using N-API, cmake would be a good option if that aligns with what core does. |
I think I think folks can start using that right away, although I don't think that whatever is used to build Node has any impact on what addon authors need to use. (So this issue can be thought of as a totally separate question from "How to build Node," as far as I can tell.) I see this issue as being a "get the word out"/documentation-only issue, short of the integration with package managers, and perhaps coordinating when/how to responsibly deprecate I foresee P.S. as a matter of smoothing out/reducing user pain points switching to |
node-gyp is able to bundle gyp as gyp is written in Python and doesn't need to be compiled for different platforms/architectures. You do, however, need Python installed. |
Okay, bundling Back to the main topic at hand: Most of my comment above was restating things from earlier in the thread, but I hoped to highlight which things are actionable. (Basically honing in on "how to make using |
For helping native addons stop depending on
|
Many popular native addons ship prebuilt binaries, which can help migration because it means a smaller percentage of end users (that e.g. use a platform for which no prebuilt binaries are available) actually need a build toolchain. Two years ago I collected data from the npm registry (to see which tools are used, how many native addons ship prebuilds, etc). When I get a chance I will dust that off and share updated data here. |
I think the next step is to talk with npm about decoupling node-gyp from there (I opened #10 with one option but I believe there are other strategies we could adopt). I'll see if we can get some npm engagement here.
FWIW I disagree with this statement, even thought |
Correction: doesn't help much because the majority of packages does not use prebuilt binaries. Take the following with a grain of salt (needs a second pass to cleanup data) but of 991 npm packages:
For more, see |
Edit: I see you do separate out the custom versions |
Native addons will be eventually affected by this change, therefore we need to devise a migration plan, including expected timelines and preferably migration tooling.
The text was updated successfully, but these errors were encountered: