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.

Disable polyfills in tranform-runtime to prevent dupplicate polyfills.

See original GitHub issue

This 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:open
  • Created 7 years ago
  • Reactions:1
  • Comments:13 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
LinusBorgcommented, Feb 24, 2017

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.

1reaction
LinusBorgcommented, Feb 21, 2017

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 for babel-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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

babel/plugin-transform-runtime
A plugin that enables the re-use of Babel's injected helper code to save on codesize.
Read more >
Remove duplicate Promise polyfill in Webpack - Stack Overflow
I'm using Babel, which imports core-js/modules/es6.promise , and fast-async, which imports nodent-runtime/zousan . They're both Promise ...
Read more >
How to transpile ES modules with webpack and Node.js
For example, we can add this line: plugins: ['@babel/plugin-transform-runtime'] , which installs a Babel runtime that disables automatic per- ...
Read more >
Supported Browsers and Features - Next.js
If any of your dependencies includes these polyfills, they'll be eliminated automatically from the production build to avoid duplication.
Read more >
babel-loader - npm
You can instead require the Babel runtime as a separate module to avoid the duplication. The following configuration disables automatic per-file ...
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