Problem/Motivation

Chalk could be updated from 4.1.2 to 5.0.0

The main problem is that chalk is now a js module, and can only be used in the context of js modules (not the commonjs environement we're currently using in core). To keep using it we need to update all our scripts to use js modules.

Proposed resolution

Update chalk to latest releases and backport to 9.4.x

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3266274

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nod_ created an issue. See original summary.

lauriii’s picture

Priority: Normal » Major
Issue tags: +Drupal 10
Parent issue: » #3238507: Drupal 10 JavaScript dependency plan
nod_’s picture

Or removing the dependency altogether. there are 4 uses and it's not mission critial.

xjm’s picture

Title: Update chalk to latest major version (5.0.0) » Update chalk to latest major version (5.0.0) or remove it as a dependency

What is this postponed on?

nod_’s picture

To keep using it we need to update all our scripts to use js modules.

And there is no plan to do that anywhere. In theory it's not too hard, but in practice we're very likely to run into incompatibilities given how many deps we have.

xjm’s picture

Issue tags: +Drupal 10 beta blocker

Can we get an issue for #5 to make this actionable?

longwave’s picture

The note on the chalk project page does say

IMPORTANT: Chalk 5 is ESM. If you want to use Chalk with TypeScript or a build tool, you will probably want to use Chalk 4 for now.

and we are using it in our custom build tool.

As we only use chalk.red() we could perhaps switch to https://github.com/medikoo/cli-color

Spokje’s picture

I like pretty colors!
Do we want to add a dependency on a module/package/thingamajig just for 4 instances of a red color when things go wrong? Not too sure.

I think removal of chalk altogether without a replacement could also be an option.

xjm’s picture

The current plan (per discussion between @nod_, @lauriii, @bnjmnm, and myself) is to simply remove the dependency. I also like pretty colors, but not well enough to attempt to justify retaining the dependency. ;)

xjm’s picture

Title: Update chalk to latest major version (5.0.0) or remove it as a dependency » Remove chalk as a dependency
Status: Postponed » Active

Thus, actionable now.

Not even sure we actually need to replace it with anything.

Spokje’s picture

Status: Active » Needs review

Also did a yarn install, but since chalk is included in a few other packages as dependency, that didn't change anything.

nod_’s picture

Status: Needs review » Reviewed & tested by the community

Got the same result, all good for me.

It's not out of the yarn.lock file but it doesn't show up when running yarn outdated anymore.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

I guess that cli colouring is less important that outdated dependencies. FWIW I'm not sure that we have to remove chalk since chalk 4 is not unsupported and is actually recommended for our use-case. That said, we're planning to retire the build step so chalk becomes even less useful.

Also I think at some point we'll have to update to use es6 modules because more of our dependencies will make the same move. But as @nod_ has pointed out we have other priorities at the moment.

Committed and pushed 445ea0fe35 to 10.1.x and e4e25769a4 to 10.0.x. Thanks!

  • alexpott committed 445ea0f on 10.1.x
    Issue #3266274 by Spokje, nod_, xjm, lauriii: Remove chalk as a...

  • alexpott committed e4e2576 on 10.0.x
    Issue #3266274 by Spokje, nod_, xjm, lauriii: Remove chalk as a...

xjm’s picture

Issue tags: +10.0.0 release notes

Dependency removals always go in the release notes.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.