Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function onWebpackMessage({ data: message }) {
if (message.webpackDashboardData) {
const modernMode = getSharedData('modern-mode').value;
const type = message.webpackDashboardData.type;
for (const data of message.webpackDashboardData.value) {
const id = `${type}-${data.type}`;
if (data.type === 'stats') {
// Stats are read from a file
const statsFile = path.resolve(api.getCwd(), `./node_modules/.stats-${type}.json`);
const value = await fs.readJson(statsFile);
const { stats, analyzer } = processStats(value);
setSharedData(id, stats);
setSharedData(`${id}-analyzer`, analyzer);
await fs.remove(statsFile);
} else if (data.type === 'progress') {
if (type === 'serve' || !modernMode) {
setSharedData(id, {
[type]: data.value,
});
} else {
// Display two progress bars
const progress = getSharedData(id).value;
progress[type] = data.value;
for (const t of ['ssr-build', 'ssr-build-modern']) {
setSharedData(`${t}-${data.type}`, {
'ssr-build': progress['ssr-build'] || 0,
'ssr-build-modern': progress['ssr-build-modern'] || 0,