source: trip-planner-front/node_modules/@babel/core/src/config/resolve-targets.ts

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.6 KB
Line 
1type browserType = typeof import("./resolve-targets-browser");
2type nodeType = typeof import("./resolve-targets");
3
4// Kind of gross, but essentially asserting that the exports of this module are the same as the
5// exports of index-browser, since this file may be replaced at bundle time with index-browser.
6({} as any as browserType as nodeType);
7
8import type { ValidatedOptions } from "./validation/options";
9import path from "path";
10import getTargets from "@babel/helper-compilation-targets";
11
12import type { Targets } from "@babel/helper-compilation-targets";
13
14export function resolveBrowserslistConfigFile(
15 browserslistConfigFile: string,
16 configFileDir: string,
17): string | undefined {
18 return path.resolve(configFileDir, browserslistConfigFile);
19}
20
21export function resolveTargets(
22 options: ValidatedOptions,
23 root: string,
24): Targets {
25 // todo(flow->ts) remove any and refactor to not assign different types into same variable
26 let targets: any = options.targets;
27 if (typeof targets === "string" || Array.isArray(targets)) {
28 targets = { browsers: targets };
29 }
30 if (targets && targets.esmodules) {
31 targets = { ...targets, esmodules: "intersect" };
32 }
33
34 const { browserslistConfigFile } = options;
35 let configFile;
36 let ignoreBrowserslistConfig = false;
37 if (typeof browserslistConfigFile === "string") {
38 configFile = browserslistConfigFile;
39 } else {
40 ignoreBrowserslistConfig = browserslistConfigFile === false;
41 }
42
43 return getTargets(targets, {
44 ignoreBrowserslistConfig,
45 configFile,
46 configPath: root,
47 browserslistEnv: options.browserslistEnv,
48 });
49}
Note: See TracBrowser for help on using the repository browser.