Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

grunt-coffee-react

jsdf7695.0.2

Compile CJSX files to JavaScript.

gruntplugin

readme

grunt-coffee-react

STATUS: DEPRECATED

This tool is no longer maintained. If you need to transition your codebase from it, a codemod is available to do so: cjsx-codemod

This project started as a way for me to explore how JSX could fit into Coffeescript syntax, as a quickly hacked together prototype. While I never really promoted it, it quickly took on a life of its own, and before long people were asking for it to support all kinds of different use cases. On top of that I had no experience writing parsers, so the result is something with insurmountable limitations.

As I eventually stopped using Coffeescript I ended up neglecting this project, but as people were using it I didn't want to kill it. I really should have, however, because it meant that people were using a crappy, ill-conceived, unmaintained tool. Now, long overdue, I'm putting it out to pasture.

Original readme follows:

Compile coffee-react-transform CJSX files to JavaScript.

Getting Started

This plugin requires Grunt ~0.4.0

Version 1.0 and higher of this plugin are only compatible with React 0.11.2 and higher

note

npm install grunt-coffee-react --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-coffee-react');

'cjsx' task

Run this task with the grunt cjsx command.

Task targets, files and options may be specified according to the grunt Configuring tasks guide.

Options

separator

Type: String Default: linefeed

Concatenated files will be joined on this string.

bare

Type: boolean

Compile the JavaScript without the top-level function safety wrapper.

join

Type: boolean Default: false

When compiling multiple CJSX files into a single .js file, concatenate first.

sourceMap

Type: boolean Default: false

Compile JavaScript and create a .map file linking it to the CJSX source. When compiling multiple .coffee files to a single .js file, concatenation occurs as though the 'join' option is enabled

sourceMapDir

Type: String Default: (same path as your compiled js files)

Generated source map files will be created here.

joinExt

Type: String Default: '.src.coffee'

Resulting extension when joining multiple CJSX files.

Usage Examples

cjsx: {
  compile: {
    files: {
      'path/to/result.js': 'path/to/source.coffee', // 1:1 compile
      'path/to/another.js': ['path/to/sources/*.cjsx', 'path/to/more/*.coffee'] // compile and concat into single file
    }
  },

  compileBare: {
    options: {
      bare: true
    },
    files: {
      'path/to/result.js': 'path/to/source.coffee', // 1:1 compile
      'path/to/another.js': ['path/to/sources/*.cjsx', 'path/to/more/*.coffee'] // compile and concat into single file
    }
  },

  compileJoined: {
    options: {
      join: true
    },
    files: {
      'path/to/result.js': 'path/to/source.coffee', // 1:1 compile, identical output to join = false
      'path/to/another.js': ['path/to/sources/*.cjsx', 'path/to/more/*.coffee'] // concat then compile into single file
    }
  },

  compileWithMaps: {
    options: {
      sourceMap: true
    },
    files: {
      'path/to/result.js': 'path/to/source.coffee', // 1:1 compile
      'path/to/another.js': ['path/to/sources/*.cjsx', 'path/to/more/*.coffee'] // concat then compile into single file
    }
  },

  compileWithMapsDir: {
    options: {
      sourceMap: true,
      sourceMapDir: 'path/to/maps/' // source map files will be created here
    },
    files: {
      'path/to/result.js': 'path/to/source.coffee'
    }
  },

  glob_to_multiple: {
    expand: true,
    flatten: true,
    cwd: 'path/to',
    src: ['*.coffee'],
    dest: 'path/to/dest/',
    ext: '.js'
  }

}

For more examples on how to use the expand API to manipulate the default dynamic path construction in the glob_to_multiple examples, see "Building the files object dynamically" in the grunt wiki entry Configuring Tasks.

changelog

v0.10.0: date: 2014-02-07 changes:

- SourceMappingURL calculated correctly

v0.9.0: date: 2014-01-29 changes:

- Source mapping fixes.
- Update coffee-script to 1.7.0
- Use lodash directly instead of deprecated grunt.util._

v0.8.2: date: 2014-01-17 changes:

- Force coffeescript 1.6.3
- Use new sourceMappingUrl syntax.

v0.8.1: date: 2014-01-17 changes:

- Fix sourcemap regression.

v0.8.0: date: 2013-12-24 changes:

- Support sourceMapDir

v0.7.0: date: 2013-04-19 changes:

- Place Sourcemaps at bottom of file
- Change extension for Sourcemaps from .maps to .js.map

v0.6.7: date: 2013-04-18 changes:

- Improved error reporting

v0.6.6: date: 2013-04-08 changes:

- Fix regression with single-file compilation.

v0.6.5: date: 2013-04-05 changes:

- Improved error reporting

v0.6.4: date: 2013-03-22 changes:

- Sourcemap support

v0.6.3: date: 2013-03-19 changes:

- Increase error logging verbosity.

v0.6.2: date: 2013-03-18 changes:

- Bump to CoffeeScript 1.6.2

v0.6.1: date: 2013-03-18 changes:

- Support `join` option

v0.6.0: date: 2013-03-06 changes:

- Bump to CoffeeScript 1.6
- Support literate CoffeeScript extension coffee.md

v0.5.0: date: 2013-02-25 changes:

- Bump to CoffeeScript 1.5
- Support literate CoffeeScript (.litcoffee)

v0.4.0: date: 2013-02-15 changes:

- First official release for Grunt 0.4.0.

v0.4.0rc7: date: 2013-01-23 changes:

- Updating grunt/gruntplugin dependencies to rc7.
- Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions.
- Bump coffeescript dependency to 1.4.

v0.4.0rc5: date: 2013-01-09 changes:

- Updating to work with grunt v0.4.0rc5.
- Switching to this.filesSrc api.

v0.4.0a: date: 2012-12-15 changes:

- Conversion to grunt v0.4 conventions.
- Remove experimental destination wildcards.

v0.3.2: date: 2012-10-12 changes:

- Rename grunt-contrib-lib dep to grunt-lib-contrib.

v0.3.1: date: 2012-09-25 changes:

 - Don't fail when there are no files.

v0.3.0: date: 2012-09-24 changes:

- Global options depreciated.

v0.2.0: date: 2012-09-10 changes:

- Refactored from grunt-contrib into individual repo.