Change record status: 
Introduced in version: 
1.2.0
Description: 

The CacheableMetadata $cacheable_metadata object is now a required first parameter passed into buildEntities() and its wrapper methods (buildReferencedEntities(), buildEntitiesWithViewModes(), buildReferencedEntitiesWithViewModes()).

The above methods now add each entity's cache dependency to the CacheableMetadata object before the access check. This ensures that publishing a previously unpublished referenced entity correctly invalidates the parent's cached page.

Before:

public function buildFull(array $build, EntityInterface $entity) {
  $build[] = $this->buildReferencedEntities($entity->field_reference);
  return $build;
}

Now:

public function buildFull(array $build, EntityInterface $entity) {
  $cacheable_metadata = CacheableMetadata::createFromRenderArray($build);
  // Pass $cacheable_metadata to any buildReferencedEntities() calls.
  $build[] = $this->buildReferencedEntities($cacheable_metadata, $entity->field_reference);

  // Apply the collected cache metadata to the final build array.
  $cacheable_metadata->applyTo($build);
  return $build;
}