treywood / babel-plugin-bluebird-async-functions Goto Github PK
View Code? Open in Web Editor NEWConvert async methods and generator functions into Bluebird's Coroutine and Method helpers
Convert async methods and generator functions into Bluebird's Coroutine and Method helpers
This plugin requires a global Promise (or a polyfill) to exist which is messy (IMO).
We could also import bluebird into the module with a simple change:
let asyncWrap = t.memberExpression(bluebird, t.identifier(methodName));
// to
let asyncWrap = t.memberExpression(state.addImport('bluebird', 'default', node.name), t.identifier(methodName));
edit: the current code makes this plugin unusable for libs
Another purpose of this transformer is to create a sandboxed environment for your code. If you use babel-polyfill and the built-ins it provides such as Promise, Set and Map, those will pollute the global scope. While this might be ok for an app or a command line tool, it becomes a problem if your code is a library which you intend to publish for others to use or if you can’t exactly control the environment in which your code will run.
doing it that way makes it work on JSPM, which doesn't run postinstall scripts
also allows you to make all dependencies devDependencies (i.e. unneeded)
I've looked around and not found a good way to replace the native es6 promise with bluebird. I tried below in my entry file
global.Promise = require('bluebird');
Promise.config({
warnings: false,
longStackTraces: true,
cancellation: true
});
require('./entry');
but still get this error in a subsequently import
ed file
exports.default = Promise.coroutine(regeneratorRuntime.mark(function _callee(_ref) {
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.