Client-side JSX transpiling

元气小坏坏 提交于 2019-12-11 14:10:35

问题


I want to create React applications with JSX and not have to use a terminal or any server-side/dev environment commands. The environment we are using doesn't allow for commands to be run in the dev environment and these applications will be purely statically hosted on a CDN.

So I know I can simply include Babel's browser.js to do the JSX transpiling in the browser. Perfect. My concern is that Babel apparently stopped supporting this and modern versions of Babel have it removed. Is there another solution? Is babel-standalone what I should be using?

I fully understand the performance penalties in using this in production, but our use case (which I can't imagine is that unusual of a use case with so many great and simple online HTML/JS IDEs) allows for this.


回答1:


Yes if you don't want to bundle your own files, babel-standalone is what you should use. See prototyping on the official documentation:
I'm using the CDN from the links above in a "codepen like" demo-project, and it works fine.



来源:https://stackoverflow.com/questions/38577282/client-side-jsx-transpiling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!