Conversation
- Swap chalk v4 for picocolors (14x smaller, zero dependencies) - Fix ReferenceError: colors is not defined (lines 115-118) The nopanic error handler referenced `colors` instead of the imported `chalk` variable, causing a crash on fatal errors - Fix TypeError: logger.warning is not a function (line 233) The websocket proxy warning used `logger.warning()` which does not exist on the logger object; changed to `logger.info()` Addresses http-party#949 Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
picocolors seems cool - 2x faster than chalk is great, 14x smaller is even better - but what issues are we going to introduce with the smaller alternative? Is chalk 14x the size for a reason? I noticed there's an included library that reports color support for known terminals - I reckon we might need that. Btw we might repeat the same mistake that caused #949; please use the name |
|
Good question. picocolors does handle color support detection -- it checks NO_COLOR, FORCE_COLOR, and whether stdout is a TTY. The difference is chalk bundles a larger lookup table that maps specific terminal app names (iTerm, ConEmu, etc.) to 256-color and truecolor support levels. But http-server only uses basic colors -- red, green, cyan, bold -- never 256-color or truecolor. So the simpler detection in picocolors covers everything we actually need here. No functionality lost for this use case. |
Summary
chalk(v4, 5 transitive deps) withpicocolors(v1, zero deps)ReferenceError: colors is not definedin the--no-panicerror handlerTypeError: logger.warning is not a functionin the WebSocket proxy checkChanges
bin/http-server
require('chalk')→require('picocolors')colorsvariable references (lines 115-118) that caused crashesin the
--no-panicerror handler —colorswas never imported, should havebeen
chalk(nowpc)logger.warning()call — the logger object has no.warning()method;changed to
logger.info()which is the available output methodpackage.json
chalk^4.1.2picocolors^1.1.1All color methods used (
red,cyan,yellow,green,magenta,bold)have exact equivalents in picocolors. Both libraries respect
NO_COLORandFORCE_COLORenvironment variables.Testing
Addresses #949