Giter Site home page Giter Site logo

wasabi's Introduction

wasabi

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.

Prerequisites

prerequisite installation
deno deno_install
rust rustup
rustfmt rustup component add rustfmt
rust-clippy rustup component add clippy
wasm-pack cargo install wasm-pack

Structure

โ”œโ”€โ”€ .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

Scripts

build

$ 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

clean

$ deno run --unstable --allow-read --allow-write --allow-run scripts/clean.ts
cleaning cargo build           ("cargo clean")
removing pkg

fmt

$ 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")

lint

$ 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")

Testing

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)

Other

Contribution

Pull request, issues and feedback are very welcome. Code style is formatted with deno fmt and commit messages are done following Conventional Commits spec.

Licence

Copyright 2020, Denosaurs. All rights reserved. MIT license.

wasabi's People

Contributors

eliassjogreen avatar qu4k avatar terkwood avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.