travelboy
travelboy

Reputation: 2697

Simple dev stack for React and JSX with ES5

I am starting out with React and I'd like to write my app in ES5. I have created an html with script tags for react.min.js, react-dom.min.js and my own app.js file. Now what do I need to do in order to be able to write JSX in my JavaScript file?

  1. Would the preprocessing (JSX into JS) typically be done on the server? Or is there a way to do it on the client?
  2. I would like to keep my development stack simple. Do I have to look into webpack or is there a simpler way to handle JSX (e.g. by npm script or through express)?
  3. Everyone seems to be using babel. Can I do without it if I write plain old ES5?

P.S: I will use NodeJS and Express on the server side to deliver the app.

Upvotes: 1

Views: 311

Answers (1)

damianfabian
damianfabian

Reputation: 1681

I would try to answer as detail as possible your questions:

  1. You could transpile JSX on server with Browserify and save some time, React will add a flag to all their components to mark the components as rendered in Server, but what most of the people is doing now is using webpack to transpile all the code before to run your application. You could do it on the client too, but I would suggest you to compile before to run your application.
  2. You could use browserify with npm to transpile your code together with babel before to run you
  3. Yes you can as soon as your explorer and your client's explorer support ES5, if not you will get an error and nothing will work, that's why everyone is using babel to support ES5 or ES6 in mostly all the browsers.

Hope this help you!

Upvotes: 1

Related Questions