ForbesLindesay / browserify-middleware

express middleware for browserify, done right
http://browserify.org
MIT License
381 stars 66 forks source link

Using reactify with the --es6 flag #46

Closed rafaelchiti closed 10 years ago

rafaelchiti commented 10 years ago

Hi sorry if it's an obvious question but I've been digging int he code that calls the transformers and can not see how to send this option to the transformer I'm using (reactify). Probable I need to configure the transformer in a different way but still not sure how to set the parameter.

This is my current code. How can I set options on that particular transformer?, is it possible the reactify API is not compatible for setting the option?.

The option I need to set is '--es6', which I guess will become {es6: true}

var browserify = require('browserify-middleware');
browserify.settings({
  transform: ['reactify'],
  extensions: ['.js', '.jsx'],
  grep: /\.jsx?$/
})

Thanks!

rafaelchiti commented 10 years ago

Nevermind, silly of me a friend just spotted out how to configure it.

var browserify = require('browserify-middleware');
var reactify = require('reactify');

var reactifyES6 = function(file) {
  return reactify(file, {'es6': true});
};

browserify.settings({
  transform: [reactifyES6],
  extensions: ['.js', '.jsx'],
  grep: /\.jsx?$/
})
nene commented 9 years ago

Not silly at all. I was looking for the same thing. It's far from obvious to figure out from Reactify documentation.

ForbesLindesay commented 9 years ago

Perhaps one of you could add a pull request to make this library's documentation clearer? Perhaps an extra example in the readme?

svileng commented 9 years ago

I was wondering the same thing, thanks for sharing your solution!

kelunik commented 8 years ago

Thanks for sharing!