* Runs an HMR-related function and falls back to * invalidating the HMR data if it throws an error.
( importMeta: ImportMetaExtended | null, id: string | null, callback: () => void, )
| 330 | * invalidating the HMR data if it throws an error. |
| 331 | */ |
| 332 | function executeWithInvalidateFallback( |
| 333 | importMeta: ImportMetaExtended | null, |
| 334 | id: string | null, |
| 335 | callback: () => void, |
| 336 | ) { |
| 337 | try { |
| 338 | callback(); |
| 339 | } catch (e) { |
| 340 | const error = e as {message?: string; stack?: string}; |
| 341 | |
| 342 | // If we have all the necessary information and APIs to send off the invalidation |
| 343 | // request, send it before rethrowing so the dev server can decide what to do. |
| 344 | if (id !== null && error.message) { |
| 345 | const toLog = error.message + (error.stack ? '\n' + error.stack : ''); |
| 346 | importMeta?.hot?.send?.('angular:invalidate', {id, message: toLog, error: true}); |
| 347 | } |
| 348 | |
| 349 | // Throw the error in case the page doesn't get refreshed. |
| 350 | throw e; |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | /** |
| 355 | * Replaces one LView in the tree with another one. |
no test coverage detected