diff --git a/CMakeLists.txt b/CMakeLists.txt index cf7293e..88bd9b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.25) find_package(cmake-bare REQUIRED PATHS node_modules/cmake-bare) +find_package(cmake-napi REQUIRED PATHS node_modules/cmake-napi) +find_package(cmake-npm REQUIRED PATHS node_modules/cmake-npm) project(bare_module_lexer C) @@ -11,3 +13,19 @@ target_sources( PRIVATE binding.c ) + +add_napi_module(bare_module_lexer_napi) + +target_sources( + ${bare_module_lexer_napi} + PRIVATE + binding.c +) + +resolve_node_module(bare-compat-napi compat) + +target_include_directories( + ${bare_module_lexer_napi} + PRIVATE + "${compat}/include" +) diff --git a/binding.js b/binding.js index cea4630..0990543 100644 --- a/binding.js +++ b/binding.js @@ -1 +1 @@ -module.exports = require.addon() +module.exports = require('require-addon')('.', __filename) diff --git a/lex.h b/lex.h index ade9695..a2f52f0 100644 --- a/lex.h +++ b/lex.h @@ -164,7 +164,7 @@ bare_module_lexer__lex (js_env_t *env, js_value_t *imports, js_value_t *exports, uint32_t nl; // Names count // Current character, unchecked -#define u(offset) (s[i + offset]) +#define u(offset) ((uint8_t) s[i + offset]) // Current character, checked #define c(offset) (i + offset < n ? u(offset) : -1) diff --git a/package.json b/package.json index 9b02a24..66f29c1 100644 --- a/package.json +++ b/package.json @@ -28,9 +28,15 @@ "url": "https://github.com/holepunchto/bare-module-lexer/issues" }, "homepage": "https://github.com/holepunchto/bare-module-lexer#readme", + "dependencies": { + "require-addon": "^1.0.2" + }, "devDependencies": { + "bare-compat-napi": "^1.0.0", "brittle": "^3.1.1", "cmake-bare": "^1.1.7", + "cmake-napi": "^1.0.5", + "cmake-npm": "^1.0.2", "standard": "^17.0.0" } }