fix(preset-env): Consider browserslist config if env.target not configured #8921
+31
−15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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