Sha256: c6bc112265af45202ac2e8942dcfe771d2a5a528ed7254d296e5203b80093302

Contents?: true

Size: 1.7 KB

Versions: 23

Compression:

Stored size: 1.7 KB

Contents

type browserType = typeof import("./resolve-targets-browser");
type nodeType = typeof import("./resolve-targets");

// Kind of gross, but essentially asserting that the exports of this module are the same as the
// exports of index-browser, since this file may be replaced at bundle time with index-browser.
({}) as any as browserType as nodeType;

import type { ValidatedOptions } from "./validation/options.ts";
import path from "path";
import getTargets, {
  type InputTargets,
} from "@babel/helper-compilation-targets";

import type { Targets } from "@babel/helper-compilation-targets";

export function resolveBrowserslistConfigFile(
  browserslistConfigFile: string,
  configFileDir: string,
): string | undefined {
  return path.resolve(configFileDir, browserslistConfigFile);
}

export function resolveTargets(
  options: ValidatedOptions,
  root: string,
): Targets {
  const optTargets = options.targets;
  let targets: InputTargets;

  if (typeof optTargets === "string" || Array.isArray(optTargets)) {
    targets = { browsers: optTargets };
  } else if (optTargets) {
    if ("esmodules" in optTargets) {
      targets = { ...optTargets, esmodules: "intersect" };
    } else {
      // https://github.com/microsoft/TypeScript/issues/17002
      targets = optTargets as InputTargets;
    }
  }

  const { browserslistConfigFile } = options;
  let configFile;
  let ignoreBrowserslistConfig = false;
  if (typeof browserslistConfigFile === "string") {
    configFile = browserslistConfigFile;
  } else {
    ignoreBrowserslistConfig = browserslistConfigFile === false;
  }

  return getTargets(targets, {
    ignoreBrowserslistConfig,
    configFile,
    configPath: root,
    browserslistEnv: options.browserslistEnv,
  });
}

Version data entries

23 entries across 16 versions & 3 rubygems

Version Path
trusty-cms-6.3.1 node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.51 node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.51 node_modules/jscodeshift/node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.50 node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.50 node_modules/jscodeshift/node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.49 node_modules/jscodeshift/node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.49 node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.48 node_modules/jscodeshift/node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.48 node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.47 node_modules/jscodeshift/node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.47 node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.46 node_modules/jscodeshift/node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.46 node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.45 node_modules/jscodeshift/node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.45 node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.44 node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.43 node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.42 node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.41 node_modules/@babel/core/src/config/resolve-targets.ts
immosquare-cleaner-0.1.40 node_modules/@babel/core/src/config/resolve-targets.ts