Skip to content

fix: Skip all transpilation and adding any polyfills when unknown browser version used #10376

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Guocork
Copy link

@Guocork Guocork commented Apr 15, 2025

Description:

Skip all transpilation and adding any polyfills when unknown browser version used

BREAKING CHANGE:
I need some help. Right now, my approach is:
when an unsupported browser version is set in browserslist-rs — for example:

"env": {
  "targets": ["Chrome > 130"]
}

Because the targets_to_versions has the ignore_unkonwn_versions option enabled in browserslist_opts, it ends up returning an empty result, and is_any_target becomes true.

So, I added a check to skip processing when the targets list is empty. But when I run cargo test, not all the tests pass. I'm not sure if there's a problem with my approach, or if I’m missing some edge cases.

Related issue (if exists):
#9778

@Guocork Guocork requested a review from a team as a code owner April 15, 2025 09:51
@CLAassistant
Copy link

CLAassistant commented Apr 15, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

changeset-bot bot commented Apr 15, 2025

⚠️ No Changeset found

Latest commit: 659ce0e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Guocork Guocork marked this pull request as draft April 15, 2025 09:51
Copy link

codspeed-hq bot commented Apr 15, 2025

CodSpeed Performance Report

Merging #10376 will improve performances by ×6.9

Comparing Guocork:main (659ce0e) with main (b4b3aff)

Summary

⚡ 3 improvements
✅ 149 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
es/lints/libs/terser 29.8 ms 29 ms +2.92%
es/preset-env/usage/builtin_type 254.7 µs 36.7 µs ×6.9
es/preset-env/usage/property 118.4 µs 19.8 µs ×6

Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

You have to look at failing test cases. You would be able to adjust the condition to create the correct condition for the input case.

@@ -58,7 +58,7 @@ where
let f = transform_data::Feature::$feature;
!exclude.contains(&f)
&& (c.force_all_transforms
|| (is_any_target
|| (!is_any_target
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!is_any_target is wrong way to detect unknown browser version

@@ -58,7 +58,7 @@ where
let f = transform_data::Feature::$feature;
!exclude.contains(&f)
&& (c.force_all_transforms
|| (is_any_target
|| (!is_any_target
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!is_any_target is not a way to detect an unknown browser version

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

Successfully merging this pull request may close these issues.

3 participants