镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

[Replacement]: @img/colour #786

Closed

Description

@Norbiros

Package to replace

@img/colour

Suggested replacement(s)

another package: color

Manifest type

preferred (lighter or more modern alternative package)

Rationale

@img/colour is just a port of the color package to CommonJS. It is just better to switch back to color and use ESM, which allows for better tree-shaking.

Source:

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

Availability

No response

Code example (optional)

Before:

const Color = require('@img/colour')

const red = Color('red').hex()

After:

import Color from 'color'

const red = Color('red').hex()

Activity

  1. 43081j commented on Jul 7, 2026

    @43081j
    Contributor

    hmm we should dig into this a bit...

    @img/colour was updated more recently, has fewer deps, and is smaller.

    i wonder if the right move here is to ask them to go ESM-only and rework their README to no longer be just a CJS port - but rather just be the more modern alternative.

  2. Norbiros commented on Jul 7, 2026

    @Norbiros
    Author

    @img/colour is solely used by sharp and sharp-related projects, meaning there is a bigger chance it might get abandoned.

    Image

    @img/colour is not its own library, it is built by generating cjs compatible code from color and its sub-dependencies like color-convert into a single file. It reduces portability, but at the same time reduces the final size (less readmes, less files), giving that 20kB size difference.

    "build:cjs": "esbuild node_modules/color/index.js --bundle --platform=node --outfile=color.cjs"

    color library has some problems like missing oklch support, but given that @img/colour is not a fork, it is just a library that rebuilds it for CommonJS, I think the migration to color is the right choice and we should continue improving that library.

  3. Norbiros commented on Jul 7, 2026

    @Norbiros
    Author

    There might be other alternatives like colorjs.io which is more modern (supports CSS Color 4), but it weights 13.2 MB instead of 91.5 kB, has different API and probably it's own caveats.

  4. 43081j commented on Jul 7, 2026

    @43081j
    Contributor

    you are right 👍

    ill wait for a 2nd opinion from core but i think color should be used here even though it is slightly bigger (because it isn't minified). it'll de-dupe better

  5. dreyfus92 commented on Jul 8, 2026

    @dreyfus92
    Member

    +1 for color here, agree with the direction, it is worth being clear about what @img/colour actually is, not a fork or an alternative, just an esbuild bundle of color regenerated for cjs. the size argument also cuts the other way in practice, the 20kb is mostly install size (readmes, unbundled files), and color / color-conver / color-string are already in half ecosystem's trees, so depending on color dedupes while @img/colour ships the same code again as an opaque build.

    one thing the migration notes should call out: color@5 is esm-only, and the whole audience for @img/colour is cjs consumers, without it the before/after swap can be a bit misleading.

    preferred type sounds right to me

  6. added
    acceptedUsed to signal if a suggested replacement has been accepted.
    on Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedUsed to signal if a suggested replacement has been accepted.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions