Skip to content

Commit d8c4700

Browse files
authored
refactor(codemod): replace chalk with picocolors (vercel#53115)
The PR replaces `chalk` inside `@next/codemod` with `picocolors`. Generally, `@next/codemod` is used through `npx`/`pnpx` as it serves as a sort of "one-time fix". By replacing `chalk` with the `picocolors` (which is 14 times smaller and 2 times faster), we can speed up the installation process of `npx @next/codemod`. Currently, `@next/codemod` has about 10k downloads per week, so I guess this PR is worth it: <img width="441" alt="image" src="https://github.com/vercel/next.js/assets/40715044/a32fd6e0-bbe6-48e8-985d-83393c141b23"> In my next PR, I will replace `chalk` inside `create-next-app` with `picocolors` as well.
1 parent 909dad5 commit d8c4700

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

packages/next-codemod/bin/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import inquirer from 'inquirer'
1313
import meow from 'meow'
1414
import path from 'path'
1515
import execa from 'execa'
16-
import chalk from 'chalk'
16+
import { yellow } from 'picocolors'
1717
import isGitClean from 'is-git-clean'
1818
import { uninstallPackage } from '../lib/uninstall-package'
1919

@@ -38,7 +38,7 @@ export function checkGitStatus(force) {
3838
} else {
3939
console.log('Thank you for using @next/codemod!')
4040
console.log(
41-
chalk.yellow(
41+
yellow(
4242
'\nBut before we continue, please stash or commit your git changes.'
4343
)
4444
)

packages/next-codemod/lib/install.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable import/no-extraneous-dependencies */
2-
import chalk from 'chalk'
2+
import { yellow } from 'picocolors'
33
import spawn from 'cross-spawn'
44

55
interface InstallArgs {
@@ -70,9 +70,9 @@ export function install(
7070
*/
7171
args = ['install']
7272
if (!isOnline) {
73-
console.log(chalk.yellow('You appear to be offline.'))
73+
console.log(yellow('You appear to be offline.'))
7474
if (useYarn) {
75-
console.log(chalk.yellow('Falling back to the local Yarn cache.'))
75+
console.log(yellow('Falling back to the local Yarn cache.'))
7676
console.log()
7777
args.push('--offline')
7878
} else {

packages/next-codemod/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
"directory": "packages/next-codemod"
99
},
1010
"dependencies": {
11-
"chalk": "4.1.0",
1211
"cheerio": "1.0.0-rc.9",
1312
"execa": "4.0.3",
1413
"globby": "11.0.1",
1514
"inquirer": "7.3.3",
1615
"is-git-clean": "1.1.0",
1716
"jscodeshift": "0.13.1",
18-
"meow": "7.0.1"
17+
"meow": "7.0.1",
18+
"picocolors": "1.0.0"
1919
},
2020
"files": [
2121
"transforms/*.js",

pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)