UNPKG

nx

Version:

The core Nx plugin contains the core functionality of Nx like the project graph, nx commands and task orchestration.

33 lines (30 loc) 840 B
import { instantiateNapiModuleSync, MessageHandler, WASI } from '@napi-rs/wasm-runtime' const handler = new MessageHandler({ onLoad({ wasmModule, wasmMemory }) { const wasi = new WASI({ print: function () { // eslint-disable-next-line no-console console.log.apply(console, arguments) }, printErr: function() { // eslint-disable-next-line no-console console.error.apply(console, arguments) }, }) return instantiateNapiModuleSync(wasmModule, { childThread: true, wasi, overwriteImports(importObject) { importObject.env = { ...importObject.env, ...importObject.napi, ...importObject.emnapi, memory: wasmMemory, } }, }) }, }) globalThis.onmessage = function (e) { handler.handle(e) }