Skip to content
Permalink
Browse files

exmaple for rust + wasm

  • Loading branch information
terrierscript committed Sep 4, 2019
1 parent 0930a39 commit b6093e4e9a0d77fe8ff24d4bb8257074ee67b967
Showing with 237 additions and 2 deletions.
  1. +2 −1 .gitignore
  2. +2 −0 package.json
  3. +10 −0 src/index.tsx
  4. +126 −0 wasm/Cargo.lock
  5. +13 −0 wasm/Cargo.toml
  6. +12 −0 wasm/src/lib.rs
  7. +72 −1 yarn.lock
@@ -1 +1,2 @@
dist/
dist/
wasm/target/**/*
@@ -9,6 +9,8 @@
"@types/react": "^16.9.2",
"@types/react-dom": "^16.8.5",
"parcel": "^1.12.3",
"parcel-bundler": "1.x",
"parcel-plugin-wasm.rs": "^1.2.12",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-is": "^16.9.0",
@@ -2,6 +2,16 @@ import React, { useContext, FC, ReactChild } from "react"
import { render } from "react-dom"
import styled, { ThemeProvider, ThemeContext } from "styled-components"
import * as ReactIs from "react-is"
// import { main } from "../wasm/src/lib.rs"
// console.log(main)
const start = async () => {
const { main } = await import("../wasm/Cargo.toml")
console.log(main())
// console.log(add(1, 2))
}
start().catch((e) => {
console.error(e)
})

const snaker = (num, weight) => {
const header = ["rad-0", "line-h", "line-h", "line-h"]

Some generated files are not rendered by default. Learn more.

@@ -0,0 +1,13 @@
[dependencies]
wasm-bindgen = "^0.2.50"

[package]
name = "wasm"
version = "0.1.0"
authors = [
"terrierscript <13282103+terrierscript@users.noreply.github.com>"
]
edition = "2018"

[lib]
crate-type = [ "cdylib" ]
@@ -0,0 +1,12 @@
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn main() -> String {
return "Hello, world!!".to_string();
}

// #[no_mangle]
// pub fn add(a: i32, b:i32) -> i32{
// return a + b
// }
@@ -1464,7 +1464,7 @@ combined-stream@^1.0.6, combined-stream@~1.0.6:
dependencies:
delayed-stream "~1.0.0"

command-exists@^1.2.6:
command-exists@^1.2.6, command-exists@^1.2.7:
version "1.2.8"
resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.8.tgz#715acefdd1223b9c9b37110a149c6392c2852291"
integrity sha512-PM54PkseWbiiD/mMsbvW351/u+dafwTJ0ye2qB60G1aGQP9j3xK2gmMDc+R34L3nDtx4qMCitXT75mkbkGJDLw==
@@ -3649,6 +3649,77 @@ pako@~1.0.5:
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.10.tgz#4328badb5086a426aa90f541977d4955da5c9732"
integrity sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==

parcel-bundler@1.x:
version "1.12.3"
resolved "https://registry.yarnpkg.com/parcel-bundler/-/parcel-bundler-1.12.3.tgz#2bbf70bfa2d06097f071653285040bd125684d09"
integrity sha512-8bq6lj0hhQeGxD9f9xEkFMXQ3d8TIlf2+isKxoi9bciB0KVEILRGllaPkUgp++5t0anToBh9+tG6ZyInXOC1/A==
dependencies:
"@babel/code-frame" "^7.0.0 <7.4.0"
"@babel/core" "^7.0.0 <7.4.0"
"@babel/generator" "^7.0.0 <7.4.0"
"@babel/parser" "^7.0.0 <7.4.0"
"@babel/plugin-transform-flow-strip-types" "^7.0.0 <7.4.0"
"@babel/plugin-transform-modules-commonjs" "^7.0.0 <7.4.0"
"@babel/plugin-transform-react-jsx" "^7.0.0 <7.4.0"
"@babel/preset-env" "^7.0.0 <7.4.0"
"@babel/runtime" "^7.0.0 <7.4.0"
"@babel/template" "^7.0.0 <7.4.0"
"@babel/traverse" "^7.0.0 <7.4.0"
"@babel/types" "^7.0.0 <7.4.0"
"@iarna/toml" "^2.2.0"
"@parcel/fs" "^1.11.0"
"@parcel/logger" "^1.11.0"
"@parcel/utils" "^1.11.0"
"@parcel/watcher" "^1.12.0"
"@parcel/workers" "^1.11.0"
ansi-to-html "^0.6.4"
babylon-walk "^1.0.2"
browserslist "^4.1.0"
chalk "^2.1.0"
clone "^2.1.1"
command-exists "^1.2.6"
commander "^2.11.0"
cross-spawn "^6.0.4"
css-modules-loader-core "^1.1.0"
cssnano "^4.0.0"
deasync "^0.1.14"
dotenv "^5.0.0"
dotenv-expand "^4.2.0"
fast-glob "^2.2.2"
filesize "^3.6.0"
get-port "^3.2.0"
htmlnano "^0.2.2"
is-glob "^4.0.0"
is-url "^1.2.2"
js-yaml "^3.10.0"
json5 "^1.0.1"
micromatch "^3.0.4"
mkdirp "^0.5.1"
node-forge "^0.7.1"
node-libs-browser "^2.0.0"
opn "^5.1.0"
postcss "^7.0.11"
postcss-value-parser "^3.3.1"
posthtml "^0.11.2"
posthtml-parser "^0.4.0"
posthtml-render "^1.1.3"
resolve "^1.4.0"
semver "^5.4.1"
serialize-to-js "^1.1.1"
serve-static "^1.12.4"
source-map "0.6.1"
terser "^3.7.3"
v8-compile-cache "^2.0.0"
ws "^5.1.1"

parcel-plugin-wasm.rs@^1.2.12:
version "1.2.12"
resolved "https://registry.yarnpkg.com/parcel-plugin-wasm.rs/-/parcel-plugin-wasm.rs-1.2.12.tgz#b13d97d8cf09d2b2267842c5b0b23b55459e2307"
integrity sha512-Yp+v5QaatcY9uD0LlpAlni9LWxyv2MnECuUdvIv1wDPT6m/81BGqAPl9/8SCBoUjwZm0za1gkrXPrI9o/49Yjg==
dependencies:
"@iarna/toml" "^2.2.0"
command-exists "^1.2.7"

parcel@^1.12.3:
version "1.12.3"
resolved "https://registry.yarnpkg.com/parcel/-/parcel-1.12.3.tgz#1f1341589380f20be924f1dd67c7fed193b346ec"

0 comments on commit b6093e4

Please sign in to comment.
You can’t perform that action at this time.