GithubHelp home page GithubHelp logo

Comments (19)

will-stone avatar will-stone commented on July 28, 2024 1

I'm happy to PR it, for sure. However, I'm a little worried I could break other situations. Would you be happy for me to add a failing test PR instead? I can try to set up a test that mimics Next.js middleware environment.

from ansis.

will-stone avatar will-stone commented on July 28, 2024 1

Oh sure, happy to do that instead too. The codesandbox can be a bit flaky. I'll let you know when I have a repo for you to spin up 👍

from ansis.

will-stone avatar will-stone commented on July 28, 2024 1

Here you go: https://github.com/will-stone/nextjs-ansis

Thanks! 🙂

from ansis.

webdiscus avatar webdiscus commented on July 28, 2024 1

I know, the node:tty not works in edge mode, therefore I don't use any node lib for it.
Locally by me, colors already works in edge mode.
I must write many tests yet.

from ansis.

will-stone avatar will-stone commented on July 28, 2024 1

It works!

CleanShot 2023-11-02 at 10 56 26@2x

will-stone/nextjs-ansis@85e413c

Thank you for this amazingly quick turnaround 🤯 This needs to be marketed to the Next.js peeps at Vercel as this lib could be their default for all logging now.

from ansis.

will-stone avatar will-stone commented on July 28, 2024 1

Yeah sorry, more of a throw away comment really. I’ll put a thread in their GitHub discussions to direct people this way when looking for a color logger that supports all of Next.js 👍😊

from ansis.

will-stone avatar will-stone commented on July 28, 2024 1

Awesome! Thanks, yeah let's close and I'll open new issues if I find any 🙂

from ansis.

will-stone avatar will-stone commented on July 28, 2024

PS thanks for this library 😄 It's probably the most versatile of the new fast colour loggers. Great to have a package still supporting CJS too, unlike some other chalky libs 😬

from ansis.

webdiscus avatar webdiscus commented on July 28, 2024

Hello @will-stone,

thank you for the issue report!
I will fix it.

Of course, your PR would be welcome too ;-)

from ansis.

webdiscus avatar webdiscus commented on July 28, 2024

I can try to set up a test that mimics Next.js middleware environment.

Yes, please create a small repository with a reproducible problem. This will help me solve the issue faster.

from ansis.

webdiscus avatar webdiscus commented on July 28, 2024

@will-stone

how can be set runtime as nodejs? I need it for testing next.js in nodejs mode.

I set export const runtime = 'nodejs' in index.tsx or middelware.ts, not works,
env contains always: NEXT_RUNTIME: 'edge'

from ansis.

will-stone avatar will-stone commented on July 28, 2024

Ah, middleware is always run in edge mode. This is the cause of the problem.

from ansis.

webdiscus avatar webdiscus commented on July 28, 2024

ok, no problem

from ansis.

will-stone avatar will-stone commented on July 28, 2024

This is one of the reasons I've been looking at Ansis: other libraries rely on node:tty and node utils aren't available in edge runtime. Here's an example of that: jorgebucaran/colorette#100 However, my investigation has also shown process.stdout isn't available either. Hoping we can work around that though.

There's a Next.js issue here that started me looking at this library. The author reckons Ansis works but maybe that was an older version.

from ansis.

webdiscus avatar webdiscus commented on July 28, 2024

@will-stone

can you please check the beta version v1.6.0-beta.0?
Thank you!

from ansis.

webdiscus avatar webdiscus commented on July 28, 2024

@will-stone Thank you for the suggestion.

This needs to be marketed to the Next.js peeps at Vercel as this lib could be their default for all logging now.

Many developers would benefit from having a small/fast/powerful/universal color library.
And it would be nice if Next.js had ansis "out of the box".

I'm afraid that Next.js will reject Ansis due to its low popularity.
Ansis has 100k downloads per week and is used by 2.3k developers.

Although chalk is also developed and maintained by one person, it is a very popular person.

We can try to suggest Asisis in Next.js, but it should not be the author (me), but another developer. If I do this, it will be perceived as self-promotion/spam.

from ansis.

webdiscus avatar webdiscus commented on July 28, 2024

@will-stone thank you :-)

from ansis.

webdiscus avatar webdiscus commented on July 28, 2024

@will-stone the support for Next.js is released in the v2.0.0.

Note:

In the new release is changed named import:
NEW (v2.x.x) named import

import ansis, { red } from 'ansis'; // default and named import
ansis.red`error`;
red`error`;

OLD (v1.5.x) named import:

import ansis from 'ansis'; // default import
import { red } from 'ansis/colors'; // named import
ansis.red`error`;
red`error`;

from ansis.

webdiscus avatar webdiscus commented on July 28, 2024

can be closed the issue?

from ansis.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.