MCPcopy
hub / github.com/rolldown/tsdown / formatProblem

Function formatProblem

src/features/pkg/attw.ts:190–246  ·  view source on GitHub ↗

* Format an ATTW problem for display

(packageName: string, problem: Problem)

Source from the content-addressed store, hash-verified

188 * Format an ATTW problem for display
189 */
190function formatProblem(packageName: string, problem: Problem): string {
191 const resolutionKind =
192 'resolutionKind' in problem ? ` (${problem.resolutionKind})` : ''
193 const entrypoint =
194 'entrypoint' in problem
195 ? ` at ${slash(path.join(packageName, problem.entrypoint))}`
196 : ''
197
198 switch (problem.kind) {
199 case 'NoResolution':
200 return ` ❌ No resolution${resolutionKind}${entrypoint}`
201
202 case 'UntypedResolution':
203 return ` ⚠️ Untyped resolution${resolutionKind}${entrypoint}`
204
205 case 'FalseESM':
206 return ` 🔄 False ESM: Types indicate ESM (${problem.typesModuleKind}) but implementation is CJS (${problem.implementationModuleKind})\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`
207
208 case 'FalseCJS':
209 return ` 🔄 False CJS: Types indicate CJS (${problem.typesModuleKind}) but implementation is ESM (${problem.implementationModuleKind})\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`
210
211 case 'CJSResolvesToESM':
212 return ` ⚡ CJS resolves to ESM${resolutionKind}${entrypoint}`
213
214 case 'NamedExports': {
215 const missingExports =
216 problem.missing?.length > 0
217 ? ` Missing: ${problem.missing.join(', ')}`
218 : ''
219 const allMissing = problem.isMissingAllNamed
220 ? ' (all named exports missing)'
221 : ''
222 return ` 📤 Named exports problem${allMissing}${missingExports}\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`
223 }
224
225 case 'FallbackCondition':
226 return ` 🎯 Fallback condition used${resolutionKind}${entrypoint}`
227
228 case 'FalseExportDefault':
229 return ` 🎭 False export default\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`
230
231 case 'MissingExportEquals':
232 return ` 📝 Missing export equals\n Types: ${problem.typesFileName} | Implementation: ${problem.implementationFileName}`
233
234 case 'InternalResolutionError':
235 return ` 💥 Internal resolution error in ${problem.fileName} (${problem.resolutionOption})\n Module: ${problem.moduleSpecifier} | Mode: ${problem.resolutionMode}`
236
237 case 'UnexpectedModuleSyntax':
238 return ` 📋 Unexpected module syntax in ${problem.fileName}\n Expected: ${problem.moduleKind} | Found: ${problem.syntax === 99 ? 'ESM' : 'CJS'}`
239
240 case 'CJSOnlyExportsDefault':
241 return ` 🏷️ CJS only exports default in ${problem.fileName}`
242
243 default:
244 return ` ❓ Unknown problem: ${JSON.stringify(problem)}`
245 }
246}

Callers 1

attwFunction · 0.85

Calls 1

slashFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…