How to use the react-dev-utils/formatWebpackMessages function in react-dev-utils

To help you get started, we’ve selected a few react-dev-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github viewstools / morph / runCraWebpackDevServerUtils.js View on Github external
if (messages.errors.length > 0) {
        if (tscCompileOnError) {
          devSocket.warnings(messages.errors)
        } else {
          devSocket.errors(messages.errors)
        }
      } else if (messages.warnings.length > 0) {
        devSocket.warnings(messages.warnings)
      }

      if (isInteractive) {
        clearConsole()
      }
    }

    const messages = formatWebpackMessages(statsData)
    const isSuccessful = !messages.errors.length && !messages.warnings.length
    if (isSuccessful) {
      console.log(chalk.green('WP Compiled successfully!'))
    }
    if (isSuccessful && (isInteractive || isFirstCompile)) {
      printInstructions(appName, urls, useYarn)
    }
    isFirstCompile = false

    // If errors exist, only show errors.
    if (messages.errors.length) {
      // Only keep the first error. Others are often indicative
      // of the same problem, but confuse the reader with noise.
      if (messages.errors.length > 1) {
        messages.errors.length = 1
      }
github govau / performance-dashboard / client / scripts / start.js View on Github external
compiler.plugin('done', function(stats) {
  clearConsole();

  // We have switched off the default Webpack output in WebpackDevServer
  // options so we are going to "massage" the warnings and errors and present
  // them in a readable focused way.
  var messages = formatWebpackMessages(stats.toJson({}, true));
  var isSuccessful = !messages.errors.length && !messages.warnings.length;
  var showInstructions = isSuccessful && isFirstCompile;

  if (isSuccessful) {
    console.log(chalk.green('Compiled successfully!'));
  }

  if (showInstructions) {
    console.log();
    console.log(`The app is listening at ${devServerPublicPath}, but develop on Rails server at ${chalk.cyan(('http://localhost:3000'))}.`)
    console.log();
    console.log('Note that the development build is not optimized.');
    console.log('To create a production build, use ' + chalk.cyan('yarn run build') + '.');
    console.log();
    isFirstCompile = false;
  }
github strues / boldr / packages / tools / src / services / startDevServer.js View on Github external
multiCompiler.plugin('done', stats => {
    const rawMessages = stats.toJson({}, true);
    const messages = formatWebpackMessages(rawMessages);

    if (!messages.errors.length && !messages.warnings.length) {
      logger.end('Compiled successfully!');
    }

    // If errors exist, only show errors.
    if (messages.errors.length) {
      logger.error('Failed to compile.\n');
      messages.errors.forEach(e => logger.error(e));
      return;
    }

    // Show warnings if no errors were found.
    if (messages.warnings.length) {
      logger.warn('Compiled with warnings.\n');
      messages.warnings.forEach(w => logger.warn(w));
github swashata / wp-webpack-script / packages / scripts / src / scripts / Build.ts View on Github external
compiler.run((err, stats) => {
					const raw = stats.toJson('verbose');
					const messages = formatWebpackMessages(raw);
					const outputLog = stats.toString({
						colors: true,
						assets: true,
						chunks: false,
						entrypoints: false,
						hash: false,
						version: false,
						modules: false,
						builtAt: false,
						timings: false,
						warnings: false,
						errors: false,
					});

					if (!messages.errors.length && !messages.warnings.length) {
						// All good
github thetribeio / node-react-starter-kit / tools / lib / webpackHotDevClient.js View on Github external
showProblems(type, errors) {
        reportBuildError(formatWebpackMessages({ errors, warnings: [] }).errors[0]);
    },
    clear() {
github labzero / lunch / tools / lib / webpackHotDevClient.js View on Github external
showProblems(type, errors) {
    const formatted = formatWebpackMessages({
      errors,
      warnings: [],
    });

    reportBuildError(formatted.errors[0]);
  },
  clear() {
github codejamninja / reactant / tools / lib / build.js View on Github external
env.CI &&
    (!_.isString(env.CI) || env.CI.toLowerCase() !== 'false') &&
    webMessages.warnings.length
  ) {
    log.info(
      chalk.yellow(
        '\ntreating warnings as errors because `CI = true`\n' +
          'most CI servers set it automatically\n'
      )
    );
    throw new Error(webMessages.warnings.join('\n\n'));
  }
  log.info(chalk.green('compiled web'));
  log.info('compiling server . . .');
  const nodeStats = await compile(webpackNodeConfig);
  const nodeMessages = formatWebpackMessages(nodeStats.toJson({}, true));
  if (nodeMessages.errors.length) {
    throw new Error(nodeMessages.errors.join('\n\n'));
  }
  if (
    env.CI &&
    (!_.isString(env.CI) || env.CI.toLowerCase() !== 'false') &&
    nodeMessages.warnings.length
  ) {
    log.info(
      chalk.yellow(
        '\ntreating warnings as errors because `CI = true`\n' +
          'most CI servers set it automatically\n'
      )
    );
    throw new Error(nodeMessages.warnings.join('\n\n'));
  }
github codejamninja / reactant / packages / web-isomorphic / src / hotDevClient.js View on Github external
async function handleErrors(errors) {
  clearErrors();
  const formatted = formatWebpackMessages({ errors, warnings: [] });
  reportBuildError(formatted.errors[0]);
  _.each(formatted.errors, (error, index) => {
    if (index < formatted.errors.length) {
      if (index === 5) {
        log.error(
          'There were more errors in other files.\n' +
            'You can find a complete log in the terminal.'
        );
      }
      log.error(stripAnsi(error));
      return true;
    }
    return false;
  });
  hadServerError = true;
  hadError = true;
github pixeloven / pixeloven / packages / pixeloven-core / src / libraries / WebpackStatsHandler.ts View on Github external
public format(): FormattedStats {
        return formatWebpackMessages(this.stats.toJson(this.level));
    }
}
github pixeloven / pixeloven / packages / pixeloven-tasks / src / serve.ts View on Github external
reporter: (middlewareOptions, reporterOptions) => {
                if (
                    reporterOptions.state &&
                    reporterOptions.stats &&
                    middlewareOptions.logLevel !== "silent"
                ) {
                    const stats = formatWebpackMessages(
                        reporterOptions.stats.toJson("verbose"),
                    );
                    if (stats) {
                        if (reporterOptions.stats.hasErrors()) {
                            logger.error(stats.errors);
                            logger.error("Failed to compile.");
                        } else if (reporterOptions.stats.hasWarnings()) {
                            logger.warn(stats.warnings);
                            logger.warn("Compiled with warnings.");
                        } else {
                            logger.info("Compiled successfully.");
                        }
                    } else {
                        logger.error(
                            "Unexpected Error: Failed to retrieve webpack stats.",
                        );