-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
CLI: Migrate from chalk
to picocolors
#28262
Conversation
This migrates away from chalk to picocolors instead, primarily because the latter is _much_ lighter. Keep in mind, `node-logger` still uses chalk as we use `hex(code)` which doesn't have an alternative in picocolors. This means it will still be in the dependency tree for many packages (for now). This seems preferable over upgrading chalk since the latest version of chalk will still be heavier, and is ESM-only (not sure if we're able to adopt ESM only deps in SB yet).
I'm on the go right now and my current laptop feels like it'll melt when i try the test runs. So its possible i have pushed pre-emptively and tests are not happy, partially relying on CI. Will make it a draft if CI fails and i'll get back to it later this week Edit: looks like a type check failed. I'll roll that package back for now if I don't figure an alternative fix out |
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 3919b23. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
@43081j Thanks so much for doing this! Re: the breaking change, can we just switch e.g. |
I think so yeah. If we can switch each of the hex colours to fixed colours, that would be great Meanwhile, the build failure is because picocolours doesn't have bright colours yet. I'm going to try go upstream and help get that into picocolours before we land this |
chalk
to picocolors
minor update: we're just waiting for picocolors to ship a new version with bright colours enabled it has been merged but no release has been cut yet. ill try help them out over there and will update this once it gets released |
picocolors has bright variants now so i've tried to update and catch up from will see how CI goes and re-review the diff when I can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me, I can help out with the merge conflicts.
code/lib/cli/package.json
Outdated
@@ -317,7 +317,8 @@ | |||
"prep": "jiti ../../../scripts/prepare/bundle.ts" | |||
}, | |||
"dependencies": { | |||
"@storybook/core": "workspace:*" | |||
"@storybook/core": "workspace:*", | |||
"picocolors": "^1.1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this was added by mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remember to remove this too.
Strictly speaking we can't actually replace these storybook/code/core/src/node-logger/index.ts Lines 10 to 18 in fce9cbe
However, A GitHub-wide search shows zero usage of this API outside of Storybook or forks of it. This doesn't mean that no-one is using it privately, we can't know that of course. These are all old forks: We do use the exported I'd vote for completely removing the export now and update the usage across the monorepo and satellite packages. A middleground would be to replace them with Thoughts @shilman ? |
I would probably lean towards removing the export too. otherwise, whatever library we choose, we're tying our public API to it which isn't great I think we should avoid re-exporting/exposing dependencies in our public API if we can |
Agree with both of you @JReinhold @43081j -- sorry for the slow reply! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code looks good to me, but a few stray dependencies have snuck their way into various package.json
s
@@ -138,11 +137,13 @@ | |||
"knip": "^5.30.1", | |||
"lint-staged": "^15.2.7", | |||
"memoizerific": "^1.11.3", | |||
"minimatch": "^10.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see usage of this anywhere in the repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The knip config file references it... I ran lint on scripts and this came up.
code/lib/cli/package.json
Outdated
@@ -317,7 +317,8 @@ | |||
"prep": "jiti ../../../scripts/prepare/bundle.ts" | |||
}, | |||
"dependencies": { | |||
"@storybook/core": "workspace:*" | |||
"@storybook/core": "workspace:*", | |||
"picocolors": "^1.1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's remember to remove this too.
FYI this introduced a regression in @storybook/addon-styling-webpack - storybookjs/addon-styling-webpack#24 |
This migrates away from chalk to picocolors instead, primarily because the latter is much lighter.
Keep in mind,
node-logger
still uses chalk as we usehex(code)
which doesn't have an alternative in picocolors. This means it will still be in the dependency tree for many packages (for now).This seems preferable over upgrading chalk since the latest version of chalk will still be heavier, and is ESM-only (not sure if we're able to adopt ESM only deps in SB yet).
This is a pretty big PR thanks to the CLI in particular. If you'd prefer I split it up into individual PRs, or at least separate out the CLI change, let me know and i'll do some git-fu
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
Run the CLI and observe that the colours are still working as expected.
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal
,ci:merged
orci:daily
GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli/src/sandbox-templates.ts
Make sure this PR contains one of the labels below:
Available labels
bug
: Internal changes that fixes incorrect behavior.maintenance
: User-facing maintenance tasks.dependencies
: Upgrading (sometimes downgrading) dependencies.build
: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup
: Minor cleanup style change. Will not show up in release changelog.documentation
: Documentation only changes. Will not show up in release changelog.feature request
: Introducing a new feature.BREAKING CHANGE
: Changes that break compatibility in some way with current major version.other
: Changes that don't fit in the above categories.