{"version":3,"file":"valid-imports.d.ts","sourceRoot":"","sources":["../../src/valid-imports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;;AAIpC,wBA2BC","sourcesContent":["import fail from './fail.js'\nimport { Package } from './types.js'\nimport validExternalExport from './valid-external-export.js'\n\n// validate the package.imports field\nexport default (pkg: Package) => {\n  const { imports } = pkg\n  if (imports === undefined) return true\n  if (Array.isArray(imports) || typeof imports !== 'object') {\n    fail(\n      'invalid imports object, must be Record<string, Import>, ' +\n        `got: ${JSON.stringify(imports)}`,\n    )\n    return process.exit(1)\n  }\n\n  for (const [i, v] of Object.entries(imports)) {\n    if (!i.startsWith('#') || i === '#' || i.startsWith('#/')) {\n      fail('invalid imports module specifier: ' + i)\n      return process.exit(1)\n    }\n    if (typeof v === 'string') continue\n    if (!validExternalExport(v)) {\n      fail(\n        `unbuilt package.imports ${i} must not be in ./src, ` +\n          'and imports in ./src must be string values. got: ' +\n          JSON.stringify(v),\n      )\n      return process.exit(1)\n    }\n  }\n  return true\n}\n"]}