v4.0.0
Breaking
The minimum Node.js runtime increased from 6.x to 10.x since 10.x is the oldest active LTS version.
If you need to continue supporting Node 6.x, either continue using kleur@3.x
or ignore the "engines" constraint of kleur@4.x
– its CommonJS files will still execute in a Node 6.x environment.
Features
-
Added native ESM support with
exports
map (for Node 12.18.x, Node 14+) (#30): 2da16a9
Thank you @kristoferbaxter~! -
Added
module
package entry (for bundler and PikaCDN) (#31): 2da16a9 -
Added new
kleur/colors
entry module: 049c080
These changes allow for import
statements with kleur
.
It's done in a way such that Node.js environments that natively support import
will work. For those that don't and are using webpack/Rollup, the "module"
entry is made available so that you can still take advantage of the ESM format.
We took this idea one step further with kleur/colors
– which individually exports each color, modifier, and background function. This allows you to import only the methods you need, and the unused pieces of code are detached from your code. In other words, kleur/colors
is 100% treeshakeable, which is a big advantage of the ESM format. Node.js (with native ESM support), Rollup, and webpack benefit from this, which means that your programs only include/load the kleur
code you use.
If you're not ready to use ESM yet, require
statements still work for both modules in all environments.
See the Individual Colors documentation for more info
import kleur from 'kleur';
import * as colors from 'kleur/colors';
console.log(
kleur.underline().green('kleur natively supports ESM~!')
);
console.log(
colors.white(colors.italic(`... so does "${ colors.green('kleur/colors') }"~!`))
);