@@ -17,11 +17,11 @@ To use **Node-API** in a native module:
17
17
18
18
1 . Add a dependency on this package to ` package.json ` :
19
19
20
- ``` json
21
- "dependencies" : {
22
- "node-addon-api" : " *" ,
23
- }
24
- ```
20
+ ``` json
21
+ "dependencies" : {
22
+ "node-addon-api" : " *" ,
23
+ }
24
+ ```
25
25
26
26
2 . Decide whether the package will enable C++ exceptions in the Node-API
27
27
wrapper, and reference this package as a dependency in `binding.gyp`.
@@ -32,51 +32,51 @@ To use **Node-API** in a native module:
32
32
33
33
To use without C++ exceptions, add the following to `binding.gyp`:
34
34
35
- ``` gyp
36
- ' dependencies' : [
37
- " <!(node -p \" require('node-addon-api').targets\" ):node_addon_api" ,
38
- ],
39
- ```
35
+ ```gyp
36
+ 'dependencies': [
37
+ " <!(node -p \" require('node-addon-api').targets\" ):node_addon_api" ,
38
+ ],
39
+ ```
40
40
41
41
To enable that capability, add an alternative dependency in `binding.gyp`:
42
42
43
- ``` gyp
44
- ' dependencies' : [
45
- " <!(node -p \" require('node-addon-api').targets\" ):node_addon_api_except" ,
46
- ],
47
- ```
48
-
49
- If you decide to use node-addon-api without C++ exceptions enabled, please
50
- consider enabling node-addon-api safe API type guards to ensure the proper
51
- exception handling pattern:
52
-
53
- ``` gyp
54
- ' dependencies' : [
55
- " <!(node -p \" require('node-addon-api').targets\" ):node_addon_api_maybe" ,
56
- ],
57
- ```
58
-
59
- 4 . If you would like your native addon to support OSX, please also add the
60
- following settings in the ` binding.gyp ` file:
61
-
62
- ``` gyp
63
- ' conditions' : [
64
- [' OS=="mac"' , {
65
- ' cflags+' : [' -fvisibility=hidden' ],
66
- ' xcode_settings' : {
67
- ' GCC_SYMBOLS_PRIVATE_EXTERN' : ' YES' , # -fvisibility=hidden
68
- }
69
- }]
70
- ]
71
- ```
72
-
73
- 5 . Include ` napi.h ` in the native module code.
43
+ ```gyp
44
+ 'dependencies': [
45
+ " <!(node -p \" require('node-addon-api').targets\" ):node_addon_api_except" ,
46
+ ],
47
+ ```
48
+
49
+ If you decide to use node-addon-api without C++ exceptions enabled, please
50
+ consider enabling node-addon-api safe API type guards to ensure the proper
51
+ exception handling pattern:
52
+
53
+ ```gyp
54
+ 'dependencies': [
55
+ " <!(node -p \" require('node-addon-api').targets\" ):node_addon_api_maybe" ,
56
+ ],
57
+ ```
58
+
59
+ 3 . If you would like your native addon to support OSX, please also add the
60
+ following settings in the `binding.gyp` file:
61
+
62
+ ```gyp
63
+ 'conditions': [
64
+ ['OS=="mac"', {
65
+ 'cflags+': ['-fvisibility=hidden' ],
66
+ 'xcode_settings': {
67
+ 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
68
+ }
69
+ }]
70
+ ]
71
+ ```
72
+
73
+ 4 . Include `napi.h` in the native module code.
74
74
To ensure only ABI-stable APIs are used, DO NOT include
75
75
`node.h`, `nan.h`, or `v8.h`.
76
76
77
- ``` C++
78
- #include " napi.h"
79
- ```
77
+ ```C++
78
+ #include "napi.h"
79
+ ```
80
80
81
81
At build time, the Node-API back-compat library code will be used only when the
82
82
targeted node version *does not* have Node-API built-in.
0 commit comments