unjs/consola

Issue with prompt (clack) cancellation detect

samuelstroschein opened this issue · 6 comments

Environment

/

Reproduction

Describe the bug

Consola bundles the NPM package, leading to downstream bugs.

Proposal

Stop bundling consola.

If bundling is important, the consumer of consola can use a bundler. A consumer using a bundler means the complexity of consola is reduced, bugs that bundling consola introduces are removed, and consola becomes more useful.

Additional context

No response

Logs

No response

pi0 commented

Hi dear @samuelstroschein. Thanks for your suggestion. Consola, because of many ecosystem reasons, is zero dependency so it bundles all deps. But it shouldn't be an issue since we can release with new versions fixed deps and there is an automated CI that regularly updates dependencies.

Regarding Clack, as also mentioned in initial integration PR notes, we only inline/fork clack source code because it lacked ability to configure formatting options and inlining code in repo means sadly we miss important upstream fixes unless manually rebasing. Once this is possible, i would be more than happy to also use upstream clack.

Hi @pi0,

Thanks for the response. The bundling/inlining seems to cause bugs, though; see #234 and bombshell-dev/clack#83 (comment) specifically.

I don't have enough background to evaluate whether bundling is worth the ecosystem impact.

pi0 commented

Thanks for clarification by linking issue. I have shared a suggestion for them there.

We can easily solve it earlier for consola btw as consola API is dedicated to itself .

pi0 commented

nice workaround!

Thanks for the workaround @samuelstroschein
I moved the solution into my options and ignore the clashing types.

export const logger = createConsola({
  async prompt(...params) {
    const response = await consola.prompt(...params);
    if (isSymbol(response) && response.toString() === "Symbol(clack:cancel)") {
      process.exit(10);
    }
    // types clash massivly. consider switching to clack directly
    return response as never;
  },
});