Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(multiStats as { stats: webpack.Stats[] }).stats.forEach((stats, statsIndex) => {
const config = (multiConfig as webpack.Configuration[])[statsIndex];
// Collect server emitted files
if (config.target === 'node') {
result.serverEmittedFiles = getEmittedFiles(stats.compilation) as UdkBuilderEmittedFile[];
// Collect browser es6 emitted files
} else if (statsIndex === 0) {
result.browserES6EmittedFiles = getEmittedFiles(stats.compilation) as UdkBuilderEmittedFile[];
// Collect browser es5 emitted files
} else if (statsIndex === 1) {
result.browserES5EmittedFiles = getEmittedFiles(stats.compilation) as UdkBuilderEmittedFile[];
// If code below run, it's mean that devkit has changed and generates more browser configs
} else {
throw new Error('BREAKING CHANGE DETECTED! Universal config must have 2 or 3 childs');
}
});
) {
const [ browserStats, serverStats ] = multiStats.stats;
const success = !multiStats.hasErrors();
const browserSuccess = !browserStats.hasErrors();
const serverSuccess = !serverStats.hasErrors();
return {
success,
hash: multiStats.hash,
browserSuccess,
browserStats,
browserEmittedFiles: getEmittedFiles(browserStats.compilation),
serverSuccess,
serverStats,
serverEmittedFiles: getEmittedFiles(serverStats.compilation),
} as UniversalCompilationOutput;
}
export function createUniversalCompilationOutput(
multiStats: webpack.compilation.MultiStats & { hasErrors: () => boolean; },
) {
const [ browserStats, serverStats ] = multiStats.stats;
const success = !multiStats.hasErrors();
const browserSuccess = !browserStats.hasErrors();
const serverSuccess = !serverStats.hasErrors();
return {
success,
hash: multiStats.hash,
browserSuccess,
browserStats,
browserEmittedFiles: getEmittedFiles(browserStats.compilation),
serverSuccess,
serverStats,
serverEmittedFiles: getEmittedFiles(serverStats.compilation),
} as UniversalCompilationOutput;
}