From a25925346a677820e4f99455c3d2fb5eedd082de Mon Sep 17 00:00:00 2001 From: Daniel Schindler Date: Sun, 2 Dec 2018 21:22:37 +0100 Subject: [PATCH 1/2] Add index.css to build --- examples/todomvc/package.json | 3 ++- examples/todomvc/webpack.config.js | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/todomvc/package.json b/examples/todomvc/package.json index 806119cd..31461e15 100644 --- a/examples/todomvc/package.json +++ b/examples/todomvc/package.json @@ -4,8 +4,9 @@ "serve": "webpack-dev-server" }, "devDependencies": { - "text-encoding": "^0.7.0", + "copy-webpack-plugin": "^4.6.0", "html-webpack-plugin": "^3.2.0", + "text-encoding": "^0.7.0", "webpack": "^4.11.1", "webpack-cli": "^3.1.1", "webpack-dev-server": "^3.1.0" diff --git a/examples/todomvc/webpack.config.js b/examples/todomvc/webpack.config.js index f15dc6b5..54b5b27a 100644 --- a/examples/todomvc/webpack.config.js +++ b/examples/todomvc/webpack.config.js @@ -1,6 +1,7 @@ +const webpack = require('webpack'); const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); -const webpack = require('webpack'); +const CopyWebpackPlugin = require('copy-webpack-plugin'); module.exports = { entry: './index.js', @@ -12,6 +13,10 @@ module.exports = { new HtmlWebpackPlugin({ template: "index.html" }), + new CopyWebpackPlugin([ + { from: 'index.css', to: 'index.css' }, + ]), + // Have this example work in Edge which doesn't ship `TextEncoder` or // `TextDecoder` at this time. new webpack.ProvidePlugin({ From 53c65039b90306be076ae9f61c7668b7638b3e8a Mon Sep 17 00:00:00 2001 From: Daniel Schindler Date: Mon, 3 Dec 2018 11:37:30 +0100 Subject: [PATCH 2/2] Change module import --- examples/todomvc/build.sh | 2 -- examples/todomvc/index.html | 1 - examples/todomvc/index.js | 7 ++++--- examples/todomvc/src/lib.rs | 4 +++- examples/todomvc/webpack.config.js | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/todomvc/build.sh b/examples/todomvc/build.sh index 018ae71c..055784b2 100755 --- a/examples/todomvc/build.sh +++ b/examples/todomvc/build.sh @@ -3,10 +3,8 @@ # For more comments about what's going on here, see the `hello_world` example set -ex -cd "$(dirname $0)" cargo build --target wasm32-unknown-unknown - cargo run --manifest-path ../../crates/cli/Cargo.toml \ --bin wasm-bindgen -- \ ../../target/wasm32-unknown-unknown/debug/todomvc.wasm --out-dir . diff --git a/examples/todomvc/index.html b/examples/todomvc/index.html index a5ac7ca1..302a28da 100644 --- a/examples/todomvc/index.html +++ b/examples/todomvc/index.html @@ -37,6 +37,5 @@

Written by Jonathan Kingston

Part of TodoMVC

- diff --git a/examples/todomvc/index.js b/examples/todomvc/index.js index cf999191..7190d16b 100644 --- a/examples/todomvc/index.js +++ b/examples/todomvc/index.js @@ -1,3 +1,4 @@ -import('./todomvc').then(todomvc => { - todomvc.run(); -}); +// For more comments about what's going on here, check out the `hello_world` +// example +import('./todomvc') + .catch(console.error); diff --git a/examples/todomvc/src/lib.rs b/examples/todomvc/src/lib.rs index 93719db1..4a88e39c 100644 --- a/examples/todomvc/src/lib.rs +++ b/examples/todomvc/src/lib.rs @@ -64,7 +64,9 @@ fn app(name: &str) { /// Entry point into the program from JavaScript #[wasm_bindgen(start)] -pub fn run() { +pub fn run() -> Result<(), JsValue> { console_error_panic_hook::set_once(); app("todos-wasmbindgen"); + + Ok(()) } diff --git a/examples/todomvc/webpack.config.js b/examples/todomvc/webpack.config.js index 54b5b27a..bfd5d8a5 100644 --- a/examples/todomvc/webpack.config.js +++ b/examples/todomvc/webpack.config.js @@ -1,7 +1,7 @@ -const webpack = require('webpack'); const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin'); +const webpack = require('webpack'); module.exports = { entry: './index.js',