cssinjs / jss

JSS is an authoring tool for CSS which uses JavaScript as a host language.
https://cssinjs.org
MIT License
7.07k stars 399 forks source link

Verbose warning option? #1485

Open josh-degraw opened 3 years ago

josh-degraw commented 3 years ago

Is your feature request related to a problem? Please describe.

I've been trying to debug some issues on my app to get it compatible with IE 11. In the process, I'm encountering a lot of warnings (only in IE) e.g. Warning [JSS] SyntaxError, Warning: [JSS] Rule is not linked. Missing sheet option "link: true".. I'm sure there's a valid reason for the warnings, but I'm at a loss as to where they are being triggered from or what the exact problems are, because the above warnings are the only information I have.

Describe the solution you'd like Ideally, I would like to at least have the option of seeing the full error stack when warnings are encountered by jss, so I can more easily identify what is causing the issues I'm running into. I'm not sure if such a behavior already exists, but from my investigation so far I have not found any.

Are you willing to implement it? Yes

kof commented 3 years ago

I would love to see a proper issue and a reproduction on codesandbox. By proper I mean the minimal thing that triggers a warning. Then we can see why the warning is wrong or how to make it more helpful if it is not wrong.

Silencing warnings instead of fixing them sounds like a not very healthy strategy. At the very end you can always override console.warn in your app and filter warnings, but I don't think this is a good way of dealing with them in general.

kof commented 3 years ago

Also be sure to check other issues, maybe this is already reported.

josh-degraw commented 3 years ago

I apologize if I wasn't clear enough in what I was asking for. I never said that the warnings are wrong or shouldn't be there.

What I'm saying is that I'm sure the warnings are there for a reason, and are valid, but literally the only thing that shows in some of these warnings is Warning [JSS] SyntaxError, with no other information.

I'm asking for an option to have more warning information, not less.

Because without something like the error's stack trace, I have no idea where the warning is coming from or what's triggering it, so I can't really fix it, since I don't have any idea what that error really was. And since I'm only getting that warning logged in IE, I know it's not just something with my code in general, it's some IE quirk. And without the further context, I can't identify the actual problem.

kof commented 3 years ago

I agree this is suboptimal, stacktrace or more info should be provided, but for now, here are 2 options:

  1. open jss in node_modules and literall ythrow an error where this warning is triggered, it seems it can only be this one, all others have a more specific message

  2. Another option - bisecting

kof commented 3 years ago

Could be related https://github.com/cssinjs/jss/issues/1492