Skip to content

Commit b042ded

Browse files
committed
init
1 parent efca3ce commit b042ded

10 files changed

+220
-3
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
dist
3+
pkg
4+
target

.vscode/settings.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cSpell.words": [
3+
"bindgen",
4+
"cdylib"
5+
]
6+
}

Cargo.lock

+123
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "scrypt-rs-wasm"
3+
version = "0.1.0"
4+
authors = ["Lars Hvam"]
5+
edition = "2018"
6+
rust-version = "1.76"
7+
8+
[lib]
9+
crate-type = ["cdylib"]
10+
11+
[dependencies]
12+
wasm-bindgen = "0.2.92"

README.md

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
# scrypt-rs-wasm
2-
test
2+
3+
todo
4+
5+
## Building
6+
7+
todo
8+
9+
## Random Notes
310

411
https://surma.dev/things/rust-to-webassembly/
512

613
https://github.com/typed-io/cryptoxide
714

815
https://github.com/MyEtherWallet/scrypt-wasm
916

10-
## Building
11-
17+
https://rustwasm.github.io/wasm-bindgen/contributing/design/exporting-rust.html

index.mjs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { greet } from './pkg/scrypt_rs_wasm.js';
2+
3+
const res = greet('World');
4+
console.dir(res);

package-lock.json

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "scrypt-rs-wasm",
3+
"private": true,
4+
"version": "1.0.0",
5+
"description": "todo",
6+
"main": "index.js",
7+
"scripts": {
8+
"test": "rm -rf pkg && wasm-pack build --target nodejs && node index.mjs"
9+
},
10+
"devDependencies": {
11+
},
12+
"author": "Lars Hvam",
13+
"license": "MIT"
14+
}

src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use wasm_bindgen::prelude::*;
2+
3+
#[wasm_bindgen]
4+
pub fn greet(a: &str) -> String {
5+
format!("Hello, {}!", a)
6+
}

webpack.config.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const path = require('path');
2+
const HtmlWebpackPlugin = require('html-webpack-plugin');
3+
const webpack = require('webpack');
4+
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
5+
6+
module.exports = {
7+
entry: './index.js',
8+
output: {
9+
path: path.resolve(__dirname, 'dist'),
10+
filename: 'index.js',
11+
},
12+
plugins: [
13+
new HtmlWebpackPlugin(),
14+
new WasmPackPlugin({
15+
crateDirectory: path.resolve(__dirname, ".")
16+
}),
17+
// Have this example work in Edge which doesn't ship `TextEncoder` or
18+
// `TextDecoder` at this time.
19+
new webpack.ProvidePlugin({
20+
TextDecoder: ['text-encoding', 'TextDecoder'],
21+
TextEncoder: ['text-encoding', 'TextEncoder']
22+
})
23+
],
24+
mode: 'development',
25+
experiments: {
26+
asyncWebAssembly: true
27+
}
28+
};

0 commit comments

Comments
 (0)