-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: rax jsx runtime #2101
base: master
Are you sure you want to change the base?
feat: rax jsx runtime #2101
Conversation
songzheng seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
这个包直接打在 rax 里就好了吧? |
jsx runtime应该避免使用者对具体jsx库的感知。由编译器自动引入 |
react 现在是怎么做的? |
编译成这样是不是更好: 独立包造成的问题是,runtime 核心能力和 rax 核心包之间可能存在版本差异问题,以及开发者是否感知到这个包的版本 |
react是在react package里,已放入jsx-runtime放在rax包中。 |
|
This module is adapted to react's jsx-runtime module. Implement Babel's "automatic" JSX runtime API: * 1.jsx(type, props, key) * 2.jsxs(type, props, key) * 3.jsxDEV(type, props, key, __source, __self)
react实现中:jsxs是jsx完全等价的别名哈 |
我指的不是生产模式 |
} | ||
} | ||
|
||
return { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最后返回 RaxElement 是不是更好点
我来处理,目前是为了体积进行了最小实现,忽略了DEV环境下 |
可以通过环境变量移除掉 DEV 的代码 |
1.jsx-runtime和createElement组织结构保持一致 2.区分环境导出不同jsx-runtime,和react一致
1.jsx-runtime和createElement组织结构保持一致 2.区分环境导出不同jsx-runtime,和react一致
1.jsx-runtime和createElement组织结构保持一致 2.区分环境导出不同jsx-runtime,和react一致
packages/rax/jsx-dev-runtime.js
Outdated
@@ -0,0 +1 @@ | |||
export {Fragment, jsxDEV} from './index'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
大括号前后加个空格 export { Fragment }....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok,不过npm run lint:fix
似乎没有自动修正这个style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
仓库有点老,没敢升级新的 lint 规则 =。=
packages/rax/jsx-runtime.js
Outdated
@@ -0,0 +1 @@ | |||
export {Fragment, jsx, jsxs, jsxDEV} from './index'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
writable: true, | ||
value: __self | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里抽成一个 utils,避免浪费体积
packages/rax/src/jsx-runtime.js
Outdated
return _jsxWithValidation(type, props, key, true, __source, __self); | ||
} | ||
|
||
const jsx = __DEV__ ? jsxWithValidation : jsxRuntime; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jsxWithValidation
用额外的文件实现,避免最后生产代码里还遗存
优化构建体积
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
整体没啥大的问题了,这两天我来切个 next 分支
export function jsxWithValidation(type, props, key) { | ||
return _jsxWithValidation(type, props, key, false); | ||
} | ||
export function jsxsWithValidation(type, props, key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的函数命名可以参考 React,可读性更强一点
修改jsxValidator导出的命名
修改jsxValidator导出的命名
ok,到时我逐步提供为Rax App提供一个jsx-runtime的版本 |
rax 近期能发一个支持jsx-runtime 的版本吗 |
期待有更多rax的文档 ,而非rax-app的文档 |
双十二之后发布 |
您好,最近这个有推进吗?已经3月了哦 |
Support jsx-runtime
This module is adapted to react's jsx-runtime module. For more information, please see:introducing-the-new-jsx-transform
usage