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 #1333

Merged
merged 1 commit into from
Sep 7, 2024
Merged

Conversation

Kocal
Copy link
Member

@Kocal Kocal commented Sep 7, 2024

Picocolors is one of the smaller library to output colors in the terminal, and it has no sub-dependencies. It can reduce the Encore package size a lot.

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

Package info for "[email protected]": 100 kB
  Released: 2021-07-30 12:02:52.839 +0000 UTC (162w1d ago)
  Downloads last week: 233,169,927 (56.55%)
  Estimated traffic last week: 23 TB
  Subdependencies: 5
  Latest version: 5.3.0 (62w2d ago)

Added dependencies:
  + [email protected]: 12 kB (11.81%)
    Downloads last week: 8,949,572 (N/A% from 1.1.0)
    Estimated traffic last week: N/A
    Subdependencies: 0 (0%)

Estimated new statistics:
  Package size: 100 kB → 76 kB (76.16%)
  Subdependencies: 5 → 6 (1)
  Traffic with last week's downloads:
    For current version: 23 TB → 18 TB (5.6 TB saved)
    For all versions: 41 TB → 31 TB (9.8 TB saved)

Migrating from chalk to picocolors is pretty simple, the API is nearly identical except whan you want to color both text and background.

When running encore --help:
image

When running encore dev:
image

@stof
Copy link
Member

stof commented Sep 7, 2024

This does not actually reduce dependencies, because chalk is still a transitive dependency of css-minimizer-webpack-plugin. So this PR doesn't actually change the size of downloaded dependencies (picocolors was already a transitive dependency, from css-minimizer-webpack-plugin > cssnano as well as other places)

@Kocal
Copy link
Member Author

Kocal commented Sep 7, 2024

In reality yes, but that's a first step, I believe someone (or me) will open this kind of PR on css-minimizer-webpack-plugin etc, and only at this time we will be able to reduce the package size.

@Kocal Kocal force-pushed the replace-chalk-by-picocolors branch from fd5cdd4 to 1c08412 Compare September 7, 2024 16:10
@Kocal Kocal merged commit ae05af4 into symfony:main Sep 7, 2024
28 checks passed
@Kocal Kocal deleted the replace-chalk-by-picocolors branch September 7, 2024 16:17
@stof
Copy link
Member

stof commented Sep 7, 2024

Looking at the npm graph, the only non-dev transitive dependencies we have are those:

  • @nuxt/friendly-errors-webpack-plugin requires chalk 2.x
  • jest-util and @jest/types require chalk 4.x. These are required by jest-worker which is required by css-minimizer-webpack-plugin

@Kocal
Copy link
Member Author

Kocal commented Sep 9, 2024

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