-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
fix: when code has declare @jsx createElement comment, swc config runtime: 'classic' #5976
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@ice/plugin-rax-compat': major | ||
--- | ||
|
||
- [fix] Using runtime: 'classic' mode when source has declare `@jsx createElement` comment |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,7 +69,18 @@ const plugin: Plugin<CompatRaxOptions> = (options = {}) => ({ | |
config.swcOptions = merge(config.swcOptions || {}, { | ||
compilationConfig: (source: string) => { | ||
const isRaxComponent = /from\s['"]rax['"]/.test(source); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. package 里面 version 加一下,changelog 补充 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 用 changeset 流程:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. push了 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
这个好像还没有补充到 CONTRIBUTING.md 中 |
||
if (isRaxComponent) { | ||
const hasJSXComment = source.indexOf('@jsx createElement') !== -1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个检测可以卸载判断条件内部,提升效率 |
||
if (hasJSXComment) { | ||
return { | ||
jsc: { | ||
transform: { | ||
react: { | ||
runtime: 'classic', | ||
}, | ||
}, | ||
}, | ||
}; | ||
} else if (isRaxComponent) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hasJSXComment 的逻辑放在 isRaxComponent 吧,这个逻辑只在 rax 下生效。 |
||
return { | ||
jsc: { | ||
transform: { | ||
|
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.
按照卓凌提的来就好了,这个不需要手动提交了