Add option to disable sort on `nx format:write` and/or group by type
See original GitHub issueDescription
#2607 and #5945 introduced the feature that nx format:write
automatically sorts all project config files alphabetically. This might not be wanted in all situation and you should have the ability to disable it.
In addition I think that the sort feature should be extended to be able to “group” the configs together by type. E.g. Apps + E2E should still be at the beginning of the file (but sorted) and only after that the libs should be sorted.
Motivation
The current behavior might not be desired for everyone and can make it harder to find certain configurations if you had a system in place how you sort them (maybe shared libs at the start and then everything sorted by app dependency)
Suggested Implementation
Add a parameter to the command name --sort
which accepts the following values false
(disables it all together), alpha
(default and current behavior) and then alphaByType
(as described above group by type and then sorted within that type)
Alternate Implementations
The least thing should be an option like --disable-sort
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:5
I have a project, which uses NX, but I want to open the demoapp in Stackblitz. For that, I needed to create a “phantom” project configuration which is the same as serving the demoapp, but its “root” property is empty, so it can start up in Stackblitz, while I can use the original configuration to run it locally when I do development on the project.
I recently updated NX in that project, and this not opt-in alphabetical sorting caused issues with nx commands (they were throwing errors that the angular.json and the nx.json were out of sync.
It was caused by that “phantom” project config, because that needs to be the first in the projects in order to work. It also broke our stackblitz integration.
I was able to make a workaround by renaming our phantom project config to start with “a” and make everything work again, but I think that an option for disabling sorting would be helpful in such cases.
Sorting should not be the default behavior. When working on huge repos were lots of projects are being added or removed all the time, it becomes a nightmare of huge and imprecise diffs.
While I would appreciate the functionality for house keeping, adding it to the generators itself is not the way.