babel / babel-preset-env

PSA: this repo has been moved into babel/babel -->

Home Page:https://github.com/babel/babel/tree/master/packages/babel-preset-env

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Polyfills included two times for two passes (not idempotent)

sheerun opened this issue · comments

When using useBuiltIns: 'usage' and doing two passes with babel, it can require polyfills multiple times, what makes babel not idempotent on second run (in my opinion it should be).

require("babel-polyfill/lib/core-js/modules/es6.promise");

require("babel-polyfill/lib/core-js/modules/es6.symbol");

require("babel-polyfill/lib/core-js/modules/web.dom.iterable");

function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); }

require("babel-polyfill/lib/core-js/modules/es6.symbol");

require("babel-polyfill/lib/core-js/modules/web.dom.iterable");

require("babel-polyfill/lib/regenerator-runtime/runtime");

require("babel-polyfill/lib/core-js/modules/es6.string.starts-with");

So we're clear, you're saying that you are explicitly running Babel twice, and it is putting in the require calls both times, and you don't want that?

I'm on the fence. If you're explicitly running it twice, it seems pretty edge-casey. There are definitely other cases where Babel is not idempotent.

Normally I don't do it, but I needed to to work around #433

I think this one is simple to implement as babel needs to parse this file anyway before inserting any additional requires. Besides there are plans to precompile (e.g. to node 0.12) dependencies that already can be precompiled when published to npm (e.g. to node 4), so this process would result it duplicated requires. I think it's better to fix it than not.

This issue has been moved to babel/babel#6600.