arthuroy / mweRollupBabelAsyncAwait

This is a minimal working example for JavaScript bundling with rollup and babel where async/await is correctly transpiled, to be compatible with IE11.

Repository from Github https://github.comarthuroy/mweRollupBabelAsyncAwaitRepository from Github https://github.comarthuroy/mweRollupBabelAsyncAwait

Minimal Working Example for Rollup + Babel with async/await

This is a minimal working example for JavaScript bundling with rollup and babel where async/await is correctly transpiled, to be compatible with IE11.

This repository was/is necessary because it is not so easy to configure Rollup to correctly transpile async/await with Babel.

How does it work

Not only is rollup-plugin-babel and rollup-plugin-node-resolve needed, but also rollup-plugin-commonjs.

There is still an issue, where babel helpers are not transpiled. Therefore the polyfill for Promise is not included automatically. To workaround this, a dummy call to Promise.resolve() is made in the head of the source.

Once the dummy call and all these plugins are included and called in rollup.config.js everything is transpiled as expected.

Steps to test/run

# clone
$ git clone https://github.com/htho/mweRollupBabelAsyncAwait.git

# install
$ npm i

# bundle
$ ./node_modules/.bin/rollup -c

# start a server
$ ./node_modules/.bin/http-server -p 8080

# visit http://localhost:8080/BuildTest.html
# check if "Hi from top level!" and "Hi from the async function!" is printed to your console.

About

This is a minimal working example for JavaScript bundling with rollup and babel where async/await is correctly transpiled, to be compatible with IE11.


Languages

Language:JavaScript 66.6%Language:HTML 33.4%