UNPKG

781 BJavaScriptView Raw
1// @flow
2
3import type { ValidatedOptions } from "./validation/options";
4import getTargets, { type Targets } from "@babel/helper-compilation-targets";
5
6export function resolveTargets(
7 options: ValidatedOptions,
8 // eslint-disable-next-line no-unused-vars
9 root: string,
10 // eslint-disable-next-line no-unused-vars
11 filename: string | void,
12): Targets {
13 let { targets } = options;
14 if (typeof targets === "string" || Array.isArray(targets)) {
15 targets = { browsers: targets };
16 }
17 // $FlowIgnore it thinks that targets.esmodules doesn't exist.
18 if (targets && targets.esmodules) {
19 targets = { ...targets, esmodules: "intersect" };
20 }
21
22 return getTargets((targets: any), {
23 ignoreBrowserslistConfig: true,
24 browserslistEnv: options.browserslistEnv,
25 });
26}