From de58854cd013fdfab98e0dccaee4ed3da1296cd2 Mon Sep 17 00:00:00 2001 From: Dylan Jeffers Date: Fri, 6 Feb 2026 13:13:46 -0800 Subject: [PATCH] Add bundlesize patch --- .../web/scripts/apply-bundlesize-patch.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 packages/web/scripts/apply-bundlesize-patch.js diff --git a/packages/web/scripts/apply-bundlesize-patch.js b/packages/web/scripts/apply-bundlesize-patch.js new file mode 100644 index 00000000000..1be4b799e04 --- /dev/null +++ b/packages/web/scripts/apply-bundlesize-patch.js @@ -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'); +}