( esbuildTarget: string | string[] | false, )
| 3540 | LightningCSSOptions['targets'] |
| 3541 | >() |
| 3542 | export const convertTargets = ( |
| 3543 | esbuildTarget: string | string[] | false, |
| 3544 | ): LightningCSSOptions['targets'] => { |
| 3545 | if (!esbuildTarget) return {} |
| 3546 | const cached = convertTargetsCache.get(esbuildTarget) |
| 3547 | if (cached) return cached |
| 3548 | const targets: LightningCSSOptions['targets'] = {} |
| 3549 | |
| 3550 | const entriesWithoutES = arraify(esbuildTarget).flatMap((e) => { |
| 3551 | const match = esRE.exec(e) |
| 3552 | if (!match) return e |
| 3553 | const year = match[1] === '6' ? 2015 : Number(match[1]) |
| 3554 | if (!esMap[year]) throw new Error(`Unsupported target "${e}"`) |
| 3555 | return esMap[year] |
| 3556 | }) |
| 3557 | |
| 3558 | for (const entry of entriesWithoutES) { |
| 3559 | if (entry === 'esnext') continue |
| 3560 | const index = entry.search(versionRE) |
| 3561 | if (index >= 0) { |
| 3562 | const browser = map[entry.slice(0, index)] |
| 3563 | if (browser === false) continue // No mapping available |
| 3564 | if (browser) { |
| 3565 | const [major, minor = 0] = entry |
| 3566 | .slice(index) |
| 3567 | .split('.') |
| 3568 | .map((v) => parseInt(v, 10)) |
| 3569 | if (!isNaN(major) && !isNaN(minor)) { |
| 3570 | const version = (major << 16) | (minor << 8) |
| 3571 | if (!targets[browser] || version < targets[browser]!) { |
| 3572 | targets[browser] = version |
| 3573 | } |
| 3574 | continue |
| 3575 | } |
| 3576 | } |
| 3577 | } |
| 3578 | throw new Error(`Unsupported target "${entry}"`) |
| 3579 | } |
| 3580 | |
| 3581 | convertTargetsCache.set(esbuildTarget, targets) |
| 3582 | return targets |
| 3583 | } |
| 3584 | |
| 3585 | export function resolveLibCssFilename( |
| 3586 | libOptions: LibraryOptions, |
no test coverage detected