0

I am receiving a "module parse failed" error when trying to load my react app with Babel6 Stage-1. We initially ran browserify but I am now trying to port us completely to Babel6.

babel.rc file

{
"presets": ["stage-1", "react"],
"env": {
  "development": {
   "presets": ["react-hmre"]
}
}}

webpack config

var path = require('path');
var webpack = require('webpack');

module.exports = {
  devtool: 'cheap-module-eval-source-map',
  entry: [
    'eventsource-polyfill', // necessary for hot reloading with IE
    'webpack-hot-middleware/client',
    './src/index'
  ],
  output: {
    path: path.join(__dirname, 'dist'),
    filename: 'bundle.js',
    publicPath: '/static/'
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin()
  ],
  module: {
    loaders: [{
      test: /\.jsx?/,
      loaders: ['babel'],
      include: path.join(__dirname, 'src'),
    },
    {
     test: /\.css$/,
     exclude: /node_modules/,
     loader: 'style!css'
   }]
  }
};

I have tried reading the documentation on Babel6 and it seems like I need to include react in my presets along with Stage-1.

I have done both and npm installed:

babel preset stage 1, babel preset react, and babel preset react hmre

Any ideas on how I can get react loading again?

Michał Perłakowski
  • 88,409
  • 26
  • 156
  • 177
Anthony Chung
  • 1,467
  • 2
  • 22
  • 44
  • 1
    Well firstly it's .babelrc, NOT babel.rc. Also make sure you have the es2015 preset: http://babeljs.io/docs/plugins/preset-es2015/ – David L. Walsh Jan 27 '16 at 03:14

1 Answers1

1

Fixed by adding es2015 to the babel.rc file

Anthony Chung
  • 1,467
  • 2
  • 22
  • 44