Code Monkey home page Code Monkey logo

coffee-react's Introduction

jsdf

github pages

coffee-react's People

Contributors

benjie avatar jsdf avatar mtscout6 avatar nfour avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coffee-react's Issues

displayName not automatically set

Hey there — Thanks for creating this compiler. I'm blown away with how it just works seamlessly and gives me the best from both CoffeeScript and React.js. One feature is missing though:

The official JSX syntax sets the displayName property automatically. This behavior isn't carried over to coffee-react which makes debugging with the react debug tools harder because you manually have to set this property on every single component.

See this ticket on the official react.js repo for more info: facebook/react#2447

Spread operator doesn't evaluate internals

As per CoffeeScript's default behavior of evaluating statements, I was surprised to find that the following statements within a spread operator result in the CJSX error: SyntaxError: Unexpected end of input: unclosed CJSX_EL

render: ->
  foo = "bar"
  <SomeComponent {...{foo}}/>
render: ->
  foo = "bar"
  <SomeComponent {...({foo})}/>
render: ->
  foo = "bar"
  <SomeComponent {...(do -> {foo})}/>

Expected output is for a structured assignment of { foo: foo } and passing that result to the spread method.

Error: Cannot find module 'mkdirp'

Error: Cannot find module 'mkdirp' after installing cjsx on osx and node 0.11.4. Worked fine after installing mkdirp but maybe this should be included in the package.json

Cannot require .litcoffee files that contain lone single quotes in Markdown

foo.cjsx:

require './bar'

bar.litcoffee:

Won't work:

    console.log "Hello world"

Run cjsx foo.cjsx

Error:

TypeError: Cannot read property '0' of null
  at Parser.module.exports.Parser.csString (/PATH/node_modules/coffee-react-transform/lib/parser.js:108:44)
  at Parser.module.exports.Parser.parse (/PATH/node_modules/coffee-react-transform/lib/parser.js:49:141)
  at module.exports.transform (/PATH/node_modules/coffee-react-transform/lib/transformer.js:9:33)
  at Object.CoffeeScript.compile (/PATH/node_modules/coffee-react/lib/coffee-react-script.js:21:13)
  at Object.CoffeeScript._compileFile (/PATH/node_modules/coffee-react/lib/coffee-react-script.js:32:29)
  at Object.loadFile (/PATH/node_modules/coffee-react/lib/register.js:14:25)
  at Module.load (/PATH/node_modules/coffee-react/lib/register.js:44:34)
  at Function.Module._load (module.js:310:12)
  at Module.require (module.js:365:17)
  at require (module.js:384:17)
  at Object.<anonymous> (/PATH/foo.cjsx:1:1)
  at Object.<anonymous> (/PATH/foo.cjsx:1:1)
  at Module._compile (module.js:460:26)

Remove the single quote and it works:

bar.litcoffee:

Will work:

    console.log "Hello world"

No context for unclosed element errors

Given unclosed.cjsx:

1 <div>
2  <div>
3 </div>

Running

$ cjsx unclosed.cjsx

Yields

SyntaxError: Unexpected end of input: unclosed CJSX_EL

With no line numbers.

For comparison, the latest Babel-powered jsx yields:

Unterminated JSX contents (3:6)
  1 | <div>
  2 |   <div>
> 3 | </div>
    |       ^

Probably related to #28

Custom element is not supported.

sample.coffee

class Button
  render: =>
    super <paper-button className="rui-button rui-form-control" onClick={@buttonClicked}>{text}</paper-button>

is translated to sample.js

// Generated by CoffeeScript 1.8.0
var Button,
  __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };

Button = (function() {
  function Button() {
    this.render = __bind(this.render, this);
  }

  Button.prototype.render = function() {
    return Button.__super__.render.call(this, React.createElement(paper - button, {
      "className": "rui-button rui-form-control",
      "onClick": this.buttonClicked
    }, text));
  };

  return Button;

})();

Note that the React.createElement doesn't give the right output.

is production ready?

Coffee-React look awesome but it has only 92 stars
⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐

can i use it in my next project?

Can the compile method return a map?

Running this from the command line I can pass the -m flag and it will produce a source map. e.g. cjsx -cm will produce both the .js file and the source map file.

However; running this in a node (in fact Jest) context I want to do:

const coffeereact = require('coffee-react');
var compiled = coffeereact.compile(src, {bare: true, map: true});

And have complied have both the compiled JS code and the source map. I want to do this so I can write the source map to the file system for later use.

At the moment putting the map: true option in this context seems to have no effect.

I'm not sure if this is possible? Or if not - perhaps this is a feature request?

.bind(this)?

Im use "qwest" library (github.com/pyrsmk/qwest) for load data from server.
Before (not coffee script) I wrote:

