Skip to content

Instantly share code, notes, and snippets.

@yorkxin

yorkxin/README.md

Last active Mar 1, 2016
Embed
What would you like to do?
CJSX (CoffeeScript + JSX) to ES6

(Not) CJSX to ES6 converter

It does noly convert a small set of codes into ES6. You sill need to edit the file.

Usage

find ./components -name "*.cjsx" -exec ./converter.sh {} \;
s/(.+) = require[(]? ?(.+)[)]?/import \1 from \2;/
s/module.exports = /export default /
s/React.createClass//
s/ displayName: "([A-Za-z0-9]+)"/class \1 extends React.Component {/
s/@/this./g
s/ (.+): ?->/ \1 () {/
s/ (.+): \((.+)\) ?->/ \1 (\2) {/
s/\((.+)\) ->/function (\1) {/
#!/bin/sh
cjsx=$1
jsx=`echo $cjsx | sed 's/.cjsx/.jsx/'`
sed -E -f coffee2es6.sed $cjsx > $jsx
rm $cjsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment