-
Notifications
You must be signed in to change notification settings - Fork 33
Support for Bluebird coroutines #4
Comments
Anything new concerning this issue ? |
I'm not sure if output to Bluebird coroutines is still provided in Babel 6 actually? Do you know? If it is, we can certainly add an option here. Otherwise it may be worth trying to install a third-party Babel plugin to try this out. |
Ok it is still supported via the plugin at http://babeljs.io/docs/plugins/transform-async-to-module-method/. It would be possible to integrate this manually by installing it and configuring the plugin, but we could integrate this as an option as well potentially. |
Here is what I did:
And below is a part of SystemJS.config({
transpiler: "plugin-babel",
packages: {
"mypackage": {
"format": "esm",
"main": "main.js",
"meta": {
"*.js": {
"loader": "plugin-babel",
"babelOptions": {
"plugins": [
["transform-async-to-module-method", {
"module": "bluebird",
"method": "coroutine"
}]
]
}
}
}
}
}
}); However, Bluebird library does not seem to be loaded typeof Promise.setScheduler // undefined Furthermore, my async functions are still transpiled with Source: let foo = async () => {
let ret = await bar()
} Transpiled: foo = function () {
var ref = _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
// ... This happens even when I do not specify any options to the plugin (ie. when I do not try to use bluebird coroutines). "meta": {
"*.js": {
"loader": "plugin-babel",
"babelOptions": {
"plugins": [
["transform-async-to-module-method"]
]
}
}
} Being able to set this behavior by passing a simple option sounds good to me. I guess most Angular (< 2) developers who start working with ES6+ will need to use Bluebird coroutines to work with |
Are you sure the configuration is applying? Because the plugin name should be |
Well, from the plugin documentation that you can find here or here, the usage in .babelrc is the following: // without options
{
"plugins": ["transform-async-to-module-method"]
}
// with options
{
"plugins": [
["transform-async-to-module-method", {
"module": "bluebird",
"method": "coroutine"
}]
]
} I tried to replace it with This is not clearly explained in JSPM docs: babelOptions: {
plugins: [
[ "react-transform", {
"transforms": [{"transform": "react-transform-jspm-hmr"}]
}]
]
} "babelOptions": {
"plugins": ["babel-plugin-transform-react-jsx"]
} Btw, would it help if I provide my full |
I've updated the options example at https://github.com/systemjs/plugin-babel#custom-presets-and-transforms to show using bluebird coroutines. In terms of loading bluebird, it's probably best to have a script tag in the head, but you could also import it via System.import. Then to use the same version of bluebird in SystemJS you could try something like |
If users want to use Bluebird promises for performance, we should provide an easy option to use this transformer without having to do more than setting the option and installing bluebird.
The text was updated successfully, but these errors were encountered: