@fermyon/wasi-ext
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

js-wasi-ext

This is a library compatible with WASI 0.2 that makes select Node.js APIs available in ComponentizeJS and StarlingMonkey.

Usage

This library currently requires Webpack and uses a plugin to define the fall backs.:

const WasiExtPlugin = require("wasi-ext/plugin")

module.exports = {
    ...
    plugins: [
        new WasiExtPlugin()
    ],
    ...
};

Note: this currently does not support the node:process syntax yet.

Because accessing environment variables needs to happen at runtime (not during pre-initialization), the actual environment variables can only be accessed from the handler function. If accessed outside, that is not supported (and currently, process.env returns an empty map; we can discuss what this behavior should be).

The library currently exports a setupExt() function that explicitly initializes process.env from the handler. We could potentially remove that depending on the desired experience of this library.

After setup:

import process from "process";

...
console.log(process.env["PET"]);

Supported APIs

  • process: certain methods are no-ops and few throw exceptions. For detailed list refer to the upstream library. process.env is only populated when inside the handler function, when outside, it returns an empty object (i.e) {}
  • fs: Limited to readFileSync and readdirSync

Readme

Keywords

none

Package Sidebar

Install

npm i @fermyon/wasi-ext

Weekly Downloads

0

Version

0.1.1

License

Apache-2.0

Unpacked Size

396 kB

Total Files

105

Last publish

Collaborators

  • karthik_ganeshram
  • flynnduism
  • technosophos
  • bacongobbler
  • radu-matei