MCPcopy
hub / github.com/vitest-dev/vitest / handleImportOutsideModuleError

Function handleImportOutsideModuleError

packages/vitest/src/node/printError.ts:315–335  ·  view source on GitHub ↗
(stack: string, logger: ErrorLogger)

Source from the content-addressed store, hash-verified

313]
314
315function handleImportOutsideModuleError(stack: string, logger: ErrorLogger) {
316 if (!esmErrors.some(e => stack.includes(e))) {
317 return
318 }
319
320 const path = normalize(stack.split('\n')[0].trim())
321 let name = path.split('/node_modules/').pop() || ''
322 if (name[0] === '@') {
323 name = name.split('/').slice(0, 2).join('/')
324 }
325 else {
326 name = name.split('/')[0]
327 }
328
329 if (name) {
330 printModuleWarningForPackage(logger, path, name)
331 }
332 else {
333 printModuleWarningForSourceCode(logger, path)
334 }
335}
336
337function printModuleWarningForPackage(
338 logger: ErrorLogger,

Callers 1

printErrorInnerFunction · 0.85

Calls 3

normalizeFunction · 0.85

Tested by

no test coverage detected