Building TonboLite

Build as Extension

To build TonboLite as an extension, you should enable loadable_extension features

cargo build --release --features loadable_extension

Once building successfully, you will get a file named libsqlite_tonbo.dylib(.dll on windows, .so on most other unixes) in target/release/

Build on Rust

cargo build

Build on Wasm

To use TonboLite in wasm, it takes a few steps to build.

  1. Add wasm32-unknown-unknown target
rustup target add wasm32-unknown-unknown
  1. Override toolchain with nightly
rustup override set nightly
  1. Build with wasm-pack
wasm-pack build --target web --no-default-features --features wasm

Once you build successfully, you will get a pkg folder containing compiled js and wasm files. Copy it to your project and then you can start to use it.

const tonbo = await import("./pkg/sqlite_tonbo.js");
await tonbo.default();

// start to use TonboLite ...

TonboLite should be used in a secure context and cross-origin isolated, since it uses SharedArrayBuffer to share memory. Please refer to this article for a detailed explanation.