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

Add a shouldInjectPolyfill option to polyfill providers #13

Merged
merged 2 commits into from
May 21, 2020

Conversation

nicolo-ribaudo
Copy link
Member

This new API has the same goal as the include/exclude options
(for this reason, it will throw an error if you try to use both), but
both have some advantages that the other one doesn't have:

  1. include/exclude are an array, so you can use them
    in a static JSON file. Also, they might be easier to use.
  2. shouldInjectPolyfill is a function, so it is more powerful: for
    example, you could use it to store somewhere a list of all
    the injected polyfill, or to throw an error if a specific
    polyfill would be injected (maybe because it's too big and
    you want to be sure that you don't rely on it)

Fixes #10, fixes babel/babel#11583 (cc @niftylettuce), fixes babel/babel#6625, can fix babel/babel#8489

This new API has the same goal as the include/exclude options
(for this reason, it will throw an error if you try to use both), but
both have some advantages that the other one doesn't have:
1) include/exclude are an array, so you can use them
    in a static JSON file. Also, they might be easier to use.
2) shouldInjectPolyfill is a function, so it is more powerful: for
    example, you could use it to store somewhere a list of all
    the injected polyfill, or to throw an error if a specific
    polyfill would be injected (maybe because it's too big and
    you want to be sure that you don't rely on it)
@nicolo-ribaudo nicolo-ribaudo added the enhancement New feature or request label May 18, 2020
@nicolo-ribaudo
Copy link
Member Author

For the people wondering about the issues closed by this PR in the babel/babel repository: we'll release this alongside with the next Babel release.

@nicolo-ribaudo nicolo-ribaudo merged commit cd6dd83 into babel:master May 21, 2020
@nicolo-ribaudo nicolo-ribaudo deleted the shouldInjectPolyfill branch May 21, 2020 22:25
@niftylettuce
Copy link

@nicolo-ribaudo can you ping me when this is released to npm? do you mean next major, minor, or patch of @babel/core?

@existentialism
Copy link
Member

@niftylettuce you can always watch "releases only"

@nicolo-ribaudo
Copy link
Member Author

This has been released!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants