refactor: improve logic to set react jsx type #681
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
优化 React JSX 类型的识别逻辑,以满足某些场景下依赖声明里不存在 react 的场景(比如使用
@emotion/react
),以及某些场景下不需要转换 React JSX 的场景,详细差异如下:改动前:先判定是否存在 react 的依赖声明,再优先使用 tsconfig 的 jsx 设置,最后兜底根据 react 版本号决定 jsx 设置,无论如何都会启用
@babel/preset-react
改动后:优先使用 tsconfig 的 jsx 设置,再根据 react 版本号决定 jsx 设置,如果两者都不存在则不会启用
@babel/preset-react