Example of using wasmbuild.

Overview

wasmbuild - Example

This repo contains an example of using wasmbuild.

Main files:

  • rs_lib/src/lib.rs - Rust source code.
  • lib/rs_lib_bg.wasm - Generated .wasm file from the Rust code.
  • lib/rs_lib.generated.js - Generated JS file that can be used to call into the Wasm file.
  • main.js - Module that shows an example of using lib/rs_lib.generated.js.

After making edits to any of the Rust code, you can rebuild by running deno task wasmbuild. This will recreate the lib/rs_lib_bg.wasm and lib/rs_lib.generated.js files.

Deno

To run the example in Deno:

deno run --allow-read=. main.js

The output should be 3.

Browser

To run the example in the browser, start an http server that serves files in the current directory as follows:

$ deno run --allow-net --allow-read https://deno.land/[email protected]/http/file_server.ts
Listening on http://localhost:4507/

Then navigate to the link shown and open the browser console. You should see 3 logged to the console.

Deno Deploy

See this playground that imports from this repo: https://dash.deno.com/playground/wasmbuild-example

Generally with Deno deploy, you would want to use Git integration to Deploy this code though.

You might also like...

Example Breakout games using small libraries/engines/templates for the js13kGames competition.

Example Breakout games using small libraries/engines/templates for the js13kGames competition.

js13kBreakouts We implemented the same breakout style game with small libraries/engines/templates for the js13kGames competition! Live Demos LittleJS

Sep 17, 2022

Firebase Storage with Angular 14 example: Upload File, Retrieve, Display, Download Url & Delete using @angular/fire AngularFireStorage

Firebase Storage with Angular 14 example: Upload File, Retrieve, Display, Download Url & Delete using @angular/fire AngularFireStorage

Angular 14 File Upload to Firebase Storage example I will show you how to make Angular 14 Firebase Storage: File Upload/Display/Delete Application usi

Sep 7, 2022

Small example showing how you can make game sprite animations using CSS with Javascript movement.

Small example showing how you can make game sprite animations using CSS with Javascript movement.

Hi there, I'm Björn Hjorth 👋 I like combining the web and game development, if you like what you see please do not be a stranger and say "Hi" on Twit

Nov 9, 2022

High performance personalization & a/b testing example using Next.js, Edge Middleware, and Builder.io

High performance personalization & a/b testing example using Next.js, Edge Middleware, and Builder.io

Next.js + Builder.io Personalization & A/B Testing with Edge Middleware This is a fork of Next.js Commerce with Builder.io integrated and using Edge M

Sep 6, 2022

Get-A-Room example application using Domain Driven Design and Clean Architecture. Written in TypeScript and deployed to AWS with a serverless stack.

Get-A-Room example application using Domain Driven Design and Clean Architecture. Written in TypeScript and deployed to AWS with a serverless stack.

Domain Driven Microservices on AWS in Practice This project provides a Domain Driven Design & Clean Architecture-informed, multi-service event-driven

Dec 31, 2022

An example web extension, using MockRTC to intercept & debug your own WebRTC traffic

An example web extension, using MockRTC to intercept & debug your own WebRTC traffic

MockRTC WebExtension Example Part of HTTP Toolkit: powerful tools for building, testing & debugging HTTP(S), WebRTC, and more This is an example web e

Oct 14, 2022

An example project to how to integrate Chat Engine into a marketplace

An example project to how to integrate Chat Engine into a marketplace

Add Chat to Your Marketplace This is a example online marketplace with Chat Engine fully integrated. It's meant to help people building online marketp

Dec 22, 2022

Example project implementing authentication, authorization, and routing with Next.js and Supabase

Example project implementing authentication, authorization, and routing with Next.js and Supabase

Magic Link Authentication and Route Controls with Supabase and Next.js To run this project, To get started with this project, first create a new proje

Dec 11, 2022

Example questions for a manager interview

