andreypopp / reactify

[DEPRECATED] Browserify transform for JSX (superset of JavaScript used in React library by Facebook)
MIT License
690 stars 68 forks source link

Configuring ES6 in task? #53

Closed ezmiller closed 9 years ago

ezmiller commented 9 years ago

I have a browserify task that is configured like so:

module.exports = function(grunt) {

  grunt.config.set('browserify', {
    dev: {
      src: 'assets/js/main.jsx',
      dest: '.tmp/public/js/main.js',
      options: {
        debug: true,
        extensions: ['.jsx'],
        transform: ['reactify']
      }
    }
  });

  grunt.loadNpmTasks('grunt-browserify');
};

I tried configuring it to use es6 this way:

module.exports = function(grunt) {

  grunt.config.set('browserify', {
    dev: {
      src: 'assets/js/main.jsx',
      dest: '.tmp/public/js/main.js',
      options: {
        debug: true,
        extensions: ['.jsx'],
        transform: ['reactify', {'es6': true}]
      }
    }
  });

  grunt.loadNpmTasks('grunt-browserify');
};

This causes an error though:

Error: path must be a string

I can't understand from the docs how to do this given that I don't want to configure the transform in my package.json. Any help would be appreciated.

davidreher commented 9 years ago

You have to use the current version (master) for this to work. There is no updated npm package available yet ...

ezmiller commented 9 years ago

@davidreher the way I ended up fixing this was by adding a second set of brackets so that transform is an array of transforms. I had this wrong in the code above: see the answer on stackoverflow.