<commit_before>#! /usr/bin/env node

process.env.NODE_ENV = 'development';
const webpack = require('webpack');
const paths = require('../config/paths');
const printErrors = require('../config/printErrors');
const createConfig = require('../config/create-config');
const devServer = require('webpack-dev-server');
const chalk = require('chalk');
const clearConsole = require('react-dev-utils/clearConsole');
const fs = require('fs-extra');
const logger = require('../config/logger');

process.noDeprecation = true; // turns off that loadQuery clutter.

// Optimistically, we make the console look exactly like the output of our
// FriendlyErrorsPlugin during compilation, so the user has immediate feedback.
// clearConsole();
logger.start('Compiling...');
let razzle = {};

// Check for razzle.config.js file
if (fs.existsSync(paths.appRazzleConfig)) {
  try {
    razzle = require(paths.appRazzleConfig);
  } catch (e) {
    clearConsole();
    logger.error('Invalid razzle.config.js file.', e);
    process.exit(1);
  }
}

// Create dev configs using our config factory, passing in razzle file as
// options.
let clientConfig = createConfig('web', 'dev', razzle);
let serverConfig = createConfig('node', 'dev', razzle);

// Check if razzle.config has a modify function. If it does, call it on the
// configs we just created.
if (razzle.modify) {
  clientConfig = razzle.modify(
    clientConfig,
    { target: 'web', dev: true },
    webpack
  );
  serverConfig = razzle.modify(
    serverConfig,
    { target: 'node', dev: true },
    webpack
  );
}

// Compile our assets with webpack
const clientCompiler = compile(clientConfig);
const serverCompiler = compile(serverConfig);

// Create a new instance of Webpack-dev-server for our client assets.
// This will actually run on a different port than the users app.
const clientDevServer = new devServer(clientCompiler, clientConfig.devServer);

// Start Webpack-dev-server
clientDevServer.listen(
  (process.env.PORT && parseInt(process.env.PORT) + 1) || razzle.port || 3001,
  err => {
    if (err) {
      logger.error(err);
    }
  }
);

// Start our server webpack instance in watch mode.
serverCompiler.watch(
  {
    quiet: true,
    stats: 'none',
  },
  stats => {}
);

// Webpack compile in a try-catch
function compile(config) {
  let compiler;
  try {
    compiler = webpack(config);
  } catch (e) {
    printErrors('Failed to compile.', [e]);
    process.exit(1);
  }
  return compiler;
}<commit_msg>See if race condition is causing test failures on CI<commit_after>#! /usr/bin/env node

process.env.NODE_ENV = 'development';
const webpack = require('webpack');
const paths = require('../config/paths');
const printErrors = require('../config/printErrors');
const createConfig = require('../config/create-config');
const devServer = require('webpack-dev-server');
const chalk = require('chalk');
const clearConsole = require('react-dev-utils/clearConsole');
const fs = require('fs-extra');
const logger = require('../config/logger');

process.noDeprecation = true; // turns off that loadQuery clutter.

// Optimistically, we make the console look exactly like the output of our
// FriendlyErrorsPlugin during compilation, so the user has immediate feedback.
// clearConsole();
logger.start('Compiling...');
let razzle = {};

// Check for razzle.config.js file
if (fs.existsSync(paths.appRazzleConfig)) {
  try {
    razzle = require(paths.appRazzleConfig);
  } catch (e) {
    clearConsole();
    logger.error('Invalid razzle.config.js file.', e);
    process.exit(1);
  }
}

// Create dev configs using our config factory, passing in razzle file as
// options.
let clientConfig = createConfig('web', 'dev', razzle);
let serverConfig = createConfig('node', 'dev', razzle);

// Check if razzle.config has a modify function. If it does, call it on the
// configs we just created.
if (razzle.modify) {
  clientConfig = razzle.modify(
    clientConfig,
    { target: 'web', dev: true },
    webpack
  );
  serverConfig = razzle.modify(
    serverConfig,
    { target: 'node', dev: true },
    webpack
  );
}

// Compile our assets with webpack
const clientCompiler = compile(clientConfig);

// Create a new instance of Webpack-dev-server for our client assets.
// This will actually run on a different port than the users app.
const clientDevServer = new devServer(clientCompiler, clientConfig.devServer);

// Start Webpack-dev-server
clientDevServer.listen(
  (process.env.PORT && parseInt(process.env.PORT) + 1) || razzle.port || 3001,
  err => {
    if (err) {
      logger.error(err);
    }
    const serverCompiler = compile(serverConfig);

    // Start our server webpack instance in watch mode.
    serverCompiler.watch(
      {
        quiet: true,
        stats: 'none',
      },
      stats => {}
    );
  }
);

// Webpack compile in a try-catch
function compile(config) {
  let compiler;
  try {
    compiler = webpack(config);
  } catch (e) {
    printErrors('Failed to compile.', [e]);
    process.exit(1);
  }
  return compiler;
}
{'fraction_non_alphanumeric': 0.13666333666333666, 'fraction_numerical': 0.002797202797202797, 'mean_word_length': 3.6266173752310538, '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': '2864907', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1493, 'n_words': 459}