Welcome to Wisp!
This project uses Rust and the Leptos framework to build web applications. While it's still under development ("Here there be dragons"), this guide will help you get started with building and running Wisp.
Rust: Download and install Rust from the official website. This will also install cargo, the Rust package manager. Trunk: Install the Trunk bundler using cargo:
cargo install trunk
There are three ways to build Wisp, depending on your needs:
To build the application for deployment, run this command in your terminal (assuming you're in the project's root directory):
trunk build --release
This option automatically rebuilds the application whenever you make changes to the code. This is useful during development. To use it, run:
trunk watch --watch src/ --watch Cargo.toml --watch index.html
This option combines building and running a development server in one command. This is also helpful for development:
trunk serve --port 3000 --open --watch src/ --watch Cargo.toml --watch index.html
This will start the development server at http://localhost:3000 and open it in your browser. The --ignore tests/ flag tells Trunk to ignore changes in the tests folder to avoid unnecessary rebuilds.
Wisp builds a single JavaScript file that loads the actual computation happening within a separate .wasm binary. This JavaScript file can be minified to reduce its size, making your web page load a bit faster – especially important for release builds.
Here's how to minify the JavaScript file:
In this example, we'll use pnpm
as the Node package manager. If you don't have one installed, you'll need to set that up first. Once you have pnpm
(or another package manager) ready, run this command in your project's root directory to install esbuild
:
pnpm install
After installing esbuild
, run the following command in your terminal (again, assuming you're in the project's root directory):
./node_modules/.bin/esbuild ./dist/**/*.js --bundle --minify --outdir=./dist --allow-overwrite
./dist/**/*.js
: This tellsesbuild
to look for all JavaScript files (represented by*.js
) within thedist
folder and its subfolders (represented by**
).--bundle
: Combines all the JavaScript files into a single minified file.--minify
: Removes unnecessary characters and whitespace from the code, reducing its size.--outdir=./dist
: Specifies the output directory for the minified file. It will be placed back in thedist
folder.--allow-overwrite
: Allowsesbuild
to overwrite any existing files in the output directory.
To check if the test cases pass in a browser environment, install wasm-pack
, and run:
wasm-pack test --headless --firefox
- Leptos: This project is built with Leptos, a powerful web framework for Rust. You can learn more about Leptos at its website.
- Rust Stability: Wisp uses Rust's stable development channel for reliability. This means it won't be able to use some experimental features available in nightly Rust releases.