gaearon/react-transform-boilerplate

Cannot use `Property Initializers` with babel-preset-stage-0

leiming opened this issue · 1 comments

Hi, I couldn't use Property Initializers with Babel 2015.

All code in scenario as follow:

run in bash:

 npm install babel-preset-stage-0 --save-dev

.babelrc

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

src/App.js

class Counter extends Component {

  static props = {
    bar : 'foo'
  }

  render() {<div>anything</div>}
}

And run npm start, console throw the error:

// ...

  [165] ./~/react/lib/onlyChild.js 1.21 kB {0} [built]
  [166] ./~/react/lib/deprecated.js 1.77 kB {0} [built]
  [167] ./~/react-dom/index.js 63 bytes {0} [built]

ERROR in ./src/App.js
Module build failed: SyntaxError: /Users/leiming/IdeaProjects/react_new/react-transform-boilerplate/src/App.js: A semicolon is required after a class property (8:3)
   6 |   static props = {
   7 |     bar : 'foo'
>  8 |   }
     |    ^
   9 | 
  10 |   constructor(props) {
  11 |     super(props);

// ...

Could you tell me the proper method about using babel-loader?

According to A semicolon is required after a class property, having replaced

  static props = { bar : 'foo'}

with

  static props = {bar : 'foo'};

can solve the problem, even thorough the semicolon is not necessary with Babel 5 .