Skip to content

Commit 7d82be1

Browse files
author
Mariusz Pasinski
committed
hack: apply workaround for "twisted" addon
Currently the addon cannot be resolved using the bare specifier, therefore this workaround makes it use an intermediate file "index.js" which would import the native addon.
1 parent 3481e82 commit 7d82be1

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const addon = require('bindings')('addon_twisted.node')
2+
3+
console.log('This should be eight:', addon.add(3, 5))

packages/node-addon-examples/examples/1-getting-started/2_function_arguments_twisted/napi/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"name": "@callstackincubator/example-3",
33
"version": "0.0.0",
44
"description": "Node.js Addons Example #2",
5-
"main": "./build/Release/addon_twisted.node",
5+
"main": "./index.js",
66
"private": true,
77
"dependencies": {
88
"bindings": "~1.5.0"
99
},
1010
"scripts": {
11-
"test": "node addon.js"
11+
"test": "node index.js"
1212
},
1313
"binary": {
1414
"napi_versions": [4]

packages/node-addon-examples/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ module.exports = {
55
"1_hello_world/node-addon-api-addon-class": () => require("./examples/1-getting-started/1_hello_world/node-addon-api-addon-class/hello.js"),
66
"2_function_arguments/napi": () => require("./examples/1-getting-started/2_function_arguments/napi/addon.js"),
77
"2_function_arguments/node-addon-api": () => require("./examples/1-getting-started/2_function_arguments/node-addon-api/addon.js"),
8-
"2_function_arguments_twisted/napi": () => require("@callstackincubator/example-3"),
8+
// "2_function_arguments_twisted/napi": () => require("@callstackincubator/example-3"),
9+
"2_function_arguments_twisted/napi": () => require("./examples/1-getting-started/2_function_arguments_twisted/napi/index.js"),
910
"3_callbacks/napi": () => require("./examples/1-getting-started/3_callbacks/napi/addon.js"),
1011
"3_callbacks/node-addon-api": () => require("./examples/1-getting-started/3_callbacks/node-addon-api/addon.js"),
1112
"4_object_factory/napi": () => require("./examples/1-getting-started/4_object_factory/napi/addon.js"),

0 commit comments

Comments
 (0)