@require directive, gives scripts the ability to declare their own dependencies. When MinCat encounters this directive, it will begin building a dependency graph, collecting and sorting all of the scripts necessary to load its current target.
Required files are free to require other files. MinCat will follow the chain of required files all the way to the end.
The order in which MinCat concatenates these files is dictated by the source graph. For instance, consider these three files:
When MinCat operates on this collection of files, it will produce a single minimized file:
c.js files will not be minimized because they contains the
/* skip minimize */ directive.
a.min.js would contain the contents of
a.js, in that order. Even though
c.js are not minimized by themselves, they are still minimized as part of
The order here is specified because
b.js contains a
@require directive that includes
b.js lacked this directive, the ordering of
c.js would be undefined. However, both would still be guaranteed to appear before
a.js requires both of them.
Note also that
c.js is included only once in
a.min.js, even though both
b.js require it. MinCat always filters its dependency graph so that it deals with a distinct list of scripts.
<references /> directive. Also like MinCat, Visual Studio uses this directive to build a graph of the current file's dependencies.
However, while these two directives serve a similar purpose, they are used in very different, incompatible ways. Specifically, the
<references /> directive is allowed (and often desired) to build self-referential structures. That is, as far as intellisense is concerned, it is valid for
a.js to reference
b.js and for
b.js to reference
a.js, forming a reference loop.
This sort of structure is useful for Visual Studio to provide complete intellisense in both files. Unfortunately, this same structure makes it impossible for MinCat to determine which file should appear first: they both require one another. While this is not a problem for intellisense, MinCat requires a less ambiguous situation.
For this reason, MinCat's
@require directive is intentionally separate from Visual Studio's similar
<references /> directive.