To support site templates, ensure component definitions are rebuilt while applying recipes

Created on 18 June 2025, 6 days ago

Overview

You've heard of site templates. We're starting to build the first real-world one over in ✨ Implement the first real-world site template Active and its children.

Site templates are, first and foremost, maximalist recipes. They have limited composability, and are focused on shipping a set of default content and a coherent look n' feel. That means they will lean heavily on Experience Builder, and need to be sure that the components they use (especially in their default content) are available during the process of applying the recipe.

After fighting through bugs with @larowlan in πŸ“Œ Set up scaffolding for the B2B SaaS site template Active , I found that all we really need XB to do is refresh the available components at certain critical points of the recipe application process. The good news is, the recipe system dispatches events at those points, so XB should just subscribe to them. Specifically:

  • The default content system's PreImportEvent should trigger a component refresh. This will allow the recipe to include default content which uses XB (landing pages, for example).
  • XB should also do a component refresh when the recipe system dispatches its RecipeAppliedEvent. This is to cover recipes which don't ship any default content -- we still want any new components to be available to XB without the user needing to do a cache clear (which, given the target audience for site templates, they may not know how to do).

Proposed resolution

Add an event subscriber which calls getDefinitions() on the component and block plugin managers whenever those two events occur.

The test coverage should confirm that if you apply a recipe -- with or without default content that uses XB -- the components in any of the recipe's dependencies are generated.

User interface changes

This change will not touch the UI.

✨ Feature request
Status

Active

Version

0.0

Component

Config management

Created by

πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @phenaproxima
  • Merge request !1156Add event subscriber β†’ (Merged) created by phenaproxima
  • Pipeline finished with Failed
    6 days ago
    Total: 699s
    #525248
  • Pipeline finished with Failed
    6 days ago
    Total: 1291s
    #525254
  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts
  • Pipeline finished with Failed
    6 days ago
    Total: 1804s
    #525281
  • Pipeline finished with Failed
    6 days ago
    Total: 2919s
    #525286
  • Pipeline finished with Failed
    5 days ago
    Total: 974s
    #525466
  • πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

    LGTM!

  • πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
    1. I don't yet understand why merely retrieving definitions is sufficient (and nor did @larowlan) β€” see MR comment for details. Can you articulate why? πŸ™
    2. This must be generalized to not hardcode assumptions for the 2 plugin-powered ComponentSources we have today (block + sdc).

      See the MR comment + #3526045-7: Consider renaming ComponentSource plugins to ComponentType β†’ for how this could be achieved.

  • πŸ‡ΊπŸ‡ΈUnited States phenaproxima Massachusetts

    I don't yet understand why merely retrieving definitions is sufficient (and nor did @larowlan) β€” see MR comment for details. Can you articulate why?

    Retrieving definitions will regenerate all the component entities if needed (as you know), but you're right that this is setting up a bug if the cache is not empty. So I added an explicit cache clear.

    This must be generalized to not hardcode assumptions for the 2 plugin-powered ComponentSources we have today (block + sdc).

    I changed the subscriber to a service collector for CachedDiscoveryInterface. That still ties it to plugins...for now. But using a service collector gives us some more leeway later, if we add a new interface for component discovery. That will make it easier to refactor. I didn't do it as you suggested in [#16120596-7] because that makes the dependency injection trickier/impossible. Besides, service collection is a well-used pattern in core.

    there's some CI fails we likely need to address

    Looks like the only one outstanding is in component-operations.cy.js, with the same damn failure that seems to inexplicably haunt every goddamned MR I submit to Experience Builder. :) I don't see how the changes here could be affecting that, since the recipe event subscriber only does anything if a recipe is applied. I'm not really sure how to approach fixing it, since I'm not sure the cause of it was ever discovered the previous times I encountered it.

  • Pipeline finished with Failed
    3 days ago
    Total: 2798s
    #527455
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

    That last commit is πŸ€©πŸ‘

  • Pipeline finished with Skipped
    about 13 hours ago
    #529367
  • πŸ‡§πŸ‡ͺBelgium wim leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί
Production build 0.71.5 2024