Don't use path dependencies in examples

This commit updates all examples to not use `path` dependencies but
rather use versioned dependencies like would typically be found in the
wild. This should hopefully make the examples more copy-pastable and
less alien to onlookers!

The development of the examples remains the same where they continue to
use the `wasm-bindgen`, `js-sys`, `web-sys`, etc from in-tree. The
workspace-level `[patch]` section ensures that they use the in-tree
versions instead of the crates.io versions.
This commit is contained in:
Alex Crichton 2018-11-07 11:14:25 -08:00
parent ac6a230d83
commit 56400c3738
23 changed files with 60 additions and 66 deletions

View File

@ -83,3 +83,6 @@ members = [
[patch.crates-io] [patch.crates-io]
wasm-bindgen = { path = '.' } wasm-bindgen = { path = '.' }
wasm-bindgen-futures = { path = 'crates/futures' }
js-sys = { path = 'crates/js-sys' }
web-sys = { path = 'crates/web-sys' }

View File

@ -1,10 +1,10 @@
[package] [package]
name = "add" name = "add"
version = "0.1.0" version = "0.1.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"] authors = ["The wasm-bindgen Developers"]
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
wasm-bindgen = { path = "../.." } wasm-bindgen = "0.2.27"

View File

@ -7,11 +7,11 @@ authors = ["The wasm-bindgen Developers"]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
js-sys = { path = "../../crates/js-sys" } js-sys = "0.3.4"
wasm-bindgen = { path = "../.." } wasm-bindgen = "0.2.27"
[dependencies.web-sys] [dependencies.web-sys]
path = "../../crates/web-sys" version = "0.3.4"
features = [ features = [
'CanvasRenderingContext2d', 'CanvasRenderingContext2d',
'Document', 'Document',

View File

@ -1,14 +1,10 @@
[package] [package]
name = "char" name = "char"
version = "0.1.0" version = "0.1.0"
authors = ["Robert Masen <r@robertmasen.com>"] authors = ["The wasm-bindgen Developers"]
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
# Here we're using a path dependency to use what's already in this repository, wasm-bindgen = "0.2.27"
# but you'd use the commented out version below if you're copying this into your
# project.
wasm-bindgen = { path = "../.." }
#wasm-bindgen = "0.2"

View File

@ -1,17 +1,17 @@
[package] [package]
name = "closures" name = "closures"
version = "0.1.0" version = "0.1.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"] authors = ["The wasm-bindgen Developers"]
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
wasm-bindgen = { path = "../.." } wasm-bindgen = "0.2.27"
js-sys = { path = "../../crates/js-sys" } js-sys = "0.3.4"
[dependencies.web-sys] [dependencies.web-sys]
path = "../../crates/web-sys" version = "0.3.4"
features = [ features = [
'CssStyleDeclaration', 'CssStyleDeclaration',
'Document', 'Document',

View File

@ -1,11 +1,11 @@
[package] [package]
name = "console_log" name = "console_log"
version = "0.1.0" version = "0.1.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"] authors = ["The wasm-bindgen Developers"]
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
wasm-bindgen = { path = "../.." } wasm-bindgen = "0.2.27"
web-sys = { path = '../../crates/web-sys', features = ['console'] } web-sys = { version = "0.3.4", features = ['console'] }

View File

@ -7,10 +7,10 @@ authors = ["The wasm-bindgen Developers"]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
wasm-bindgen = { path = "../.." } wasm-bindgen = "0.2.27"
[dependencies.web-sys] [dependencies.web-sys]
path = '../../crates/web-sys' version = "0.3.4"
features = [ features = [
'Document', 'Document',
'Element', 'Element',

View File

@ -7,4 +7,4 @@ authors = ["The wasm-bindgen Developers"]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
wasm-bindgen = { path = "../.." } wasm-bindgen = "0.2.27"

View File

@ -8,14 +8,14 @@ crate-type = ["cdylib"]
[dependencies] [dependencies]
futures = "0.1.20" futures = "0.1.20"
wasm-bindgen = { path = "../..", features = ["serde-serialize"] } wasm-bindgen = { version = "0.2.27", features = ["serde-serialize"] }
js-sys = { path = "../../crates/js-sys" } js-sys = "0.3.4"
wasm-bindgen-futures = { path = "../../crates/futures" } wasm-bindgen-futures = "0.3.4"
serde = "^1.0.59" serde = "^1.0.59"
serde_derive = "^1.0.59" serde_derive = "^1.0.59"
[dependencies.web-sys] [dependencies.web-sys]
path = "../../crates/web-sys" version = "0.3.4"
features = [ features = [
'Headers', 'Headers',
'Request', 'Request',

View File

@ -1,10 +1,10 @@
[package] [package]
name = "guide-supported-types-examples" name = "guide-supported-types-examples"
version = "0.1.0" version = "0.1.0"
authors = ["Nick Fitzgerald <fitzgen@gmail.com>"] authors = ["The wasm-bindgen Developers"]
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
wasm-bindgen = { path = "../.." } wasm-bindgen = "0.2.27"

View File

@ -7,8 +7,4 @@ authors = ["The wasm-bindgen Developers"]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
# Here we're using a path dependency to use what's already in this repository, wasm-bindgen = "0.2.27"
# but you'd use the commented out version below if you're copying this into your
# project.
wasm-bindgen = { path = "../.." }
#wasm-bindgen = "0.2"

View File

@ -1,10 +1,10 @@
[package] [package]
name = "import_js" name = "import_js"
version = "0.1.0" version = "0.1.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"] authors = ["The wasm-bindgen Developers"]
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
wasm-bindgen = { path = "../.." } wasm-bindgen = "0.2.27"

View File

@ -1,16 +1,16 @@
[package] [package]
name = "julia_set" name = "julia_set"
version = "0.1.0" version = "0.1.0"
authors = ["Marcin Baraniecki <marcinbar1@gmail.com>"] authors = ["The wasm-bindgen Developers"]
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
wasm-bindgen = { path = "../.." } wasm-bindgen = "0.2.27"
[dependencies.web-sys] [dependencies.web-sys]
path = '../../crates/web-sys' version = "0.3.4"
features = [ features = [
'ImageData', 'ImageData',
'CanvasRenderingContext2d', 'CanvasRenderingContext2d',

View File

@ -1,10 +1,10 @@
[package] [package]
name = "no_modules" name = "no_modules"
version = "0.1.0" version = "0.1.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"] authors = ["The wasm-bindgen Developers"]
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
wasm-bindgen = { path = "../.." } wasm-bindgen = "0.2.27"

View File

@ -7,11 +7,11 @@ authors = ["The wasm-bindgen Developers"]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
js-sys = { path = "../../crates/js-sys" } js-sys = "0.3.4"
wasm-bindgen = { path = "../.." } wasm-bindgen = "0.2.27"
[dependencies.web-sys] [dependencies.web-sys]
path = "../../crates/web-sys" version = "0.3.4"
features = [ features = [
'CanvasRenderingContext2d', 'CanvasRenderingContext2d',
'CssStyleDeclaration', 'CssStyleDeclaration',

View File

@ -7,9 +7,9 @@ authors = ["The wasm-bindgen Developers"]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
wasm-bindgen = { path = "../.." } wasm-bindgen = "0.2.27"
humantime = "1" humantime = "1"
[dependencies.web-sys] [dependencies.web-sys]
path = '../../crates/web-sys' version = "0.3.4"
features = ['Window', 'Performance', 'PerformanceTiming'] features = ['Window', 'Performance', 'PerformanceTiming']

View File

@ -9,13 +9,13 @@ crate-type = ["cdylib"]
[dependencies] [dependencies]
console_error_panic_hook = "0.1" console_error_panic_hook = "0.1"
futures = "0.1" futures = "0.1"
js-sys = { path = '../../crates/js-sys' } js-sys = "0.3.4"
raytracer = { git = 'https://github.com/alexcrichton/raytracer', branch = 'update-deps' } raytracer = { git = 'https://github.com/alexcrichton/raytracer', branch = 'update-deps' }
wasm-bindgen = { path = "../..", features = ['serde-serialize'] } wasm-bindgen = { version = "0.2.27", features = ['serde-serialize'] }
wasm-bindgen-futures = { path = '../../crates/futures' } wasm-bindgen-futures = "0.3.4"
[dependencies.web-sys] [dependencies.web-sys]
path = '../../crates/web-sys' version = "0.3.4"
features = [ features = [
'CanvasRenderingContext2d', 'CanvasRenderingContext2d',
'ErrorEvent', 'ErrorEvent',

View File

@ -10,12 +10,12 @@ crate-type = ["cdylib"]
askama = "0.7.2" askama = "0.7.2"
[dependencies] [dependencies]
js-sys = { path = "../../crates/js-sys" } js-sys = "0.3.4"
wasm-bindgen = { path = "../../" } wasm-bindgen = "0.2.27"
askama = "0.7.2" askama = "0.7.2"
[dependencies.web-sys] [dependencies.web-sys]
path = "../../crates/web-sys" version = "0.3.4"
features = [ features = [
'console', 'console',
'CssStyleDeclaration', 'CssStyleDeclaration',

View File

@ -1,11 +1,11 @@
[package] [package]
name = "wasm-in-wasm" name = "wasm-in-wasm"
version = "0.1.0" version = "0.1.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"] authors = ["The wasm-bindgen Developers"]
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
wasm-bindgen = { path = "../.." } wasm-bindgen = "0.2.27"
js-sys = { path = "../../crates/js-sys" } js-sys = "0.3.4"

View File

@ -1,14 +1,10 @@
[package] [package]
name = "wasm2js" name = "wasm2js"
version = "0.1.0" version = "0.1.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"] authors = ["The wasm-bindgen Developers"]
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
# Here we're using a path dependency to use what's already in this repository, wasm-bindgen = "0.2.27"
# but you'd use the commented out version below if you're copying this into your
# project.
wasm-bindgen = { path = "../.." }
#wasm-bindgen = "0.2"

View File

@ -7,10 +7,10 @@ authors = ["The wasm-bindgen Developers"]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
wasm-bindgen = { path = "../.." } wasm-bindgen = "0.2.27"
[dependencies.web-sys] [dependencies.web-sys]
path = "../../crates/web-sys" version = "0.3.4"
features = [ features = [
'AudioContext', 'AudioContext',
'AudioDestinationNode', 'AudioDestinationNode',

View File

@ -7,11 +7,11 @@ authors = ["The wasm-bindgen Developers"]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
js-sys = { path = "../../crates/js-sys" } js-sys = "0.3.4"
wasm-bindgen = { path = "../.." } wasm-bindgen = "0.2.27"
[dependencies.web-sys] [dependencies.web-sys]
path = "../../crates/web-sys" version = "0.3.4"
features = [ features = [
'Document', 'Document',
'Element', 'Element',

View File

@ -57,13 +57,14 @@ fn main() {
let mut crates = Vec::new(); let mut crates = Vec::new();
crates.push(read_crate("./Cargo.toml".as_ref())); crates.push(read_crate("./Cargo.toml".as_ref()));
find_crates("crates".as_ref(), &mut crates); find_crates("crates".as_ref(), &mut crates);
find_crates("examples".as_ref(), &mut crates);
let pos = CRATES_TO_PUBLISH.iter() let pos = CRATES_TO_PUBLISH.iter()
.chain(CRATES_TO_AVOID_PUBLISH) .chain(CRATES_TO_AVOID_PUBLISH)
.enumerate() .enumerate()
.map(|(i, c)| (*c, i)) .map(|(i, c)| (*c, i))
.collect::<HashMap<_, _>>(); .collect::<HashMap<_, _>>();
crates.sort_by_key(|krate| pos[&krate.name[..]]); crates.sort_by_key(|krate| pos.get(&krate.name[..]));
match &env::args().nth(1).expect("must have one argument")[..] { match &env::args().nth(1).expect("must have one argument")[..] {
"bump" => { "bump" => {
@ -90,6 +91,8 @@ fn find_crates(dir: &Path, dst: &mut Vec<Crate>) {
.any(|c| krate.name == *c) .any(|c| krate.name == *c)
{ {
dst.push(krate); dst.push(krate);
} else if dir.iter().any(|s| s == "examples") {
dst.push(krate);
} else { } else {
panic!("failed to find {:?} in whitelist or blacklist", krate.name); panic!("failed to find {:?} in whitelist or blacklist", krate.name);
} }