Skip to content
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

Move to ESM #102

Merged
merged 3 commits into from
Feb 5, 2025
Merged

Move to ESM #102

merged 3 commits into from
Feb 5, 2025

Conversation

LitoMore
Copy link
Collaborator

@LitoMore LitoMore commented Sep 11, 2022

Closes #57
Closes #103
Closes #104

@michaelfaith
Copy link

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

@LitoMore LitoMore marked this pull request as draft June 4, 2023 22:55
@LitoMore
Copy link
Collaborator Author

LitoMore commented Jun 4, 2023

I will add TypeScript declarations as well.

@LitoMore LitoMore marked this pull request as ready for review June 5, 2023 00:50
@LitoMore
Copy link
Collaborator Author

LitoMore commented Jun 5, 2023

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

@LitoMore LitoMore marked this pull request as draft June 5, 2023 12:19
@LitoMore
Copy link
Collaborator Author

LitoMore commented Jun 5, 2023

@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
Copy link

michaelfaith commented Jun 5, 2023

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
Copy link
Collaborator Author

LitoMore commented Jun 5, 2023

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

@michaelfaith
Copy link

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

@michaelfaith
Copy link

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

@fantasy0v0
Copy link

fantasy0v0 commented Jan 16, 2024

could you release a separate package for the ESM version?

@LitoMore LitoMore marked this pull request as ready for review January 31, 2025 16:32
@LitoMore
Copy link
Collaborator Author

Hi @Qix-, do you want to have a look?

@Qix-
Copy link
Owner

Qix- commented Feb 3, 2025

Looks good on a cursory once-over. Let's see what CI says, and get this merged finally.

@Qix-
Copy link
Owner

Qix- commented Feb 3, 2025

@LitoMore
Copy link
Collaborator Author

LitoMore commented Feb 3, 2025

@Qix- Removed the unused script.

@Qix-
Copy link
Owner

Qix- commented Feb 4, 2025

Looks like CI is failing still, surrounding the types. I can try to look at this sometime later today or tomorrow if you don't have time, but as soon as this is green I'll check it out and do a release.

@LitoMore
Copy link
Collaborator Author

LitoMore commented Feb 4, 2025

Ah, my bad. I should run the test before committing new changes.

I can handle this failing test. Which solution do you prefer?

+/* eslint-disable import/no-duplicates */
import convert from './index.js';
import type {Channels, RGB, HSL, HSV, CMYK, LAB, LCH, HCG, HWB, XYZ, Apple, Gray, ANSI16, ANSI256, Keyword, HEX} from './index.js';
+/* eslint-enable */
-imoprt convert from './index.js';
-import type {Channels, RGB, HSL, HSV, CMYK, LAB, LCH, HCG, HWB, XYZ, Apple, Gray, ANSI16, ANSI256, Keyword, HEX} from './index.js';
+import convert, {type Channels, type RGB, type HSL, type HSV, type CMYK, type LAB, type LCH, type HCG, type HWB, type XYZ, type Apple, type Gray, type ANSI16, type ANSI256, type Keyword, type HEX} from './index.js';
-imoprt convert from './index.js';
-import type {Channels, RGB, HSL, HSV, CMYK, LAB, LCH, HCG, HWB, XYZ, Apple, Gray, ANSI16, ANSI256, Keyword, HEX} from './index.js';
+// eslint-disable-next-line @typescript-eslint/consistent-type-imports
+import convert, {Channels, RGB, HSL, HSV, CMYK, LAB, LCH, HCG, HWB, XYZ, Apple, Gray, ANSI16, ANSI256, Keyword, HEX} from './index.js';

@Qix-
Copy link
Owner

Qix- commented Feb 5, 2025

Probably the second. I can see a case in the future where the conversions are built beforehand and thus the types are generated. Whatever makes the linter happy now is fine in the meantime. :)

@LitoMore
Copy link
Collaborator Author

LitoMore commented Feb 5, 2025

@Qix- Updated with the second option.

@Qix- Qix- merged commit 282a3f9 into Qix-:master Feb 5, 2025
3 checks passed
@LitoMore LitoMore deleted the esm branch February 5, 2025 18:57
@Qix-
Copy link
Owner

Qix- commented Feb 5, 2025

Thanks, released as 3.0.0 :)

@michaelfaith
Copy link

Stoked to finally see this land. Thanks @LitoMore and @Qix-!

@LitoMore
Copy link
Collaborator Author

LitoMore commented Feb 5, 2025

I've drafted a PR for tree-shaking support:

@Qix-
Copy link
Owner

Qix- commented Feb 6, 2025

Sorry for dragging my heels for so long on this. Been a strange string of years. Appreciate the patience :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update module color-name version Convert to import/export definitions
5 participants