-
Notifications
You must be signed in to change notification settings - Fork 108
fix(update): async module update miss async deps #1437
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
Conversation
Walkthrough此次变更对 Changes
Sequence Diagram(s)sequenceDiagram
participant A as ModuleGraph
participant B as DependencyManager
participant C as Module
A->>B: 请求更新依赖
B->>C: 检查依赖变化
C-->>B: 返回变化信息
B->>A: 更新依赖状态
A->>A: 清除旧依赖
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (4)
- crates/mako/src/dev/update.rs (4 hunks)
- crates/mako/src/module.rs (2 hunks)
- crates/mako/src/module_graph.rs (1 hunks)
- scripts/test-hmr.mjs (1 hunks)
Additional comments not posted (15)
crates/mako/src/module_graph.rs (4)
108-114: 检查节点存在性在移除依赖边之前,函数首先检查起始节点是否存在。这是一个很好的做法,可以防止程序崩溃。
116-121: 检查目标节点存在性同样地,函数也检查目标节点是否存在。这是必要的,可以防止不必要的错误。
123-128: 移除依赖边函数尝试找到并移除依赖边。如果边不存在,什么也不做。这是一个合理的处理方式。
Line range hint
343-344:
使用新方法clear_dependency在移除依赖边时,使用了新方法
clear_dependency。这提高了代码的可读性和可维护性。crates/mako/src/module.rs (2)
38-42: 定义ResolveTypeFlags结构体结构体使用
bitflags!宏定义,包含两个标志:Sync和Async。这是一个合理的实现方式。
60-67: 实现From<&ResolveType>转换实现合理地将
ResolveType::DynamicImport和ResolveType::Worker映射到Async标志,其他所有ResolveType值默认映射到Sync标志。crates/mako/src/dev/update.rs (7)
428-431: 定义Diff结构体结构体包含三个字段:
added、removed和modified。这是一个合理的实现方式。
434-446: 检查依赖变更函数首先检查是否有新增或删除的依赖。这是一个合理的做法,可以快速确定是否有依赖变更。
448-470: 比较新旧依赖函数使用
HashMap来比较新旧依赖。这种方法提高了比较的效率和清晰度。
478-501: 比较依赖列表的差异函数通过集合操作来确定新增、删除和修改的依赖。这种方法简化了逻辑,提高了性能。
324-330: 构建模块并比较依赖函数通过并行迭代构建模块,并比较新旧依赖。这种方法提高了性能。
Line range hint
337-388:
更新依赖关系函数更新模块图中的依赖关系,确保依赖关系的准确性和一致性。
476-496: 移除模块及其依赖函数移除模块及其依赖,并更新模块图。这种方法确保了模块图的准确性和一致性。
scripts/test-hmr.mjs (2)
1529-1537: 确保测试覆盖所有必要场景测试用例设置了G2库的配置,验证其加载情况,并在重新加载后检查HTML内容。请确保测试覆盖了所有必要的场景,例如G2库加载失败的情况。
1556-1571: 验证所有断言的正确性请确保所有断言都正确无误。例如,
assert.match(lastResult.html, /g2 loaded/);和assert.match(thisResult.html, /Update Success/, 'after reload');都需要验证。Verification successful
验证所有断言的正确性
已确认所有断言都正确无误。以下是找到的断言:
assert.match(lastResult.html, /g2 loaded/);assert.match(thisResult.html, /Update Success/, 'after reload');这些断言在测试中检查了特定的HTML内容,验证了预期条件。
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all assertions in the "async module update" test case. # Test: Search for the assertions in the test case. Expect: All assertions to be correct. rg --type javascript -A 5 $'assert.match'Length of output: 75
Script:
#!/bin/bash # Description: Verify all assertions in the "async module update" test case. # Test: Search for the assertions in the test case. Expect: All assertions to be correct. rg 'assert.match' -A 5 scripts/test-hmr.mjsLength of output: 374
Problem
Dependence数据需要记录 import source 的 span,用来给 aysnc module 定位需要转换哪句 import 语句;Solution
update 时更新 modified module 所有 edge 上的 Dependence 信息
Summary by CodeRabbit
新功能
ResolveTypeFlags结构,增强同步与异步状态标记功能。clear_dependency方法,以便更方便地移除模块之间的依赖关系。测试
@antv/g2库的异步导入行为及版本更新。