Skip to content

Commit 24e24b9

Browse files
committed
fix: compile for the node env
1 parent a143019 commit 24e24b9

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

CMakeLists.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,14 @@ if(ZMQ_WASM OR CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
100100
# export an indirect function table for napi-wasm
101101
add_link_options("--export-table")
102102

103-
add_compile_options("-fwasm-exceptions")
104-
105103
# Add WebAssembly-specific exports for napi-wasm
106104
add_link_options("SHELL:-s EXPORTED_FUNCTIONS=['_malloc','_free','_napi_register_wasm_v1']")
107105
add_link_options("SHELL:-s EXPORTED_RUNTIME_METHODS=['ccall','cwrap']")
108106
add_link_options("SHELL:-s ALLOW_MEMORY_GROWTH=1")
109-
110-
# Allow undefined symbols on Linux for runtime loading
107+
add_link_options("SHELL:-s ENVIRONMENT='node'")
111108
add_link_options("SHELL:-s ERROR_ON_UNDEFINED_SYMBOLS=0")
112-
add_link_options("SHELL:-Wl,--unresolved-symbols=ignore-all")
109+
add_link_options("SHELL:-s DISABLE_EXCEPTION_CATCHING=0")
110+
add_link_options("--no-entry")
113111
endif()
114112

115113
# Set MacOS deployment target
@@ -162,6 +160,7 @@ project_options(
162160
ENABLE_CACHE
163161
ENABLE_COMPILE_COMMANDS_SYMLINK
164162
${ENABLE_SANITIZER_UNDEFINED}
163+
ENABLE_INTERPROCEDURAL_OPTIMIZATION
165164
)
166165

167166
file(GLOB_RECURSE SOURCES "./src/*.cc" "./src/*.cpp")

examples/wasm/index.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ async function main() {
2424
const wasm = await getWasm()
2525

2626
const {instance} = await WebAssembly.instantiate(wasm, {
27-
env: napi,
27+
napi: napi,
28+
env: {} // The env imports will be provided by napi-wasm
2829
})
2930

3031
// Create an environment.

0 commit comments

Comments
 (0)