diff --git a/automatic_updates_extensions/tests/src/Kernel/ExtensionUpdateStageTest.php b/automatic_updates_extensions/tests/src/Kernel/ExtensionUpdateStageTest.php
index 76e8e06daf83e86ae8a5be9fe38f15f031748b3b..505abe68589c360f42457c6260ee5347e6b51dd9 100644
--- a/automatic_updates_extensions/tests/src/Kernel/ExtensionUpdateStageTest.php
+++ b/automatic_updates_extensions/tests/src/Kernel/ExtensionUpdateStageTest.php
@@ -100,6 +100,7 @@ class ExtensionUpdateStageTest extends AutomaticUpdatesExtensionsKernelTestBase
       [
         'update',
         '--with-all-dependencies',
+        '--optimize-autoloader',
         'drupal/my_module:9.8.1',
         'drupal/my_dev_module:1.2.0-alpha1@alpha',
       ],
diff --git a/package_manager/src/StageBase.php b/package_manager/src/StageBase.php
index c51efdfef6c8880070f827eddcc4f97fc02ac771..4416133dd19615e7f1d05318d24336b8b8a8ceed 100644
--- a/package_manager/src/StageBase.php
+++ b/package_manager/src/StageBase.php
@@ -456,7 +456,7 @@ abstract class StageBase implements LoggerAwareInterface {
 
     // If constraints were changed, update those packages.
     if ($runtime || $dev) {
-      $command = array_merge(['update', '--with-all-dependencies'], $runtime, $dev);
+      $command = array_merge(['update', '--with-all-dependencies', '--optimize-autoloader'], $runtime, $dev);
       $do_stage($command);
     }
     $this->dispatch(new PostRequireEvent($this, $runtime, $dev));
diff --git a/tests/src/Kernel/UpdateStageTest.php b/tests/src/Kernel/UpdateStageTest.php
index 0169b8d2e916541ea931e3b94f1e589516fc1ae8..bc1d323a65549765e1d44f4bef8d6f9e21f9b474 100644
--- a/tests/src/Kernel/UpdateStageTest.php
+++ b/tests/src/Kernel/UpdateStageTest.php
@@ -102,6 +102,7 @@ class UpdateStageTest extends AutomaticUpdatesKernelTestBase {
       [
         'update',
         '--with-all-dependencies',
+        '--optimize-autoloader',
         'drupal/core-recommended:9.8.1',
         'drupal/core-dev:9.8.1',
       ],