Lazy-Loaded Component Bundles Leave Blank Placeholders on Network Failure
0 reputation · 04 Oct 2022, 17:10 UTC
Context
StencilJS lazy-loads components by injecting a <script> tag for each component bundle. When the network request for that bundle fails, the component never renders and the page shows an empty placeholder with no error surfaced inside the component's shadow DOM.
Constraints and Uncertainty
- The framework does not provide a built-in fallback strategy such as retry, error component, or graceful degradation.
- No public API exists to hook into the load-failure event; the only observable signals are the global
window.onerroror the script element'sonerror, which are not scoped to a specific component. - Bundle filenames (e.g.,
component-name.js) are not guaranteed stable across builds, making programmatic retry difficult. - Fallback logic appears to work only in
<script type="module">contexts; legacy IE11 builds silently ignore it.
Goal
Determine whether a declarative fallback mechanism or configuration option can be added to Stencil's lazy-loading pipeline so that failed component loads can be recovered safely without custom workarounds.
What is the recommended pattern for detecting a lazy-load failure at the component level?
Can a fallback component be specified declaratively in the component's TSX or via Stencil config?
Is there a stable identifier for a failed bundle that would allow a retry strategy?