highlight.js
highlight.js copied to clipboard
refactor(tools): replace @colors/colors with smaller and faster ansis
This PR replaces @colors/colors used in CLI tools with smaller and faster ansis.
Benefits of ansis
- The unpacked size is smaller:
@colors/colors- 41.5 kB,ansis- 7 kB, see Compare the size of packages - 10x faster than
@colors/colors, see Benchmarks - Supports Truecolor with fallback: TrueColor → 256 colors → 16 colors → no colors
- Doesn't extend
String.prototype - Zero dependencies
- Test coverage 100%
Packages that already use ansis
facebook/stylex, nestjs/nest, sequelize/core, oclif/core, salesforcecli/cli and thousands others
Changes
The changes in CLI tools:
- replace
@colors/colorswithansis - add color preview for selectors used in CSS
- fix ESLint errors in tools code
Checklist
- [ ] Added markup tests, or they don't apply here because...
- [ ] Updated the changelog at
CHANGES.md
Test
This PR does not require unit/integration tests, but you can do the manual test.
Clone and install the forked repository:
git clone https://github.com/webdiscus/ansis-highlight.js.git
cd ansis-highlight.js
git checkout switch-to-ansis
npm i
npm run build
1) Run CheckTheme tools in CLI
For example, we want to check the vs2015 style:
node ./tools/checkTheme.js ./src/styles/vs2015.css
In console output will be displayed color text and NEW added preview of colors used in CSS selectors:
2) Run CheckAutoDetect tools in CLI
node ./tools/checkAutoDetect.js
In console output will be displayed color text: