MCPcopy
hub / github.com/vuejs/core / hmrShouldReload

Function hmrShouldReload

packages/compiler-sfc/src/parse.ts:435–457  ·  view source on GitHub ↗
(
  prevImports: Record<string, ImportBinding>,
  next: SFCDescriptor,
)

Source from the content-addressed store, hash-verified

433 * pruning result changes due to template changes.
434 */
435export 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.

Callers 1

parseFunction · 0.85

Calls 1

isImportUsedFunction · 0.90

Tested by

no test coverage detected