Qix- / color-convert

Plain color conversion functions in JavaScript
MIT License
744 stars 96 forks source link

Move to ESM #102

Open LitoMore opened 2 years ago

LitoMore commented 2 years ago

Closes #57 Closes #103 Closes #104

michaelfaith commented 1 year ago

@Qix- any chance of a review? This would also support: https://github.com/Qix-/color/issues/256

LitoMore commented 1 year ago

I will add TypeScript declarations as well.

LitoMore commented 1 year ago

This needs more changes to support tree shaking. I will handle this later.

LitoMore commented 1 year ago

@Qix- Do you have some ideas for the tree shaking?

I have two ideas, the first one is:

import {rgb, keyword} from 'color-convert';

rgb.hsl(0, 0, 0);
rgb.hex(0, 0, 0);
keyword.rgb(0, 0, 0);

Another idea is to make all convert functions to single one:

import {rgbToHsl, rgbToHex, keywordToRgb} from 'color-convert';

rgbToHsl(0, 0, 0);
rgbToHex(0, 0, 0);
keywordToRgb(0, 0, 0);

What do you think?

michaelfaith commented 1 year ago

I feel like a refactor for tree-shakability might be appropriate to have as a separate PR? Converting to ESM with the API "as-is" (this pr), and then updating for tree-shaking, potentially modifying the api in a breaking way, as a separate change. Thoughts? (that's, of course, assuming that the next major release waits for both PRs to land)

LitoMore commented 1 year ago

Both are OK for me. That depends on @Qix-.

michaelfaith commented 1 year ago

Either way, appreciate all the work you've put in. Hopefully @Qix- gives it a look soon.

michaelfaith commented 1 year ago

@Qix- any chance on feedback here? This has been pending for almost a year

fantasy0v0 commented 8 months ago

could you release a separate package for the ESM version?