Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub fn build(b: *std.Build) void {
.linkage = .dynamic,
});

lib_example.linker_allow_shlib_undefined = true;
const install_lib_example = b.addInstallArtifact(lib_example, .{
.dest_sub_path = "example.node",
});
Expand All @@ -40,7 +41,7 @@ pub fn build(b: *std.Build) void {
const test_napi = b.addTest(.{
.name = "napi",
.root_module = module_napi,
.filters = &[_][]const u8{},
.filters = b.option([][]const u8, "napi.filters", "napi test filters") orelse &[_][]const u8{},
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this change was made from using a newer version of zbuild (same for below)

});
const install_test_napi = b.addInstallArtifact(test_napi, .{});
const tls_install_test_napi = b.step("build-test:napi", "Install the napi test");
Expand All @@ -54,7 +55,7 @@ pub fn build(b: *std.Build) void {
const test_example = b.addTest(.{
.name = "example",
.root_module = module_example,
.filters = &[_][]const u8{},
.filters = b.option([][]const u8, "example.filters", "example test filters") orelse &[_][]const u8{},
});
const install_test_example = b.addInstallArtifact(test_example, .{});
const tls_install_test_example = b.step("build-test:example", "Install the example test");
Expand Down
5 changes: 4 additions & 1 deletion example/test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const example = require('../zig-out/lib/example.node');

console.log(example.add(1, 2));
console.log(example.surprise());
console.log(example.surprise());
1 change: 1 addition & 0 deletions zbuild.zon
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
.imports = .{.napi},
},
.linkage = .dynamic,
.linker_allow_shlib_undefined = true,
.dest_sub_path = "example.node",
},
},
Expand Down