Skip to content

ESM-only - #4542

Open
florian-lefebvre wants to merge 18 commits into
lovell:mainfrom
florian-lefebvre:feat/esm-only
Open

florian-lefebvre wants to merge 18 commits into
lovell:mainfrom
florian-lefebvre:feat/esm-only

Conversation

@florian-lefebvre

@florian-lefebvre florian-lefebvre commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Closes #4539

@florian-lefebvre

Copy link
Copy Markdown
Contributor Author

Tests pass locally for me. @lovell can you run the workflows?

@florian-lefebvre
florian-lefebvre marked this pull request as ready for review June 11, 2026 14:05
@florian-lefebvre

Copy link
Copy Markdown
Contributor Author

@lovell I think I fixed everything (coverage and node 20), should be good to go

@florian-lefebvre

Copy link
Copy Markdown
Contributor Author

I just tried running the failing tests locally on Windows 11 and can't replicate, so I think that they should pass now that lint is fixed, but no guarantee :/

@florian-lefebvre

Copy link
Copy Markdown
Contributor Author

I think the issue was around the font file so I tried another approach of having the font file directly in the repo. I tried it locally on windows 11 and it worked but again, no guarantee. If that doesn't work, I'm out of ideas

@florian-lefebvre

Copy link
Copy Markdown
Contributor Author

It worked 🎉

Comment thread lib/colour.js
@@ -4,7 +4,7 @@
*/

import color from '@img/colour';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@img/colour is essentially the CommonJS version of the color package:

This package converts the color package and its dependencies, all of which are MIT-licensed, to CommonJS.

Since sharp is now ESM-only, this seems like a good time to migrate to color directly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let Lovell decide but I think it makes sense

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context I also opened e18e/module-replacements#786 about it

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i prefer not to self-promote but it seems relevant here: i did also launch hueful recently. which is more modern and faster than color.

Lovell, if you'd be open to trying it out in sharp in a follow up to this, i'd be very happy to help out. it'd drop a few dependencies too

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@43081j It gets my vote purely on the correct spelling of colour. It is able to parse objects like the following?

{ r: 255, g: 102, b: 0, alpha: 0.5 }
{ c: 1, m: 239, y: 227, k: 5 }

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an aside, the @img/colour CJS wrapper is currently downloaded more than the upstream ESM-only color package 😅

@43081j 43081j Oct 9, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most of it operates on a [c0, c1, c2, alpha?] tuple.

we're missing the color() function but i plan on adding those too (which will bring in CMYK and some others).

i can make a draft PR to prove it out if you like and we can see how it goes that way

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@43081j Great, thank you. I prefer your space+tuple structure as it removes ambiguity e.g. the h property of HSL is not the same as the h property of OKLCH. It would be a breaking change, plus I guess ESM-only dependent.

@Norbiros

Copy link
Copy Markdown

We could also replace semver with verkit - e18e/ecosystem-issues#277

@gameroman

Copy link
Copy Markdown

Looks like conflicts need to be resolved

@florian-lefebvre

Copy link
Copy Markdown
Contributor Author

Yeah I resolve conflicts from time to time, I don't do it too often since there's no ETA

Resolved conflicts so the ESM-only layout survives main's changes.

- lib/index.mjs and scripts/build.mjs: deleted on the branch and modified on
  main. Kept the deletions and carried main's SPDX copyright header onto the
  renamed lib/index.js.
- .github/CONTRIBUTING.md: kept main's rewrite and dropped the build:dist
  instructions for the CJS build the branch removes.
- .github/workflows/ci.yml: kept main's Ubuntu 26.04 and action version bumps,
  kept npx patch-package, dropped the build:dist steps, and dropped build:dist
  from the new build-asan job. Kept the branch's Node.js version pins.
- test/unit/tile.js: combined main's yauzl-based extractor with the branch's
  ESM imports.

This branch has not been deployed

No deployments
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.

ESM-only

5 participants