<commit_before>#!/usr/bin/env node
const path = require('path');
const argv = require('yargs')
  .config()
  .pkgConf('_dev')
  .default({
    watch: false,
    docs: false,
    metadata: true,
    debug: true,
    headerFile: require.resolve('./header.js'),
    minHeaderFile: require.resolve('./minHeader.js'),
    name: 'index',
  })
  .option('entries', {
    required: true,
    array: 'true',
    coerce: entries => {
      return entries.map(entry => path.resolve(entry));
    },
  })
  .option('destDir', {
    required: true,
    coerce: path.resolve,
  })
  .argv;

const dir = path.join(__dirname, '..');

process.env.NODE_PATH = `${process.env.NODE_PATH || ''}:${dir}/node_modules`;
require('module')._initPaths();

const browserify      = require('browserify');
const bundleProcessor = require('./bundleProcessor');

const config = {
  debug: argv.debug,

  entries: argv.entries,
  standalone: argv.standalone,

  transform: [
    [ require('babelify'), {
      babelrc: false,
      sourceType: 'module',
      global: true,
      ...require('../.babelrc'),
    } ],
    [ require('envify'), {
      global: true,
      _: 'purge',
    } ],
  ],

  plugin: argv.watch
    ? [
      require('watchify'),
      require('errorify'),
    ]
    : [
      require('browser-pack-flat/plugin'),
      require('common-shakeify'),
    ],

  cache: {},
  packageCache: {},
};

const b = browserify(config);

if (argv.watch) {
  b.on('update', update);
  b.on('log', msg => console.log(msg));
}
else {
  process.on('beforeExit', () => {
    console.log(' done.');
  });
}

function update (ids) {
  if (argv.docs) {
    require('./docs')({
      stdio: ['ignore', 'ignore', 'inherit'],
    });
  }

  if (argv.watch) {
    console.log('Bundling...');
  }
  else {
    process.stdout.write('Bundling...');
  }

  if (ids) {
    console.log(ids.reduce((formatted, id) => {
      return `${formatted}\n    ${path.relative(process.cwd(), id)}`;
    }, ''));<commit_msg>_dev: rearrange browserify config<commit_after>#!/usr/bin/env node
const path = require('path');
const argv = require('yargs')
  .config()
  .pkgConf('_dev')
  .default({
    watch: false,
    docs: false,
    metadata: true,
    debug: true,
    headerFile: require.resolve('./header.js'),
    minHeaderFile: require.resolve('./minHeader.js'),
    name: 'index',
  })
  .option('entries', {
    required: true,
    array: 'true',
    coerce: entries => {
      return entries.map(entry => path.resolve(entry));
    },
  })
  .option('destDir', {
    required: true,
    coerce: path.resolve,
  })
  .argv;

const dir = path.join(__dirname, '..');

process.env.NODE_PATH = `${process.env.NODE_PATH || ''}:${dir}/node_modules`;
require('module')._initPaths();

const browserify      = require('browserify');
const bundleProcessor = require('./bundleProcessor');

const plugins = (() => {
  if (argv.watch) {
    return [
      require('watchify'),
      require('errorify'),
    ];
  }
  return [
    require('browser-pack-flat/plugin'),
    require('common-shakeify'),
  ];
})();


const b = browserify(argv.entries, {
  debug: argv.debug,

  standalone: argv.standalone,

  transform: [
    [ require('babelify'), {
      babelrc: false,
      sourceType: 'module',
      global: true,
      ...require('../.babelrc'),
    } ],
    [ require('envify'), {
      global: true,
      _: 'purge',
    } ],
  ],

  plugin: plugins,

  cache: {},
  packageCache: {},
});

if (argv.watch) {
  b.on('update', update);
  b.on('log', msg => console.log(msg));
}
else {
  process.on('beforeExit', () => {
    console.log(' done.');
  });
}

function update (ids) {
  if (argv.docs) {
    require('./docs')({
      stdio: ['ignore', 'ignore', 'inherit'],
    });
  }

  if (argv.watch) {
    console.log('Bundling...');
  }
  else {
    process.stdout.write('Bundling...');
  }

  if (ids) {
    console.log(ids.reduce((formatted, id) => {
      return `${formatted}\n    ${path.relative(process.cwd(), id)}`;
    }, ''));
{'fraction_non_alphanumeric': 0.20859512440311637, 'fraction_numerical': 0.0, 'mean_word_length': 2.815915627996165, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '2106983', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1353, 'n_words': 245}