- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 33.7k
 
          src: include node_api_types.h instead of node_api.h in node.h
          #60496
        
          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
base: main
Are you sure you want to change the base?
  
    src: include node_api_types.h instead of node_api.h in node.h
  
  #60496
              Conversation
| 
           Review requested: 
  | 
    
| "Experimental features may be unstable." | ||
| #endif | ||
| #endif | ||
| 
               | 
          
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For context, this was moved because this file actually depends on these macros being applied, so previously there was an implicit requirement that js_native_api.h would need to be included prior to this file, either directly or indirectly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is not a semver-major change. I'm wondering if this can be split into a PR so that it can be backport-ed? Usually we don't mark node-api header changes as semver-major and node-api headers are sync-ed across LTS versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@legendecas Yup, that makes a ton of sense. Opened #60512 with the non-breaking changes to Node-API headers.
          Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@            Coverage Diff             @@
##             main   #60496      +/-   ##
==========================================
+ Coverage   88.54%   88.55%   +0.01%     
==========================================
  Files         704      704              
  Lines      207843   207843              
  Branches    40044    40041       -3     
==========================================
+ Hits       184028   184057      +29     
+ Misses      15858    15834      -24     
+ Partials     7957     7952       -5     
 🚀 New features to boost your workflow:
  | 
    
This means that `node.h` can include only this file, instead of the entirety of `node_api.h`. Split out from nodejs#60496 since it was rightfully pointed out that the breaking part of the change should not touch Node-API headers.
This means that `node.h` can include only this file, instead of the entirety of `node_api.h`. Split out from #60496 since it was rightfully pointed out that the breaking part of the change should not touch Node-API headers. PR-URL: #60512 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
| 
           Sorry for being late. This needs a rebase after #60512 landed.  | 
    
Including `node.h` should not result in all of Node-API also being available to callers. Users who want `node_api.h` contents should explicitly include that header. We currently include it specifically for `napi_addon_register_func`; by moving that into `node_api_types.h` and including that instead, we can reduce unintentionally included API surface a lot. Refs: nodejs#60345 (comment)
617271c    to
    73d929d      
    Compare
  
    | 
           @legendecas Yep, done! And no worries at all, your input here has been great.  | 
    
Edit: Split out #60512 from this PR and marking this PR as blocked on it
Including
node.hshould not result in all of Node-API also being available to callers. Users who wantnode_api.hcontents should explicitly include that header.We currently include it specifically for
napi_addon_register_func; by moving that intonode_api_types.hand including that instead, we can reduce unintentionally included API surface a lot.Refs: #60345 (comment)