<commit_before>const env = process.env.BABEL_ENV || process.env.NODE_ENV;
const useBabili = !!parseInt(process.env.SPUST_USE_BABILI || '0', 10);
const notWebpack = !!parseInt(process.env.SPUST_NOT_WEBPACK || '0', 10);

let supportReactLoadable = false;
let supportStyledComponents = false;

// detect if we have react-loadable, babel-plugin-import-inspector and import-inspector
// if one of them is missing, throw an error, if all of them are missing, user doesn't want
// to use it
let reactLoadableAvailable = false;
let importInspectorAvailable = false;
let babelImportInspectorAvailable = false;

// detect if we have styled-components and babel-plugin-styled-components
// if one of them is missing, throw an error
let styledComponentsAvailable = false;
let babelStyledComponentsAvailable = false;

try {
  require.resolve('react-loadable');
  reactLoadableAvailable = true;
  require.resolve('babel-plugin-import-inspector');
  babelImportInspectorAvailable = true;
  require.resolve('import-inspector');
  importInspectorAvailable = true;
  supportReactLoadable = true;
} catch (e) {
  // do not throw if all of them are missing
  if (
    !supportReactLoadable &&
    (reactLoadableAvailable || importInspectorAvailable || babelImportInspectorAvailable)
  ) {
    throw new Error(
      `
  Please install react-loadable, babel-plugin-import-inspector and import-inspector.
  You have to provide all of these dependencies in order to make it work correctly.
    `,
    );
  }
}

try {
  require.resolve('styled-components');
  styledComponentsAvailable = true;
  require.resolve('babel-plugin-styled-components');
  babelStyledComponentsAvailable = true;
  supportStyledComponents = true;
} catch (e) {
  if (!supportStyledComponents && (styledComponentsAvailable || babelStyledComponentsAvailable)) {
    throw new Error(
      `
  Please install styled-components and babel-plugin-styled-components.
  You have to provide both in order to support styled-components v2.
    `,
    );
  }
}

const plugins = [
  supportReactLoadable
    ? [
        require.resolve('babel-plugin-import-inspector'),
        {
          serverSideRequirePath: true,
          webpackRequireWeakId: true,
        },
      ]
    : null,
  supportStyledComponents
    ? [
        require.resolve('babel-plugin-styled-components'),
        { displayName: env === 'test' || env === 'development' },
      ]
    : null,
  require.resolve('babel-plugin-transform-class-properties'),
  [
    require.resolve('babel-plugin-transform-object-rest-spread'),
    {
      useBuiltIns: true,
    },
  ],
  [
    require.resolve('babel-plugin-transform-react-jsx'),
    {
      useBuiltIns: true,
    },
  ],
  [
    require.resolve('babel-plugin-transform-runtime'),
    {
      helpers: false,
      polyfill: false,
      regenerator: true,
    },
  ],
  require.resolve('babel-plugin-idx'),
  require.resolve('babel-plugin-syntax-dynamic-import'),
].filter(Boolean);

if (env === 'development' || env === 'test') {
  const devPlugins = [
    require.resolve('babel-plugin-transform-react-jsx-source'),
    require.resolve('babel-plugin-transform-react-jsx-self'),
  ];

  plugins.push(...devPlugins);
}

const clientEnvPresets = [
  [
    require.resolve('babel-preset-env'),
    {
      targets: Object.assign(
        {},
        useBabili ? { browsers: '> 2%' } : {},
        !useBabili
          ? {
              ie: 10,
              // We currently minify with uglify
              // Remove after https://github.com/mishoo/UglifyJS2/issues/448
              uglify: true,
            }
          : {},
        {
          // Disable polyfill transforms
          useBuiltIns: false,
          // Do not transform modules to CJS
          modules: false,
        },
      ),
    },
  ],
];

const serverEnvPresets = [
  [
    require.resolve('babel-preset-env'),
    {
      targets: {
        node: 'current',
      },
      // Disable polyfill transforms
      useBuiltIns: false,
      // Do not transform modules to CJS in non test env
      modules: env === 'test' || notWebpack ? undefined : false,
    },
  ],
];

const serverPlugins = [];

if (!supportReactLoadable) {
  serverPlugins.push(require.resolve('babel-plugin-dynamic-import-node'));
}
<commit_msg>use babel-plugin-dynamic-import-node during tests<commit_after>const env = process.env.BABEL_ENV || process.env.NODE_ENV;
const useBabili = !!parseInt(process.env.SPUST_USE_BABILI || '0', 10);
const notWebpack = !!parseInt(process.env.SPUST_NOT_WEBPACK || '0', 10);

