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: add batch for watcher change event #662

Merged
merged 1 commit into from
Oct 31, 2024
Merged

Conversation

XGHeaven
Copy link
Collaborator

主要修了两个问题

  • watcher 监听文件的事件没有 batch,导致同时修改多个文件的话会同时重新编译多次,这里手动加了 250ms debounce,暂时不支持配置,后续打算重构这块
  • watcher 需要等待第一次启动成功启动后,才能触发相应的事件,否则会报常量未初始化的错误,这里加了一个 beginBlock/endBlock 的方法拦截一下,这期间的所有文件事件都会被缓存,直到第一次启动成功后调用 endBlock 再统一消费

@XGHeaven XGHeaven force-pushed the feat/batch-watcher-change branch from 65fcf92 to 01d289e Compare October 12, 2024 07:28
Copy link

pkg-pr-new bot commented Oct 12, 2024

Open in Stackblitz

More templates

@ice/create-pkg

pnpm add https://pkg.pr.new/ice-lab/icepkg/@ice/create-pkg@662

@ice/pkg-plugin-docusaurus

pnpm add https://pkg.pr.new/ice-lab/icepkg/@ice/pkg-plugin-docusaurus@662

@ice/pkg-plugin-jsx-plus

pnpm add https://pkg.pr.new/ice-lab/icepkg/@ice/pkg-plugin-jsx-plus@662

@ice/pkg

pnpm add https://pkg.pr.new/ice-lab/icepkg/@ice/pkg@662

@ice/pkg-plugin-rax-component

pnpm add https://pkg.pr.new/ice-lab/icepkg/@ice/pkg-plugin-rax-component@662

@ice/remark-react-docgen-docusaurus

pnpm add https://pkg.pr.new/ice-lab/icepkg/@ice/remark-react-docgen-docusaurus@662

ice-npm-utils

pnpm add https://pkg.pr.new/ice-lab/icepkg/ice-npm-utils@662

commit: 01d289e

@ClarkXia
Copy link
Contributor

重新编译多次是指全量文件吗

@XGHeaven
Copy link
Collaborator Author

@ClarkXia 这里指的是编译的链路。文件一次还是只编译一个的。比如我一次性改了 20 个文件,就会触发 20 次编译链路和相关的生命周期,会输出 20 次编译完成的 log。

整个编译链路还是很慢的,即使只有一个文件,尤其是带有别的插件的时候,现在是 batch 了,只走一次编译,会把变化的文件都编译了。

@XGHeaven XGHeaven merged commit c2b0b0e into main Oct 31, 2024
4 checks passed
@XGHeaven XGHeaven deleted the feat/batch-watcher-change branch October 31, 2024 02:47
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.

3 participants