Skip to content
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: 添加 react 代码性能优化转换 #261

Merged
merged 1 commit into from
Feb 24, 2022
Merged

feat: 添加 react 代码性能优化转换 #261

merged 1 commit into from
Feb 24, 2022

Conversation

LeuisKen
Copy link
Member

参考如下 issue 引入了两个 babel plugin:

用本地项目测了一下,terser 产物的体积会有非常小的增加,不会导致什么实质影响。

@vercel
Copy link

vercel bot commented Feb 17, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/ecomfe/reskript/H2Brsvr2pUSbmKs9ZqhaX3vQsv1Q
✅ Preview: https://reskript-git-fork-leuisken-master-ecomfe.vercel.app

@otakustay
Copy link
Member

解决一下CI问题,应该是少类型定义

@@ -59,6 +61,12 @@ export default (options: BabelConfigOptionsFilled): TransformOptions => {
pluginThrowExpressions,
pluginDynamicImport,
pluginImportMeta,
// https://babeljs.io/docs/en/babel-plugin-transform-react-constant-elements
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这2个插件不应该加在parseOnly里,parseOnly顾名思义是只用来做语法解析的,比如给eslint用。

babel配置一共有3层:

  1. parseOnly:只做解析,不做转换用,给lint、jest等工具
  2. transformMinimal:做代码转换,但不做激进的优化,基本只用于skr babel输出
  3. transform:全量的优化,代码在index.ts

所以你需要在那边加这些插件

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的,不过好奇怪为啥 CI 又挂了

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

超时了,可以先不管

@otakustay
Copy link
Member

下次提交的时候记得rebase master一下,我把CI修了把,应该更容易跑通了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants