Skip to content

Commit be27c13

Browse files
authored
Add bundlesize patch (#13665)
1 parent 6c68f85 commit be27c13

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Applies a patch to bundlesize to fix compatibility with chalk v4+
5+
* This script fixes the issue where chalk.default is required instead of chalk directly
6+
*/
7+
8+
const fs = require('fs');
9+
const path = require('path');
10+
11+
const colorsPath = path.join(__dirname, '../node_modules/bundlesize/src/utils/colors.js');
12+
13+
if (fs.existsSync(colorsPath)) {
14+
let content = fs.readFileSync(colorsPath, 'utf8');
15+
16+
// Check if patch is already applied
17+
if (!content.includes('chalkInstance')) {
18+
content = `const chalk = require('chalk')
19+
const chalkInstance = chalk.default || chalk
20+
21+
module.exports = {
22+
subtle: chalkInstance.gray,
23+
pass: chalkInstance.green,
24+
fail: chalkInstance.red,
25+
title: chalkInstance.bold,
26+
info: chalkInstance.magenta
27+
}
28+
`;
29+
fs.writeFileSync(colorsPath, content, 'utf8');
30+
console.log('✓ Applied bundlesize patch for chalk v4+ compatibility');
31+
}
32+
} else {
33+
console.warn('⚠ bundlesize colors.js not found, skipping patch');
34+
}

0 commit comments

Comments
 (0)