<commit_before>// https://www.wisdomgeek.com/development/web-development/how-to-setup-jest-typescript-babel-webpack-project/
module.exports = (api) => {
  // Testing if babel is being run in test mode
  const isTest = api.env('test');

  /**
   * Cache the returned value forever and don't call this function again. This is the default behavior but since we
   * are reading the env value above, we need to explicitly set it after we are done doing that, else we get a
   * caching was left unconfigured error.
   */
  api.cache(true);
  return {
    presets: [
      [
        // Allows smart transpilation according to target environments
        '@babel/preset-env',
        {
          // Specifying which browser versions you want to transpile down to
          targets: '> 0.25%, not dead',
          /**
           * Specifying what module type should the output be in.
           * For test cases, we transpile all the way down to commonjs since jest does not understand TypeScript.
           * For all other cases, we don't transform since we want Webpack to do that in order for it to do
           * dead code elimination (tree shaking) and intelligently select what all to add to the bundle.
           */ modules: isTest ? 'commonjs' : false,
        },
      ],
      // Enabling Babel to understand TypeScript
      '@babel/preset-typescript',
    ],
  };
};
<commit_msg>fix(core): compile down to commonjs (#29)<commit_after>// https://www.wisdomgeek.com/development/web-development/how-to-setup-jest-typescript-babel-webpack-project/
module.exports = (api) => {
  /**
   * Cache the returned value forever and don't call this function again. This is the default behavior but since we
   * are reading the env value above, we need to explicitly set it after we are done doing that, else we get a
   * caching was left unconfigured error.
   */
  api.cache(true);

  return {
    presets: [
      [
        // Allows smart transpilation according to target environments
        '@babel/preset-env',
        {
          // Specifying which browser versions you want to transpile down to
          targets: '> 0.25%, not dead',

          modules: 'commonjs',
        },
      ],
      // Enabling Babel to understand TypeScript
      '@babel/preset-typescript',
    ],
  };
};

{'fraction_non_alphanumeric': 0.09424083769633508, 'fraction_numerical': 0.0034904013961605585, 'mean_word_length': 2.4377811094452775, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '7341784', 'n_tokens_mistral': 649, 'n_tokens_neox': 620, 'n_words': 246}