Comments (19)
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.
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.
Here you go: https://github.com/will-stone/nextjs-ansis
Thanks! 🙂
from ansis.
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.
It works!
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.
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.
Awesome! Thanks, yeah let's close and I'll open new issues if I find any 🙂
from ansis.
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.
Hello @will-stone,
thank you for the issue report!
I will fix it.
Of course, your PR would be welcome too ;-)
from ansis.
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.
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.
Ah, middleware is always run in edge mode. This is the cause of the problem.
from ansis.
ok, no problem
from ansis.
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.
can you please check the beta version v1.6.0-beta.0
?
Thank you!
from ansis.
@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.
@will-stone thank you :-)
from ansis.
@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.
can be closed the issue?
from ansis.
Related Issues (9)
- [Feature Request] British English (Gray & Grey) HOT 3
- [BUG] 1.3.5 seems broken HOT 10
- [Suggestions] Improving types and expose colours as named exports HOT 10
- [BUG] 1.5.0 missing exports main HOT 10
- [FEATURE REQUEST] Fallbacks when true color or ANSI 256 is not supported HOT 13
- Color detection when using PM2 HOT 7
- [FEATURE REQUEST] Expose `supportsColor` or similar HOT 7
- isSupported returns true when redirecting stdout on windows HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansis.