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