Note: this is more of a question/idea than the actual task. I am not going to pretend I know much about this area, so please feel free to point out all the whole in this concept, and bury it.
In T191638 it has been briefly mentioned that git-ignoring not needed files from libraries checked in into mediawiki vendor component might make sense in case of third-party libraries we don't control, and possibly (this is my own interpretation) could even replace the use of .gitattributes for the same thing.
It seems clear we cannot add .gitattributes to libraries that are not ours, and thus e.g. we might end up checking in test classes to mediawiki vendor (which might, or might not be intednded). Adding unwanted parts to gitignore would help reducing the amount of stuff we add.
Following this concept, would it make sense to loosen up excludes made currently with .gitattributes in WMF's or WMDE's libraries? AFAICT, the only reason some WMDE/Wikibase libs exclude test code etc is to not check them in the mediawiki vendor. Arguably, it is giving users of those libraries a bit less flexibility in what they get and can use (of course as long as they install tarballs using composer, not clone the whole git repo). We still would avoid putting not wanted stuff to mediwiki vendor, but the exlcude would be more local, in this component's .gitignore.
I am not sure how clearly I managed to describe the issue, and whether it makes any sense. I wanted to have a trace of the idea we had in the other ticket, and hear for wiser people have to say.