Skip to content

Commit

Permalink
chore(hmr): pretty import circular output
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Oct 24, 2024
1 parent f60fc6f commit ec79996
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions plugins/vite/hmr.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import path from "node:path"

import { red, yellow } from "kolorist"
import type { HmrContext, Plugin } from "vite"

Expand All @@ -21,10 +23,9 @@ function isNodeWithinCircularImports(
importer,
...[...currentChain].reverse(),
...nodeChain.slice(importerIndex, -1).reverse(),
]
console.warn(
yellow(`Circular imports detected: ${importChain.map((m) => m.file).join(" -> ")}`),
)
].map((m) => path.relative(process.cwd(), m.file))

console.warn(yellow(`Circular imports detected: ${importChain.join("\n↳ ")}`))
return true
}

Expand Down

0 comments on commit ec79996

Please sign in to comment.