<commit_before>import path from 'path'
import fs from 'fs-extra'
import minimatch from 'minimatch'
import browserify from 'browserify'
import forgetify from 'forgetify'
import babelify from 'babelify'
import envify from 'loose-envify'
import uglifyify from 'uglifyify'
import uglify from 'uglify-js'
import resolve from 'resolve'
import postcss from '../transforms/postcss'
import { debounce } from '../utils/common'
import { depTree } from '../deptree'
import { triggerRefresh } from '../serve'
import { CONFIG } from '../config'

let bundler
export function initBundle () {
  const b = browserify({
    plugin: [forgetify],
    paths: [CONFIG.sourceDir],
    debug: process.env.NODE_ENV === 'development',
    cache: {}, packageCache: {},
    insertGlobalVars: {
      React: (file, basedir) => 'require("react")',
      _INSERT_CSS_: (file, basedir) => 'require("insert-css")',
    },
  })

  b.transform(babelify, {
    presets: [
      resolve.sync('babel-preset-es2015', { basedir: process.cwd() }),
      resolve.sync('babel-preset-react', { basedir: process.cwd() }),
    ],<commit_msg>Use current directory to resolve babel presets<commit_after>import path from 'path'
import fs from 'fs-extra'
import minimatch from 'minimatch'
import browserify from 'browserify'
import forgetify from 'forgetify'
import babelify from 'babelify'
import envify from 'loose-envify'
import uglifyify from 'uglifyify'
import uglify from 'uglify-js'
import resolve from 'resolve'
import postcss from '../transforms/postcss'
import { debounce } from '../utils/common'
import { depTree } from '../deptree'
import { triggerRefresh } from '../serve'
import { CONFIG } from '../config'

let bundler
export function initBundle () {
  const b = browserify({
    plugin: [forgetify],
    paths: [CONFIG.sourceDir],
    debug: process.env.NODE_ENV === 'development',
    cache: {}, packageCache: {},
    insertGlobalVars: {
      React: (file, basedir) => 'require("react")',
      _INSERT_CSS_: (file, basedir) => 'require("insert-css")',
    },
  })

  b.transform(babelify, {
    presets: [
      resolve.sync('babel-preset-es2015', { basedir: __dirname }),
      resolve.sync('babel-preset-react', { basedir: __dirname }),
    ],
{'fraction_non_alphanumeric': 0.1455038409399006, 'fraction_numerical': 0.0036150022593764122, 'mean_word_length': 4.066361556064074, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4602447', 'n_tokens_mistral': 709, 'n_tokens_neox': 696, 'n_words': 194}