Skip to content
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

cliui remove kleur colors (ESM project) #113

Open
fraxken opened this issue Oct 23, 2021 · 2 comments
Open

cliui remove kleur colors (ESM project) #113

fraxken opened this issue Oct 23, 2021 · 2 comments
Labels

Comments

@fraxken
Copy link

fraxken commented Oct 23, 2021

Hello 👋

The package cliui remove "some" colors when working with ESM. Everything is fine with CJS. I found the problem on a CLI project I just migrated and I couldn't understand why my colors were not working anymore.

I'm working on Windows 10 and Node.js v16


How to reproduce:

$ mkdir cliui_bug
$ cd cliui_bug
$ npm init -y
$ npm i kleur cliui -P
# Add type: module in package.json 

The index.js file

import kleur from "kleur";
import cliui from "cliui";
// const kleur = require("kleur");
// const cliui = require("cliui");

const { white, cyan, red } = kleur;

const ui = cliui();

const title = `${white().bold("name:")} ${cyan().bold("express")}`;
console.log(title);
ui.div(
  { text: title, width: 50 }
);
ui.div({ text: red("-------------------------------------------------------------------"), width: 70 });

console.log(ui.toString());

Output with ESM:
image

The title with cliui doesn't work. If you switch the project to CJS it will work as expected.

Best Regards,
Thomas

@shadowspawn
Copy link
Member

A few of the key dependencies are not available for dual cjs and esm builds. The first esm build of cliui stayed "pure" and substituted in some simple routines rather than use the older cjs flavours. I think this is probably the cause of the difference you see.

There are some open issues and PR about the problem and possible solutions: #89 #138 #139 #140

@fraxken
Copy link
Author

fraxken commented May 21, 2023

@shadowspawn Yes, we forked to drop CJS and fix the few issues we had: cliui

We plan to maintain that fork short-term (but probably not long term).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants