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

Can Browserslist add a parameter for the current time? #802

Open
SilentTiger opened this issue Oct 31, 2023 · 10 comments
Open

Can Browserslist add a parameter for the current time? #802

SilentTiger opened this issue Oct 31, 2023 · 10 comments

Comments

@SilentTiger
Copy link

SilentTiger commented Oct 31, 2023

The configuration of mine is "last 6 years". I am curious to discern the discrepancy between the outcome of executing this query today and the result of conducting the same query the previous year.

It seems a little bit similar to #680

@ai
Copy link
Member

ai commented Oct 31, 2023

We can add environment variable for that. Please send PR.

@SilentTiger
Copy link
Author

We can add environment variable for that. Please send PR.

@ai could you give me more details about the environment variable

@ai
Copy link
Member

ai commented Oct 31, 2023

Here is section of our docs:

https://github.com/browserslist/browserslist#environment-variables

And a small brief about the whole idea

https://en.wikipedia.org/wiki/Environment_variable

@SilentTiger
Copy link
Author

@ai furthermore, have you ever thought about make it can be run in browser?

@ai
Copy link
Member

ai commented Oct 31, 2023

@SilentTiger you can use webpack/vite options to set environment variable for client-side bundle.

But I don’t think it will be popular to replace current time in browser.

@SilentTiger
Copy link
Author

@ai oh, I mean not only the environment variable in browser, but also the whole Browserslist, thus maybe the https://browsersl.ist/ won't need a backend for query.

@ai
Copy link
Member

ai commented Nov 1, 2023

Browserslist supports working in browsers except >10% in Ru query, because statistics for all countries will bloat JS bundle size.

@SilentTiger
Copy link
Author

I've added the first commit about this feature, the environment variable has been added, and the "last_years" query has been modified. Can you give me some suggestions, I just want to know if I was on the right way.

Thanks.

Here is the commit: SilentTiger@23b0373

@ai
Copy link
Member

ai commented Dec 12, 2023

Looks good. Please create PR for deeper analysis.

@SilentTiger
Copy link
Author

Thanks!

I think the "last_years" is not the only query that will be affected by this modification, I'll check other queries, and this will take time.

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

2 participants