Wrap webpack compile in a try catch.
422581
function compile(config) {
  return new Promise((resolve, reject) => {
    let compiler;
    try {
      compiler = webpack(config);
    } catch (e) {
      console.log('compile errors:', [e]); // eslint-disable-line
      reject(e);
      process.exit(1);
    }
    compiler.run((err, stats) => {
      err ? reject(err) : resolve(stats);
    });
  });
}
82915
function build(previousFileSizes) {
  console.log('Creating an optimized production build...');

  let compiler = webpack(config);
  return new Promise((resolve, reject) => {
    compiler.run((err, stats) => {
      if (err) {
        return reject(err);
      }
      const messages = formatWebpackMessages(stats.toJson({}, true));
      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;
        }
        return reject(new Error(messages.errors.join('\n\n')));
      }
      if (
        process.env.CI &&
        (typeof process.env.CI !== 'string' ||
          process.env.CI.toLowerCase() !== 'false') &&
        messages.warnings.length
      ) {
        console.log(
          chalk.yellow(
            '\nTreating warnings as errors because process.env.CI = true.\n' +
              'Most CI servers set it automatically.\n'
          )
        );
        return reject(new Error(messages.warnings.join('\n\n')));
      }

      // Create stylesheet for use with the DBP
      const css = fs.readFileSync(
        path.join(paths.appBuild, 'styles', 'style.min.css'),
        'utf-8'
      );
      const out = postcss()
        .use(
          prefixer({
            prefix: '.et_divi_builder #et_builder_outer_content',
            exclude: [],

            // Optional transform callback for case-by-case overrides
            /*transform: function(prefix, selector, prefixedSelector) {
          if (selector === 'body') {
            return 'body.' + prefix;
          } else {
            return prefixedSelector;
          }
        }*/
          })
        )
        .process(css).css;

      fs.writeFileSync(
        path.join(paths.appBuild, 'styles', 'style-dbp.min.css'),
        out
      );

      return resolve({
        stats,
        previousFileSizes,
        warnings: messages.warnings,
      });
    });
  });
}
245942
function buildExcludeCheck (transpileDependencies = []) {
  const dependencyChecks = transpileDependencies.map((dependency) => (
    new RegExp(`node_modules.${dependency}`)
  ))

  // see: https://webpack.js.org/configuration/module/#condition
  return function (assetPath) {
    const shouldTranspile = dependencyChecks
      .reduce((result, check) => result || assetPath.match(check), false)

    if (shouldTranspile) { return false }
    return !!assetPath.match(/node_modules/)
  }
}
371511
function reactdown(source: string): ?string {
  this.cacheable();

  let compiler = this._compiler;

  // We read the config once. That means on changes to config one must restart
  // the compiler.
  //
  // TODO: Improve on that, so changes to configration do not require restarting
  // Webpack compiler.
  if (compiler.__reactdownConfig === undefined) {
    try {
      compiler.__reactdownConfig = discoverConfig(compiler.context).config;
    } catch (error) {
      if (error instanceof ValidationError) {
        this.emitError(formatConfigurationError(error));
        return;
      }
      throw error;
    }
  }

  let config = mergeConfig(
    compiler.__reactdownConfig,
    parseConfigFromQuery(this.query)
  );

  config.buildImageURL = url => new TaggedCodeRef(url);

  let code;
  try {
    code = renderToString(source, config).code;
  } catch (error) {
    // TODO: this is a hackyway how we distinguish errors from parser
    if (error.ruleId !== undefined) {
      this.emitError(formatSyntaxError(error));
    } else {
      throw error;
    }
  }
  return code;
}
1221196
function wrap_sync(fn) {
  return function (params) {
    var val = fn(params);
    if (val && !isPromise(val)) throw val;
    return val;
  };
}
457908
function tryPlugin(mId, space) {
  const parsed = parse(mId);
  const pluginId = parsed.prefix.slice(0, -1);
  // text,json,raw plugins are built-in
  if (pluginId) {
    if (pluginId !== 'text' && pluginId !== 'raw') {
      return new Promise((resolve, reject) => {
        const req = (deps, callback, errback) => {
          const errback2 = e => {
            if (errback) {
              try {
                errback(e);
              } catch (err) {
                // ignore
              }
            }
            reject(e);
          };
          return requirejs(deps, callback, errback2);
        };
        try {
          const onload = loaded => {
            space.define(mId, [], () => loaded);
            resolve(space.req(mId));
          };
          onload.error = err => reject(err);

          requirejs([pluginId], plugin => {
            // Call requirejs plugin api load(name, require, load, options)
            // Options set to {} just to make existing requirejs plugins happy.
            plugin.load(parsed.bareId, req, onload, {});
          });
        } catch (err) {
          reject(err);
        }
      });
    }
  } else if (parsed.ext && parsed.ext !== '.js') {
    // Try extension plugin like "ext:css".
    const extPluginName = 'ext:' + parsed.ext.slice(1);
    if (userSpace.has(extPluginName) || packageSpace.has(extPluginName)) {
      return new Promise((resolve, reject) => {
        const req = (deps, callback, errback) => {
          const errback2 = e => {
            if (errback) {
              try {
                errback(e);
              } catch (err) {
                // ignore
              }
            }
            reject(e);
          };
          return requirejs(deps, callback, errback2);
        };
        try {
          const onload = loaded => {
            space.define(mId, [], () => loaded);
            resolve(space.req(mId));
          };
          onload.error = err => reject(err);

          requirejs([extPluginName], plugin => {
            // Call requirejs plugin api load(name, require, load, options)
            // Options set to {} just to make existing requirejs plugins happy.
            plugin.load(parsed.cleanId, req, onload, {});
          });
        } catch (err) {
          reject(err);
        }
      });
    }
    // else by default use text! for any unknown extname
    return new Promise(resolve => {
      space.define(parsed.cleanId,['text!' + parsed.cleanId], m => m);
      resolve(space.req(mId));
    });
  }
}
681010
function(tag, compile, cb) {
  return new Promise(function(resolve, reject) {
    compile.run((err, stats) => {
      if (err) {
        console.error(err)
        return reject(err)
      }

      console.log(
        tag,
        stats.toString({
          chunks: false, // Makes the build much quieter
          colors: true
        })
      )

      resolve(stats)
      if (cb) {
        cb(stats)
      }
    })
  })
}
1267687
function compile(fileNames, options, verbose) {
  const program = ts.createProgram(fileNames, options)
  const emitResult = program.emit()

  /* istanbul ignore next */
  if (verbose) {
    const allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics)

    allDiagnostics.forEach((diagnostic) => {
      if (diagnostic.file) {
        const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(
          diagnostic.start
        )
        const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")
        console.log(
          `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`
        )
      } else {
        console.log(`${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`)
      }
    })
  }
}
235910
async function packaging () {
  await ngPackagr.ngPackage({project: path.join(config.libPath, 'ng-package.json')})
    .then((res) => {
      console.info('done packaging'.green)
    })
    .catch((err) => {
      console.error('Build failed: '.red, err)
      process.exit(1)
    })
  const {stdout, stderr} = await exec('npm pack', {cwd: path.join(config.libPath, 'dist')})
  console.info('done npm pack'.green)
  return {stdout, stderr}
}
261649
function buildPack(webpackConfig, cb, spinnerText) {
  var spinner = ora(spinnerText || 'building for uncompressed files...')
  spinner.start()
  webpack(webpackConfig, function (err, stats) {
    spinner.stop()
    if (err) {
      throw err
    }
    process.stdout.write(stats.toString({
      colors: true,
      modules: false,
      children: false,
      chunks: false,
      chunkModules: false
    }) + '\n')
    cb && cb()
  })
}
1070466
function compile(config) {
  let compiler;
  try {
    compiler = webpack(config);
  } catch (e) {
    printErrors('Failed to compile.', [e]);
    process.exit(1);
  }
  return compiler;
}
1252835
function wrapAll(callback) {
    // Prepare packages
    var packs = {};

    packages.forEach(function (pack, name) {
        packs[name] = pack;
    });

    return callback(packs);
}
698189
function build(previousFileSizes) {
    return new Promise((resolve, reject) => {
      webpack(webpackConfig).run((err, stats) => {
        if (err) {
          printErrors('Failed to compile.', [err]);
          reject();
          process.exit(1);
        }

        if (stats.compilation.errors.length) {
          printErrors('Failed to compile.', stats.compilation.errors);
          reject();
          process.exit(1);
        }

        if (process.env.CI && stats.compilation.warnings.length) {
          printErrors('Failed to compile. When process.env.CI = true, warnings are treated as failures. Most CI servers set this automatically.', stats.compilation.warnings);
          reject();
          process.exit(1);
        }

        console.log(chalk.green('Compiled successfully.'));
        console.log();

        console.log('File sizes after gzip:');
        console.log();
        printFileSizesAfterBuild(stats, previousFileSizes);
        console.log();

        const publicUrl = paths.publicUrl;
        const publicPath = webpackConfig.output.publicPath;

        if (publicUrl && publicUrl.indexOf('.github.io/') !== -1) {
          console.log(`The ${chalk.cyan('build')} folder is ready to be deployed.`);
          console.log(`To publish it at ${chalk.green(publicUrl)}, run:`);
          console.log();
          console.log(`  ${chalk.cyan(useYarn ? 'yarn' : 'npm')} run deploy`);
          console.log();
        } else if (publicPath !== '/') {
          const buildPath = path.relative(process.cwd(), paths.dist);
          console.log(`The ${chalk.cyan(buildPath)} folder is ready to be deployed.`);
          console.log();
        } else {
          if (publicUrl) {
            console.log(`The project was built assuming it is hosted at ${chalk.green(publicUrl)}.`);
            console.log(`You can control this with the ${chalk.green('homepage')} field in your ${chalk.cyan('package.json')}.`);
            console.log();
          } else {
            console.log('The project was built assuming it is hosted at the server root.');
            console.log(`To override this, specify the ${chalk.green('homepage')} in your ${chalk.cyan('package.json')}.`);
            console.log('For example, add this to build it for GitHub Pages:');
            console.log();
            console.log(`  ${chalk.green('"homepage"')}${chalk.cyan(': ')}${chalk.green('"http://myname.github.io/myapp"')}${chalk.cyan(',')}`);
            console.log();
          }
          const buildPath = path.relative(process.cwd(), paths.dist);
          console.log(`The ${chalk.cyan(buildPath)} folder is ready to be deployed.`);
          console.log('You may serve it with a static server:');
          console.log();
          if (useYarn) {
            console.log(`  ${chalk.cyan('yarn')} global add serve`);
          } else {
            console.log(`  ${chalk.cyan('npm')} install -g serve`);
          }
          console.log(`  ${chalk.cyan('serve')} -s build`);
          console.log();
        }
        resolve();
      });
    });
  }
