Open codewithmichael opened 8 years ago
I recently published dependency-sorter, which handles pretty much everything this issue needs. I'm fine with importing a minified copy (or portion) of it here with attribution.
The weight system might be overkill, though. It would probably suffice to pull the method that performs the initial topological sort.
Aside: To address concerns in issue #2 without a weight system, we could just cherry-pick the libs from DEFAULT_MODULES
after the topological sort and append them to the end of the list—specifically RequireJS.
I copied in a minified version of dependency-sorter
and have this working on branch issue1-and-issue2
(it will resolve both this issue and issue #2).
Still requires README documentation.
Due to the documentation rewrite (issue #25), there will be no documentation pass.
In review - PR #26.
Currently the modules config accepts either Object or Array syntax—the latter being required when load order is important.
A simpler system is to use a "depends" field to note when one lib requires another.
The obvious advantages are a unified syntax (Object-only) and explicit requirement designation ("B depends on A").
Example:
There's no specific necessity to deprecate the array syntax, as a "depends" system necessitates conversion to an Array (or similar construct) for ordered processing.
Circular Dependencies:
In case of circular dependency, it's natural to assume no guaranteed load order.