【发布时间】:2016-09-13 06:56:30
【问题描述】:
我们正在尝试将 Node.js 6.5.0 与 Babel 一起使用,以使 async functions 使用 Bluebird 而不是原生 V8 ES6 承诺:
我们的package.json 仅包含以下Babel 条目:
"devDependencies": {
"babel-cli": "^6.9.0",
"babel-plugin-transform-async-to-module-method": "^6.8.0",
"babel-plugin-transform-es2015-destructuring": "^6.9.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.14.0",
}
和.babelrc:
{
"plugins": [
"transform-es2015-modules-commonjs",
"transform-es2015-destructuring",
[
"transform-async-to-module-method",
{
"module": "bluebird",
"method": "coroutine"
}
]
]
}
然而我们async functions返回的ES6映射在执行过程中会导致如下错误:
产生了一个不能被视为承诺的值 [object Map]
我们如何解决这个问题?
附:当async functions 使用transform-async-to-generator 转换为generators 时,一切正常
【问题讨论】:
标签: node.js ecmascript-6 babeljs bluebird