Manager Interview Questions A list of interview questions for manager roles. Follow Ryan Burgess on Twitter Management How would you describe your man

Dec 12, 2022
Comments
  • Add example using this on Deploy

    Add example using this on Deploy

    Maybe just in a playground, but I think I need to make the repo public first though:

    import { instantiate } from "https://raw.githubusercontent.com/denoland/wasmbuild_example/610ab64d51777169b9b33f7c7491f8be3f68b08b/lib/rs_lib.generated.js";
    
    const { add } = await instantiate();
    
    serve((req: Request) => new Response(add(1, 2)));
    
    opened by dsherret 0
  • can't find crate for `core`

    can't find crate for `core`

    error[E0463]: can't find crate for `core`
      |
      = note: the `wasm32-unknown-unknown` target may not be installed
      = help: consider downloading the target with `rustup target add wasm32-unknown-unknown`
    
    error[E0463]: can't find crate for `compiler_builtins`
    
    For more information about this error, try `rustc --explain E0463`.
    error: could not compile `cfg-if` due to 2 previous errors
    warning: build failed, waiting for other jobs to finish...
    cargo build failed
    

    I got this error when running deno task wasmbuild and the command rustup target add wasm32-unknown-unknown didn't work, I am wondering how I should fix this? Thanks!

    opened by jxuanli 3
Owner
Deno
Deno
Example auto-generated OpenAPI client library and an accompanying example Angular app.

To utilize this demo Head into petstore_frontend\petes_pets Run npm install Go to frontend_client_lib\out Run npm install Head back into petstore_fron

Alan Gross 1 Jan 21, 2022
NextJS with GraphQL using type-graphl and graphql-codegen adoptable dogs example code

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Jack Herrington 2 Mar 31, 2022
Simple SAGA example using amqp and nodejs

Simple SAGA example using amqp and nodejs The banks works as the following the diagram: All the banks are listening their own queue on the broker. Eve

jose teodoro da silva 7 Sep 23, 2022
Example Serverless DynamoDB integration tests using Jest, TypeScript and the AWS CDK

serverless dynamodb integration tests ?? Example Serverless DynamoDB integration tests using Jest, TypeScript and the AWS CDK Introduction How to inte

Lee Gilmore 8 Nov 4, 2022
Example of how to instrument your BattleSnake with New Relic, using NodeJS

Instrummenting your BattleSnake with New Relic using NodeJS Learn how to instrument your BattleSnake with New Relic using the NodeJS agent. For this r

New Relic Experimental 1 Apr 29, 2022
Solidity NFT whitelist contract example using MerkleTree.js for constructing merkle root and merkle proofs.

MerkleTree.js Solidity NFT Whitelist example Allow NFT minting only to whitelisted accounts by verifying merkle proof in Solidity contract. Merkle roo

Miguel Mota 65 Dec 29, 2022
Dapp example for airdropping ERC-20 tokens using World ID, preserving privacy for the claimers with zero-knowledge proofs.

World ID Example - Mesha Airdrop This repository contains an example decentralized application (dapp) for World ID. With Mesha Airdrop test airdroppin

Worldcoin 14 Dec 16, 2022
Next.js example using Hellō for authentication

Example application using Hellō and iron-session ?? Online demo at https://next-with-hello.vercel.app This example creates an authentication system th

Thomas Smith 3 May 20, 2022
example app that creates a new player in Spotify Connect to play music from in the browse using Spotify Web Playback SDK.

Spotify Web Playback SDK Demo Requirements User must have Spotify Premium, DRM & EME supported and JavaScript enabled Web Browser. License Copyright 2

Sijey 8 Jul 20, 2022
Keyauth v1 example, includes a demo and is encrypted using aes.

Keyauth Keyauth V1.0 api wrapper in nodejs that includes requests being encrypted using aes. Discord & Support Server . Keyauth Example const Keyauth

null 3 Nov 27, 2022