-
Notifications
You must be signed in to change notification settings - Fork 51
feat: switch to ESM-only #93
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
base: main
Are you sure you want to change the base?
Conversation
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';
```
|
@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 |
|
this could export with |
|
@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 |
|
I think package can safely drop CommonJS at this point as all active NodeJS versions support ESM out of the box now. |
|
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: |
|
@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. |
Is there any specific issue that ESM only module going to address? |
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 |
|
Yes, it can't be used in non-Node.js runtimes that don't support syntax such as At Astro we need to support multiple runtimes, and we require ESM |
Switches to ES modules.
Usages: