See Update 2 below for what the real problem seems to be.
I am having trouble getting a React JS to work in some browsers. In Chrome it worked perfectly.
In Firefox 47.0.1 I got this error:
SyntaxError: missing } after property list
In IE 11 I get this error:
SCRIPT1009: Expected '}'
I upgrade Firefox to Firefox 52 and it now works fine in Firefox.
Any ideas what the issue is?
Also, how can I track down errors like this when it points to the entire babel.js file? Normally errors are reported when the bundle.js is created, however, in this case it reports everything is working fine.
The suggested duplicate SyntaxError: missing } after property list is not the same issue as that one pinpoints what the error is whereas in my case it does not.
Update:
As per Saral's answer I am posting my webpack.config.js file here:
var webpack = require('webpack');
var path = require('path');
var DIST_DIR = path.resolve(__dirname, 'dist');
var SRC_DIR = path.resolve(__dirname, 'src');
var config = {
entry: SRC_DIR + '/app/index.js',
output: {
path: DIST_DIR + '/public/js',
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.jsx?$/,
include: SRC_DIR,
loader: 'babel-loader',
query: {
presets: ['es2015','react']
}
}
]
}
};
module.exports = config;
Update 2
Okay, I think I have tracked down the error. All my code seems to be correct, but for some reason the older browsers are getting hung up on the first occurrence of the word async
. I was under the assumption that Babel converted the async
into something older browsers could understand. However, this does not seem to be happening. What can I do to fix this?
My .babelrc
file looks like this:
{
"presets" : ["es2015", "react"]
}
Is it necessary to have the presets both in the webpack.config.js and the .babelrc file? If not, is one preferred over the other?
In the future, how can I get the browser to report which JavaScript line it doesn't like? Currently it points to a huge "eval" section.