mirror of
https://github.com/vuejs/vue-cli.git
synced 2026-04-22 12:28:44 -05:00
docs: add a note on polyfills in lib/wc
This commit is contained in:
@@ -10,6 +10,8 @@ See [here][browserslist] for how to specify browser ranges.
|
||||
|
||||
A default Vue CLI project uses [@vue/babel-preset-app][babel-preset-app], which uses `@babel/preset-env` and the `browserslist` config to determine the Polyfills needed for your project.
|
||||
|
||||
### useBuiltIns: 'usage'
|
||||
|
||||
By default, it passes [`useBuiltIns: 'usage'`](https://new.babeljs.io/docs/en/next/babel-preset-env.html#usebuiltins-usage) to `@babel/preset-env` which automatically detects the polyfills needed based on the language features used in your source code. This ensures only the minimum amount of polyfills are included in your final bundle. However, this also means **if one of your dependencies has specific requirements on polyfills, by default Babel won't be able to detect it.**
|
||||
|
||||
If one of your dependencies need polyfills, you have a few options:
|
||||
@@ -40,6 +42,10 @@ If one of your dependencies need polyfills, you have a few options:
|
||||
|
||||
See [@babel-preset/env docs](https://new.babeljs.io/docs/en/next/babel-preset-env.html#usebuiltins-usage) for more details.
|
||||
|
||||
### Polyfills when Building as Library or Web Components
|
||||
|
||||
When using Vue CLI to [build a library or Web Components](./build-targets.md), it is recommended to pass `useBuiltIns: false` to `@vue/babel-preset-app` to disable automatic polyfill injection. This ensures you don't include unnecessary polyfills in your code, as it should be the responsibility of the consuming app to include polyfills.
|
||||
|
||||
## Modern Mode
|
||||
|
||||
With Babel we are able to leverage all the newest language features in ES2015+, but that also means we have to ship transpiled and polyfilled bundles in order to support older browsers. These transpiled bundles are often more verbose than the original native ES2015+ code, and also parse and run slower. Given that today a good majority of the modern browsers have decent support for native ES2015, it is a waste that we have to ship heavier and less efficient code to those browsers just because we have to support older ones.
|
||||
|
||||
Reference in New Issue
Block a user