{"version":3,"file":"valid-exports.d.ts","sourceRoot":"","sources":["../../src/valid-exports.ts"],"names":[],"mappings":";AAKA,wBAsCC","sourcesContent":["import addDot from './add-dot.js'\nimport fail from './fail.js'\nimport { TshyConfig } from './types.js'\nimport validExternalExport from './valid-external-export.js'\n\nexport default (\n  e: any,\n): e is Exclude<TshyConfig['exports'], undefined> => {\n  if (!e || typeof e !== 'object' || Array.isArray(e)) return false\n  for (const [sub, exp] of Object.entries(e)) {\n    if (sub !== '.' && !sub.startsWith('./')) {\n      fail(`tshy.exports key must be \".\" or start with \"./\", got: ${sub}`)\n      return process.exit(1)\n    }\n\n    // just a module. either a built export, or a simple unbuilt export\n    if (typeof exp === 'string') {\n      e[sub] = addDot(exp)\n      continue\n    }\n\n    if (typeof exp !== 'object') {\n      fail(\n        `tshy.exports ${sub} value must be valid package.json exports ` +\n          `value, got: ${JSON.stringify(exp)}`,\n      )\n      return process.exit(1)\n    }\n\n    // can be any valid external export, but the resolution of\n    // import and require must NOT be in ./src\n    if (!validExternalExport(exp)) {\n      fail(\n        `tshy.exports ${sub} unbuilt exports must not be in ./src, ` +\n          `and exports in src must be string values. ` +\n          `got: ${JSON.stringify(exp)}`,\n      )\n      return process.exit(1)\n    }\n\n    e[sub] = exp\n  }\n  return true\n}\n"]}