Better polyfill default setting for @vue/babel-preset-app
See original GitHub issueWhat problem does this feature solve?
The current implementation of our bable preset sets the useBuiltIns
option of the ``babel-preset-envpreset to
usage`:
https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/babel-preset-app/index.js#L19
What that means it that only feature that babel comes across during transpilation are actually polyfilled.
The good
This is awesome since it keeps unnecessary polyfills out of our app
the bad
It’s bad because any code in node_modules
that relies on a poylfill requires the developer to manually inlcude this polyfill in i.e.main.js
so it’s picked up by babel. This is because we don’t run /node_modules
contents through babel, so the usage
options doesn’T pick up the feature
The alternative
I think the current default is resulting in bad dev UX, because the dev has to know and understand about the way that usage
works.
As an alternative, I propose to select entry
as the defsault value for useBuiltIns
.
The good
Now all features necessary for the targeted browsers will be polyfilled. That ensures that all code from /node_modules
relying on a feature that we ourselves don’t use will work nonetheless.
The bad
Unnecessary polyfills might be included. To allow the dev to optimize this, we could document how he could switch to usage
polyfilling and what the implications are.
What does the proposed API look like?
https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/babel-preset-app/index.js#L19:
- useBuiltIns = 'usage',
+ useBuiltIns = 'entry',
https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/generator/template/src/main.js
+ import '@babel/polyfill'
import Vue from 'vue'
import App from './App.vue'
Issue Analytics
- State:
- Created 5 years ago
- Reactions:10
- Comments:22 (14 by maintainers)
Top GitHub Comments
This is what we have setup on our cli plugin https://github.com/vuetifyjs/vue-cli-plugin-vuetify/blob/dev/generator/index.js#L67 . So I think that covers it.
I think it’s problematic for Vuetify to rely on
Object.entries()
andObject.values()
which are pretty new additions (ES2017) - they provide marginal value but complicate the user polyfill requirements. /cc @johnleider