我現在用的是 “electron”: “^1.4.14”。沒辦法用 babel-preset-es2017。因為我用了 import {x} from “./y”,這句在 babel preset es2017 會直出,而 electron 不吃。
我會想用 preset 2017 是因為想要 asysnc await 句法,而 preset es2015 沒辦法翻。所以妥協的結果是,用 preset es2015 再加上 plugin
最後試成功的是這樣子的:
"babel": "^6.5.2",
"babel-core": "^6.21.0",
"babel-loader": "^6.2.10",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-es2017": "^6.22.0",
"babel-preset-react": "^6.16.0",
"babel-runtime": "^6.22.0",
```
雖然安裝了 `babel-preset-es2017`,但是在 webpack 設定還是用 `babel-preset-es2015`,在 loader 設定為:
loaders: [
{
test: /\.js|\.jsx?$/,
loader: 'babel-loader',
include: [SRC_PATH],
query: {
presets: ['es2015', 'react'],
plugins: ["syntax-async-functions","transform-regenerator","transform-runtime"]
}
},
...
]
“`
沒有留言:
張貼留言