This is a template repository for deno modules that want to use wasm. To use it simply click the "Use this template" button to generate a new repo with all the stuff you need to get started writing rust and running it using wasm in deno.
prerequisite | installation |
---|---|
deno | deno_install |
rust | rustup |
rustfmt | rustup component add rustfmt |
rust-clippy | rustup component add clippy |
wasm-pack | cargo install wasm-pack |
βββ .github
β βββ workflows
β β βββ checks.yml - Performs deno lint, fmt and test
β β βββ depsbot.yml - Checks the freshness of deno dependencies
β βββ FUNDING.yml - The denosaurs funding file, omit if not denosaur
βββ scripts - A directory containing all development scripts
β βββ _deps.ts - All of the dependencies for the scripts
β βββ _util.ts - Utilities used in the scripts
β βββ build.ts - The build script for generating the wasm.js file
β βββ clean.ts - Removes all build data, often solving build issues
β βββ fmt.ts - Formats both typescript and rust ignoring build data
β βββ lint.ts - Lints both typescript and rust ignoring build data
βββ src - The rust part of the module
β βββ lib.rs - The rust entry point
βββ pkg - Ignored by .gitignore, used when building
βββ target - Ignored by .gitignore, used when building
βββ .gitignore - A standard .gitignore file for ignoring build directories
βββ .rustfmt.toml - The rustfmt configuration
βββ Cargo.toml - A file describing the rust part of the module
βββ LICENSE - A standard license file you are free to change to fit your needs
βββ mod.ts - The entry point for the deno module
βββ README.md - This readme file
βββ test.ts - Containing tests
βββ wasm.js - A js file containing the built wasm and some glue code generated by the build script
$ deno run --unstable --allow-read --allow-write --allow-run scripts/build.ts
building rust ("wasm-pack build --target web --release")
read wasm (size: 1274 bytes)
compressed wasm using lz4 (reduction: 224 bytes, size: 1050 bytes)
encoded wasm using base64 (increase: 350 bytes, size: 1400 bytes)
read js (size: 1776 bytes)
inlined js and wasm (size: 3357 bytes)
minified js (size reduction: 754 bytes, size: 2603 bytes)
writing output to file (wasm.js)
final size is: 2603 bytes
$ deno run --unstable --allow-read --allow-write --allow-run scripts/clean.ts
cleaning cargo build ("cargo clean")
removing pkg
$ deno run --unstable --allow-run scripts/fmt.ts
formatting typescript ("deno --unstable fmt scripts/ test_deps.ts test.ts mod.ts")
Checked 9 files
formatting rust ("cargo fmt")
$ deno run --unstable --allow-run scripts/lint.ts
linting typescript ("deno --unstable lint scripts test_deps.ts test.ts mod.ts")
Checked 9 files
linting rust ("cargo clippy -q")
Requires the wasm.js
file to be built first.
$ deno test
running 1 tests
test add ... ok (2ms)
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (2ms)
Pull request, issues and feedback are very welcome. Code style is formatted with
deno fmt
and commit messages are done following
Conventional Commits spec.
Copyright 2020, Denosaurs. All rights reserved. MIT license.