Coffee-React

raw JSON →
5.0.1 verified Fri May 01 auth: no javascript deprecated

Deprecated tool that provided JSX-like syntax for building React components with CoffeeScript, using the CJSX format. The 5.0.1 stable release is the last; the project has been abandoned. It wraps coffee-react-transform and coffee-script to compile CJSX to JavaScript, and includes a cjsx executable that functions as a coffee replacement. Key differentiator: allowed React JSX syntax within CoffeeScript files. Now superseded by cjsx-codemod for migration. No longer maintained or recommended for new projects.

error Error: Cannot find module 'coffee-react-transform'
cause Missing required dependency when using coffee-react directly via require().
fix
Ensure both coffee-react and coffee-react-transform are installed: npm install coffee-react coffee-react-transform
error cjsx: command not found
cause Package not installed globally or not in PATH.
fix
Install globally: npm install -g coffee-react@5.0.1, or use npx coffee-react
error Parse error on line ... Unexpected token '<'
cause CJSX syntax not correctly formatted or using incompatible JSX-like syntax.
fix
Review CJSX syntax rules; ensure elements are properly closed and attributes use CoffeeScript expressions.
deprecated This package is no longer maintained and marked as deprecated. Use cjsx-codemod to transition away.
fix Migrate codebase using cjsx-codemod (https://github.com/jsdf/cjsx-codemod) and consider moving to modern alternatives like Babel with JSX.
gotcha Insurmountable limitations exist in the parser; complex CJSX syntax may produce bugs.
fix Avoid writing new CJSX code; use standard JSX with JavaScript or TypeScript instead.
breaking Version 5.x only supports React 0.13.x - 0.15.x. Using with newer React versions will cause issues.
fix Pin React to 0.13.x - 0.15.x, or move away from coffee-react.
npm install coffee-react
yarn add coffee-react
pnpm add coffee-react

Installs coffee-react globally, compiles a CJSX file to JavaScript using the cjsx command, then outputs the resulting JS.

npm install -g coffee-react@5.0.1
cat <<EOF > component.cjsx
MyComponent = React.createClass
  render: ->
    <div className="greeting">
      Hello, {if @props.name? then @props.name else 'World'}!
    </div>
EOF
cjsx -c component.cjsx
cat component.js