Building

WASM-Frontmatter:

A Javascript package written in Rust leveraging WASM

Josh Finnie

What is WASM-Frontmatter?

  • It's a javascript package to "replace" gray-matter
  • It's API is completely Web Assembly
  • It's currently about twice as fast as gray-matter
  • It's almost at API parity (still working on callbacks)

[1] Gray Matter: https://www.npmjs.com/package/gray-matter
[2] WASM Frontmatter: https://www.npmjs.com/package/wasm-frontmatter

What is WASM?

  • WebAssembly (WASM) is an open web standard that defines a portable binary-code format for executable programs in the web giving near-native code execution speed in the web browser. [1]

[1] https://en.wikipedia.org/wiki/WebAssembly

Tools WASM-Frontmatter Uses

Below are the two tools I use to build WASM-Frontmatter:

  • Rust, of course
  • WASM-Pack

Rust

  • All logic for WASM-Frontmatter is written using Rust.
  • It uses the wasm-bindgen[1] crate heavily to build connections between the Rust code and Javascript.

[1] https://rustwasm.github.io/docs/wasm-bindgen/

WASM-Pack

  • A tool seeks to be a one-stop shop for building and working with rust- generated WebAssembly that you would like to interop with JavaScript, in the browser or with Node.js [1]
  • This command line tool is tightly coupled to the wasm-bindgen package we use to code our application in rust
  • It also very nicely helps build and publish your application to NPM

[1] https://rustwasm.github.io/docs/wasm-pack/

WASM-Pack (Con't)

  • Have Rust installed.
  • Install WASM-pack through this script:                              

 

  • Once installed, run the following commands to get your package up and running:
$ wasm-pack new hello-world
$ cd hello-world
$ wasm-pack build
$ wasm-pack publish
$ curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

Live Code!

Thank you!

Josh Finnie

@joshfinnie (almost everywhere)

Building WASM-Frontend

By Josh Finnie

Building WASM-Frontend

  • 120
Loading comments...

More from Josh Finnie