Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

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

Notifications You must be signed in to change notification settings

htho/mweRollupBabelAsyncAwait

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published