Node.js support

Although WasmEdge QuickJS already supports JavaScript ES6 and CJS modules, many existing apps simply use Node.js built-in APIs. Those APIs are provided by Node.js and do not have corresponding external JavaScript files to rollup into a bundle. In order to reuse existing Node.js apps, we are in the process of implementing many Node.JS APIs for WasmEdge QuickJS. The goal is to have Node.js programs running without change in WasmEdge QuickJS.

The progress of Node.js support in WasmEdge QuickJS is tracked in this issue.

There are two approaches for supporting Node.js APIs in WasmEdge QuickJS.

The JavaScript modules

Some Node.js functions can be implemented in pure JavaScript using the modules approach. For example,

  • The querystring functions just perform string manipulations.
  • The buffer functions manage and encode arrays and memory structures.
  • The encoding and http functions provide a Node.js fetch() API wrapper around JavaScript functions implemented in Rust.

The Rust internal modules

Other Node.js functions must be implemented in Rust using the internal_module approach. There are two reasons for that. First, some Node.js API functions are CPU intensive (e.g., encoding) and is most efficiently implemented in Rust. Second, some Node.js API functions require access to the underlying system (e.g., networking and file system) through native host functions.

Node.js compatibility support in WasmEdge QuickJS is a work in progress. It is a great way for new developers to get familiar with WasmEdge QuickJS. Join us!