workspaces-to-typescript-project-references: add option to sort references with dependent-upon logic
Hi guys, I was wondering if it wouldn't be that complicated to add an option to sort references using a dependent-upon logic instead of an alphabetical one (especially in the root tsconfig file).
By dependent-upon logic I mean for packages that are dependencies for other packages to appear first in the lists.
I assume you already have the required information since you need to resolve the dependency graph to create the references.
My proposal is motivated by this issue: https://github.com/typescript-eslint/typescript-eslint/issues/2094#issuecomment-1564719858
I know that it is some sort of edge case, but I think that this sorting logic could be of more value than the alphabetical one (which can be easily obtained at a latter time).
My intention is to import my tsconfig file and use the references list. This way I don't need to keep a separate list of dependencies with this particular order elsewhere.
Cheers.
I am not aware of any semantic difference in the order of references.
It looks like TypeScript docs does not mention it.
- https://www.typescriptlang.org/docs/handbook/project-references.html
However, I think it makes sense to topological sort the elements of references.
Currently, references is not sorted. This change will make it more stable (but this is a BREAKING CHANGE).
- #44
๐ old lerna has --sort option, but it will be removed. I don't think it's worth much to make it an option.
- lerna/README.md at 11d847308bb8f4078e47a30a14b4d883948c4530 ยท lerna/lerna
- Lerna 6: Obsolete Options | Lerna
๐ moon has same feature for TypeScript project references. It may be worth looking into what sorting MOON does.