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

core.js semver version seems wrong, only considers strict major version #33

Open
jquense opened this issue Sep 1, 2020 · 5 comments
Open

Comments

@jquense
Copy link
Contributor

jquense commented Sep 1, 2020

Went to upgrade after #31 was released and noticed that the issue continued to persist. The reason is get-modules-list-for-target-version is being fed 3 for the version by default, which ignores 3.1, 3.2, etc. I tried a few semver-y things to be more inclusive but it seems core-js doesn't support those, so one needs to manually set 3.6 or whatever the latest is, which seems less than ideal.

@nicolo-ribaudo
Copy link
Member

"latest" cannot be the default version because it would cause breaking changes whenever a new minor version of core-js is released (the plugin wouldn't be compatible with the previous version by default).
I can manually set the default to be 3.6, if that works.

@jquense
Copy link
Contributor Author

jquense commented Sep 2, 2020

breaking would be bad, it's not clear tho why it would break. shouldn't any minor version be compatible with previous ones for the major version?

@nicolo-ribaudo
Copy link
Member

Let's suppose that core-js 3.6 doesn't support es.promise.finally, and that it is introduced by version 3.7.

If I have this code:

new Promise().finally();

the generated output might be something like this, which is perfectly compatible with core-js 3.6:

import "es.promise";

new Promise().finally();

Now, let's suppose that core-js 3.7 is released. If the plugin defaults to "latest core-js version", then it defaults to a version that supports es.promise.finally. The generated code would then be

import "es.promise";
import "es.promise.finally";

new Promise().finally();

However, this code will break if the user had "core-js": "3.6" in their package.json because it doesn't support es.promise.finally.

@jquense
Copy link
Contributor Author

jquense commented Sep 2, 2020

ah, right. That isn't great, tho maybe not much of a problem in practice as generally package mgmt sides on the latest compatible semver version. The other side of this is also mildly broken (which is how i got here). where i have the latest corejs installed but babel-polyfill was not polyfiling it. Practically this produces in the same sort of broken runtime time code, tho i'd suggest the later is more likely to happen than the former.

in any case, maybe this deserves a more prominent spot in the readme that you must match your local core-js version exactly or miss out on supported polyfills.

Could also have the plugin check if there are supported polyfills in a higher version and warn the user?

@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Sep 2, 2020

I can throw an error if you don't explicitly set the version maybe?

Could also have the plugin check if there are supported polyfills in a higher version and warn the user?

That's a good idea!

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