File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments