| 433 | * pruning result changes due to template changes. |
| 434 | */ |
| 435 | export function hmrShouldReload( |
| 436 | prevImports: Record<string, ImportBinding>, |
| 437 | next: SFCDescriptor, |
| 438 | ): boolean { |
| 439 | if ( |
| 440 | !next.scriptSetup || |
| 441 | (next.scriptSetup.lang !== 'ts' && next.scriptSetup.lang !== 'tsx') |
| 442 | ) { |
| 443 | return false |
| 444 | } |
| 445 | |
| 446 | // for each previous import, check if its used status remain the same based on |
| 447 | // the next descriptor's template |
| 448 | for (const key in prevImports) { |
| 449 | // if an import was previous unused, but now is used, we need to force |
| 450 | // reload so that the script now includes that import. |
| 451 | if (!prevImports[key].isUsedInTemplate && isImportUsed(key, next)) { |
| 452 | return true |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | return false |
| 457 | } |
| 458 | |
| 459 | /** |
| 460 | * Dedent a string. |