reactjs / react-php-v8js

PHP library that renders React components on the server
Other
1.33k stars 127 forks source link

consider add JSX support? #11

Closed 18601673727 closed 9 years ago

zpao commented 9 years ago

Feel free to have a go at it. This isn't an actively supported project so we won't be adding that ourselves.

18601673727 commented 9 years ago

@zpao

Yeah, may I ask one question first? Directly put JSXTransformer.js into v8 will work or not?

Because I'm trying to modify the ReactJS.php file and Chrome says:

Unable to load the webpage because the server sent no data.

Here's the code what I changed:

...
$react[] = "var React = global.React";
// app's components
$transformer = file_get_contents('/Users/abc/php/public/js/react/JSXTransformer.js');
$react[] = $transformer;
$react[] = $appsrc;
$react[] = ';';
...

Thanks!

zpao commented 9 years ago

You can't just include JSXTransformer and have it work. You actually need to run JSXTransformer (or preferably Babel) server side to transform the JSX to plain JS so that it's actually executable. $appsrc needs to be turned from JSX to JS, which means another v8 context that needs to run. React-rails does this so you might be able to find some inspiration there.

18601673727 commented 9 years ago

You're right, the only way I could use for transpilation is node now, through it adds complexity to my project's architecture. Anyway I just found JSXTransformer is deprecated so this issue shall been closed and thanks very much for your time!