From 5083e7bdeaa2dd86ab4dfdd153b59668541a344d Mon Sep 17 00:00:00 2001 From: Pauan Date: Wed, 11 Mar 2020 14:23:41 +0100 Subject: [PATCH] Updating examples to use Rollup --- Cargo.toml | 11 +++---- examples/animation/.gitignore | 3 +- examples/animation/Cargo.toml | 10 +++--- examples/animation/README.md | 9 +---- .../animation/{static => dist}/index.html | 2 +- examples/animation/js/index.js | 1 - examples/animation/package.json | 15 ++++----- examples/animation/rollup.config.js | 17 ++++++++++ examples/animation/webpack.config.js | 33 ------------------- examples/counter/.gitignore | 3 +- examples/counter/Cargo.toml | 8 ++--- examples/counter/README.md | 9 +---- examples/counter/{static => dist}/index.html | 2 +- examples/counter/js/index.js | 1 - examples/counter/package.json | 15 ++++----- examples/counter/rollup.config.js | 17 ++++++++++ examples/counter/webpack.config.js | 33 ------------------- examples/todomvc/.gitignore | 3 +- examples/todomvc/Cargo.toml | 8 ++--- examples/todomvc/README.md | 9 +---- examples/todomvc/{static => dist}/index.html | 2 +- .../lib/todomvc-app-css/index.css | 0 .../lib/todomvc-common/base.css | 0 .../lib/todomvc-common/base.js | 0 examples/todomvc/js/index.js | 1 - examples/todomvc/package.json | 15 ++++----- examples/todomvc/rollup.config.js | 17 ++++++++++ examples/todomvc/webpack.config.js | 33 ------------------- src/operations.rs | 2 +- 29 files changed, 93 insertions(+), 186 deletions(-) rename examples/animation/{static => dist}/index.html (78%) delete mode 100644 examples/animation/js/index.js create mode 100644 examples/animation/rollup.config.js delete mode 100644 examples/animation/webpack.config.js rename examples/counter/{static => dist}/index.html (78%) delete mode 100644 examples/counter/js/index.js create mode 100644 examples/counter/rollup.config.js delete mode 100644 examples/counter/webpack.config.js rename examples/todomvc/{static => dist}/index.html (94%) rename examples/todomvc/{static => dist}/lib/todomvc-app-css/index.css (100%) rename examples/todomvc/{static => dist}/lib/todomvc-common/base.css (100%) rename examples/todomvc/{static => dist}/lib/todomvc-common/base.js (100%) delete mode 100644 examples/todomvc/js/index.js create mode 100644 examples/todomvc/rollup.config.js delete mode 100644 examples/todomvc/webpack.config.js diff --git a/Cargo.toml b/Cargo.toml index c9b0a46..d3628de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "dominator" version = "0.5.7" -authors = ["Pauan "] +authors = ["Pauan "] description = "Zero cost declarative DOM library using FRP signals" repository = "https://github.com/Pauan/rust-dominator" homepage = "https://github.com/Pauan/rust-dominator" @@ -19,15 +19,12 @@ default = ["wasm-bindgen/enable-interning"] lazy_static = "1.3.0" discard = "1.0.3" pin-utils = "0.1.0-alpha.4" -futures-channel-preview = "0.3.0-alpha.16" -futures-util-preview = "0.3.0-alpha.16" +futures-channel = "0.3.0" +futures-util = "0.3.0" futures-signals = "0.3.5" wasm-bindgen = "0.2.48" js-sys = "0.3.22" - -[dependencies.wasm-bindgen-futures] -version = "0.3.22" -features = ["futures_0_3"] +wasm-bindgen-futures = "0.4.9" [dependencies.web-sys] version = "0.3.22" diff --git a/examples/animation/.gitignore b/examples/animation/.gitignore index 36867e8..5008655 100644 --- a/examples/animation/.gitignore +++ b/examples/animation/.gitignore @@ -1,6 +1,5 @@ node_modules -/dist +/dist/js /target -/pkg /wasm-pack.log /yarn-error.log diff --git a/examples/animation/Cargo.toml b/examples/animation/Cargo.toml index 98c7c42..3f90ddf 100644 --- a/examples/animation/Cargo.toml +++ b/examples/animation/Cargo.toml @@ -2,7 +2,7 @@ name = "animation" version = "0.1.0" description = "Animation demo using dominator" -authors = ["Pauan "] +authors = ["Pauan "] categories = ["wasm"] readme = "README.md" license = "MIT" @@ -15,16 +15,14 @@ lto = true crate-type = ["cdylib"] [dependencies] -dominator = { path = "../.." } +console_error_panic_hook = "0.1.5" +dominator = "0.5.0" wasm-bindgen = "0.2.45" futures-signals = "0.3.0" -futures-preview = "0.3.0-alpha.16" +futures = "0.3.0" [dependencies.web-sys] version = "0.3.22" features = [ "console", ] - -[target."cfg(debug_assertions)".dependencies] -console_error_panic_hook = "0.1.5" diff --git a/examples/animation/README.md b/examples/animation/README.md index 46fe09f..fa8376c 100644 --- a/examples/animation/README.md +++ b/examples/animation/README.md @@ -4,14 +4,7 @@ yarn install ``` -## How to run in debug mode - -```sh -# Builds the project and opens it in a new browser tab. Auto-reloads when the project changes. -yarn start -``` - -## How to build in release mode +## How to build ```sh # Builds the project and places it into the `dist` folder. diff --git a/examples/animation/static/index.html b/examples/animation/dist/index.html similarity index 78% rename from examples/animation/static/index.html rename to examples/animation/dist/index.html index a84aaf3..eee5f3c 100644 --- a/examples/animation/static/index.html +++ b/examples/animation/dist/index.html @@ -5,6 +5,6 @@ rust-dominator • Animation - + diff --git a/examples/animation/js/index.js b/examples/animation/js/index.js deleted file mode 100644 index 9db81ab..0000000 --- a/examples/animation/js/index.js +++ /dev/null @@ -1 +0,0 @@ -import("../pkg/index.js").catch(console.error); diff --git a/examples/animation/package.json b/examples/animation/package.json index bef4f1d..344eac7 100644 --- a/examples/animation/package.json +++ b/examples/animation/package.json @@ -1,17 +1,14 @@ { - "author": "Pauan ", + "private": true, + "author": "Pauan ", "name": "animation", "version": "0.1.0", "scripts": { - "build": "rimraf dist pkg && webpack", - "start": "rimraf dist pkg && webpack-dev-server -d" + "build": "rimraf dist/js && rollup --config" }, "devDependencies": { - "@wasm-tool/wasm-pack-plugin": "^0.4.2", - "copy-webpack-plugin": "^5.0.3", - "webpack": "^4.33.0", - "webpack-cli": "^3.3.3", - "webpack-dev-server": "^3.7.1", - "rimraf": "^2.6.3" + "@wasm-tool/rollup-plugin-rust": "^1.0.0", + "rimraf": "^3.0.2", + "rollup": "^1.31.0" } } diff --git a/examples/animation/rollup.config.js b/examples/animation/rollup.config.js new file mode 100644 index 0000000..01b54d3 --- /dev/null +++ b/examples/animation/rollup.config.js @@ -0,0 +1,17 @@ +import rust from "@wasm-tool/rollup-plugin-rust"; + +export default { + input: { + index: "./Cargo.toml", + }, + output: { + dir: "dist/js", + format: "iife", + sourcemap: true, + }, + plugins: [ + rust({ + serverPath: "js/", + }), + ], +}; diff --git a/examples/animation/webpack.config.js b/examples/animation/webpack.config.js deleted file mode 100644 index e1bb304..0000000 --- a/examples/animation/webpack.config.js +++ /dev/null @@ -1,33 +0,0 @@ -const path = require("path"); -const CopyPlugin = require("copy-webpack-plugin"); -const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin"); - -const dist = path.resolve(__dirname, "dist"); - -module.exports = { - mode: "production", - stats: "errors-warnings", - entry: { - index: "./js/index.js" - }, - output: { - path: dist, - filename: "[name].js" - }, - devServer: { - liveReload: true, - open: true, - noInfo: true, - overlay: true - }, - plugins: [ - new CopyPlugin([ - path.resolve(__dirname, "static") - ]), - - new WasmPackPlugin({ - crateDirectory: __dirname, - extraArgs: "--out-name index" - }) - ] -}; diff --git a/examples/counter/.gitignore b/examples/counter/.gitignore index 36867e8..5008655 100644 --- a/examples/counter/.gitignore +++ b/examples/counter/.gitignore @@ -1,6 +1,5 @@ node_modules -/dist +/dist/js /target -/pkg /wasm-pack.log /yarn-error.log diff --git a/examples/counter/Cargo.toml b/examples/counter/Cargo.toml index 6435a0b..b3ada63 100644 --- a/examples/counter/Cargo.toml +++ b/examples/counter/Cargo.toml @@ -2,7 +2,7 @@ name = "counter" version = "0.1.0" description = "Counter demo using dominator" -authors = ["Pauan "] +authors = ["Pauan "] categories = ["wasm"] readme = "README.md" license = "MIT" @@ -15,10 +15,8 @@ lto = true crate-type = ["cdylib"] [dependencies] -dominator = { path = "../.." } +console_error_panic_hook = "0.1.5" +dominator = "0.5.0" wasm-bindgen = "0.2.48" futures-signals = "0.3.0" lazy_static = "1.0.0" - -[target."cfg(debug_assertions)".dependencies] -console_error_panic_hook = "0.1.5" diff --git a/examples/counter/README.md b/examples/counter/README.md index 46fe09f..fa8376c 100644 --- a/examples/counter/README.md +++ b/examples/counter/README.md @@ -4,14 +4,7 @@ yarn install ``` -## How to run in debug mode - -```sh -# Builds the project and opens it in a new browser tab. Auto-reloads when the project changes. -yarn start -``` - -## How to build in release mode +## How to build ```sh # Builds the project and places it into the `dist` folder. diff --git a/examples/counter/static/index.html b/examples/counter/dist/index.html similarity index 78% rename from examples/counter/static/index.html rename to examples/counter/dist/index.html index b4968da..0113194 100644 --- a/examples/counter/static/index.html +++ b/examples/counter/dist/index.html @@ -5,6 +5,6 @@ rust-dominator • Counter - + diff --git a/examples/counter/js/index.js b/examples/counter/js/index.js deleted file mode 100644 index 9db81ab..0000000 --- a/examples/counter/js/index.js +++ /dev/null @@ -1 +0,0 @@ -import("../pkg/index.js").catch(console.error); diff --git a/examples/counter/package.json b/examples/counter/package.json index 9c66da7..a495720 100644 --- a/examples/counter/package.json +++ b/examples/counter/package.json @@ -1,17 +1,14 @@ { - "author": "Pauan ", + "private": true, + "author": "Pauan ", "name": "counter", "version": "0.1.0", "scripts": { - "build": "rimraf dist pkg && webpack", - "start": "rimraf dist pkg && webpack-dev-server -d" + "build": "rimraf dist/js && rollup --config" }, "devDependencies": { - "@wasm-tool/wasm-pack-plugin": "^0.4.2", - "copy-webpack-plugin": "^5.0.3", - "rimraf": "^2.6.3", - "webpack": "^4.33.0", - "webpack-cli": "^3.3.3", - "webpack-dev-server": "^3.7.1" + "@wasm-tool/rollup-plugin-rust": "^1.0.0", + "rimraf": "^3.0.2", + "rollup": "^1.31.0" } } diff --git a/examples/counter/rollup.config.js b/examples/counter/rollup.config.js new file mode 100644 index 0000000..01b54d3 --- /dev/null +++ b/examples/counter/rollup.config.js @@ -0,0 +1,17 @@ +import rust from "@wasm-tool/rollup-plugin-rust"; + +export default { + input: { + index: "./Cargo.toml", + }, + output: { + dir: "dist/js", + format: "iife", + sourcemap: true, + }, + plugins: [ + rust({ + serverPath: "js/", + }), + ], +}; diff --git a/examples/counter/webpack.config.js b/examples/counter/webpack.config.js deleted file mode 100644 index e1bb304..0000000 --- a/examples/counter/webpack.config.js +++ /dev/null @@ -1,33 +0,0 @@ -const path = require("path"); -const CopyPlugin = require("copy-webpack-plugin"); -const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin"); - -const dist = path.resolve(__dirname, "dist"); - -module.exports = { - mode: "production", - stats: "errors-warnings", - entry: { - index: "./js/index.js" - }, - output: { - path: dist, - filename: "[name].js" - }, - devServer: { - liveReload: true, - open: true, - noInfo: true, - overlay: true - }, - plugins: [ - new CopyPlugin([ - path.resolve(__dirname, "static") - ]), - - new WasmPackPlugin({ - crateDirectory: __dirname, - extraArgs: "--out-name index" - }) - ] -}; diff --git a/examples/todomvc/.gitignore b/examples/todomvc/.gitignore index 36867e8..5008655 100644 --- a/examples/todomvc/.gitignore +++ b/examples/todomvc/.gitignore @@ -1,6 +1,5 @@ node_modules -/dist +/dist/js /target -/pkg /wasm-pack.log /yarn-error.log diff --git a/examples/todomvc/Cargo.toml b/examples/todomvc/Cargo.toml index b7e45b6..d3992c7 100644 --- a/examples/todomvc/Cargo.toml +++ b/examples/todomvc/Cargo.toml @@ -2,7 +2,7 @@ name = "todomvc" version = "0.1.0" description = "TodoMVC using dominator" -authors = ["Pauan "] +authors = ["Pauan "] categories = ["wasm"] readme = "README.md" license = "MIT" @@ -15,7 +15,8 @@ lto = true crate-type = ["cdylib"] [dependencies] -dominator = { path = "../.." } +console_error_panic_hook = "0.1.5" +dominator = "0.5.0" futures-signals = "0.3.0" wasm-bindgen = "0.2.48" serde_json = "1.0.10" @@ -31,6 +32,3 @@ features = [ "Storage", "Url", ] - -[target."cfg(debug_assertions)".dependencies] -console_error_panic_hook = "0.1.5" diff --git a/examples/todomvc/README.md b/examples/todomvc/README.md index 46fe09f..fa8376c 100644 --- a/examples/todomvc/README.md +++ b/examples/todomvc/README.md @@ -4,14 +4,7 @@ yarn install ``` -## How to run in debug mode - -```sh -# Builds the project and opens it in a new browser tab. Auto-reloads when the project changes. -yarn start -``` - -## How to build in release mode +## How to build ```sh # Builds the project and places it into the `dist` folder. diff --git a/examples/todomvc/static/index.html b/examples/todomvc/dist/index.html similarity index 94% rename from examples/todomvc/static/index.html rename to examples/todomvc/dist/index.html index c8d48d2..45762ed 100644 --- a/examples/todomvc/static/index.html +++ b/examples/todomvc/dist/index.html @@ -15,6 +15,6 @@

