-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
perf(client): Replace chalk
with kleur/color
#18900
Conversation
Signgicantly reduces bundle size (from 280K to 255K) and improves `require(runtime)` performance by 5-10ms.
CodSpeed Performance ReportMerging #18900 Summary
|
packages/client/src/runtime/utils/createErrorMessageWithContext.ts
Outdated
Show resolved
Hide resolved
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.
Halfway so far, I'll continue reviewing further. Thanks for doing this!
…t.ts Co-authored-by: Alexey Orlenko <alex@aqrln.net>
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 can't say that I read every line, but at least most 😅
Looks great 🙌🏼
|
||
export class DbCommand implements Command { | ||
public static new(cmds: Commands): DbCommand { | ||
return new DbCommand(cmds) | ||
} | ||
|
||
private static help = format(` | ||
${process.platform === 'win32' ? '' : chalk.bold('🏋️ ')}Manage your database schema and lifecycle during development. | ||
${process.platform === 'win32' ? '' : bold('🏋️ ')}Manage your database schema and lifecycle during development. |
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.
bold
with emoji probably doesn't have any visible effect
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.
although not sure, maybe it might depending on the font
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.
there's quite a lot of these bold emojis as far as I see, maybe there was some intention behind it
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.
my guess would be, they used to be some plain unicode symbol for which bold made sense and got changed to emoji later
import terminalLink from 'terminal-link' | ||
|
||
export function link(url): string { | ||
return terminalLink(url, url, { | ||
fallback: (url) => chalk.underline(url), | ||
fallback: (url) => underline(url), |
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.
nit:
fallback: (url) => underline(url), | |
fallback: underline, |
(feel free to ignore though)
Address some of the feedback added to #18900 after it got merged
Address some of the feedback added to #18900 after it got merged
Address some of the feedback added to #18900 after it got merged
Address some of the feedback added to #18900 after it got merged
Signgicantly reduces bundle size (kleur is <1KB in size, which reduces library runtime size from 280K to 255K) and
improves
require(runtime)
performance by 5-10ms:Few implementation notes:
kleur
is limited to 16 colors, in particular,*Bright
versions of the colors are not supported. I replaced them with non-bright versions, which still look ok in the several places I've checked, and IMHO, is a fair price to pay for size/startup performance improvements. If you disagree - let me know.migrate
andcli
technically did not need to migrate, but since we moving and sharing code between different packages from time to time, I've decided it would be better if we handle colors the same way everywhere and went for completechalk
removal.Close prisma/client-planning#341