perf(unplugin-dts): optimize watch rebuilds - #487
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
概述
优化 TypeScript 项目在 watch 模式下的 Program 重建和文件监听生命周期,同时补齐跨 bundler 的新增、删除、重命名与输出目录隔离行为。
该 PR 只包含 TypeScript watch 与通用 watcher 基础设施,不包含后续 Vue/Volar 生命周期调整,也不改变公开 API 或选项。
主要变更
性能结果
冻结的 7 组配对 A/B benchmark 中:
480 文件公共依赖场景中,watchChange 的下降部分确实转移到了 buildStart;但 transform 从 38.9ms 降至 0.6ms,writeBundle 从 306.5ms 降至 203.4ms,关键路径归因合计从 511.7ms 降至 359.6ms。SourceFile identity 观测显示 566/567 个 SourceFile 被复用。
正确性与验证
pnpm --filter unplugin-dts test:PR1 独立状态 11 files / 78 tests passed。git diff --check通过。pnpm build通过。playground/ts-vite和原有playground/vue-vite构建通过。已知边界
纯 Rollup/Rolldown 在递归源码目录与输出目录重叠时继续 fail-close,避免生成文件形成无限 rebuild;这种布局下,未被引用的新文件可能需要调整目录布局或重启 watcher。