Skip to content

Commit

Permalink
fix: make the native addon to be context-aware
Browse files Browse the repository at this point in the history
Since Electron 14, all native addons must be context-aware. Therefore,
in order to make node-tree-sitter run with Electron >= 14, it has to be
context-aware. Ref: electron/electron#18397

In this commit, NAN_MODULE_WORKER_ENABLED is used to make the native
addon context-aware. It will allow context as the third param but will
ignore it. This change doesn't mean that the addon will be safe
to be initialised multiple times so can be run on worker threads
though. Perhaps, someone with better understanding of the library need
to implement AddEnvironmentCleanupHook to clean up resources. Ref:
https://nodejs.org/api/addons.html#context-aware-addons
  • Loading branch information
Bong Nguyen committed Nov 15, 2022
1 parent 16f7319 commit 7a0883e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
4 changes: 1 addition & 3 deletions binding.gyp
Expand Up @@ -24,15 +24,13 @@
['OS == "mac"', {
'xcode_settings': {
'MACOSX_DEPLOYMENT_TARGET': '10.9',
'CLANG_CXX_LANGUAGE_STANDARD': 'c++17',
},
}]
],
"cflags": [
"-std=c++17",
],
'xcode_settings': {
'CLANG_CXX_LANGUAGE_STANDARD': 'c++17',
},
},
{
"target_name": "tree_sitter",
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "tree-sitter",
"version": "0.20.1",
"version": "0.20.2",
"description": "Incremental parsers for node",
"author": "Max Brunsfeld",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/binding.cc
Expand Up @@ -22,6 +22,6 @@ void InitAll(Local<Object> exports) {
TreeCursor::Init(exports);
}

NODE_MODULE(tree_sitter_runtime_binding, InitAll)
NAN_MODULE_WORKER_ENABLED(tree_sitter_runtime_binding, InitAll)

} // namespace node_tree_sitter

0 comments on commit 7a0883e

Please sign in to comment.