Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions packages/web/scripts/apply-bundlesize-patch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env node

/**
* Applies a patch to bundlesize to fix compatibility with chalk v4+
* This script fixes the issue where chalk.default is required instead of chalk directly
*/

const fs = require('fs');
const path = require('path');

const colorsPath = path.join(__dirname, '../node_modules/bundlesize/src/utils/colors.js');

if (fs.existsSync(colorsPath)) {
let content = fs.readFileSync(colorsPath, 'utf8');

// Check if patch is already applied
if (!content.includes('chalkInstance')) {
content = `const chalk = require('chalk')
const chalkInstance = chalk.default || chalk

module.exports = {
subtle: chalkInstance.gray,
pass: chalkInstance.green,
fail: chalkInstance.red,
title: chalkInstance.bold,
info: chalkInstance.magenta
}
`;
fs.writeFileSync(colorsPath, content, 'utf8');
console.log('✓ Applied bundlesize patch for chalk v4+ compatibility');
}
} else {
console.warn('⚠ bundlesize colors.js not found, skipping patch');
}