From 8682198acf264110fa4860b8927dc5513393ce23 Mon Sep 17 00:00:00 2001 From: Mike Burr Date: Sat, 24 Jul 2021 12:34:15 -0600 Subject: [PATCH 1/6] must test remotely... --- README.md | 7 +++++++ www/.gitignore | 2 ++ www/index.html | 8 +++++++- www/index.js | 5 +++-- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4145870..19a3ded 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,10 @@ tutorial. The tutorial builds increasingly featureful implementations of [game-of-life]: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life [tutorial]: https://rustwasm.github.io/book/game-of-life/introduction.html + +### Documenting "Without Bundler" + +``` +cargo build --target wasm32-unknown-unknown +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/.gitignore b/www/.gitignore index 3c3629e..9fa9f9b 100644 --- a/www/.gitignore +++ b/www/.gitignore @@ -1 +1,3 @@ node_modules +wasm_game_of_life.js +wasm_game_of_life_bg.wasm diff --git a/www/index.html b/www/index.html index e55e022..7e5662b 100644 --- a/www/index.html +++ b/www/index.html @@ -25,6 +25,12 @@
- + + + + + + + diff --git a/www/index.js b/www/index.js index 6f1c15f..6605c78 100644 --- a/www/index.js +++ b/www/index.js @@ -1,5 +1,6 @@ -import { Universe, Cell } from "wasm-game-of-life"; -import { memory } from "wasm-game-of-life/wasm_game_of_life_bg"; + +import { Universe, Cell } from "./wasm_game_of_life.js"; +import { memory } from "./wasm_game_of_life_bg.wasm"; const CELL_SIZE = 5; // px const GRID_COLOR = "#CCCCCC"; From 9c5ab5bb933e45ec2fbacb1f749644e822e0459c Mon Sep 17 00:00:00 2001 From: Mike Burr Date: Sat, 24 Jul 2021 14:45:58 -0600 Subject: [PATCH 2/6] no console errors --- www/index.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/www/index.html b/www/index.html index 7e5662b..11e4036 100644 --- a/www/index.html +++ b/www/index.html @@ -25,12 +25,12 @@
- - - - - - - + + From f0c4d048821997ed014b7602314555f5cfa441aa Mon Sep 17 00:00:00 2001 From: Mike Burr Date: Sat, 24 Jul 2021 14:54:30 -0600 Subject: [PATCH 3/6] workss --- www/index.html | 8 +------- www/index.js | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/www/index.html b/www/index.html index 11e4036..acb334e 100644 --- a/www/index.html +++ b/www/index.html @@ -25,12 +25,6 @@
- - + diff --git a/www/index.js b/www/index.js index 6605c78..bd6b985 100644 --- a/www/index.js +++ b/www/index.js @@ -1,6 +1,6 @@ -import { Universe, Cell } from "./wasm_game_of_life.js"; -import { memory } from "./wasm_game_of_life_bg.wasm"; +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"; From fc328c37dd351d9c65254b0f3d0d0a7f421bee20 Mon Sep 17 00:00:00 2001 From: Mike Burr Date: Sat, 24 Jul 2021 14:55:24 -0600 Subject: [PATCH 4/6] closer to master --- www/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/www/index.js b/www/index.js index bd6b985..5c1736a 100644 --- a/www/index.js +++ b/www/index.js @@ -1,4 +1,3 @@ - import init, { Universe, Cell } from "./wasm_game_of_life.js"; var memory = (await init("./wasm_game_of_life_bg.wasm")).memory; From eb49dc51ffed652e24615f4f6d8d000afdcbe454 Mon Sep 17 00:00:00 2001 From: Mike Burr Date: Sat, 24 Jul 2021 14:58:30 -0600 Subject: [PATCH 5/6] no need --- www/bootstrap.js | 5 ----- www/webpack.config.js | 14 -------------- 2 files changed, 19 deletions(-) delete mode 100644 www/bootstrap.js delete mode 100644 www/webpack.config.js 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/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']) - ] -}; From 06abe3004065c67eb10fde56fc17fe4ac27cf223 Mon Sep 17 00:00:00 2001 From: Mike Burr Date: Sat, 24 Jul 2021 15:14:35 -0600 Subject: [PATCH 6/6] unneeded in this universe --- .travis.yml | 17 ++++------------ README.md | 7 ------- www/.bin/create-wasm-app.js | 24 ----------------------- www/.gitignore | 1 - www/README.md | 39 ------------------------------------- www/package.json | 32 ------------------------------ 6 files changed, 4 insertions(+), 116 deletions(-) delete mode 100755 www/.bin/create-wasm-app.js delete mode 100644 www/README.md delete mode 100644 www/package.json 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/README.md b/README.md index 19a3ded..4145870 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,3 @@ tutorial. The tutorial builds increasingly featureful implementations of [game-of-life]: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life [tutorial]: https://rustwasm.github.io/book/game-of-life/introduction.html - -### Documenting "Without Bundler" - -``` -cargo build --target wasm32-unknown-unknown -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 9fa9f9b..960b12e 100644 --- a/www/.gitignore +++ b/www/.gitignore @@ -1,3 +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/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" - } -}