2
私はasync/awaitを探索しようとしています。私は、関数を呼び出すとき、私は私のコンソールでこれを得た:ここバーコード6とウェブパックでasync/awaitを使用する正しい方法
Promise { <state>: "pending" }
は私webpack.conf.jsです:
var path = require("path");
var webpack = require('webpack');
var BundleTracker = require('webpack-bundle-tracker');
module.exports = {
devtool: 'eval',
entry: [
'babel-regenerator-runtime',
'./static/apps/app.jsx'
],
output : {
path: __dirname,
filename: "./static/js/bundles/[name]-[hash].js"
},
module: {
loaders: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
plugins: [ 'transform-decorators-legacy', 'syntax-async-functions', 'transform-async-to-generator'],
presets: ['react', 'es2015', 'stage-0']
}
}
]
},
plugins: process.env.NODE_ENV === 'production' ? [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.NoErrorsPlugin(),
new webpack.optimize.UglifyJsPlugin({
compress: { warnings: false },
comments: false,
sourceMap: true,
mangle: true,
minimize: true
})
] : [new BundleTracker({filename: './webpack-stats.json'}), new webpack.NoErrorsPlugin()]
};
と私の機能:
export async function x() {
return await (5 * 5);
}
と呼ばれる方法: