<commit_before>import browserSync from 'browser-sync';
import webpack from 'webpack';
import webpackHotMiddleware from 'webpack-hot-middleware';
import webpackDevMiddleware from 'webpack-middleware';
import { webpackServer, webpackClient, stats } from '../config';
import run from '../lib/run';
import serve from './serve';
import clean from './clean';
import copy from './copy';

function _dev() {
  return new Promise((resolve, reject) => {
    const webpackPackage = [webpackClient, webpackServer];
    const bundler = webpack(webpackPackage);
    const hotMiddlewares = bundler.compilers
      .filter(compiler => compiler.options.target !== 'node')
      .map(compiler => webpackHotMiddleware(compiler));
    let bs;
    let runCount = 0;
    bundler.watch(200, async (err, res) => {
      if (err) {
        return reject(err);
      }

      console.log(res.toString(stats));

      if (++runCount % webpackPackage.length !== 0) {
        return null;
      }

      if (!bs) {
        await run(serve);
        bs = browserSync.create();
        bs.init({
          proxy: {
            target: 'localhost:5000',
            middleware: [
              webpackDevMiddleware(bundler, {
                publicPath: '/',
                stats,
              }),
              ...hotMiddlewares,
            ],
          },
        }, resolve);
      }
    });
  });
}

async function dev() {
  await run(clean);
  await run(copy);
  await _dev();
}

export default dev;<commit_msg>Update improve building dev bundle<commit_after>import browserSync from 'browser-sync';
import webpack from 'webpack';
import webpackHotMiddleware from 'webpack-hot-middleware';
import webpackDevMiddleware from 'webpack-middleware';
import { webpackServer, webpackClient, stats } from '../config';
import run from '../lib/run';
import serve from './serve';
import clean from './clean';
import copy from './copy';

function _dev() {
  return new Promise((resolve) => {
    const webpackPackage = [webpackClient, webpackServer];
    const bundler = webpack(webpackPackage);
    const hotMiddlewares = bundler.compilers
      .filter(compiler => compiler.options.target !== 'node')
      .map(compiler => webpackHotMiddleware(compiler));
    const wpMiddleware = webpackDevMiddleware(bundler, {
      publicPath: '/',
      stats,
    });
    let bs;
    bundler.plugin('done', async () => {
      if (!bs) {
        await run(serve);
        bs = browserSync.create();
        bs.init({
          proxy: {
            target: 'localhost:5000',
            middleware: [
              wpMiddleware,
              ...hotMiddlewares,
            ],
          },
        }, resolve);
      }
    });
  });
}

async function dev() {
  await run(clean);
  await run(copy);
  await _dev();
}

export default dev;
{'fraction_non_alphanumeric': 0.13409824309788454, 'fraction_numerical': 0.004661168877733955, 'mean_word_length': 2.470149253731343, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6467783', 'n_tokens_mistral': 795, 'n_tokens_neox': 785, 'n_words': 203}