@assemblyscript/wasi-shim

中文文档
0.1.0发布于 2022/08/22Apache-2.0ES Module零依赖近 30 天下载 8551

Patches the AssemblyScript compiler to utilize WASI imports instead of Web APIs.

原始使用文档
文档目录4 节
  1. Supported features
  2. Usage
  3. Migrating from 0.20
  4. Considerations

WASI shim for AssemblyScript

Test status Publish status

Patches the AssemblyScript compiler to utilize WASI imports instead of Web APIs.

Note that this shim also serves a higher purpose, that is as an example of how to target any non-standard interface with the AssemblyScript compiler, including your own!

Supported features

See the assembly folder for the concrete implementations.

ComponentFunctionality
consoleassert, log, debug, info, warn, error, time, timeEnd
cryptogetRandomValues
datenow
internalabort, trace, seed
performancenow
processarch, platform, argv, env, exitCode, stdin¹, stdout¹, stderr¹, hrtime

¹ Limited/basic support

Usage

First, install the WASI shim alongside the AssemblyScript compiler:

npm install --save-dev @assemblyscript/wasi-shim

Afterwards, reference the provided configuration file in your builds.

Option 1: Command line

When invoking asc manually, add --config ./node_modules/@assemblyscript/wasi-shim/asconfig.json as a command line option.

Option 2: Config file

When using an asconfig.json for your project, extend the provided configuration file instead:

{
  "extends": "./node_modules/@assemblyscript/wasi-shim/asconfig.json",
  // ...
}

That's it. The AssemblyScript compiler now emits WASI-compatible modules. No more Web APIs!

Migrating from 0.20

Using this shim offers almost identical functionality to the former WASI support that was included with the AssemblyScript compiler up to version 0.20. The differences are:

  • The prior import "wasi" mechanism is no longer necessary and hence no longer supported.
  • The compiler does no longer try to detect if a module is a WASI command or reactor. By default, a command will be assumed. For a reactor, specify --exportStart _initialize. See the WASI documentation for differences.

Considerations

Since version 0.21, AssemblyScript considers WASI, derived proposals, the W3C's endorsement of its subgroup and the Bytecode Alliance's practices, that not all of their respective members necessarily are aware and/or approve of, harmful to open standards in general and the WebAssembly specification in particular.

The AssemblyScript project neither endorses nor officially supports any particular custom interface suitable to undermine purpose, goals and/or values of open Web standards. This package is nonetheless provided to our community for those who, given the subsequently established market situation, have no other choice than to use such interfaces or derived products. Regardless of the existence of this package, we explicitly welcome healthy competition in the rich design space of modern host interfaces. Specifically, we'd love to see (and use) a truly open host interface that keeps the Web in mind, i.e. adheres to WebAssembly's goals, while being portable, secure and efficient for many programming languages — including those that are a natural fit for the Web platform.

版本与发布记录

@assemblyscript/wasi-shim 共发布 2 个版本,首次发布于 2022/08/22;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.0latest2022/08/224 年前
0.0.02022/08/224 年前

关于 @assemblyscript/wasi-shim 的常见问题

@assemblyscript/wasi-shim 是什么?

Patches the AssemblyScript compiler to utilize WASI imports instead of Web APIs.

如何安装 @assemblyscript/wasi-shim?

在项目目录运行 npm install @assemblyscript/wasi-shim,或使用 pnpm add / yarn add / bun add。

@assemblyscript/wasi-shim 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/assemblyscript__wasi-shim 是否存在。

@assemblyscript/wasi-shim 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@assemblyscript/wasi-shim 可以商用吗?

@assemblyscript/wasi-shim 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@assemblyscript/wasi-shim 的下载量有多少?

根据 npm 官方下载统计,@assemblyscript/wasi-shim 在 2026/10/07 – 2026/11/05 这 30 天内被下载 8,551 次,日均约 285 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@assemblyscript/wasi-shim 还在维护吗?

最新版本 0.1.0 发布于 2022/08/22(4 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/08/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。