Giter Club home page Giter Club logo

mwerollupbabelasyncawait's Introduction

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.

mwerollupbabelasyncawait's People

Contributors

htho avatar

Stargazers

 avatar Alistair MacDonald avatar Sean G. Wright avatar Steve Gravrock avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.