How to rebuild derived plugins after new entities are installed? I have a problem with a stale plugin-derivatives cache in a kernel test:

  protected function setUp() {
    parent::setUp();
    $this-&gt;installConfig(['my_module', 'my_module_test']);
  }


The my_module_test module installs new entities that should produce derived plugins, but when my test class tries to instantiate these plugins, they are not found.

It works if I explicitly call $this-&gt;container-&gt;get('{my_plugin_manager}')-&gt;clearCachedDefinitions() after installConfig(), so it's definitely a stale plugin cache. But I'm worried this problem might happen elsewhere. Is there some way to tag the plugin cache with {my_entity_type}_list so it gets invalidated by new entities? Or do I simply need to invalidate it explicitly whenever I do something that creates new entities?
Yes you should do that.

Module install is not really a problem as all plugins are invalidated then anyway, but entities can also be changed in the UI.

See \Drupal\block_content\Entity\BlockContent::postSave() for an example that does that in core.