You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Preview 1 refers to [the first iteration of the Component Model](https://github.com/WebAssembly/WASI/tree/main/legacy)
83
+
which was based on WITX and is now deprecated.
84
+
Preview 2 refers to [a newer iteration of the Component Model](https://github.com/WebAssembly/WASI/tree/main/wasip2)
85
+
which uses WebAssembly Interface Types (WIT).
83
86
84
-
Many programming language toolchains may only support Preview 1 components natively, but this isn't a problem
85
-
in practice as Preview 1 components can be *adapted* into Preview 2 components automatically.
87
+
Many programming language toolchains may only support Preview 1 components natively,
88
+
but this isn't a problem in practice as Preview 1 components can be *adapted* into Preview 2 components automatically.
86
89
87
-
While somewhat confusing a WASI Preview 1 "component" is in fact a *WebAssembly core module*. More precisely, a
88
-
Preview 1 "component" is a WebAssembly core module with a well-defined set of imports and exports ([legacy specification][wasi-p1]).
90
+
While somewhat confusing, a WASI Preview 1 "component" is in fact a *WebAssembly core module*.
91
+
More precisely, a Preview 1 "component" is a WebAssembly core module with a well-defined set of imports and exports ([legacy specification][wasi-p1]).
89
92
90
93
## Q: What are component imports?
91
94
92
-
WebAssembly components are self-describing -- information about required external functionality (which must be provided by the platform or another component) is included in the binary.
93
-
For example, a WebAssembly component that may require some use of outside environment variables may *import* a WASI interface like `wasi:cli/environment`.
95
+
WebAssembly components are self-describing: information about required external functionality
96
+
(which must be provided by the platform or another component) is included in the binary.
97
+
For example, a WebAssembly component that may require outside environment variables may *import*
98
+
a WASI interface like `wasi:cli/environment`.
94
99
95
100
> [!NOTE]
96
-
> The values provided by the `wasi:cli/environment` are not guaranteed
97
-
> to be ENV variables on the host machine -- this is a choice left to the
98
-
> platform, in the implementation of `wasi:cli/environment` that it exposes.
101
+
> The values provided by the `wasi:cli/environment`interface are not guaranteed
102
+
> to be environment variables on the host machine—this is a choice left to the platform,
103
+
> in the implementation of `wasi:cli/environment` that it exposes.
99
104
>
100
105
> For example, platforms may choose to elide sensitive environment variables, or provide none at all, in practice.
101
106
102
-
Imports are easiest illustrated with WIT:
107
+
Imports are most easily illustrated with WIT:
103
108
104
109
```wit
105
-
package example-namespace:example-package;
106
-
107
-
world example-world {
108
-
import wasi:cli/environment@0.2.4;
109
-
}
110
+
{{#include ../../examples/faq/example.wit}}
110
111
```
111
112
112
-
The [`environment` interface in `wasi:cli`][wasi-cli-env] provides various types and functions for interacting with
113
-
environment variables.
113
+
The [`environment` interface in `wasi:cli`][wasi-cli-env] provides various types and functions
114
+
for interacting with environment variables.
114
115
115
-
The component is said to "import" the `wasi:cli/environment` interface, using the available functions and types therein.
116
+
The component is said to "import" the `wasi:cli/environment` interface,
0 commit comments