Part of TodoMVC

- + diff --git a/examples/todomvc/static/lib/todomvc-app-css/index.css b/examples/todomvc/dist/lib/todomvc-app-css/index.css similarity index 100% rename from examples/todomvc/static/lib/todomvc-app-css/index.css rename to examples/todomvc/dist/lib/todomvc-app-css/index.css diff --git a/examples/todomvc/static/lib/todomvc-common/base.css b/examples/todomvc/dist/lib/todomvc-common/base.css similarity index 100% rename from examples/todomvc/static/lib/todomvc-common/base.css rename to examples/todomvc/dist/lib/todomvc-common/base.css diff --git a/examples/todomvc/static/lib/todomvc-common/base.js b/examples/todomvc/dist/lib/todomvc-common/base.js similarity index 100% rename from examples/todomvc/static/lib/todomvc-common/base.js rename to examples/todomvc/dist/lib/todomvc-common/base.js diff --git a/examples/todomvc/js/index.js b/examples/todomvc/js/index.js deleted file mode 100644 index 9db81ab..0000000 --- a/examples/todomvc/js/index.js +++ /dev/null @@ -1 +0,0 @@ -import("../pkg/index.js").catch(console.error); diff --git a/examples/todomvc/package.json b/examples/todomvc/package.json index 808965e..c2efd64 100644 --- a/examples/todomvc/package.json +++ b/examples/todomvc/package.json @@ -1,17 +1,14 @@ { - "author": "Pauan ", + "private": true, + "author": "Pauan ", "name": "todomvc", "version": "0.1.0", "scripts": { - "build": "rimraf dist pkg && webpack", - "start": "rimraf dist pkg && webpack-dev-server -d" + "build": "rimraf dist/js && rollup --config" }, "devDependencies": { - "@wasm-tool/wasm-pack-plugin": "^0.4.2", - "copy-webpack-plugin": "^5.0.3", - "rimraf": "^2.6.3", - "webpack": "^4.33.0", - "webpack-cli": "^3.3.3", - "webpack-dev-server": "^3.7.1" + "@wasm-tool/rollup-plugin-rust": "^1.0.0", + "rimraf": "^3.0.2", + "rollup": "^1.31.0" } } diff --git a/examples/todomvc/rollup.config.js b/examples/todomvc/rollup.config.js new file mode 100644 index 0000000..01b54d3 --- /dev/null +++ b/examples/todomvc/rollup.config.js @@ -0,0 +1,17 @@ +import rust from "@wasm-tool/rollup-plugin-rust"; + +export default { + input: { + index: "./Cargo.toml", + }, + output: { + dir: "dist/js", + format: "iife", + sourcemap: true, + }, + plugins: [ + rust({ + serverPath: "js/", + }), + ], +}; diff --git a/examples/todomvc/webpack.config.js b/examples/todomvc/webpack.config.js deleted file mode 100644 index e1bb304..0000000 --- a/examples/todomvc/webpack.config.js +++ /dev/null @@ -1,33 +0,0 @@ -const path = require("path"); -const CopyPlugin = require("copy-webpack-plugin"); -const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin"); - -const dist = path.resolve(__dirname, "dist"); - -module.exports = { - mode: "production", - stats: "errors-warnings", - entry: { - index: "./js/index.js" - }, - output: { - path: dist, - filename: "[name].js" - }, - devServer: { - liveReload: true, - open: true, - noInfo: true, - overlay: true - }, - plugins: [ - new CopyPlugin([ - path.resolve(__dirname, "static") - ]), - - new WasmPackPlugin({ - crateDirectory: __dirname, - extraArgs: "--out-name index" - }) - ] -}; diff --git a/src/operations.rs b/src/operations.rs index 52bc062..80f72c4 100644 --- a/src/operations.rs +++ b/src/operations.rs @@ -10,7 +10,7 @@ use futures_signals::signal::{Signal, SignalExt}; use futures_signals::signal_vec::{VecDiff, SignalVec, SignalVecExt}; use web_sys::Node; use wasm_bindgen::UnwrapThrowExt; -use wasm_bindgen_futures::futures_0_3::spawn_local; +use wasm_bindgen_futures::spawn_local; use crate::bindings; use crate::dom::Dom;