Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Chalk by Picocolors #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Kocal
Copy link

@Kocal Kocal commented Sep 9, 2024

πŸ”— Linked issue

No existing issue.

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This PR the dependency Chalk by Picolors, a more lightweight dependency, with less sub-dependencies, and also faster (thus this is not really significant here).

I don't believe we need ~88Kb and 6 sub-dependencies to display colors in terminal, picocolors is totally enough for our usages.

Less dependencies means less possible vulnerability security issues, we already saw a lot of "not so known" but over-used dependencies being discrelty modified to introduce malicious code. It also means a reduction of consumed bandwidth.

See https://npmgraph.js.org/?q=@nuxt/friendly-errors-webpack-plugin#select=exact%3Achalk%402.4.2 and the report below:

Package size report
===================

Package info for "@nuxt/[email protected]": 19 MB
  Released: 2023-11-23 14:43:35.95 +0000 UTC (41w3d ago)
  Downloads last week: 156,930 (45.05%)
  Estimated traffic last week: 2.9 TB
  Subdependencies: 91

Removed dependencies:
  - [email protected]: 88 kB (0.47%)
    Downloads last week: 52,915,586 (N/A% from 2.4.2)
    Downloads last week from "@nuxt/[email protected]": 156,930 (N/A%)
    Traffic last week: N/A
    Traffic from "@nuxt/[email protected]": 2.9 TB (N/A%)
    Subdependencies: 6 (6.59%)

Added dependencies:
  + [email protected]: 12 kB (0.06%)
    Downloads last week: 10,649,179 (N/A% from 1.1.0)
    Estimated traffic last week: N/A
    Subdependencies: 0 (0%)

Estimated new statistics:
  Package size: 19 MB β†’ 370 kB (1.98%)
  Subdependencies: 91 β†’ 9 (-82)
  Traffic with last week's downloads:
    For current version: 2.9 TB β†’ 58 GB (2.9 TB saved)
    For all versions: 6.5 TB β†’ 129 GB (6.4 TB saved)

Note, here we're using Chalk 2.4.2, which is 5 years old. It is not possible to use the latest version 5 (which has no sub-dependencies, and weighs less than 2.4.2) because it is ESM-compatible only.
Chalk therefore recommends using CJS-compatible version 4, but it still weighs ~90KB and still has 5 sub-dependencies :(

Thanks!

@stof
Copy link

stof commented Sep 9, 2024

Adding to that, webpack itself uses picocolors so this dependency is likely to be deduplicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants