Unable to run transformed jsx to js file in browser. Asking for in browser jsxtransformer

356 Views Asked by At

I am trying to use reactify for jsx transformation and I have done the transformation from jsx to regular js using reactify. But when I try to run my transformed js file, it's somehow not showing the content. But when I import in browser jsxtransformer then it's showing the content. I am not able to understand the error in my procedure. If someone knows about it, please help me. Thank You..

1

There are 1 best solutions below

1
On

As the documentation states, in-browser transpiling has been removed from Babel, however Daniel15 has created a standalone build for use in "non-Node.js environments including browsers" here:

https://github.com/Daniel15/babel-standalone

All you need to do is add this reference to your page: <script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.4.4/babel.min.js"></script>

And then make sure you're using the type="text/babel" attribute in your references to other script files, for example:

<script type="text/babel" src="scripts/myReactComponent.jsx"></script>