bytecodealliance / bytecodealliance/ComponentizeJS

Supporting a 'wasm:' prefix on imports

未关闭
#297 23 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Rust
星标
391
派生
53
平均合并
3 天 5 小时
30 天内合并 PR
1

描述

Right now, code that uses imports via WASI look like regular imports, with the package name being the first indicator:

```js
import { someFn } from "ns:pkg/iface@0.1.0";

export const run = {
run() { ... }
}
```

This works, but I think going forward life for embedders and tooling/ecosystem projects will be *much* easier if we prefix these imports with `wasi:` (or something similar) to note them/control how the imports are done.

The idea is that the above code would turn into:

```js
import { someFn } from "wasi:ns:pkg/iface@0.1.0";

export const run = {
run() { ... }
}
```

There are other ways to indicate the type of an import/control (i.e. [import attributes](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import/with), for example) , but prefixing with `wasi:` is incredibly simple and offers a point of leverage -- being able to easily tell which imports are "wasi"/underlying paltform imports. This mirrors the convention of `node:` as an import prefix which is used in more modern code bases (i.e. `from "node:fs"` rather than `from "fs"`).

Changes may be required "below" *and* "above" componentize JS to make this work, but I figure that ComponentizeJS is a good place to discuss and eventually start this work.

[EDIT] I changed the title to `wasm` since `wasi` is clearly not the right prefix -- `wasm:`, `wit:`, `component:` or something else are clearly more correct, though it's not *exactly* clear which is best.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。