qwest.get("/api/getData")
    .then(function(response){
        this.setState({data: response})
    }.bind(this))

And this will work.

In coffeeScript I wrote:

qwest.get("/api/getData")
    .then (response) -> 
          this.setState({data: response})
    .bind(this)

And this dont work

I'm sure problem in .bind(this), because after compile i will get this js:

qwest.get("/api/getData")
     .then(function(response) {
              return this.setState({
                conf: response
              });
          }).bind(this);

.bind() is not in front of a square bracket

Tabs don't count as whitespace

When using tabs for indentation, code like this

<Text style={styles.welcome}>
    Welcome to React Native!
</Text>

compiles to

React.createElement(Text, {
      "style": styles.welcome
    }, "\t\t\t\tWelcome to React Native!")

which messes up the layout

Getting unexpected indentation errors while nesting tags and aligning tag attributes

Hi,

I just ran into unexpected indentation errors while aligning tag attributes vertically within a cjsx file.

React = require "react"

Example = React.createClass
  render: ->
    <div
      foo="bar"
      >
      <div
        bar="foo"
        >
      </div>
    </div>

React.render <Example />, document.getElementById "app"

gives me the following error:

unexpected indentation while parsing file: /path/to/js/app.cjsx

This is while using it through coffee-reactify. Using the cjsx command line tool, however, shows an error too:

/path/to/js/app.cjsx:11:7: error: unexpected indentation
      )
      ^

Trying a by-hand-conversion of the example online with the [https://facebook.github.io/react/jsx-compiler.html](live react compiler):

var React = require("react");

var Example = React.createClass({
  render: function () {
    <div
      foo="bar"
      >
      <div
        bar="foo"
        >
      </div>
    </div>
  }
});

React.render(<Example />, document.getElementById("app"));

does not reveal any errors so I guess it is not an error within jsx but within cjsx..

Version information:

$ ./node_modules/coffee-reactify/node_modules/.bin/cjsx -v
coffee-react version 3.0.1
coffee-react-transform version 3.0.1
coffee-script version 1.9.1

Multiple base files with -c command

It'd be great to be able to do:

cjsx -c --output build app.cjsx app2.cjsx

with:
.
+-- builds
| + app.js
| + app2.js

as the output. At least personally I have two different root files and would like to be able to compile them both off the same command. Right now I have to use gulp to compile them separately.

New here!

Hi there,

I was googling for "react coffeescript" and this is what I got.

So I'm wondering what the difference is between using coffeescript to write React components and classes and using this package?

Warning with React 15

When using CJSX with React 15, a warning is issued:

Warning: React.__spread is deprecated and should not be used.

ReactClass does not have the displayName property?

I use 'coffee-react' compile my *.cjsx files , and the compiled .js files are ok. But , in the complied .js files, ReactClass does not have the displayName property. Then in chrome dev tools with FaceBook React Developer Tools, I can't see the components name.
1

Spread Operator Fails On Inline Function Calls

The following code:
<div {...f(x, b)}></div>
generates an error at compile time.
It compiles fine using babel, and <div {...f(x)}></div> compiles just fine.

As another (less minimal) example:

<div
  label={t 'audience'}
  {...@bindState('name', @_updateName)}
/>

compiles but then produces

// Generated by CoffeeScript 1.9.3
(function() {
  React.createElement("div", {
    "label": t('audience'),
    "bindState": true,
    "State": true,
    "name": true,
    "me": true,
    "_updateName": true,
    "e": true
  });

}).call(this);

which makes no sense.

`style={color: 0xfff}` planned?

style={color: 0xfff} seems pretty natural as js allows 0xfff. I like that notation better than using a string '#fff'. There wouldn't be a time when you'd give color a single pixel value (ie color: 4095px would never happen, so it should be safe)

Actually to use this notation of passing a number as a color, you'd have to enforce always using 6 digits, as you wouldn't know the difference between 0xfff and 0x000fff.

Can coffee-react be used directly in a Browser?

As coffee-script, browsers use /extras/coffee-script.js with tag <script src="text/coffeescript> to write or reference to coffeescript directly in a browser. Can coffee-react do the same currently?

Release coffee-react-jstransform

I am willing to 'maintain' it, I'm a student and so I don't have much time, but right now, we need some little fixes.

The coffee-react-jstransform package is not even public at all, by a little 'reverse engineering' on dist/js-syntax-transform.js it seems like it embedded an ESPrima compiler with JSX syntax enabled and some unknown wrapper located at the bottom of the script.

CoffeeScript is not dead. The contributors are doing very hard to keep the pace of CoffeeScript up to date. Hopefully, we can also keep CJSX alive, even it was abandoned, we should have picked up the ashes, such good infrastructure should not be made to waste.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.