A Rollup.js plugin to transform ECMAScript 6 generator and async functions.
This Rollup plugin will replace async and generator functions with ES5 Promise based functions.
Plugin using regenerator module.
rollup-plugin-nodent- Convert ES2017 async/await withnodent.
npm install --save-dev rollup-plugin-regenerator
or with yarn
yarn add -D rollup-plugin-regenerator
var rollup = require('rollup').rollup;
var regenerator = require('rollup-plugin-regenerator');
rollup({
input: 'my-entry.js',
context: 'window', // or 'global' for Node.js
plugins: [
regenerator()
]
}).then(...);includeRuntime: Iffalse- do not include 'regeneratorRuntime()' polyfill (optional).sourceMap: Iffalse- forced disable source maps generating (optional).include,exclude: A minimatch pattern, or an array of minimatch patterns of including ID, or excluding ID (optional).
- I have a warning by Rollup:
The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten. Just specifycontextoption in Rollup input options(as shown above). - Does it make sense to use this plugin? I think no. Under the hood
regeneratorusesbabelfor transformations, so it's better to use it as ababelplugin.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin my-new-feature - Submit a pull request
Licensed under MIT license.