This repository has been archived on 2022-08-19. You can view files and clone it, but cannot push or open issues or pull requests.
hydrogen-web/scripts/babel-test.js
Bruno Windels d7407ecf66 WIP
2021-10-20 11:39:01 +02:00

32 lines
840 B
JavaScript

babel = require('@babel/standalone');
const code = `
async function doit() {
const foo = {bar: 5};
const mapped = Object.values(foo).map(n => n*n);
console.log(mapped);
await Promise.resolve();
}
doit();
`;
const {code: babelCode} = babel.transform(code, {
babelrc: false,
configFile: false,
presets: [
[
"env",
{
useBuiltIns: "entry",
modules: false,
corejs: "3.4",
targets: "IE 11",
// we provide our own promise polyfill (es6-promise)
// with support for synchronous flushing of
// the queue for idb where needed
// exclude: ["es.promise", "es.promise.all-settled", "es.promise.finally"]
}
]
]
});
console.log(babelCode);