Skip to content

Commit f42e7c2

Browse files
committed
docs: Add some notes about cdylib
Closes: #683
1 parent 89ce7d0 commit f42e7c2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

site/content/_index.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,23 @@ include all JavaScript snippets generated by `wasm-bindgen` for interfacing with
110110
By default, functions exported from Rust, using `wasm-bingen`, can be accessed in the JavaScript code through the global
111111
variable `window.wasmBindings`. This behavior can be disabled, and the name can be customized.
112112

113+
## Library crate
114+
115+
Aside from having a `main` function, it is also possible to up your project as a `cdylib` project. In order to do that,
116+
add the following to your `Cargo.toml`:
117+
118+
```toml
119+
[lib]
120+
crate-type = ["cdylib", "rlib"]
121+
```
122+
123+
And then, define the entrypoint in your `lib.rs` like (does not need to be `async`):
124+
125+
```rust
126+
#[wasm_bindgen(start)]
127+
pub async fn run() {}
128+
```
129+
113130
# Next Steps
114131

115132
That's not all! Trunk has even more useful features. Head on over to the following sections to learn more about how to use Trunk effectively.

0 commit comments

Comments
 (0)