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 with Colorette #408

Merged
merged 1 commit into from May 24, 2021
Merged

Replace Chalk with Colorette #408

merged 1 commit into from May 24, 2021

Conversation

kytta
Copy link
Contributor

@kytta kytta commented May 24, 2021

One of the dependencies that listr2 uses is Chalk. While being an excellent tool, it's unnecessarily bulky. Upon installation, Chalk adds another 5 dependencies, taking 200 KB of space — and all that for some ANSI tags.

This pull request replaces Chalk with Colorette. Colorette is:

  • Small: it has no dependencies and takes 5 times less space, than Chalk:
    Picture showing size difference between Chalk and Colorette installations: 200K vs. 36K
  • Fast: it's 50% faster than Chalk:
    Picture showing speed difference between Chalk and Colorette: 410K vs. 627K ops/sec
  • Simple: Colorette's API is very similar to those of Chalk
  • Widely used: Autoprefixer, PostCSS and Webpack use Colorette instead of Chalk

Moving to Colorette reduces listr2's dependency footprint and increases performance.


Caveat: since the colour "orange" is not a standard terminal colour, calls to it have been replaced with "yellow".

@kytta
Copy link
Contributor Author

kytta commented May 24, 2021

For some reason, lint fails on Node 15 (and, for that matter, 16). This appears to be some internal error of either ESLint or Typescript (or the plugin, connecting both)

Details
$ eslint --ext .ts,.js,.tsx,.jsx src/

Oops! Something went wrong! :(

ESLint: 7.26.0

TypeError: Cannot read property 'type' of null
Occurred while linting /home/runner/work/listr2/listr2/src/interfaces/task.interface.ts:2
    at isExportNameClass (/home/runner/work/listr2/listr2/node_modules/eslint-plugin-import/lib/rules/newline-after-import.js:51:69)
    at checkForNewLine (/home/runner/work/listr2/listr2/node_modules/eslint-plugin-import/lib/rules/newline-after-import.js:79:45)
    at checkImport (/home/runner/work/listr2/listr2/node_modules/eslint-plugin-import/lib/rules/newline-after-import.js:133:9)
    at /home/runner/work/listr2/listr2/node_modules/eslint/lib/linter/safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (/home/runner/work/listr2/listr2/node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (/home/runner/work/listr2/listr2/node_modules/eslint/lib/linter/node-event-generator.js:256:26)
    at NodeEventGenerator.applySelectors (/home/runner/work/listr2/listr2/node_modules/eslint/lib/linter/node-event-generator.js:285:22)
    at NodeEventGenerator.enterNode (/home/runner/work/listr2/listr2/node_modules/eslint/lib/linter/node-event-generator.js:299:14)
    at CodePathAnalyzer.enterNode (/home/runner/work/listr2/listr2/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:711:23)
error Command failed with exit code 2.
info Visit yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 2.

@cenk1cenk2
Copy link
Collaborator

Thank you @NickKaramoff . This is a great improvement. Yeah it currently has some problems with linting and such, I am really busy with other projects therefore did not had the chance to improve up on this library. But will merge it anyway.

@cenk1cenk2 cenk1cenk2 merged commit d6c9329 into listr2:master May 24, 2021
@cenk1cenk2
Copy link
Collaborator

🎉 This PR is included in version 3.8.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@cenk1cenk2
Copy link
Collaborator

I would also like to reduce dependencies, especially rxjs for a event emitter approach but have not yet made it work. Hopefully in the upcoming months I will release it with v4.

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

Successfully merging this pull request may close these issues.

None yet

2 participants