petehunt / node-jsx

transparently require() jsx from within node
164 stars 32 forks source link

Please create better documentation on main page #39

Open dschinkel opened 9 years ago

dschinkel commented 9 years ago

I know you may take it for granted and are seasoned at node + react, but on your main page can you explain the use case for this? I want to know what this gives me, not just how to use it. And being new to this, it's not that evident as you have no description and I cannot just infer by the usage why I should require jsx in my code for react. Just for newbies you need to have a little more explanation.

alejandrosanabriav commented 9 years ago

Right here there a example how use it http://www.smashingmagazine.com/2015/04/21/react-to-the-future-with-isomorphic-apps/

dschinkel commented 9 years ago

Just asking for you to put up bit of info up front like most open source projects do... I that article explains nothing to what your module's use case.

On Apr 21, 2015, at 10:53 PM, Alejandro Sanabria notifications@github.com wrote:

Right here there a example how use it http://www.smashingmagazine.com/2015/04/21/react-to-the-future-with-isomorphic-apps/

— Reply to this email directly or view it on GitHub.

zpnk commented 9 years ago

Hi @dschinkel,

With how small this module is, the usage info in the readme really is sufficient. There just isn't much more to add docs for. (The entire module is only 34 lines)

As far as why you would want/need to use this, the statement:

Transparently require() jsx from node.

kind of sums it up.

The problem this module solves is that Node cannot parse jsx files due to the syntax. If you try to require a file with jsx syntax, it will freak out. However, when working with React components on the server (such as with isomorphic apps) you will find that you do need to require jsx files, most likely to render them and send the html to the client. In order to require them without errors, you have a few options: 1) compile the jsx files to regular js first, then require that or 2) dynamically transform jsx files as they are required.

Node-jsx takes the latter, simpler approach which avoids having an extra build step on the server-side. If you already have a build process for your server, then you could just add jsx compilation there and not need to use this module. As the name implies, node-jsx is strictly for the server, and is not needed in the browser.

A quick note on usage the readme doesn't mention: The statement require('node-jsx').install() only needs to be included once, in your "entry" file. (Whatever you run to start the node process, ie: index.js, app.js, server.js, etc) I like to put it at the top, as the first line. Then it's pretty much set it and forget it.

Hope I was able to clear some things up. :)

dschinkel commented 9 years ago

Thanks Zack, your last paragraph answered what I was missing and could not infer. I am new to node and react so I would know know of that pain yet :)

On Apr 24, 2015, at 11:47 AM, Zach K notifications@github.com wrote:

Hi @dschinkel,

With how small this module is, the usage info in the readme really is sufficient. There just isn't much more to add docs for. (The entire module is only 34 lines)

As far as why you would want/need to use this, the statement:

Transparently require() jsx from node.

kind of sums it up.

The problem this module solves is that Node cannot parse jsx files due to the syntax. If you try to require a file with jsx syntax, it will freak out. However, when working with React components on the server (such as with isomorphic apps) you will find that you do need to require jsx files, most likely in order to render them and send the html to the client. In order to require them without errors, you have a few options: 1) compile the jsx files to regular js first, then require that or 2) dynamically transform jsx files when they are required.

Node-jsx takes the latter, simpler approach which avoids having an extra build step on the server-side. If you already have a build process for your server, then you could just add jsx compilation and not need to use this module. As the name implies, node-jsx is strictly for the server, and is not needed in the browser.

A quick note on usage the readme doesn't mention: The statement require('node-jsx').install() only needs to be included once, in your "entry" file. (Whatever you run to start the node process, ie: index.js, app.js, server.js, etc) I like to put it at the top, as the first line. It's pretty much set it and forget it.

Hope I was able to clear some things up. :)

— Reply to this email directly or view it on GitHub.