Skip to content

Commit d5eeaf3

Browse files
authored
feat: wasm tagrets in multiplatform dsl (#4284)
1 parent 5a0088f commit d5eeaf3

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

docs/topics/multiplatform/multiplatform-dsl-reference.md

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ The complete list of available targets is the following:
7272
<td><code>jvm</code></td>
7373
<td></td>
7474
</tr>
75+
<tr>
76+
<td rowspan="2">Kotlin/Wasm</td>
77+
<td><code>wasmJs</code></td>
78+
<td>Use it if you plan to run your projects in the JavaScript runtime.</td>
79+
</tr>
80+
<tr>
81+
<td><code>wasmWasi</code></td>
82+
<td>Use it if you need support for the <a href="https://github.com/WebAssembly/WASI">WASI</a> system interface.</td>
83+
</tr>
7584
<tr>
7685
<td>Kotlin/JS</td>
7786
<td><code>js</code></td>
@@ -129,7 +138,7 @@ In any target block, you can use the following declarations:
129138
|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
130139
| `attributes` | Attributes used for [disambiguating targets](multiplatform-set-up-targets.md#distinguish-several-targets-for-one-platform) for a single platform. |
131140
| `preset` | The preset that the target has been created from, if any. |
132-
| `platformType` | Designates the Kotlin platform of this target. Available values: `jvm`, `androidJvm`, `js`, `native`, `common`. |
141+
| `platformType` | Designates the Kotlin platform of this target. Available values: `jvm`, `androidJvm`, `js`, `wasm`, `native`, `common`. |
133142
| `artifactsTaskName` | The name of the task that builds the resulting artifacts of this target. |
134143
| `components` | The components used to setup Gradle publications. |
135144
| `compilerOptions` | The [compiler options](gradle-compiler-options.md) used for the target. This declaration overrides any `compilerOptions {}` configured at [top level](multiplatform-dsl-reference.md#top-level-blocks). To use it, add the following opt-in: `@OptIn(ExperimentalKotlinGradlePluginApi::class)` |
@@ -161,17 +170,35 @@ kotlin {
161170
}
162171
```
163172

164-
### JavaScript targets
173+
### Web targets
165174

166-
The `js {}` block describes the configuration of JavaScript targets. It can contain one of two blocks depending on the target execution environment:
175+
The `js {}` block describes the configuration of Kotlin/JS targets, and the `wasmJs {}` block describes the configuration of
176+
Kotlin/Wasm targets interoperable with JavaScript. They can contain one of two blocks depending on the target execution
177+
environment:
167178

168-
| **Name** | **Description** |
169-
|-----------|--------------------------------------|
170-
| `browser` | Configuration of the browser target. |
171-
| `nodejs` | Configuration of the Node.js target. |
179+
| **Name** | **Description** |
180+
|-----------------------|--------------------------------------|
181+
| [`browser`](#browser) | Configuration of the browser target. |
182+
| [`nodejs`](#node-js) | Configuration of the Node.js target. |
172183

173184
Learn more about [configuring Kotlin/JS projects](js-project-setup.md).
174185

186+
A separate `wasmWasi {}` block describes the configuration of Kotlin/Wasm targets that support the WASI system interface.
187+
Here, only the [`nodejs`](#node-js) execution environment is available:
188+
189+
```kotlin
190+
kotlin {
191+
wasmWasi {
192+
nodejs()
193+
binaries.executable()
194+
}
195+
}
196+
```
197+
198+
All the web targets, `js`, `wasmJs`, and `wasmWasi`, also support the `binaries.executable()` call. It explicitly
199+
instructs the Kotlin compiler to emit executable files. For more information, see [Execution environments](js-project-setup.md#execution-environments)
200+
in the Kotlin/JS documentation.
201+
175202
#### Browser
176203

177204
`browser {}` can contain the following configuration blocks:

0 commit comments

Comments
 (0)