reactjs - Is there any way of using JSX in a native CommonJS environment? -


I am launching a new project in an environment that includes native CommonJS support Module is required - This is an atom-shell project, there is no possibility of using pre-compiling steps in such browser-style or webpage AFAIK

I have enabled Because of my app.jsx declaration on my index.html to use JSX on the entry point file JSXTransformer was previously declared:

  & lt; Script src = "script / vendor / JSXTransformer.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / jsx" src = "script / app.jsx" & gt; & Lt; / Script & gt;  

I want to use JSX syntax for my module which are imported as a common JS module inside my app.jsx module:

  // This raises an error, tags like XML are not supported var grid = required ('./scripts / grid.jsx') ;  

As far as I understand, I will be forced to leave the JSX syntax and vanilla syntax for any modules loaded through the requirement Will have to go with. Are there any alternatives to using JSX in this situation?

[update]

Now that JSX Transformer, you can use the babel to support JSX in a common JS environment:

use

 Requires  ("Babel / Register");  

All later files needed for the node with the extension .es6 , .es , .jsx And .js will be changed by the bubble. This is also automatically required.

Note: By default all node_module will be ignored. You can override it by ignoring the ridge:

  ("Babel / Register") ({// This `node_module` Ignore - you can optionally match an array of // stars or ignore a regex / glob: incorrect}); If this is a node. JS is environment (like atom-shell) so you can use it. :  Requires 
  ('node-jsx'). Install () is required (". / MyComponent.js");  

You can also use the .jsx extension if you want:

 < Code> Required ('node-jsx'). Install ({extension: '.jsx'}) is required ("./ myComponent.jsx");  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -