LoaderB0T / awesome-logging

Advanced logging messages, interactive prompts, loading animations and more in TypeScript
13 stars 0 forks source link

Not actually CJS compatible #145

Open JonFranchi opened 10 months ago

JonFranchi commented 10 months ago

Hello, I was trying to make use of the CJS build of this but it looks to be unusable. Multiple required dependencies using ESM, namely chalk v5+, which states on their github to be ESM only from 5 onward, but still CJS friendly from 4. I tried to fix that with resolutions, but then slice-ansi had the same problem so I gave up.

LoaderB0T commented 10 months ago

Hi, it seems you are right. The export itself is CJS but the dependencies aren't... Not sure what the best solution is here ... You could try to update your project to esm as well, CJS dependencies continue to work then. Kinda the same philosophy the chalk guys have. Also IIRC there should be a way to consume ESM Modules in CJS projects with certain tsconfig options, no?

The only other solution I could think of is to publish the CJS bundle with all dependencies bundled into it... Which could work, but would be really annoying for the consumer. Also might not work with all licenses.

Open for ideas 💡 Best regards Janik

prisis commented 5 months ago

Just found this repo :)

Would you consider to switch from chalk to https://www.npmjs.com/package/@visulima/colorize/v/latest? Colorize supports cjs and esm exports out of the box and more.

To validate that your cjs and esm support is correct and dont breake, you could copy the intigration test from https://github.com/visulima/visulima/blob/main/packages/colorize/__tests__/intigration/package.test.ts