zh-lx / code-inspector

Click the dom on the page, it will open your IDE and position the cursor to the source code location of the dom.
https://inspector.fe-dev.cn/en
MIT License
1.52k stars 113 forks source link

性能优化 #111

Closed PeterChen1997 closed 5 months ago

PeterChen1997 commented 5 months ago

感谢开发这个插件,功能很赞

我在大型项目中遇到一个问题,如果组件非常多,编译耗时明显增加,这块后面会考虑增加缓存之类的优化方案吗🤔

zh-lx commented 5 months ago

对于性能问题(针对 webpack 项目)可以有以下优化方向:

  1. 如果热更新时有性能影响,那大概率是因为插件优先于 eslint-loader 或者 prettier 执行引起它们热更新时二次执行,可以设置 enforcePre: false 让插件后执行。参照enforcePre
  2. 对于冷启动,插件目前兼容全部可能 jsx 类型的文件,即针对 vue|jsx|tsx|js|ts|mjs|mts 后缀类型的文件都会检测编译,可以通过 match api 自己设置正则以排除不必要的文件类型,参照 match
  3. 冷启动时,对于缓存策略为 cache: { type: 'filesystem' } 的 webpack项目,插件为了保证交互注入逻辑通信端口和启动的 node 服务端口一致,会强制不走缓存,这一点目前木办法优化

可以针对自己的项目进行排查应用优化策略

PeterChen1997 commented 5 months ago

好咧感谢,我看一下

zh-lx commented 5 months ago

好的,暂时先关闭了,有上述方案无效欢迎进群进一步反馈