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

Respect --silent flag #543

Open
tadjik1 opened this issue Oct 22, 2020 · 13 comments
Open

Respect --silent flag #543

tadjik1 opened this issue Oct 22, 2020 · 13 comments

Comments

@tadjik1
Copy link

tadjik1 commented Oct 22, 2020

Hey there,
thanks a lot for the beautiful tool! Can you please improve the warning about outdated caniuse-lite version? At the moment it doesn't respect --silent flag and print messages in the console:

browserslist/node.js

Lines 373 to 378 in 4db22ae

console.warn(
'Browserslist: caniuse-lite is outdated. Please run:\n' +
'npx browserslist@latest --update-db\n' +
'\n' +
'Why you should do it regularly:\n' +
'https://github.com/browserslist/browserslist#browsers-data-updating'

https://docs.npmjs.com/misc/config#loglevel

@ai
Copy link
Member

ai commented Oct 22, 2020

Why do you think this warning is not important for your case?

@tadjik1
Copy link
Author

tadjik1 commented Oct 27, 2020

I wouldn't say it's unimportant - but there should be a way to control which messages (or which levels) should be sent to the output. NPM has settings called loglevel, and --silent means that no messages should be printed. If you do not want to check NPM flags you can also provide your own environment variable or some other way to control this behavior.

@ai
Copy link
Member

ai commented Oct 27, 2020

What is default npm’s loglevel?

@tadjik1
Copy link
Author

tadjik1 commented Oct 27, 2020

@ai
Copy link
Member

ai commented Oct 27, 2020

Yeap. Let’s respect --silent. Send PR.

@extronics
Copy link

Why do you think this warning is not important for your case?

I'm on a typescript/backend project using jest for tests. Since typescript + jest may use babel for transpilation (https://jestjs.io/docs/getting-started#using-typescript) which in turn uses @babel/preset-env, i'm now getting browserslist included in a backend-only project. So these warnings don't do anything for me (except maybe annoying me) since the code is not built for browsers.

I assume backend+typescript+jest it not that rare of a stack so there are probably a lot of users out there with this issue.

It would be great if you could accept that your views on good practices may not hold for 100% of all cases where this library ends up in the dependencies. It's questionable behaviour already for a library somewhere deep down the dependency tree to start printing to the current process' standard error. Just imagine ANY non-human interpretation of process output suddenly receiving random outputs from libraries. So at least consider providing an escape hatch to silence this.

@laurent22
Copy link

We work on a monorepo which includes a mobile and desktop app, so this caniuse-lite is not something we need but is probably included by a sub-package somewhere.

So we get a dozen of these useless warnings every time we build the Android app for example. And I tried to run the suggested command to finally get rid of them, but it's showing me an error about package.json, and I don't have all day to figure this out since we don't even need browserslist.

Why do you think this warning is not important for your case?

In our case, indeed we know it's not important.

@Aghassi
Copy link

Aghassi commented Jan 23, 2023

Looks like the easiest way out of this is with this line https://github.com/browserslist/browserslist/blob/4db22aed0f0453b73fabc87264bf7210d101075b/node.js#LL367C21-L367C49

Is that accurate? Setting process.env.BROWSERSLIST_IGNORE_OLD_DATA to true would skip this check right?

@laurent22
Copy link

laurent22 commented Mar 22, 2023

When we build our Android app, not a browser app, with no direct dependency to browserslist, this is what we get:

transform[stderr]: Browserslist: caniuse-lite is outdated. Please run:
transform[stderr]:   npx browserslist@latest --update-db
transform[stderr]:   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
transform[stderr]: Browserslist: caniuse-lite is outdated. Please run:
transform[stderr]:   npx browserslist@latest --update-db
transform[stderr]:   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
transform[stderr]: Browserslist: caniuse-lite is outdated. Please run:
transform[stderr]:   npx browserslist@latest --update-db
transform[stderr]:   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
transform[stderr]: Browserslist: caniuse-lite is outdated. Please run:
transform[stderr]:   npx browserslist@latest --update-db
transform[stderr]:   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
transform[stderr]: Browserslist: caniuse-lite is outdated. Please run:
transform[stderr]:   npx browserslist@latest --update-db
transform[stderr]:   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
transform[stderr]: Browserslist: caniuse-lite is outdated. Please run:
transform[stderr]:   npx browserslist@latest --update-db
transform[stderr]:   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
transform[stderr]: Browserslist: caniuse-lite is outdated. Please run:
transform[stderr]:   npx browserslist@latest --update-db
transform[stderr]:   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
transform[stderr]: Browserslist: caniuse-lite is outdated. Please run:
transform[stderr]:   npx browserslist@latest --update-db
transform[stderr]:   Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating

In our case nothing make these useless warnings go away:

  • npx browserslist@latest --update-db fails with a typical non-sensical JS error

  • Setting process.env.BROWSERSLIST_IGNORE_OLD_DATA doesn't stop it either

Please consider for a second that developers aren't idiots. If we need to update something, we'll do it, thank you very much. You don't need to repeat it 8 times, on every single build, for a package we don't even need! (but is included somewhere as a transitive dependency) Not to mention with no way to actually update what you want us so badly to update.

@ai
Copy link
Member

ai commented Mar 22, 2023

@laurent22 if you can't understand why standard method don't work, maybe it means that you lost control over build tool complexity and you are really doing something work.

Now you have a problem with a warning which you can ignore. But what you will do on the same case if you will have an issue without a way to understand why it doesn't work?

@laurent22
Copy link

laurent22 commented Mar 22, 2023

Blame the user, I love that and sort of expected from someone who prints 24 lines in people's builds with zero useful info in there, and condescending answers like "Why do you think this warning is not important for your case?".

So I guess we can expect these useless warnings to stay.

@ai
Copy link
Member

ai commented Mar 22, 2023

@laurent22 this warning is not useless. It really affect on Web average performance.

@james-skinner-deltatre
Copy link

Also working on a backend typescript project so warnings are not relevant.

Setting the BROWSERSLIST_IGNORE_OLD_DATA env variable to anything fixed the issue

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

No branches or pull requests

6 participants