Disable polyfills in tranform-runtime to prevent dupplicate polyfills.
See original GitHub issueThis issue was also discussed here - https://forum.vuejs.org/t/multiple-promise-libraries-being-exported-in-webpack/6610. My thanks to @LinusBorg
Setup
Module | Version |
---|---|
Node.js | 6.9.2 |
npm | 4.3 |
vue-cli | 2.8.1 |
vue | 2.1.10 |
webpack | 2.2.1 |
babel | 6.22 |
Issue details
I have a modified version of the vue-js webpack template which I migrated to webpack 2(some time back) and also made other changes. I have added es6-promise for use with vuex as it needs a Promise library implementation. When I recently used webpack-bundle-analyzer, I saw something odd. A snippet from the vendor.js:

The promise library polyfill is being exported twice. From the discussion with Linus, we were able to conclude that this is happening due to babel-plugin-transform-runtime which, among other things, also introduces polyfills for things likeMap
and Promise
. This section from babel-loader README is quite relevant but I failed to solve the issue with the bootstrap suggested. Linus suggested that the babel config could be changed to not add polyfills by default:
"plugins": [
["transform-runtime", { "polyfill": false}]
]
Are there any polyfills required by vue, vuex and vue-router? I will also try to get rid of the polyfills and check if something breaks.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:13 (12 by maintainers)
I’m not sure yet weither we want to remove it completely. the
helpers
part of the plugin is useful, leaving it ouot could clutter the transpiled modules with duplicated helper code.No, that’s not what I meant. What I mean is:
If we remove the tranform-runtime (or deactivate the automatic polyfill feature it provides), then you, the developer, have to manually keep track of the polyfill-requiring ES6 features you use include those polyfills if you want to make your app work with out-of-date browsers.
I think we can counter-balance that by switching the
es2015
preset forbabel-preset-env
, especially this feature of that preset, so users can easily add the polyfills that their target browser needs. Maybe that could even be a new option in the setup process.