shaoruu/rust-typescript-template

Create Rust + TypeScript libraries with ease! PR'S WELCOMED!

:sparkles: Inspiration

I wanted to create a WebAssembly/Rust library with additional JS features, but I couldn't find any resources on how to integrate the npm-ready library built by wasm-pack with TypeScript. All the examples online either seemed to use the output of wasm-pack using npm link, or didn't have TypeScript support. So, I created this, a template that allows you to embed wasm-pack all within one single TypeScript-based library. Enjoy!

:building_construction: Install

Before development, make sure you have installed:

  • wasm-pack
  • cargo-watch
# clone the repo
git clone --depth 1 --branch master https://github.com/iantheearl/rust-typescript-template.git your-project-name
cd your-project-name

# install dependencies
yarn

# start development
yarn run dev

# run example
yarn run example

# visit http://localhost:8080

After installation, start developing here:

  • ./pkg: Rust source files
  • ./src: TypeScript source files

:printer: Publish

# build the library to ./dist, including .wasm
yarn build

# push to npm
npm publish --access public

:tv: Deployment

# build the example to `./example/build`, and push that folder to the gh-pages branch
yarn deploy

Configure github to deploy branch gh-pages.

:open_file_folder: Structure

  • ./core: Rust code, the core of your library
  • ./pkg: wasm-pack built npm-ready library
  • ./src: TypeScript source code, where u can import from wasm-pack
  • ./example: A web app that uses your library directly from ./dist
  • ./tests: To test your library

License

MIT © Rust TypeScript Template

Information - Updated Sep 27, 2022

Stars: 23
Forks: 4
Issues: 0

Rust / Wasm client web app framework

Pull requests which improve test coverage are also very welcome

Rust / Wasm client web app framework

A Rust/WASM Library to interact with Bitcoin SV

npm i bsv-wasm-bundler --save

A Rust/WASM Library to interact with Bitcoin SV

WASM / Rust / D3 example

Fetch data with Rust + WASM and show it with JS + D3

WASM / Rust / D3 example

@texhno-rust-wasm-game-of-life

A template for kick starting a Rust and WebAssembly project using Tutorial

@texhno-rust-wasm-game-of-life

rust wasm worker hello world

Built using the template at which

rust wasm worker hello world

Rust WASM Web Worker Examples

This repository contains four different examples of using web workers in conjunction with WASM in

Rust WASM Web Worker Examples

rust-wasm-mandelbrot

WebAssembly でマンデルブロ集合を描きます

rust-wasm-mandelbrot

conway_rust_wasm

Conway's Game of Life with Rust and Web Assembly

conway_rust_wasm

Rust-Wasm-Game-of-Life

A fast and efficient Conway's Game of Life simulation made with Rust & compiled for the web

Rust-Wasm-Game-of-Life
Facebook Instagram Twitter GitHub Dribbble
Privacy