-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix(preset-env): Consider browserslist config if env.target not configured #8921
base: main
Are you sure you want to change the base?
fix(preset-env): Consider browserslist config if env.target not configured #8921
Conversation
🦋 Changeset detectedLatest commit: e0be2b6 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
25eb315
to
7a7aaf8
Compare
cc @kwonoj |
It seems some of the tests fail due to them expecting a specific prerecorded results, but this result has now changed due to the previous default without a target being Seems forcing a browserslist query when target is none is not the best approach. I won't try any fixes before hearing your feedback on how to handle this. Should we make the |
@egfx-notifications Any update on this? 🙏 How about adding some constant to opt in this behavior? Something like |
No, still waiting on maintainer feedback before I put any more work into this.
This would probably be a elegant non-breaking way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rebase?
7a7aaf8
to
d731765
Compare
Wait a sec, that rebase is faulty. I'm going to fix this manually asap. |
Nice to see some action here! Thanks @egfx-notifications |
Defaults to empty PathBuf for wasm32 target, but does not seem to be used anyway
Maybe reconsider this later if this is functionality we want
d731765
to
a5a35fa
Compare
I think I addressed all of the changes between my original commits and now. Unfortunately I can't run |
No worries, I‘ll update the tests if needed |
CodSpeed Performance ReportMerging #8921 will degrade performances by 3.55%Comparing Summary
Benchmarks breakdown
|
crates/preset_env_base/src/query.rs
Outdated
.clone() | ||
.into_os_string() | ||
.into_string() | ||
.unwrap_or_else(|_| panic!("Invalid path \"{:?}\"", path)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should not panic!()
here. Can you return an instance of anyhow::Error
instead?
crates/preset_env_base/src/query.rs
Outdated
.with_context(|| "failed to resolve browserslist query from browserslist config")?; | ||
|
||
let versions = | ||
BrowserData::parse_versions(distribs).expect("failed to parse browser version"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here. We don't have to panic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, and sorry for a (very) late review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed it while reviewing, but while trying to update tests to merge this PR, I found that this PR makes the swc
crate ignore jsc.target
.
Could you fix it?
You can run UPDATE=1 cargo test --test projects --test tsc --test error_msg
from ./crates/swc
to update test snapshots.
Description:
The
env.path
option in.swcrc
was originally implemented forbrowserslist
, but implementation was (unintentionally?) removed during the migration tobrowserslist-rs
(#2845).Searching the current directory for browserslist configuration was also dropped in the process.
This PR reimplements searching for browserslist configuration using the lookup functionality provided by
browserslist-rs
BREAKING CHANGE:
This may be considered a breaking change since the previous (broken) behavior for unconfigured
env.targets
was to return aBrowserData
struct with allOption
s set toNone
. Now the result of a browserslistdefaults
query is returned instead. This probably was the original behavior withbrowserslist
, though.Update: Thinking about it again,
targets_to_versions()
is part ofpreset_env_base
s public API so we should probably consider this a breaking change anyway.Things to consider:
browserslist-rs
does not provide configuration loading for wasm32 targets (which is probably to be expected that we won't check environment variables or search a filesystem in that case)feat(preset-env): Let browserslist-rs handle default config path
changes the default for an unconfiguredenv.path
from an empty string for wasm targets / current dir for other targets to aNone
value.browserslist-rs
already looks up the current dir ifpath
isNone
and it felt better to let it handle this case itselfThe commit which migrated from
browserslist
tobrowserslist-rs
mentioned fixing thedefault_path
, but does not mention what was broken and I also did not find any other usage of thepath
property. If the previous implementation was intentional, just ignore that last commit in the PR, the first two sufficiently address the bug.Related issue:
Fixes #3365
Implements #3085