583629
function compile(config, cb) {
  let compiler;
  try {
    compiler = webpack(config);
  } catch (e) {
    printErrors('Failed to compile.', [e]);
    process.exit(1);
  }
  compiler.run((err, stats) => {
    cb(err, stats);
  });
}
941066
def compile(self, source, dest, is_two_file=True, post=None, lang=None):
        """"""
        makedirs(os.path.dirname(dest))
        with io.open(dest, "w+", encoding="utf8") as out_file:
            with io.open(source, "r", encoding="utf8") as in_file:
                data = in_file.read()
            data, shortcode_deps = self.compile_string(data, source, is_two_file, post, lang)
            out_file.write(data)
        if post is None:
            if shortcode_deps:
                self.logger.error(
                    "Cannot save dependencies for post {0} (post unknown)",
                    source)
        else:
            post._depfile[dest] += shortcode_deps
        return True
751527
def error_wrap(func):
    """"""
    def f(*args, **kw):
        code = func(*args, **kw)
        check_error(code, context="client")
    return f
900005
function webpack_error_handler (err, stats, callback) {

  if(err) throw new gutil.PluginError('webpack', err);
  if(PRODUCTION){
    gutil.log('[webpack]', stats.toString({
        // output options
        source: false
    }));
  } else {
    var jsonStats = stats.toJson({
      errorDetails: false
    });
    if(jsonStats.errors.length > 0){
        gutil.log(gutil.colors.red('ERROR\n' + jsonStats.errors.join('\n')));
    }
    if(jsonStats.warnings.length > 0){
        gutil.log(gutil.colors.yellow('WARNING\n' + jsonStats.warnings.join('\n')));
    }
  }

  callback();
}