Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let outputPaths: undefined | Map;
const finalize = (success: boolean, error?: string) => ({
// ...event,
success,
error,
baseOutputPath,
outputPath: baseOutputPath,
outputPaths: outputPaths && Array.from(outputPaths.values()) || [baseOutputPath],
} as BrowserBuilderOutput);
if (!success && useBundleDownleveling) {
// If using bundle downleveling then there is only one build
// If it fails show any diagnostic messages and bail
if (webpackStats && webpackStats.warnings.length > 0) {
context.logger.warn(statsWarningsToString(webpackStats, { colors: true }));
}
if (webpackStats && webpackStats.errors.length > 0) {
context.logger.error(statsErrorsToString(webpackStats, { colors: true }));
}
return finalize(success);
} else if (success) {
outputPaths = ensureOutputPaths(baseOutputPath, i18n);
let noModuleFiles: EmittedFiles[] | undefined;
let moduleFiles: EmittedFiles[] | undefined;
let files: EmittedFiles[] | undefined;
const scriptsEntryPointName = normalizeExtraEntryPoints(
options.scripts || [],
'scripts',
(stats, config, logger) => {
// config.stats contains our own stats settings, added during buildWebpackConfig().
const json = stats.toJson(config.stats);
if (verbose) {
logger.info(stats.toString(config.stats));
} else {
logger.info(statsToString(json, config.stats));
}
if (stats.hasWarnings()) {
logger.warn(statsWarningsToString(json, config.stats));
}
if (stats.hasErrors()) {
logger.error(statsErrorsToString(json, config.stats));
}
};
const jsonString = stats.toString(statsConfig)
.split('\n')
.map(line => ' ' + line)
.join('\n');
this.context.logger.info(statsTitle + jsonString);
} else {
const json = stats.toJson(statsConfig);
const jsonString = statsToString(json, statsConfig)
.split('\n')
.map(line => ' ' + line)
.join('\n');
this.context.logger.info(statsTitle + jsonString);
if (stats.hasWarnings()) {
this.context.logger.warn(statsWarningsToString(json, statsConfig));
}
if (stats.hasErrors()) {
this.context.logger.error(statsErrorsToString(json, statsConfig));
}
}
}
}
let statsTitle = '';
if (configName) {
statsTitle = 'Name: '
+ (options.colors ? terminal.bold(configName) : configName)
+ (options.verbose ? '\n' : '');
}
const statsString = options.verbose
? stats.toString(statsToOptions)
: statsToString(getStatsJson(), statsToOptions);
logger.info(statsTitle + statsString);
if (!options.verbose) {
if (stats.hasWarnings()) {
logger.warn(statsWarningsToString(getStatsJson(), statsToOptions));
}
if (stats.hasErrors()) {
logger.error(statsErrorsToString(getStatsJson(), statsToOptions));
}
}
logger.info('');
};
let statsTitle = '';
if (configName) {
statsTitle = 'Name: '
+ (options.colors ? terminal.bold(configName) : configName)
+ (options.verbose ? '\n' : '');
}
const statsString = options.verbose
? stats.toString(statsToOptions)
: statsToString(getStatsJson(), statsToOptions);
logger.info(statsTitle + statsString);
if (!options.verbose) {
if (stats.hasWarnings()) {
logger.warn(statsWarningsToString(getStatsJson(), statsToOptions));
}
if (stats.hasErrors()) {
logger.error(statsErrorsToString(getStatsJson(), statsToOptions));
}
}
logger.info('');
};