MCPcopy Create free account
hub / github.com/effect-app/libs / parseBarrelExports

Function parseBarrelExports

repos/effect/packages/tools/jsdocs/src/Jsdocs.ts:570–614  ·  view source on GitHub ↗
(indexPath: string)

Source from the content-addressed store, hash-verified

568 }
569 const packageJsonPath = path.join(normalizedRoot, "package.json")
570 let parsed: unknown
571 try {
572 parsed = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"))
573 } catch (error) {
574 const result = {
575 _tag: "Failure",
576 error: `unable to read package.json at ${packageJsonPath}: ${String(error)}`
577 } as const
578 packageMetadataCache.set(normalizedRoot, result)
579 return result
580 }
581 if (!isRecord(parsed)) {
582 const result = { _tag: "Failure", error: `package.json at ${packageJsonPath} must be an object` } as const
583 packageMetadataCache.set(normalizedRoot, result)
584 return result
585 }
586 if (typeof parsed.name !== "string" || parsed.name.length === 0) {
587 const result = {
588 _tag: "Failure",
589 error: `package.json at ${packageJsonPath} must include a non-empty name`
590 } as const
591 packageMetadataCache.set(normalizedRoot, result)
592 return result
593 }
594 if (parsed.exports === undefined) {
595 const result = { _tag: "Failure", error: `package.json at ${packageJsonPath} must include exports` } as const
596 packageMetadataCache.set(normalizedRoot, result)
597 return result
598 }
599 const result = {
600 _tag: "Success",
601 value: {
602 root: normalizedRoot,
603 sourceRoot: path.join(normalizedRoot, "src"),
604 name: parsed.name,
605 exports: parsed.exports
606 }
607 } as const
608 packageMetadataCache.set(normalizedRoot, result)
609 return result
610}
611
612function parseBarrelExports(indexPath: string): Result<ParsedBarrelExports, string> {
613 const normalizedIndexPath = path.resolve(indexPath)
614 const cached = barrelExportCache.get(normalizedIndexPath)
615 if (cached !== undefined) {
616 return cached
617 }

Callers 1

resolveBarrelImportFunction · 0.85

Calls 5

normalizePathNameFunction · 0.70
getMethod · 0.65
setMethod · 0.65
addMethod · 0.65
StringInterface · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…