podio / requirejs-react-jsx

A RequireJS plugin for loading jsx in development and compiling (with r.js). Supports bundling and 1:1 source maps in development and production.
MIT License
104 stars 20 forks source link

Difference between client-side and build compilation #9

Closed kirill-konshin closed 9 years ago

kirill-konshin commented 9 years ago

Client side allows syntax:

React.createClass({
  render(){ // no ":function" between name and ()
    // ...
  }
});

During the build this causes an error.

srn commented 9 years ago

This should work if you remember to include this in your requirejs.config:

jsx: {
  transformOptions: {
    harmony: true
  }
}
kirill-konshin commented 9 years ago

It probably should be enabled by default to match with client-side default settings.

Second, usually module configurations are stored as config property of object supplied to requirejs.config():

requirejs.config({
  config: { // note this additional config property
    jsx: {...}
  }
});

From the plugin it should be accessed as:

// was
var options = config.jsx && config.jsx.options.transformOptions || {}; // btw this is still not safe enough
// proposed
var options = config.config && config.config.jsx && config.config.jsx.options.transformOptions || {};
kirill-konshin commented 9 years ago

http://requirejs.org/docs/api.html#config-moduleconfig Link to documentation about config section.

srn commented 9 years ago

You're right. Feel free to create a PR with the proposed changes :+1:

kirill-konshin commented 9 years ago

Here you go: PR https://github.com/podio/requirejs-react-jsx/pull/10

kirill-konshin commented 9 years ago

BUMP!

kirill-konshin commented 9 years ago

I've found a small issue + I've added a safer check. This could be 0.14.1 :) PR created https://github.com/podio/requirejs-react-jsx/pull/11

Munter commented 9 years ago

This seems to be dealt with now. Thanks for the contributions!

kirill-konshin commented 9 years ago

Confirmed.