Спасибо за комментарий @ Keith, который дал мне понять, что мне нужно включать polyfills отдельно. Вот рабочий "привет мир" с babel.js:
<script src="https://polyfill.io/v2/polyfill.js?features=default,es5,es6&flags=gated,always"></script>
<script src="https://unpkg.com/@babel/standalone@7.2.5/babel.js"></script>
<script type="text/babel" data-presets="es2015,es2016,es2017,stage-3">
async function test() { return 10; }
console.log("done");
</script>
Редактировать : При тестировании с моим реальным кодом я получал сообщения "runtimeGenerator не определен", так что это не полное решение. Я попытался включить его прямо из источника, и это, похоже, сработало, но потом я снова получил «undefined is not function», и поэтому, чтобы спасти то, что осталось от моих волос и здравомыслия, я отошел от компьютера.
Редактировать 2: Вот что мне понадобилось:
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/facebook/regenerator/packages/regenerator-runtime/runtime.js"></script>
<script src="https://polyfill.io/v2/polyfill.js?features=default,es5,es6,Array.prototype.@@iterator,Array.prototype.entries,Array.prototype.find,Array.prototype.findIndex,Array.prototype.copyWithin,Array.prototype.findIndex,Array.prototype.includes,Array.prototype.keys,Array.prototype.values,DOMTokenList.prototype.@@iterator,DocumentFragment,Element.prototype.dataset,EventSource,Function.name,HTMLCanvasElement.prototype.toBlob,HTMLDocument,MutationObserver,NodeList.prototype.@@iterator,IntersectionObserver,IntersectionObserverEntry,NodeList.prototype.@@iterator,Object.entries,Object.values,Promise.prototype.finally,RegExp.prototype.flags,String.fromCodePoint,String.prototype.codePointAt,String.prototype.padEnd,String.prototype.padStart,String.prototype.repeat,Symbol.hasInstance,Symbol.isConcatSpreadable,Symbol.match,Symbol.replace,Symbol.search,Symbol.species,Symbol.split,Symbol.toPrimitive,Symbol.toStringTag,console.exception,fetch,screen.orientation,setImmediate&flags=gated,always"></script>
<script src="https://unpkg.com/@babel/standalone@7.2.5/babel.js"></script>
<script>
var beforeCode = "YOUR ES6+ CODE";
var afterCode = Babel.transform(beforeCode, {
presets: ['es2015','es2016','es2017','stage-3'],
plugins: ['transform-async-to-generator','transform-regenerator'],
}).code;
var script = document.createElement("script");
script.innerHTML = afterCode;
document.head.appendChild(script);
</script>
Мне также нужно было добавить NodeList.forEach
polyfill, который polyfill.io не поддерживает.