Skip to content

Commit

Permalink
Add a guard for Node.js
Browse files Browse the repository at this point in the history
This reverts commit e1b21a0.
  • Loading branch information
kleisauke committed Nov 14, 2022
1 parent e1b21a0 commit f68b323
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/library_wasm_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ mergeInto(LibraryManager.library, {
// Executes a wasm function call received via a postMessage.
_wasm_worker_runPostMessage: function(e) {
// Node.js passes the data directly.
let data = e.data || e, wasmCall = data['_wsc']; // '_wsc' is short for 'wasm call', trying to use an identifier name that will never conflict with user code
let data = e.data
#if ENVIRONMENT_MAY_BE_NODE
|| e
#endif
, wasmCall = data['_wsc']; // '_wsc' is short for 'wasm call', trying to use an identifier name that will never conflict with user code
wasmCall && getWasmTableEntry(wasmCall)(...data['x']);
},

Expand Down
2 changes: 1 addition & 1 deletion test/code_size/hello_wasm_worker_wasm.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function l(a) {
}

function n(a) {
a = a.data || a;
a = a.data;
let d = a._wsc;
d && f.get(d)(...a.x);
}
Expand Down
8 changes: 4 additions & 4 deletions test/code_size/hello_wasm_worker_wasm.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"a.html": 737,
"a.html.gz": 433,
"a.js": 736,
"a.js.gz": 465,
"a.js": 733,
"a.js.gz": 463,
"a.wasm": 1805,
"a.wasm.gz": 1002,
"total": 3278,
"total_gz": 1900
"total": 3275,
"total_gz": 1898
}

0 comments on commit f68b323

Please sign in to comment.