How to use the Drupal 9 module in a Drupal 10 project using Composer if its MR is already ready for Drupal 10 compatibility

We have often found that in the Drupal 9 project, multiple modules are not compatible with Drupal 10, and when we check the module issue queue, especially with the term "Automated Drupal 10 compatibility fixes", we can find at least one issue where the project update bot creates this issue automatically against each module and provides a patch with possible fixes except for making changes in module.info.yml.

We can further use that patch and create an MR, and then the same MR can be used for adding the module to Drupal 10 projects.

In this post, I am taking an example of the "A Simple Timeline" module, which is not compatible with Drupal 10, and there is already a MR with the change needed for Drupal 10 compatibility.

Using the below steps, we can add this module to our Drupal 10 project until the above PR gets merged and the module maintainer does a release.

  1. We need to update our project "composer.json" file the with following changes under "repositories" section.
    Issue form command 

    {
      "type": "git",
      "url": "https://git.drupalcode.org/issue/simple_timeline-3289667.git",
      "only": ["drupal/simple_timeline"]
    }
  2. Now, we will run the below composer command along with a branch name followed by a commit ID, in which D10 changes are pushed.

    composer require drupal/simple_timeline:dev-3289667-automated-drupal-10#f1ba3a44685cf612304de86d2d4640f895e4ca26
    
    ./composer.json has been updated
    Running composer update drupal/simple_timeline
    Gathering patches for root package.
    No patches supplied.
    Loading composer repositories with package information
    Updating dependencies                                 
    Lock file operations: 1 install, 0 updates, 0 removals
      - Locking drupal/simple_timeline (dev-3289667-automated-drupal-10 f1ba3a4)
    Writing lock file
    Installing dependencies from lock file (including require-dev)
    Package operations: 1 install, 0 updates, 0 removals
      - Syncing drupal/simple_timeline (dev-3289667-automated-drupal-10 f1ba3a4) into cache
    Gathering patches for root package.
    No patches supplied.
    Gathering patches for dependencies. This might take a minute.
      - Installing drupal/simple_timeline (dev-3289667-automated-drupal-10 f1ba3a4): Cloning f1ba3a4468 from cache
    Generating autoload files
    50 packages you are using are looking for funding.
    Use the `composer fund` command to find out more!
    No security vulnerability advisories found
  3. Check extend page and enable the module.Module
0/5