question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better polyfill default setting for @vue/babel-preset-app

See original GitHub issue

What problem does this feature solve?

The current implementation of our bable preset sets the useBuiltIns option of the ``babel-preset-envpreset tousage`:

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:closed
  • Created 5 years ago
  • Reactions:10
  • Comments:22 (14 by maintainers)

github_iconTop GitHub Comments

4reactions
johnleidercommented, May 10, 2018

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.

3reactions
yyx990803commented, May 10, 2018

I think it’s problematic for Vuetify to rely on Object.entries() and Object.values() which are pretty new additions (ES2017) - they provide marginal value but complicate the user polyfill requirements. /cc @johnleider

Read more comments on GitHub >

github_iconTop Results From Across the Web

@vue/babel-preset-app - npm
The default value is 'usage' , which adds imports to polyfills based on the usage in transpiled code. For example, if you use...
Read more >
Browser Compatibility | Vue CLI
A default Vue CLI project uses @vue/babel-preset-app, which uses @babel/preset-env and the browserslist config to determine the Polyfills ...
Read more >
@vue/babel-preset-app | Yarn - Package Manager
This is the default Babel preset used in all Vue CLI projects. ... preset-env automatically determines the transforms and polyfills to apply based...
Read more >
babel/preset-env
This option configures how @babel/preset-env handles polyfills. When either the usage or entry options are used, @babel/preset-env will add direct references ...
Read more >
How to pass options to babel plugin transform-modules ...
js core modules by default. This is no longer the case. Verify if you need this module and configure a polyfill for it....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found