Migrating from pnpm to bun sped up build time by 70.59%!!
A short update on my blog
This blog used yarn -> pnpm -> bun.
After migrating to bun, I got a 70%+ speed increase after bun v1.3.
Note that we broke live reloads on my markdown, so i had to manually refresh the page using API calls:
import type { NextApiRequest, NextApiResponse } from 'next';
// Store connected clients
const clients: NextApiResponse[] = [];
export default function handler(req: NextApiRequest, res: NextApiResponse) {
// Set CORS headers for development
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET,OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type');
if (req.method === 'OPTIONS') {
return res.status(200).end();
}
// Handle SSE client connections
if (req.query.subscribe === 'true') {
res.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache, no-transform',
'Connection': 'keep-alive',
});
res.write('event: connected\n');
res.write('data: true\n\n');
clients.push(res);
req.on('close', () => {
clients.splice(clients.indexOf(res), 1);
});
return; // Important: don't send any more headers or end the response
}
// Handle incoming refresh signals from watch-md.js
if (req.method === 'GET') {
clients.forEach(client => {
client.write('event: refresh\n');
client.write('data: true\n\n');
});
return res.status(200).json({ message: 'Refresh signal broadcasted' });
}
res.status(404).end();
}