Skip to content

ES6 not compiling #278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
desmondhume opened this issue May 27, 2015 · 5 comments
Closed

ES6 not compiling #278

desmondhume opened this issue May 27, 2015 · 5 comments

Comments

@desmondhume
Copy link

I'm trying to use ES6 features in this react component:

import React from "react/addons";
import {GoogleMaps} from "react-google-maps";

class SimpleMap extends React.Component {
  render () {
    const {props, state} = this,
          {googleMapsApi} = props;
    return (
      <GoogleMaps containerProps={{
          style: {
            height: "100%",
          },
        }}
        googleMapsApi={google.maps}
        zoom={8}
        center={{lat: -34.397, lng: 150.644}} />
    );
  }

}

export default SimpleMap;

but I keep getting this error no matter what i do:

Error: Parse Error: Line 2: Illegal import declaration
  (in `[...]app/assets/javascripts/components/simple_map.js.jsx`)

I'm using react-rails along with browserify-rails.

In my config/application.rb I put:

config.react.jsx_transform_options = {
  harmony: true
}

I don't know what to try next...any suggestion/idea?

@krzysiek1507
Copy link
Contributor

Did you try without import?

@rmosolgo
Copy link
Member

the harmony option currently supports some ES6 features, but not all. I've never found a clear-cut list of features it supports but you can see the visitors (which correspond to transforms) here: https://github.com/facebook/jstransform/tree/master/visitors

vipulnsward added a commit to vipulnsward/react-rails that referenced this issue Jun 11, 2015
… ruby-babel-transpiler

- Make new BabelTransformer the default transformer
- README changes to reflect new Babel Transformer
- Added deprecation warning for usage of old transformer options
- Move old transformer to JSXTransformer
- Fixed  component generator test after changes to new transformer

Fixes reactjs#292, reactjs#278
@tirdadc
Copy link

tirdadc commented Jun 18, 2015

I was trying to use computed property names and it seems to be supported, but despite setting the harmony flag to true I get Uncaught SyntaxError: Unexpected token [ when it hits the new syntax.

Is there anything else to do aside from setting this in development.rb (and other environment config files)?

config.react.variant = :development
config.react.addons = true
config.react.jsx_transform_options = {
  harmony: true
}

@vipulnsward
Copy link
Contributor

These will go away with #295

@rmosolgo
Copy link
Member

rmosolgo commented Jul 9, 2015

Try 1.1.0, it uses @vipulnsward 's new BabelTransformer 😄

@rmosolgo rmosolgo closed this as completed Jul 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants