Skip to content

Commit

Permalink
Add unresolved question about file watching heuristics
Browse files Browse the repository at this point in the history
  • Loading branch information
fitzgen committed Mar 11, 2019
1 parent 8aae141 commit b8eaf03
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions text/010-wasm-pack-watch-and-serve.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ ARGS:
### Implementation

We can use [the `notify` crate][notify] to watch the filesystem for
changes. Initially, we will just watch the crate directory for
changes. Eventually, we can use [`cargo build --build-plan`][build-plan] to get
a list of files that we should be watching.
changes. Initially, we will use some heuristics to determine which files an
directories to watch (see unresolved questions). Eventually, we can use [`cargo
build --build-plan`][build-plan] to get a list of files that we should be
watching.

[notify]: https://crates.io/crates/notify
[build-plan]: https://github.com/rust-lang/cargo/issues/5579
Expand Down Expand Up @@ -225,6 +226,20 @@ and add these `wasm-pack` features?
features. But ideally we shouldn't need to do this given that `miniserve`
seems to fulfill all of our requirements.

* Until we can use `cargo build --build-plan`, what heuristics should we employ
to guess what files and directories to watch for changes? This decision seems
like something that doesn't have to be written in stone in this RFC, and can
be experimented with during implementation and via user feedback. That said,
there have been suggestions for all of

* the crate's directory and its contained files and directories,
* walking up to find the `.git` folder at the root of a git repository and
watching the whole repository,
* finding the root of the workspace (either via `cargo-metadata` or by peeking

This comment has been minimized.

Copy link
@chinedufn

chinedufn Mar 11, 2019

FWIW in larger projects where you have multiple watchers for different subcrates in the workspace needing to rebuild whenever something in the workspace changed would be no fun since wasted builds means time that other things don’t get to build because the build directory is locked.

I am working on a project with like .. 8+ watchers running (not 8 are for wasm-pack but a couple of them are.)

Sorry for the word jumble .. on mobile .. but basically calling out that changing for anything besides dependencies of the crate in question would slow me down in my larger projects where I am working on multiple workspace crates with very different watching needs.

Also - in my largest project I will include things into the binary from pretty arbitrary folders. So being able to specify folders or files to watch would be nice.

FWIW I’m getting a lot of mileage out of watchexec in my larger more complicated projects that have atypical watching needs .. so the first place that I’d use wasm-pack is in smaller one off demos / tutorials / etc where watching everything is mostly fine.
Will be lovely not needing to tell people to install a static server and a watcher on top of installing wasm-pack!

Hope the feedback helps!

at the set of dependencies in the crate's `Cargo.toml`) and watching the
whole workspace,
* and some combination of these options.

[https]: https://crates.io/crates/https
[miniserve]: https://crates.io/crates/miniserve
[simple-http]: https://crates.io/crates/simple-http-server

0 comments on commit b8eaf03

Please sign in to comment.