I'm trying to run async await functions in JavaScript using the babel-loader of webpack. I'm using the following configuration:
{
name: 'client',
context: path.join(__dirname, 'src', 'static', 'scripts'),
entry: {
index: './index.js'
},
output: {
path: path.join(__dirname, 'src', 'static', 'bundles'),
filename: '[name].js'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
query: {
presets: ['es2015', 'stage-0']
}
}
]
},
resolve: {
root: path.join(__dirname),
fallback: path.join(__dirname, 'node_modules'),
modulesDirectories: ['node_modules'],
}
}
but it keeps pushing an error with the following message:
Module build failed: Error: ./src/static/scripts/index.js: Expected type "Identifier" with option {}
My index.js has this content:
console.log('hi from app');
async function hello() {
return Promise.resolve('hi')
}
async function conversation () {
const hi = await hello()
console.log(hi);
}