Introduce an extension factory middleware#29068
Conversation
Changed Packages
|
Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
32a80b9 to
3d26073
Compare
Rugvip
left a comment
There was a problem hiding this comment.
Nice! 🎉
Some optional bits and followup investigation but good to merge for me
| export type ExtensionFactoryMiddleware = Parameters< | ||
| ExtensionDefinition['override'] | ||
| >[0]['factory']; |
| apis: ApiHolder; | ||
| createRoot(): JSX_2.Element; | ||
| tree: AppTree; |
There was a problem hiding this comment.
Forgot about this bit and was thinking it could make sense to wrap things up a bit more potentially. Then I had the thought that maybe we should go in the opposite direction, where we only return { apis, tree } here and grab the root from the tree instead. Or going even further, adding apis into the tree and just returning { tree }
Either way, happy to merge as is but I might tinker a bit with this in a followup.
There was a problem hiding this comment.
Mmm. Could be. Didn't personally feel super comfortable making backwards incompatible changes to this function, but if it makes sense, go for it.
| ...context, | ||
| config: configOverride, |
There was a problem hiding this comment.
The type indicates that that we can override inputs as well right? i.e.
backstage/packages/frontend-plugin-api/src/wiring/createExtension.ts
Lines 407 to 412 in 4c46e99
I can take care of getting that sorted if you want though.
There was a problem hiding this comment.
That'd be great! I think it also can take params? But it wasn't immediately obvious to me how to incorporate either.
|
Thank you for contributing to Backstage! The changes in this pull request will be part of the |
What / Why
I believe we'll find a variety of use-cases unlocked if we introduce a way to modify extensions en-masse as they are being instantiated. A naive example of what would be possible:
Another use-case would be swapping out extensions entirely under some circumstances, e.g. for A/B testing (for which access to metadata about the extension tree would be helpful).
✔️ Checklist
Signed-off-byline in the message. (more info)