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

feat(babel-preset-app): pass full config to @babel/preset-env #5522

Merged
merged 1 commit into from May 29, 2020

Conversation

lucaswerkmeister
Copy link
Contributor

Pass not just the useBuiltIns and corejs options, but the whole envOptions object, into the @babel/preset-env preset that is used to transform @babel/runtime, just like for the @babel/preset-env that is used for the application source code. This allows users to also specify other options, such as exclude and polyfills, and have them apply here too.

In particular, this can be used to exclude the Promise polyfill, e. g. if Promise is already polyfilled in some other way. Previously,

exclude: ['es.promise'],
polyfills: ['es.array.iterator', 'es.object.assign'],

could be used to configure the preset for the application source code, but the babel runtime would be transformed without those options, and so es.promise would still end up being included.

Closes #5208

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Docs
  • Underlying tools
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No (I think)

Other information:

Pass not just the useBuiltIns and corejs options, but the whole
envOptions object, into the @babel/preset-env preset that is used to
transform @babel/runtime, just like for the @babel/preset-env that is
used for the application source code. This allows users to also specify
other options, such as `exclude` and `polyfills`, and have them apply
here too.

In particular, this can be used to exclude the Promise polyfill, e. g.
if Promise is already polyfilled in some other way. Previously,

    exclude: ['es.promise'],
    polyfills: ['es.array.iterator', 'es.object.assign'],

could be used to configure the preset for the application source code,
but the babel runtime would be transformed without those options, and so
es.promise would still end up being included.

Closes vuejs#5208
@lucaswerkmeister
Copy link
Contributor Author

(On second thought, polyfills: ['es.object.assign'] might be better than polyfills: ['es.array.iterator', 'es.object.assign'], since according to the corresponding comment, es.array.iterator is only needed to make es.promise work on IE. But I’m not sure.)

@lucaswerkmeister
Copy link
Contributor Author

If anyone is wondering where this PR is coming from or interested in more context, feel free to look at this task and specifically this comment in our downstream bug tracker :)

@sodatea
Copy link
Member

sodatea commented May 29, 2020

Thanks!
Actually I was thinking about dropping the transpilation of @babel/runtime entirely considering babel/babel#7597 has been fixed.

But I'm not sure if that's safe to do…
Maybe this PR is a better option before the runtime is sure to be bug-free.

@lucaswerkmeister
Copy link
Contributor Author

@micgro42 I think you were also wondering whether the transpilation was still necessary, did you come to any conclusion?

@micgro42
Copy link

"Conclusion"? No. My approach would likely just be to remove it, let the tests run, and test it manually on IE11 and Safari. If all that checks out then I'd probably call it a day.

@sodatea
Copy link
Member

sodatea commented May 29, 2020

After investigation, there's still one edge case: babel/babel#9277

So I think I'll go for this PR instead of removing transpilation at the moment.

@sodatea sodatea merged commit 0809fc8 into vuejs:dev May 29, 2020
@lucaswerkmeister lucaswerkmeister deleted the preset-env branch May 29, 2020 13:19
@lucaswerkmeister
Copy link
Contributor Author

Cool, thanks :)

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

Successfully merging this pull request may close these issues.

@vue/babel-preset-app option exclude conflict
3 participants