- Description:
Watches source files for changes and triggers server restarts and/or web rebuilds.
This module is meant for development use. It sets up filesystem watchers on:
-
Backend/module sources (server-side JS):
- Adds BackendJS core directory (
libdir) and<cwd>/modules - Adds all configured module paths from
app.path.modules(deduped) - Watches recursive
*.jschanges (ignoringmod.ignore) - On change, calls the internal restart handler (
_restart) to restart the process
- Adds BackendJS core directory (
-
Web/source assets (client-side files), only when
mod.buildis configured:- Builds a unique set of web roots including:
app.cwd<backendjs>/../web- Any directories listed in
mod.web- If an entry is absolute: watch it as-is
- If relative: apply it to every package in
app.packages(e.g.web/js)
- Watches recursive files matching
mod.match(default:.js|.css|.html) while ignoringmod.ignore(default ignores*.bundle.(js|css)) - On change, calls the internal rebuild handler (
_rebuild) which runs the build command
- Builds a unique set of web roots including:
Additional behavior:
- If
app.repl.watcherPortis set, starts a REPL on that port (for dev introspection). - Uses
mod.delayto debounce rapid save bursts (handled by the restart/build handlers). - Logs what it is watching and what build command is used.
- Finally calls
startProcess()to launch/ensure the watched process is running.
-
- Source:
module:watcher
- Description:
Watch the sources for changes and restart the server
- Source: