watcher

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:

    1. 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 *.js changes (ignoring mod.ignore)
      • On change, calls the internal restart handler (_restart) to restart the process
    2. Web/source assets (client-side files), only when mod.build is 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 ignoring mod.ignore (default ignores *.bundle.(js|css))
      • On change, calls the internal rebuild handler (_rebuild) which runs the build command

    Additional behavior:

    • If app.repl.watcherPort is set, starts a REPL on that port (for dev introspection).
    • Uses mod.delay to 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: