Skip to content

browserify v2 plugin to compile coffeescript + react jsx (cjsx) automatically

License

Notifications You must be signed in to change notification settings

leiit/coffee-reactify

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

coffee-reactify

browserify v2 plugin for compiling coffee-react-transform CJSX markup in Coffeescript.

example

given some files written in a mix of coffee and cjsx:

neat-ui.coffee:

require './rad-component.cjsx'

React.renderComponent RadComponent({rad:"mos def"}),
	document.getElementById('container')

rad-component.cjsx:

# @cjsx React.DOM 

React = require('react')

RadComponent = React.createClass
  render: ->
    <div className="rad-component">
      <p>is this component rad? {@props.rad}</p>
    </div>

install coffee-reactify:

$ npm install -g coffee-reactify

version compatibility:

  • 2.1.x - React 0.12.1
  • 2.x - React 0.12
  • 1.x - React 0.11.2
  • 0.x - React 0.11 and below

when you compile your app, pass -t coffee-reactify to browserify:

$ browserify -t coffee-reactify neat-ui.coffee > bundle.js

you can omit the .coffee or .cjsx extension from your requires if you add the extension to browserify's module extensions:

require './component'
...
$ browserify -t coffee-reactify --extension=".cjsx" --extension=".coffee" neat-ui.coffee > bundle.js

providing the transform option coffeeout: true will passthrough the transformed output of .coffee files with the @cjsx pragma without compiling them to javascript. this means you can use a different coffee compiler transform such as icsify or coffeeify in conjunction with this transform.

note: at this stage, .cjsx files will still be compiled even with --coffeeout. this is a workaround for the fact that other transform modules like coffeeify will ignore .cjsx files due to the different file extension.

$ browserify -t [ coffee-reactify --coffeeout ] -t coffeeify neat-ui.coffee > bundle.js

install

With npm do:

npm install coffee-reactify

license

MIT

About

browserify v2 plugin to compile coffeescript + react jsx (cjsx) automatically

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 84.4%
  • CoffeeScript 10.5%
  • Shell 5.1%