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

Possibility of detecting polyfills with the --checkFeatures flag #229

Open
cascornelissen opened this issue Jan 7, 2025 · 2 comments
Open

Comments

@cascornelissen
Copy link

cascornelissen commented Jan 7, 2025

First of all, I want to share that I'm really stoked about this new --checkFeatures flag, I've tried setting up something similar in the past and stopped when I realised how much work this would be.

Requested Update

If even remotely possible it'd be nice if the --checkFeatures flag would take polyfills like core-js into account.

Why Is This Update Needed?

We're using core-js to polyfill certain ES features such as Array.prototype.toSorted() but when trying out the new --checkFeatures we noticed that this triggers an error when running es-check with es2022.

This might be vastly more complicated than one would initially think as in our setup we load the polyfill in a different file (chunk) than where .toSorted() is being called. Additionally there's of course a plethora of different polyfills and trying to even detect some of them might result in a lot of work. Maybe alternative ways of doing this can be thought of.

Are There Examples Of This Requested Update Elsewhere?

Not that we could find 🤷🏼‍♂️

@p3k
Copy link

p3k commented Jan 13, 2025

The option is called --checkFeatures (now), correct?

I was bitten by this, as es-check claims the following code (just a simplified reproduction) is not es2017-compatible:

Array.prototype.at = function(index) { return this[index]; };
[1, 2, 3].at(2); // 3

(I could imagine it might work even in 1996 LiveScript…? Maybe the array needs to be created differently, though.)

I understand this might be difficult to implement (I know very little about AST parsing) – so is it out of scope of this utility?

@cascornelissen cascornelissen changed the title Possibility of detecting polyfills with the --detectFeatures flag Possibility of detecting polyfills with the --checkFeatures flag Jan 14, 2025
@cascornelissen
Copy link
Author

My bad, changed --detectFeatures to --checkFeatures, no idea why I came up with a new name for the option while writing this ticket 😂

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