diff --git a/core/core.services.yml b/core/core.services.yml
index 2f04124..911d0b0 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -920,3 +920,6 @@ services:
     arguments: ['@module_handler']
     tags:
       - { name: mime_type_guesser }
+parameters:
+  core_plugin_namespaces:
+    Drupal\Entity: core/lib/Drupal/Core/Entity
diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index 2551a4d..3d9b76f 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -1011,17 +1011,6 @@ protected function compileContainer() {
 
     // Get a list of namespaces and put it onto the container.
     $namespaces = $this->getModuleNamespacesPsr4($this->getModuleFileNames());
-    // Add all components in \Drupal\Core and \Drupal\Component that have a
-    // Plugin directory.
-    foreach (array('Core', 'Component') as $parent_directory) {
-      $path = DRUPAL_ROOT . '/core/lib/Drupal/' . $parent_directory;
-      $parent_namespace = 'Drupal\\' . $parent_directory;
-      foreach (new \DirectoryIterator($path) as $component) {
-        if (!$component->isDot() && $component->isDir() && is_dir($component->getPathname() . '/Plugin')) {
-          $namespaces[$parent_namespace . '\\' . $component->getFilename()] = $path . '/' . $component->getFilename();
-        }
-      }
-    }
     $container->setParameter('container.namespaces', $namespaces);
 
     // Store the default language values on the container. This is so that the
@@ -1062,6 +1051,11 @@ protected function compileContainer() {
       }
     }
 
+    // Allow service files to provide additional plugin directories.
+    if ($plugin_namespaces = $container->getParameter('core_plugin_namespaces')) {
+      $namespaces += $plugin_namespaces;
+    }
+
     // Identify all services whose instances should be persisted when rebuilding
     // the container during the lifetime of the kernel (e.g., during a kernel
     // reboot). Include synthetic services, because by definition, they cannot
