-
Notifications
You must be signed in to change notification settings - Fork 2
The Tree
Throughout a mako build, a tree (aka: graph) is at the core of everything. While most plugins operate on individual files, some more advanced plugins can traverse the entire graph and make modifications. Check out the mako-tree documentation for more information about the API it exposes.
The term build in mako refers to the entire process of taking entry files, finding dependency files then assembling the output files. This process goes through 2 distinct phases:
During the parse phase, a "dependency tree" is being built up by recursively processing each entry file and it's dependencies. By the end of this phase, the tree will consist of all the input files that will be used during the compile phase.
During the compile phase, the dependency tree is cloned, and then becomes a "build tree". The tree may be deconstructed some, such as when entire JS/CSS dependency trees are combined into a single file. This is why each build gets a new tree, since it is destructive by design. By the end of this phase, the tree will consist of all the files that will be written.
Generally, but not always, this corresponds pretty closely with the number of entry files. Some notable exceptions are CSS with linked images/fonts, which will also remain in the tree so they will be copied to the destination.
At it's core, the tree uses a graph data structure. (powered by graph.js) This choice makes some of the more tricky aspects of dependency tree traversal simpler and more efficient.