Skip to content

Instantly share code, notes, and snippets.

@boneskull
Created February 5, 2017 19:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boneskull/326ea620d3d68fd18015c1d1a0431003 to your computer and use it in GitHub Desktop.
Save boneskull/326ea620d3d68fd18015c1d1a0431003 to your computer and use it in GitHub Desktop.
babel bug with polyfill and async function in same module
{
"presets": [
[
"env",
{
"targets": {
"node": 4
}
}
]
]
}
'use strict';
var foo = function () {
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
case 'end':
return _context.stop();
}
}
}, _callee, this);
}));
return function foo() {
return _ref.apply(this, arguments);
};
}();
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
require('babel-polyfill');
require('babel-polyfill');
async function foo () {
}
$ node ./babel-bug.dist.js
/path/to/babel-bug.dist.js:4
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee() {
^
ReferenceError: regeneratorRuntime is not defined
at /path/to/babel-bug.dist.js:4:32
at Object.<anonymous> (/path/to/babel-bug.dist.js:19:2)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:420:7)
at startup (bootstrap_node.js:139:9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment