Skip to content

Conversation

@43081j
Copy link

@43081j 43081j commented Apr 16, 2025

Switches to ES modules.

Usages:

// If you're in a CJS project in Node 20 and above
const {default: picocolors} = require('picocolors');

// If you're in an ESM project in any version
import picocolors from 'picocolors';

// If you're in a CJS project before Node 20
const {default: picocolors} = await import('picocolors');

// In a browser, you can use ESM just the same
import picocolors from 'picocolors';

Switches to ES modules.

Usages:

```ts
// If you're in a CJS project in Node 20 and above
const {default: picocolors} = require('picocolors');

// If you're in an ESM project in any version
import picocolors from 'picocolors';

// If you're in a CJS project before Node 20
const {default: picocolors} = await import('picocolors');

// In a browser, you can use ESM just the same
import picocolors from 'picocolors';
```
@43081j 43081j mentioned this pull request Apr 16, 2025
@43081j
Copy link
Author

43081j commented Jun 1, 2025

@alexeyraspopov any thoughts on this?

And rgb support

Those are the last two things people have been asking for. Happy to chat through it here, discord or email. Whatever works, but would be nice to figure it out

@SuperchupuDev
Copy link

SuperchupuDev commented Jul 20, 2025

this could export with as 'module.exports' (plus the normal default export) so that cjs users don't have to do const {default: picocolors} = require('picocolors'); and instead can do const picocolors = require('picocolors'); like they've always done. the docs for it are at https://nodejs.org/api/modules.html#loading-ecmascript-modules-using-require (if you scroll a bit down)

@43081j
Copy link
Author

43081j commented Jul 22, 2025

@alexeyraspopov do you want any help maintaining this package?

i'd be more than happy to help out and help land things like this.

i think the only remaining wins sitting around are ESM (this), and RGB support

adoption of this package is stalled in various places because of the lack of these

i already maintain a lot of very popular packages so would be happy to take some of the load off you if you're interested

@shinebayar-g
Copy link

I think package can safely drop CommonJS at this point as all active NodeJS versions support ESM out of the box now.

@ematipico
Copy link

It's been months since this PR was up, and the owner hasn't replied. I believe it is safe to say we need to fork it in order to move the ecosystem forward.

And them, this package is downloaded A LOT: 94,848,835. Such a pity :(

@43081j
Copy link
Author

43081j commented Nov 19, 2025

@alexeyraspopov would you be interested in adding a maintainer to help you here if you're no longer active enough?

the problems the astro team are running into are entirely solved by this PR, we could land it any day. if only we can get a small amount of your time to merge and publish.

the browser module is not a browser module, it doesn't run in browsers. picocolors today is broken because of this.

as far as we can all see, this repo is no longer maintained. just let us know if that is the case. we can then fork and start moving everyone off picocolors. its fine if that is the case, but we should wait for you to tell us as its a huge effort to migrate.

@alexeyraspopov
Copy link
Owner

It's been months since this PR was up, and the owner hasn't replied. I believe it is safe to say we need to fork it in order to move the ecosystem forward.

Is there any specific issue that ESM only module going to address?

@43081j
Copy link
Author

43081j commented Nov 19, 2025

It's been months since this PR was up, and the owner hasn't replied. I believe it is safe to say we need to fork it in order to move the ecosystem forward.

Is there any specific issue that ESM only module going to address?

https://github.com/alexeyraspopov/picocolors/pull/93/files#diff-f2643a531dbece45f7790f658baaaf1f4726d0f611ba52047effd2cade0b3887R1

this

whether you switch to ESM or not, this change really needs to happen as it is a bug fix

as well as that, the browser bundle isn't a browser bundle. it is a CJS module which doesn't run in browsers. so that needs to go away or be replaced with an ES module

this PR does that by replacing the entire thing with an ES module. but you could also just ship both if you really want

@ematipico
Copy link

Yes, it can't be used in non-Node.js runtimes that don't support syntax such as module.exports .

At Astro we need to support multiple runtimes, and we require ESM

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.

5 participants