客户端JSX转换 [英] Client-side JSX transpiling

查看:121
本文介绍了客户端JSX转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用JSX创建React应用程序,而不必使用终端或任何服务器端/开发环境命令.我们使用的环境不允许在开发环境中运行命令,而这些应用程序将完全静态地托管在CDN上.

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.

所以我知道我可以简单地将Babel的browser.js包含在浏览器中进行JSX转换.完美的.我担心的是Babel显然已停止支持此功能,而Babel的现代版本已将其删除.还有其他解决方案吗?我应该使用 babel-standalone 吗?

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?

我完全理解在生产环境中使用此功能会带来的性能损失,但是我们的用例(我无法想象这与拥有这么多出色而简单的在线HTML/JS IDE的用例不同寻常)允许了这种情况. /p>

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.

推荐答案

是的,如果您不想捆绑自己的文件,请 Babel-standalone 是您应该使用的. 请参见官方文档:
我在"codepen like"演示项目中使用上面链接中的CDN,并且工作正常.

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.

这篇关于客户端JSX转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