From f42e7c221c58d28ddd32acff5e9f5b326690e9ea Mon Sep 17 00:00:00 2001 From: Jens Reimann Date: Fri, 26 Jan 2024 13:18:25 +0100 Subject: [PATCH] docs: Add some notes about cdylib Closes: #683 --- site/content/_index.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/site/content/_index.md b/site/content/_index.md index ab117ac4..b893e5fd 100644 --- a/site/content/_index.md +++ b/site/content/_index.md @@ -110,6 +110,23 @@ include all JavaScript snippets generated by `wasm-bindgen` for interfacing with By default, functions exported from Rust, using `wasm-bingen`, can be accessed in the JavaScript code through the global variable `window.wasmBindings`. This behavior can be disabled, and the name can be customized. +## Library crate + +Aside from having a `main` function, it is also possible to up your project as a `cdylib` project. In order to do that, +add the following to your `Cargo.toml`: + +```toml +[lib] +crate-type = ["cdylib", "rlib"] +``` + +And then, define the entrypoint in your `lib.rs` like (does not need to be `async`): + +```rust +#[wasm_bindgen(start)] +pub async fn run() {} +``` + # Next Steps 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.