diff --git a/.travis.yml b/.travis.yml index b3fd994..bd3169d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,17 +5,8 @@ sudo: false cache: - cargo -INSTALL_NODE_VIA_NVM: &INSTALL_NODE_VIA_NVM - | - rustup target add wasm32-unknown-unknown - curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash - source ~/.nvm/nvm.sh - nvm install v10.5 - -install: - - *INSTALL_NODE_VIA_NVM - - curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -f - script: - - wasm-pack build - - cd ./www && npm install && ./node_modules/.bin/webpack + - rustup target add wasm32-unknown-unknown + - cargo build --target wasm32-unknown-unknown + - cargo install wasm-bindgen + - wasm-bindgen --out-dir www --target web --reference-types --no-typescript --omit-default-module-path target/wasm32-unknown-unknown/debug/wasm_game_of_life.wasm diff --git a/www/.bin/create-wasm-app.js b/www/.bin/create-wasm-app.js deleted file mode 100755 index 2f42973..0000000 --- a/www/.bin/create-wasm-app.js +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env node - -const { spawn } = require("child_process"); -const fs = require("fs"); - -let folderName = '.'; - -if (process.argv.length >= 3) { - folderName = process.argv[2]; - if (!fs.existsSync(folderName)) { - fs.mkdirSync(folderName); - } -} - -const clone = spawn("git", ["clone", "https://github.com/rustwasm/create-wasm-app.git", folderName]); - -clone.on("close", code => { - if (code !== 0) { - console.error("cloning the template failed!") - process.exit(code); - } else { - console.log("🦀 Rust + 🕸 Wasm = ❤"); - } -}); diff --git a/www/.gitignore b/www/.gitignore index 3c3629e..960b12e 100644 --- a/www/.gitignore +++ b/www/.gitignore @@ -1 +1,2 @@ -node_modules +wasm_game_of_life.js +wasm_game_of_life_bg.wasm diff --git a/www/README.md b/www/README.md deleted file mode 100644 index e151096..0000000 --- a/www/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# create-wasm-app -> an npm init project for generating a project that consumes rust-generated wasm via webpack - -## Usage - -``` -npm init wasm-app -``` - -## What's Included - -- `.gitignore`: ignores `node_modules` -- `LICENSE-APACHE` and `LICENSE-MIT`: most Rust projects are licensed this way, so these are included for you -- `README.md`: the file you are reading now! -- `index.html`: a bare bones html document that includes the webpack bundle -- `index.js`: example js file with a comment showing how to import and use a wasm pkg -- `package.json` and `package-lock.json`: - - pulls in devDependencies for using webpack: - - [`webpack`](https://www.npmjs.com/package/webpack) - - [`webpack-cli`](https://www.npmjs.com/package/webpack-cli) - - [`webpack-dev-server`](https://www.npmjs.com/package/webpack-dev-server) - - defines a `start` script to run `webpack-dev-server` -- `webpack.config.js`: configuration file for bundling your js with webpack - -## License - -Licensed under either of - -* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) -* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) - -at your option. - -### Contribution - -Unless you explicitly state otherwise, any contribution intentionally -submitted for inclusion in the work by you, as defined in the Apache-2.0 -license, shall be dual licensed as above, without any additional terms or -conditions. diff --git a/www/bootstrap.js b/www/bootstrap.js deleted file mode 100644 index 7934d62..0000000 --- a/www/bootstrap.js +++ /dev/null @@ -1,5 +0,0 @@ -// A dependency graph that contains any wasm must all be imported -// asynchronously. This `bootstrap.js` file does the single async import, so -// that no one else needs to worry about it again. -import("./index.js") - .catch(e => console.error("Error importing `index.js`:", e)); diff --git a/www/index.html b/www/index.html index e55e022..acb334e 100644 --- a/www/index.html +++ b/www/index.html @@ -25,6 +25,6 @@
- + diff --git a/www/index.js b/www/index.js index 6f1c15f..5c1736a 100644 --- a/www/index.js +++ b/www/index.js @@ -1,5 +1,5 @@ -import { Universe, Cell } from "wasm-game-of-life"; -import { memory } from "wasm-game-of-life/wasm_game_of_life_bg"; +import init, { Universe, Cell } from "./wasm_game_of_life.js"; +var memory = (await init("./wasm_game_of_life_bg.wasm")).memory; const CELL_SIZE = 5; // px const GRID_COLOR = "#CCCCCC"; diff --git a/www/package.json b/www/package.json deleted file mode 100644 index ef91ed1..0000000 --- a/www/package.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "create-wasm-app", - "version": "0.0.0", - "description": "create an app to consume rust-generated wasm packages", - "main": "index.js", - "scripts": { - "start": "webpack-dev-server" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/rustwasm/create-wasm-app.git" - }, - "keywords": [ - "webassembly", - "wasm", - "rust", - "webpack" - ], - "author": "Ashley Williams ", - "license": "(MIT OR Apache-2.0)", - "bugs": { - "url": "https://github.com/rustwasm/create-wasm-app/issues" - }, - "homepage": "https://github.com/rustwasm/create-wasm-app#readme", - "dependencies": { - "wasm-game-of-life": "file:../pkg", - "copy-webpack-plugin": "^5.0.0", - "webpack": "^4.16.3", - "webpack-cli": "^3.1.0", - "webpack-dev-server": "^3.1.5" - } -} diff --git a/www/webpack.config.js b/www/webpack.config.js deleted file mode 100644 index b209f8c..0000000 --- a/www/webpack.config.js +++ /dev/null @@ -1,14 +0,0 @@ -const CopyWebpackPlugin = require("copy-webpack-plugin"); -const path = require('path'); - -module.exports = { - entry: "./bootstrap.js", - output: { - path: path.resolve(__dirname, "dist"), - filename: "bootstrap.js", - }, - mode: "development", - plugins: [ - new CopyWebpackPlugin(['index.html']) - ] -};