PHP Library for JSX Compilation
I have used the following code for importing React JavaScript library and JSX compiler:
<script src="build/react.js"></script>
<script src="build/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js">
</script>
I want to compile JSX using a server-side library, instead of using
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js">
</script>
Which is around 1MB. So, is there any PHP Library available for JSX Compilation?
Answer
You really shouldn't be using Babel in the browser. Take the time to learn how to set up a build environment that uses Babel to precompile your JavaScript. The typical workflow uses Babel in conjunction with either Webpack or Browserify to bundle your modules.
Official documentation:
If you need React server side rendering within a PHP backend, you might like to check out https://github.com/reactjs/react-php-v8js. It doesn't do JSX compilation, just server side rendering. So you still need to precompile your JavaScript.
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?