<commit_before>import babel from "rollup-plugin-babel";
import resolve from "@rollup/plugin-node-resolve";
import replace from "@rollup/plugin-replace";
import sourceMaps from "rollup-plugin-sourcemaps";
import { terser } from "rollup-plugin-terser";

const root = process.platform === "win32" ? path.resolve("/") : "/";
const external = id => !id.startsWith(".") && !id.startsWith(root);
const globals = {
  '@babel/runtime/helpers/esm/extends': 'extends',
  '@babel/runtime/helpers/esm/assertThisInitialized': 'assertThisInitialized',
  '@babel/runtime/helpers/esm/inheritsLoose': 'inheritsLoose',
  '@babel/runtime/helpers/esm/wrapNativeSuper': 'wrapNativeSuper',
  '@babel/runtime/helpers/esm/taggedTemplateLiteralLoose': 'taggedTemplateLiteralLoose'
};

const input = "src/index.js";
const name = "polished";

const getBabelOptions = ({ useESModules }, targets) => ({
  babelrc: false,
  runtimeHelpers: true,
  presets: [
    [
      "@babel/preset-env",
      {
        loose: true,
        modules: false,
        exclude: [/transform-typeof-symbol/],
        targets,
        bugfixes: true
      }
    ],
    "@babel/flow"
  ],
  plugins: [
    "add-module-exports",
    "annotate-pure-calls",
    "preval",
    ["@babel/transform-runtime", { useESModules }]
  ]
});

export default [
  {
    input,
    output: { file: `dist/${name}.esm.js`, format: "esm" },
    external,
    plugins: [
      sourceMaps(),
      resolve(),
      babel(
        getBabelOptions(
          { useESModules: true },
          { esmodules: true }
        )
      )
    ]
  },
  {
    input,
    output: { file: `dist/${name}.cjs.js`, format: "cjs" },
    external,
    plugins: [
      sourceMaps(),
      resolve(),
      babel(getBabelOptions({ useESModules: false }))
    ]
  },
  {
    input,
    output: { file: `dist/${name}.js`, format: "umd", name, globals },
    external,
    plugins: [
      sourceMaps(),
      resolve(),
      babel(getBabelOptions({ useESModules: true })),
      replace({ "process.env.NODE_ENV": JSON.stringify("development") })
    ]
  },
  {
    input,
    output: { file: `dist/${name}.min.js`, format: "umd", name, globals },
    external,
    plugins: [
      sourceMaps(),
      resolve(),
      babel(getBabelOptions({ useESModules: true })),
      replace({ "process.env.NODE_ENV": JSON.stringify("production") }),
      terser()
    ]
  }
];<commit_msg>build(rollup): add browser support queries to non-esm builds<commit_after>import babel from "rollup-plugin-babel";
import resolve from "@rollup/plugin-node-resolve";
import replace from "@rollup/plugin-replace";
import sourceMaps from "rollup-plugin-sourcemaps";
import { terser } from "rollup-plugin-terser";

const root = process.platform === "win32" ? path.resolve("/") : "/";
const external = id => !id.startsWith(".") && !id.startsWith(root);
const globals = {
  '@babel/runtime/helpers/esm/extends': 'extends',
  '@babel/runtime/helpers/esm/assertThisInitialized': 'assertThisInitialized',
  '@babel/runtime/helpers/esm/inheritsLoose': 'inheritsLoose',
  '@babel/runtime/helpers/esm/wrapNativeSuper': 'wrapNativeSuper',
  '@babel/runtime/helpers/esm/taggedTemplateLiteralLoose': 'taggedTemplateLiteralLoose'
};

const input = "src/index.js";
const name = "polished";

const getBabelOptions = ({ useESModules }, targets) => ({
  babelrc: false,
  runtimeHelpers: true,
  presets: [
    [
      "@babel/preset-env",
      {
        loose: true,
        modules: false,
        exclude: [/transform-typeof-symbol/],
        targets,
        bugfixes: true
      }
    ],
    "@babel/flow"
  ],
  plugins: [
    "add-module-exports",
    "annotate-pure-calls",
    "preval",
    ["@babel/transform-runtime", { useESModules }]
  ]
});

export default [
  {
    input,
    output: { file: `dist/${name}.esm.js`, format: "esm" },
    external,
    plugins: [
      sourceMaps(),
      resolve(),
      babel(getBabelOptions({ useESModules: true }, { esmodules: true })),
    ],
  },
  {
    input,
    output: { file: `dist/${name}.cjs.js`, format: "cjs" },
    external,
    plugins: [
      sourceMaps(),
      resolve(),
      babel(
        getBabelOptions(
          { useESModules: false },
          ">0.5%, not dead, ie >= 11, not op_mini all"
        )
      ),
    ],
  },
  {
    input,
    output: { file: `dist/${name}.js`, format: "umd", name, globals },
    external,
    plugins: [
      sourceMaps(),
      resolve(),
      babel(
        getBabelOptions(
          { useESModules: true },
          ">0.5%, not dead, ie >= 11, not op_mini all"
        )
      ),
      replace({ "process.env.NODE_ENV": JSON.stringify("development") }),
    ],
  },
  {
    input,
    output: { file: `dist/${name}.min.js`, format: "umd", name, globals },
    external,
    plugins: [
      sourceMaps(),
      resolve(),
      babel(
        getBabelOptions(
          { useESModules: true },
          ">0.5%, not dead, ie >= 11, not op_mini all"
        )
      ),
      replace({ "process.env.NODE_ENV": JSON.stringify("production") }),
      terser(),
    ],
  },
];
{'fraction_non_alphanumeric': 0.17009493670886075, 'fraction_numerical': 0.0031645569620253164, 'mean_word_length': 2.6939371804236667, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3899945', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1707, 'n_words': 317}