« Home

Feature. tr/depends: hash-only file dependencies [tr-depends]

tr's content-addressed build already tracks @include{path} as an extra input to a card's build signature, so a generated HTML file (e.g. Agda's HTML backend) changes invalidate the card even when the .scrbl itself is untouched. But @include also splices the file's bytes into the rendered output, which is only right when you actually want the file inlined.

Sometimes a card links to a hand-authored file it does not want inlined -- e.g. an animation .js loaded from a raw script element instead of being spliced in. Until now the only way to make editing that file invalidate the card was to fake an @include, which would incorrectly splice the JS source into the page.

@tr/depends{path} provides a solution for this: it renders nothing, and only tells the build signature "this card also depends on this file". path is resolved relative to the project root, not _tmp/ like @include is, since a @tr/depends file is never spliced in and so has no render-time resolution rule of its own.

@title{Some Animation}
@tr/depends{assets/anim.js}

@p{... some card content that loads the file via a script element ...}

Editing assets/anim.js now rebuilds the card even though card file xxx.scrbl never changed.