You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Now includes polyfills for Promise and Object.assign by default;
- New option "polyfills" for @vue/babel-preset-app allows customization of
included-by-default polyfills.
Copy file name to clipboardexpand all lines: packages/@vue/babel-preset-app/README.md
+20-1
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ This is the default Babel preset used in all Vue CLI projects.
12
12
-`targets` is determined:
13
13
- using `browserslist` field in `package.json` when building for browsers
14
14
- set to `{ node: 'current' }` when running unit tests in Node.js
15
+
- Includes `Promise` and `Object.assign` polyfills by default so that they are usable even in non-transpiled dependencies (only for environments that need them)
@@ -45,7 +46,25 @@ This is the default Babel preset used in all Vue CLI projects.
45
46
46
47
Default: `'usage'`
47
48
48
-
Explicitly set `useBuiltIns` option for `babel-preset-env`. See [babel-preset-env docs](https://github.com/babel/babel/tree/master/packages/babel-preset-env#usebuiltins) for more details.
49
+
Explicitly set `useBuiltIns` option for `babel-preset-env`.
50
+
51
+
The default value is `'usage'`, which adds imports to polyfills based on the usage in transpiled code. Note that the usage detection does not apply to your dependencies (which are excluded by `cli-plugin-babel` by default). If one of your dependencies need polyfills, you have three options:
52
+
53
+
1. Add that dependency to the `transpileDependencies` option in `vue.config.js`. This would enable the same usage-based polyfill detection for that dependency as well;
54
+
55
+
2. OR, you can explicitly include the needed polyfills using the [polyfills](#polyfills) option for this preset.
56
+
57
+
3. Use `useBuiltIns: 'entry'` and then add `import '@babel/polyfill'` to your entry file. This will import **ALL** polyfills based on your `browserslist` targets so that you don't need to worry about dependency polyfills anymore, but will likely bloat your final bundle with some unused polyfills.
58
+
59
+
See [babel-preset-env docs](https://github.com/babel/babel/tree/master/packages/babel-preset-env#usebuiltins) for more details.
60
+
61
+
-**polyfills**
62
+
63
+
Default: `['es6.promise', 'es6.object.assign']`
64
+
65
+
A list of [core-js](https://github.com/zloirock/core-js) polyfills to force-include when using `useBuiltIns: 'usage'`.
66
+
67
+
Use this option when you have 3rd party dependencies that are not processed by Babel but have specific polyfill requirements. **These polyfills are automatically excluded if they are not needed for your target environments specified via `browserslist`**.
0 commit comments