Efficient rebuild of scripts when `lib` files change

This script watches the lib folder, and when changes to ts files are made, it does 2 things:

  1. Create/update a dependency graph of libFilePath -> dependantScriptPaths[]
  2. Touches all script files that depend on the changed lib file to trigger rebuild.

https://gist.github.com/BeSpunky/d40bf6052b2c9a4f3a58b22108e5124a

TLDR Currently, ScriptKit only rebuilds scripts if it detects changes to the scripts folder. If you extract your reusable parts and put them into the lib folder, ScriptKit doesn't pick up on changes to those files. The manual way to overcome this is to save your script file again and trigger rebuild.

No more... :)

Actually, this is a 3 scripts solution:

  1. update-script-dependency-graphs: Partially rebuilds the graph if a triggering file has been provided, otherwise completely rebuilds it.
  2. watch-libs: Watches lib files, partially rebuild the graph using update-script-dependency-graph, then touch the scripts.
  3. watch-scripts: Watch script files, partially rebuild the graph