Skip to content

Method to retrieve a list of dependencies used to compile a template #233

@rdmurphy

Description

@rdmurphy

Hello! I've poked around a bit but haven't had any luck figuring out if this is already possible — is there/could there be a way to determine what all files were involved in compiling a template? This would essentially be the list of "dependencies" that went into preparing a template. This would be useful for setting up a file watcher or doing intelligent re-compiles of templates only when one of a template's dependencies change.

Some examples in the wild:

  • In Nunjucks this is handled by an .on('load') event on the Nunjucks instance itself, but IMO it suffers from a couple flaws — it's not clear which input file being rendered triggered a load event, and setting this up is removed from the compile process.

  • In dart-sass this is undocumented but each render returns a list of includedFiles which references every single sass file that was touched in the process of preparing the styles. This is particularly ideal because there's no confusion as to how an entrypoint was prepared — this list is part of the render's response.

I will admit I am not 100% familiar with how liquidjs parses files and whether it eagerly does so or not, but I could imagine some sort of reference being added to Template instances (AKA the return value of parse and parseFile) may be workable.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions