Is it possible to make a patch that modifies a module's composer.json? I want to confirm some behavior of Composer to see if this is a limitation of Composer or something I did wrong.

This is based on an issue in the Markdown module queue.

Basically, here's the issue.


The Markdown module requires ^0.15 of a library.
I wrote a patch to require ~0.15 of the library. (to allow 0.16, 0.17, etc.)


But, when I apply this patch via Composer, and then try to update the library, I still get a drupal/markdown  1.2.0  requires  league/commonmark (^0.15.0) even though the module's (patched) code on my site requires ~0.15.

So, is there no way to "patch" a composer.json so that it will be picked up for composer update?  Am I reliant on the module maintainer to commit the patch?
This issue is actually addressed in the composer-patches documentation:

Because patching occurs after Composer calculates dependencies and installs packages, changes to an underlying dependency's composer.json file introduced in a patch will have no effect on installed packages.
If you need to modify a dependency's composer.json or its underlying dependencies, you cannot use this plugin. Instead, you must do one of the following:

Work to get the underlying issue resolved in the upstream package.
Fork the package and specify your fork as the package repository in your root composer.json
Specify compatible package version requirements in your root composer.json


If you want to follow option #2, you can fork the project's git repo, modify it, and add the forked repo to your project's repositories property:
    {
        &quot;type&quot;:&quot;git&quot;,
        &quot;url&quot;: &quot;https://github.com/vendor/module&quot;
    }

So you can reference that dependency until the upstream has resolved the issue.