-
-
Notifications
You must be signed in to change notification settings - Fork 199
Add babel option to pre-include polyfills #607
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
Conversation
Hi @ihmels, Thank you for opening this PR. If a dependency requires polyfills it should probably be handled by
The description of
Also, could you also add some tests to check that it works as expected? |
I'm not of the opinion that it should be handled by But I think it is a good idea to add a way to set |
That's my point, if a dependency requires a polyfill to work you already know that it uses things that are not supported by your env, so it would be way safer to transpile it anyway. And if you really know that you are only missing polyfills you should already be able to add them by importing individual
I can't find anything better right now, maybe just with the plural form instead since they'll most likely contain arrays?
Hmm... I'm not sure that's needed. For more advanced configurations having a |
The downside to that would be that you would now be responsible for configuring all of the Babel config (e.g. can't take advantage of us adding the react preset if you enable React). BUT, I hear your point. Configuring the env preset is already possible, but ugly as you'd need to rely on the preset being on the 0 index. Encore
.configureBabel((babelConfig) => {
babelConfig.presets[0][1].include = ['foo-plugin'];
}); That's not great :). We DO expose some copy "options" as the second argument of If we're going to solve this, I think it would be via some sort of WDYT? |
I have created #642 that introduces the method |
This PR adds an
polyfills
option toEncore.configureBabel()
to configure theinclude
option of@babel/preset-env
. It's inspired by thepolyfills
option of@vue/babel-preset-app
.This option is useful to include polyfills that are required by project dependencies and therefore cannot be covered by
useBuiltIns: 'usage'
.