let supportReactLoadable = false;
let supportStyledComponents = false;

// detect if we have react-loadable, babel-plugin-import-inspector and import-inspector
// if one of them is missing, throw an error, if all of them are missing, user doesn't want
// to use it
let reactLoadableAvailable = false;
let importInspectorAvailable = false;
let babelImportInspectorAvailable = false;

// detect if we have styled-components and babel-plugin-styled-components
// if one of them is missing, throw an error
let styledComponentsAvailable = false;
let babelStyledComponentsAvailable = false;

try {
  require.resolve('react-loadable');
  reactLoadableAvailable = true;
  require.resolve('babel-plugin-import-inspector');
  babelImportInspectorAvailable = true;
  require.resolve('import-inspector');
  importInspectorAvailable = true;
  supportReactLoadable = true;
} catch (e) {
  // do not throw if all of them are missing
  if (
    !supportReactLoadable &&
    (reactLoadableAvailable || importInspectorAvailable || babelImportInspectorAvailable)
  ) {
    throw new Error(
      `
  Please install react-loadable, babel-plugin-import-inspector and import-inspector.
  You have to provide all of these dependencies in order to make it work correctly.
    `,
    );
  }
}

try {
  require.resolve('styled-components');
  styledComponentsAvailable = true;
  require.resolve('babel-plugin-styled-components');
  babelStyledComponentsAvailable = true;
  supportStyledComponents = true;
} catch (e) {
  if (!supportStyledComponents && (styledComponentsAvailable || babelStyledComponentsAvailable)) {
    throw new Error(
      `
  Please install styled-components and babel-plugin-styled-components.
  You have to provide both in order to support styled-components v2.
    `,
    );
  }
}

const plugins = [
  supportReactLoadable
    ? [
        require.resolve('babel-plugin-import-inspector'),
        {
          serverSideRequirePath: true,
          webpackRequireWeakId: true,
        },
      ]
    : null,
  supportStyledComponents
    ? [
        require.resolve('babel-plugin-styled-components'),
        { displayName: env === 'test' || env === 'development' },
      ]
    : null,
  require.resolve('babel-plugin-transform-class-properties'),
  [
    require.resolve('babel-plugin-transform-object-rest-spread'),
    {
      useBuiltIns: true,
    },
  ],
  [
    require.resolve('babel-plugin-transform-react-jsx'),
    {
      useBuiltIns: true,
    },
  ],
  [
    require.resolve('babel-plugin-transform-runtime'),
    {
      helpers: false,
      polyfill: false,
      regenerator: true,
    },
  ],
  require.resolve('babel-plugin-idx'),
  require.resolve('babel-plugin-syntax-dynamic-import'),
].filter(Boolean);

if (env === 'development' || env === 'test') {
  const devPlugins = [
    require.resolve('babel-plugin-transform-react-jsx-source'),
    require.resolve('babel-plugin-transform-react-jsx-self'),
  ];

  plugins.push(...devPlugins);
}

const clientEnvPresets = [
  [
    require.resolve('babel-preset-env'),
    {
      targets: Object.assign(
        {},
        useBabili ? { browsers: '> 2%' } : {},
        !useBabili
          ? {
              ie: 10,
              // We currently minify with uglify
              // Remove after https://github.com/mishoo/UglifyJS2/issues/448
              uglify: true,
            }
          : {},
        {
          // Disable polyfill transforms
          useBuiltIns: false,
          // Do not transform modules to CJS
          modules: false,
        },
      ),
    },
  ],
];

const serverEnvPresets = [
  [
    require.resolve('babel-preset-env'),
    {
      targets: {
        node: 'current',
      },
      // Disable polyfill transforms
      useBuiltIns: false,
      // Do not transform modules to CJS in non test env
      modules: env === 'test' || notWebpack ? undefined : false,
    },
  ],
];

const serverPlugins = [];

if (!supportReactLoadable || env === 'test') {
  serverPlugins.push(require.resolve('babel-plugin-dynamic-import-node'));
}

{'fraction_non_alphanumeric': 0.12397756485160084, 'fraction_numerical': 0.003271792474877308, 'mean_word_length': 2.8728506787330317, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1670920', 'n_tokens_mistral': 2630, 'n_tokens_neox': 2537, 'n_words': 557}