Try to reduce unused composer dependencies

Created on 5 June 2025, 18 days ago

Problem/Motivation

Drupal CMS currently ships with various optional recipes, these have their own requirements so end up in composer.lock

After ✨ Automatically unpack recipes on project creation Active the recipe dependencies will end up directly in composer.json as first class composer dependencies.

Per 🌱 [META] Integrate site templates into Drupal CMS Active it seems likely unless something changes, that the initial site templates will be shipped with Drupal CMS. And if this is the case, it's likely that all of the dependencies of all of the site templates will be added to composer.json, even though only one template would get actually applied.

While the dependencies being in composer.json does not impact runtime Drupal operation, it will affect updates, because composer has no idea that a dependency is unused (and nor will site builders in most cases), so if that dependency isn't compatible with e.g. Drupal 12.0.0, or a new branch of a contrib module, it will start to prevent updates from happening altogether.

Additionally by the time that happens, it might not be in newer Drupal CMS versions at all, so not blocking new releases, only existing sites.

Steps to reproduce

Proposed resolution

The very end goal here would be to have (curated) project browsing of recipes/site templates so that installing any of them is a composer require - that way while dependencies might eventually become stale, they'll only be added in the first place when they're going to be used. 🌱 [meta] composer require / install module discrepancy issues Active is open for pruning of things that have eventually become stale which is its own issue.

There might be an interim step where Drupal CMS hard-codes specific recipes (and site templates when it gets there) that can be installed, but then rather than having them locally, they're composer required - so come from Drupal.org but without the browsing being in place?

User interface changes

Configuration changes

🌱 Plan
Status

Active

Component

General

Created by

πŸ‡¬πŸ‡§United Kingdom catch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @catch
  • πŸ‡¦πŸ‡ΊAustralia pameeela

    This is already the plan, happy to have it documented here but not sure that we need anything further?

  • πŸ‡¬πŸ‡§United Kingdom catch

    @pameela do you mean this:

    There might be an interim step where Drupal CMS hard-codes specific recipes (and site templates when it gets there) that can be installed, but then rather than having them locally, they're composer required - so come from Drupal.org but without the browsing being in place?

    If so that sounds good, but is there an implementation issue for that then? When I asked @phenaproxima he suggested opening an issue.

  • πŸ‡¦πŸ‡ΊAustralia pameeela

    Yes exactly, we plan to specify the recipes we want to expose, but will need to do this in a way that it can be updated so not sure exactly how yet. Because hardcoding fully where it's static post-install is also not really acceptable.

    We are also not sure what the actual recommended recipes will be. So since we don't know the recipes and don't know the mechanism, we don't have an issue but I guess we can create a placeholder that is postponed.

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    Do we still need this? Drupal CMS 1.2.0 uses recipe unpacking by default, so site owners are free to prune unnecessary dependencies as desired. I think that pretty much obviates this issue...?

  • πŸ‡¬πŸ‡§United Kingdom catch

    site owners are free to prune unnecessary dependencies as desired.

    How do site owners prune those dependencies?

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    composer remove such-and-such. There's no UI for pruning Composer dependencies, although surely one could be created with Package Manager as its base.

  • πŸ‡¬πŸ‡§United Kingdom catch

    When I'm building Drupal sites, I composer require the dependencies I need then install them. Sometimes a dependency isn't needed any more, so I need to uninstall it, and then later composer remove it (because you have to deploy the uninstall before you can remove the code), this doesn't happen that often but it does occasionally.

    Modules and their packages on composer don't necessarily match, so it's a fairly laborious process to audit a site for unused composer dependencies overall as opposed to requiring and removing as you go along.

    When you update to a new major version of core, it's quite likely that some modules won't be compatible with that new Drupal version. Even if all the modules that Drupal CMS ships with are compatible with Drupal 12 or 13, this might not be the case for modules it shipped with in February 2025. In these cases, if a module isn't installed, composer remove is the easiest way to make your site compatible - but you have to know that it's not used and how to remove it.

    This is going to be even worse for someone that's not familiar with composer on the command line or the nuances of composer requirements vs. installed modules, and it's exacerbated if sites start out with a large number of unused dependencies that were never installed in the first place.

Production build 0.71.5 2024