An `exports` value's targets, best first: a string, a fallback array, or (nested) conditions, by key order within each tier.
(value: unknown)
| 219 | |
| 220 | /** An `exports` value's targets, best first: a string, a fallback array, or (nested) conditions, by key order within each tier. */ |
| 221 | function exportTargets(value: unknown): string[] { |
| 222 | if (typeof value === 'string') return [value]; |
| 223 | if (Array.isArray(value)) return value.flatMap(exportTargets); |
| 224 | if (!value || typeof value !== 'object') return []; |
| 225 | const conditions = Object.entries(value as Record<string, unknown>); |
| 226 | const tier = (key: string): number => (RESOLVING_CONDITIONS.has(key) ? 0 : TYPE_CONDITIONS.has(key) ? 2 : 1); |
| 227 | return [0, 1, 2].flatMap((t) => conditions.filter(([key]) => tier(key) === t).flatMap(([, v]) => exportTargets(v))); |
| 228 | } |
| 229 | |
| 230 | /** What an `exports` value's `browser` condition names, at any depth of its conditions. */ |
| 231 | function browserTargets(value: unknown): string[] { |
no test coverage detected