One weird deployment issue with ES6+Babel I’ve been wondering about is the polyfill dependency. If you were fine having babel
or babel-core
as a non-dev-dependency, it’d be easy to just import 'babel/polyfill'
. The problem is that those are big dependencies, like 25MB or so.
You’d think there’d just be an npm package that’s babel-polyfill
, which would include regenerator and corejs, but I haven’t found exactly that yet. Any ideas? npm’s babel-es6-polyfill
is apparently meant only for browsers. So far I’ve taken to including babel-polyfill
as a dependency that can’t be managed easily by npm or git.
As an example, imagine you have test.es6:
function* foo(){}
babel -o test.js test.es6
will give you this as test.js:
"use strict";
var marked0$0 = [foo].map(regeneratorRuntime.mark);
function foo() {
return regeneratorRuntime.wrap(function foo$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {
case 0:
case "end":
return context$1$0.stop();
}
}, marked0$0[0], this);
}
You’d think there’d be an npm package that wouldn’t include Babel’s compiler, but would include the requisite polyfill stuff. babel-polyfill
is some subfolder within babel
, so I don’t think you can get it on its own very easily.