From caac2eba5381c6bd33f2f18390cb9a445d86b76f Mon Sep 17 00:00:00 2001 From: Daniel Schindler Date: Fri, 30 Nov 2018 17:42:36 +0100 Subject: [PATCH] Add #[wasm_bindgen(start)], plugins to webpack config, Update deps --- examples/todomvc/.gitignore | 5 ++++- examples/todomvc/Cargo.toml | 4 ++-- examples/todomvc/index.html | 1 - examples/todomvc/src/lib.rs | 2 +- examples/todomvc/webpack.config.js | 13 +++++++++++++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/examples/todomvc/.gitignore b/examples/todomvc/.gitignore index 6dfa488e..caf09561 100644 --- a/examples/todomvc/.gitignore +++ b/examples/todomvc/.gitignore @@ -1,3 +1,6 @@ target/ -todomvc.js +dist/ +_site/ + +todomvc* *.swp diff --git a/examples/todomvc/Cargo.toml b/examples/todomvc/Cargo.toml index 5ae330d1..56e07815 100644 --- a/examples/todomvc/Cargo.toml +++ b/examples/todomvc/Cargo.toml @@ -13,10 +13,10 @@ askama = "0.7.2" js-sys = "0.3.5" wasm-bindgen = "0.2.28" askama = "0.7.2" -console_error_panic_hook = "0.1" +console_error_panic_hook = "0.1.5" [dependencies.web-sys] -version = "0.3.4" +version = "0.3.5" features = [ 'console', 'CssStyleDeclaration', diff --git a/examples/todomvc/index.html b/examples/todomvc/index.html index 36082a2a..a5ac7ca1 100644 --- a/examples/todomvc/index.html +++ b/examples/todomvc/index.html @@ -37,7 +37,6 @@

Written by Jonathan Kingston

Part of TodoMVC

- diff --git a/examples/todomvc/src/lib.rs b/examples/todomvc/src/lib.rs index 0925cddb..93719db1 100644 --- a/examples/todomvc/src/lib.rs +++ b/examples/todomvc/src/lib.rs @@ -63,7 +63,7 @@ fn app(name: &str) { } /// Entry point into the program from JavaScript -#[wasm_bindgen] +#[wasm_bindgen(start)] pub fn run() { console_error_panic_hook::set_once(); app("todos-wasmbindgen"); diff --git a/examples/todomvc/webpack.config.js b/examples/todomvc/webpack.config.js index dce27149..f15dc6b5 100644 --- a/examples/todomvc/webpack.config.js +++ b/examples/todomvc/webpack.config.js @@ -1,4 +1,6 @@ const path = require('path'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const webpack = require('webpack'); module.exports = { entry: './index.js', @@ -6,5 +8,16 @@ module.exports = { path: path.resolve(__dirname, 'dist'), filename: 'index.js', }, + plugins: [ + new HtmlWebpackPlugin({ + template: "index.html" + }), + // Have this example work in Edge which doesn't ship `TextEncoder` or + // `TextDecoder` at this time. + new webpack.ProvidePlugin({ + TextDecoder: ['text-encoding', 'TextDecoder'], + TextEncoder: ['text-encoding', 'TextEncoder'] + }) + ], mode: 'development' };