nodejs / nodejs/node-gyp

Use `node-api-headers` package instead of full nodejs headers

Open
#2,736 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

nodejs/nan
Dominant language
Python
Stars
10.7k
Forks
1.9k
Avg merge
1d 4h
Merged PRs (30d)
5

Description

For modules built using NAN, they need the correct version of the nodejs/electron headers to build against.

For modules built using Node-API, they do not need the full headers and instead only need a small subset. That small subset is available as its own package on npm. https://github.com/nodejs/node-api-headers.

If node-gyp was to use node-api-headers for sourcing the node-api headers, that would provide some benefits:

  1. Some builds would be sped up as they wouldnt need to download the full headers. Perhaps node-api-headers could be bundled into node-gyp? Not sure how that would work when new versions are released.

  2. Some native modules are accidentally including headers that are not part of node-api and so do not follow the stability guarantees https://nodejs.org/api/n-api.html#implications-of-abi-stability. This is all too easy to do when porting code from NAN to Node-API.

It would be ideal if there was a way for modules to opt into using node-api-headers instead of the full headers, and it should be recommended in the docs for node-api based modules to enable this option.

Perhaps in the next major version it could be looked into enabling this automatically, but I dont know if that would be achievable or if it would break too many modules.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the node-api-headers package and node-gyp's current header-sourcing behavior. Clarify whether support should be opt-in or automatic, how it would coexist with full Node.js headers for NAN modules, and what documentation and validation would define completion.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs
Domain
build-system, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.