How to use the browserslist.aliases function in browserslist

To help you get started, we’ve selected a few browserslist examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github popeindustries / buddy / src / config / buildOptions.js View on Github external
['transform-runtime', { helpers: true, polyfill: false, regenerator: false, moduleName: 'babel-runtime' }],
  ['transform-es2015-modules-commonjs', { loose: true, noInterop: true, strictMode: false }]
];
const DEFAULT_BABEL_ENV_OPTIONS = {
  modules: false,
  exclude: ['transform-regenerator'],
  loose: true
};
const OPTIONS_WHITELIST = ['autoprefixer', 'babel', 'cssnano', 'postcss'];
// const POSTCSS_PLUGINS_COMPRESS = [['cssnano', {}]];
const RE_BABEL_PREFIX = /babel-preset-|babel-plugin-/;
const RE_BROWSERSLIST_QUERY = /last|unreleased|not|extends|%|>=?|<=?/i;
const RE_BUDDY_PREFIX = /buddy-plugin-/;
const RE_ES_TARGET = /^es/i;
const RE_NODE_TARGET = /^node|^server/i;
const VALID_BROWSERS = [...Object.keys(browserslist.data), ...Object.keys(browserslist.aliases)];

module.exports = {
  isBrowserEnvironment,
  parseVersion,

  /**
   * Add 'preset' definition for 'type'
   */
  addPreset(type: string, name: string, preset: Array) {
    if (isNullOrUndefined(allPlugins[type])) {
      allPlugins[type] = {};
    }
    allPlugins[type][name] = preset;
  },

  /**
github babel / babel / packages / babel-preset-env / src / targets-parser.js View on Github external
// @flow

import browserslist from "browserslist";
import invariant from "invariant";
import semver from "semver";
import findSuggestion from "levenary";
import { semverify, isUnreleasedVersion, getLowestUnreleased } from "./utils";
import browserModulesData from "../data/built-in-modules.json";
import { TargetNames } from "./options";
import type { Targets } from "./types";

const browserslistDefaults = browserslist.defaults;

const validBrowserslistTargets = [
  ...Object.keys(browserslist.data),
  ...Object.keys(browserslist.aliases),
];

const objectToBrowserslist = (object: Targets): Array => {
  return Object.keys(object).reduce((list, targetName) => {
    if (validBrowserslistTargets.indexOf(targetName) >= 0) {
      const targetVersion = object[targetName];
      return list.concat(`${targetName} ${targetVersion}`);
    }
    return list;
  }, []);
};

const validateTargetNames = (targets: Targets): void => {
  const validTargets = Object.keys(TargetNames);
  for (const target in targets) {
    if (!TargetNames[target]) {
github zloirock / core-js / packages / core-js-compat / targets-parser.js View on Github external
const normalized = list.map(([engine, version]) => {
    if (has(browserslist.aliases, engine)) {
      engine = browserslist.aliases[engine];
    }
    if (aliases.has(engine)) {
      engine = aliases.get(engine);
    } else if (engine === 'android' && compare(version, '>', '4.4.4')) {
      engine = 'chrome';
    }
    return [engine, String(version)];
  }).filter(([engine]) => {
    return validTargets.has(engine);
github zloirock / core-js / packages / core-js-compat / targets-parser.js View on Github external
const normalized = list.map(([engine, version]) => {
    if (has(browserslist.aliases, engine)) {
      engine = browserslist.aliases[engine];
    }
    if (aliases.has(engine)) {
      engine = aliases.get(engine);
    } else if (engine === 'android' && compare(version, '>', '4.4.4')) {
      engine = 'chrome';
    }
    return [engine, String(version)];
  }).filter(([engine]) => {
    return validTargets.has(engine);
github babel / babel-preset-env / src / normalize-options.js View on Github external
const unknownOpts = opts.filter(opt => !validIncludesAndExcludes.has(opt));

  invariant(
    unknownOpts.length === 0,
    `Invalid Option: The plugins/built-ins '${unknownOpts.join(
      ", ",
    )}' passed to the '${type}' option are not
    valid. Please check data/[plugin-features|built-in-features].js in babel-preset-env`,
  );

  return opts;
};

const validBrowserslistTargets = [
  ...Object.keys(browserslist.data),
  ...Object.keys(browserslist.aliases),
];

export const normalizePluginName = (plugin: string): string =>
  plugin.replace(/^babel-plugin-/, "");

export const normalizePluginNames = (plugins: Array): Array =>
  plugins.map(normalizePluginName);

export const checkDuplicateIncludeExcludes = (
  include: Array = [],
  exclude: Array = [],
): void => {
  const duplicates: Array = include.filter(
    opt => exclude.indexOf(opt) >= 0,
  );