You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
homePageCards.tsx — removed static ScorecardHomepageCardWithProvider import; each widget's components callback now uses a lazyScorecardWidget helper that does:
The 7 per-widget wrapper functions (AggregatedCardWith*Content) are replaced by inline factory callbacks passed to lazyScorecardWidget, which performs the dynamic import once and passes the component to the factory.
NFS alpha expose summary
Metric
BEFORE
AFTER
Δ
Sync chunks
9
6
-3
Sync size
1,591.3 KB
1,041.7 KB
-549.6 KB (-34.5%)
Async chunks
206
215
+9
Async size (listed)
1,190.3 KB
1,805.6 KB
+615.3 KB
✔️ Checklist
A changeset describing the change and affected packages. (more info)
Added or Updated documentation
Tests for new functionality and regression tests for bug fixes
The following are alternative approaches to this PR:
1. Hoist a shared import promise (single loader)
➕ Guarantees only one dynamic import promise is created regardless of how many widgets resolve at once
➕ Centralizes error handling/logging for the lazy import
➖ Adds a bit of module-level state/indirection
➖ Current approach already benefits from module caching in most bundlers/runtimes
2. Use React.lazy/Suspense for the card module
➕ Standard React idiom for code-splitting with built-in loading fallback patterns
➖ May not fit the HomePageWidgetBlueprint async 'components' contract as cleanly
➖ Requires ensuring Suspense boundaries exist where the widget renders
Recommendation: The current helper-based dynamic import approach is a good fit for Backstage HomePageWidgetBlueprint’s async components API and removes repeated wrapper components. If reviewers observe repeated resolver invocations causing overhead, consider hoisting a single shared import promise to make the "import once" behavior explicit, but it’s not strictly required given typical module caching.
Files changed (2) +53 / -61
Enhancement (1) +48 / -61
homePageCards.tsxLazy-load Scorecard homepage card component and inline widget factories+48/-61
Lazy-load Scorecard homepage card component and inline widget factories
• Replaces a static import of ScorecardHomepageCardWithProvider with a dynamic import resolved inside a new lazyScorecardWidget helper. Removes multiple per-widget wrapper components in favor of inline factories that render the provider with the appropriate metricId/aggregationId.
hungry-mangos-guess.mdAdd patch changeset for scorecard homepage loading optimization+5/-0
Add patch changeset for scorecard homepage loading optimization
• Adds a patch changeset entry for the scorecard plugin describing the homepage loading optimization. This ensures the change is captured in release/versioning automation.
[type conventions]workspaces/scorecard/plugins/scorecard/src/alpha/extensions/homePageCards.tsx:25 — The factory callback return type uses the global JSX.Element, which is deprecated in @types/react v18+. The scorecard workspace pins @types/react to ^18 and test files use React.ReactElement instead.
Remediation: Replace () => JSX.Element with () => React.ReactElement or omit the explicit return type and let TypeScript infer it.
🤖 Finished Review · ✅ Success · Started 2:59 PM UTC · Completed 3:11 PM UTC
Commit: cf245a6 · View workflow run →
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hey, I just made a Pull Request!
Resolves: https://redhat.atlassian.net/browse/RHIDP-15511
Code changes
ScorecardHomepageCardWithProviderimport; each widget'scomponentscallback now uses alazyScorecardWidgethelper that does:NFS
alphaexpose summary✔️ Checklist