How to claim a package, omitting files with the composer

Say I want to require a composer package, but there are several directories in the package that I think should not be included. eg. maybe the tests/ directory or something else. Is there any way to omit this directory from what the composer loads?

There is the --prefer-dist flag, but which requires repositories, there is a .gitattributes file present with export-ignore for various files / directories. But what if this repo doesn't have one? Of course, I could make a pull request, but what if they disagree? What if the project is abandoned? For these reasons, I believe that the --prefer-dist flag is suboptimal and I need a response (if one exists) other than "use --prefer-dist ".

+5
source share
1 answer

Symfony tried to do this, and their experience forced them to reverse this decision . The composer had information about using .gitattributes in the documentation, but deleted it .

In fact, removing some part of the package from a separate distribution path can cause more problems than it solves. From my point of view, the CLI switch --prefer-dist and --prefer-source is either a clone selector for a huge repository that takes a lot of time, or it loads a ZIP with such an exact version, but the results should be equal, that is, I should not be forced to --prefer-source for ALL of my dependencies just because one package that decided to "optimize for deployment" decided to remove the documentation and tests from their ZIP.

Yes, during development, I usually look at their code and tests to help me understand what is going on - or what SHOULD continue, and no.

Conclusion: Composer is not a deployment tool. If you care about the size of your application, your task is to remove everything that you don’t need or want, and possibly optimize other things (minimize JS and CSS, optimize images, etc.). This should not be the task of Composers or any accompanying package for this optimization for you.

+2
source

Source: https://habr.com/ru/post/1238535/


All Articles