i dont understand the directory option
VincentJ711 opened this issue · 1 comments
VincentJ711 commented
I don't see the point of the directory option. What does it even do? Can this be documented? I feel like the filename option is all the client needs to provide. For example, "give me the dependency tree starting at the given filename". Thanks.
mrjoelkemp commented
There might be ways of eliminating its use by inferring the root directory about the given filename. However, for accuracy, the root directory is taken in to avoid guessing what the root is based on the given file. That root is mostly just used as a naive fallback if compiler configuration wasn't supplied to explicitly declare the root.
- One example of where it's used: https://github.com/dependents/node-filing-cabinet/blob/01443be2e00de2e3285a4c697d62c27968fd8ee3/index.js#L230.
- For AMD file resolution, it's used as a fallback for determining the resolution directory of the project.