node到v7后支持了async/await,
不想再让项目代码被babel编译的面目全非,
只想编译node还不支持的es6 modules(import export),
请问babel支持的是哪个插件,
或者可以如何设置让babel只编译这部分?
装了
"babel-cli": "^6.18.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.18.0"
.babelrc
{
"plugins": [
"transform-es2015-modules-commonjs"
]
}
但是--out-file
后还是不能支持es6 modules
还有另一个问题就是node v7目前还是不支持 async/await
PHP中文网2017-04-17 15:16:48
Haha, just happened to see this article: https://segmentfault.com/a/11...
Global installationbabel-cli
, *inux, etc. remember to sudo
npm i babel-cli -g
Install the babel-plugin-transform-es2015-modules-commonjs
plug-in in the project root directory
npm i babel-plugin-transform-es2015-modules-commonjs --save-dev
Write the .babelrc
configuration file in the project root directory, with the content as follows.
{
"plugins": [
"transform-es2015-modules-commonjs"
]
}
Test it.
babel es2016.js -o es2016.transform.js