I mean, can I publish that package standalone without javascript version of package/ traditional addon c++?
https://gist.github.com/gabrielschulhof/153edf2819362b8b50758d5ab4ff5e0e provides the skeleton for a N-API-based package which only uses plain C.
@gabrielschulhof thank you, this is what exactly I need in package.json:
"scripts": {
"install": "node-gyp rebuild"
}
And:
gypfile": true,
"dependencies": {
"node-addon-api": "^1.2.0"
}
Hmmm, weird - I didn't know you needed to have "install": "node-gyp rebuild" and "gypfile": true in your package.json. I thought npm behaved differently depending on whether a binding.gyp file was present.
I did not try yet, just a thaught how it must to be. I think by default npm builds a target if there is gyp file in the folder. Explicitly "gypfile": false brings npm to not to touch binding.gyp
And else one thing. One need to tag one's package with "n-api" .
npm publish --tag n-api
As is in
https://nodejs.org/en/docs/guides/publishing-napi-modules/
Hi @Globik you need to add the tag only if you have a pre-existent addon implemented with classic Node API or NAN and you want maintain both versions specially at beginning. So developers that use your addon can install new version implemented with N-API as reported below:
npm install your-addon@n-api
In the mean time if you install the addon without indicating the tag npm will install the previous version.
If you are implementing a new addon using N-API you don't need to tag it just publish as any other module.
@NickNaso hi, oh, thank you for your helpful info. Now I see how to be. it'sOK, just like any other module if it's a new addon. It's great. No need extra tags.
The n-api tag is also useful for existing addons. If you wish to release an experimental N-API version of your addon along with the classical V8 or Nan version, then you would use the tag. When you are ready to commit to N-API, you would publish a newer version of your addon without the tag, and that would continue the string of releases now with N-API.
@Globik anything more needed in this issue or can it be closed?
袨ne can close. The only wish: to add a link for sceleton somewhere in a readme docs or in a wiki. Thank you.
Most helpful comment
The
n-apitag is also useful for existing addons. If you wish to release an experimental N-API version of your addon along with the classical V8 or Nan version, then you would use the tag. When you are ready to commit to N-API, you would publish a newer version of your addon without the tag, and that would continue the string of releases now with N-API.