Updating examples to use Rollup

This commit is contained in:
Pauan 2020-03-11 14:23:41 +01:00
parent 833a3c4ec0
commit 5083e7bdea
29 changed files with 93 additions and 186 deletions

View File

@ -1,7 +1,7 @@
[package]
name = "dominator"
version = "0.5.7"
authors = ["Pauan <pcxunlimited@gmail.com>"]
authors = ["Pauan <pauanyu+github@pm.me>"]
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"

View File

@ -1,6 +1,5 @@
node_modules
/dist
/dist/js
/target
/pkg
/wasm-pack.log
/yarn-error.log

View File

@ -2,7 +2,7 @@
name = "animation"
version = "0.1.0"
description = "Animation demo using dominator"
authors = ["Pauan <pcxunlimited@gmail.com>"]
authors = ["Pauan <pauanyu+github@pm.me>"]
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"

View File

@ -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.

View File

@ -5,6 +5,6 @@
<title>rust-dominator • Animation</title>
</head>
<body>
<script src="index.js"></script>
<script src="js/index.js"></script>
</body>
</html>

View File

@ -1 +0,0 @@
import("../pkg/index.js").catch(console.error);

View File

@ -1,17 +1,14 @@
{
"author": "Pauan <pcxunlimited@gmail.com>",
"private": true,
"author": "Pauan <pauanyu+github@pm.me>",
"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"
}
}

View File

@ -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/",
}),
],
};

View File

@ -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"
})
]
};

View File

@ -1,6 +1,5 @@
node_modules
/dist
/dist/js
/target
/pkg
/wasm-pack.log
/yarn-error.log

View File

@ -2,7 +2,7 @@
name = "counter"
version = "0.1.0"
description = "Counter demo using dominator"
authors = ["Pauan <pcxunlimited@gmail.com>"]
authors = ["Pauan <pauanyu+github@pm.me>"]
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"

View File

@ -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.

View File

@ -5,6 +5,6 @@
<title>rust-dominator • Counter</title>
</head>
<body>
<script src="index.js"></script>
<script src="js/index.js"></script>
</body>
</html>

View File

@ -1 +0,0 @@
import("../pkg/index.js").catch(console.error);

View File

@ -1,17 +1,14 @@
{
"author": "Pauan <pcxunlimited@gmail.com>",
"private": true,
"author": "Pauan <pauanyu+github@pm.me>",
"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"
}
}

View File

@ -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/",
}),
],
};

View File

@ -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"
})
]
};

View File

@ -1,6 +1,5 @@
node_modules
/dist
/dist/js
/target
/pkg
/wasm-pack.log
/yarn-error.log

View File

@ -2,7 +2,7 @@
name = "todomvc"
version = "0.1.0"
description = "TodoMVC using dominator"
authors = ["Pauan <pcxunlimited@gmail.com>"]
authors = ["Pauan <pauanyu+github@pm.me>"]
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"

View File

@ -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.

View File

@ -15,6 +15,6 @@
<p>Part of <a href="http://todomvc.com">TodoMVC</a></p>
</footer>
<script src="lib/todomvc-common/base.js"></script>
<script src="index.js"></script>
<script src="js/index.js"></script>
</body>
</html>

View File

@ -1 +0,0 @@
import("../pkg/index.js").catch(console.error);

View File

@ -1,17 +1,14 @@
{
"author": "Pauan <pcxunlimited@gmail.com>",
"private": true,
"author": "Pauan <pauanyu+github@pm.me>",
"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"
}
}

View File

@ -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/",
}),
],
};

View File

@ -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"
})
]
};

View File

@ -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;