friendly-errors-webpack-plugin icon indicating copy to clipboard operation
friendly-errors-webpack-plugin copied to clipboard

Replace Chalk by Picocolors

Open Kocal opened this issue 1 year ago โ€ข 1 comments

๐Ÿ”— 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)
  • [x] ๐Ÿ‘Œ Enhancement (improving an existing functionality)
  • [ ] โœจ New feature (a non-breaking change that adds functionality)
  • [x] ๐Ÿงน 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!

Kocal avatar Sep 09 '24 06:09 Kocal

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

stof avatar Sep 09 '24 11:09 stof