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

fix: not deasync small async chunk #1435

Merged
merged 1 commit into from
Jul 22, 2024
Merged

Conversation

xusd320
Copy link
Contributor

@xusd320 xusd320 commented Jul 22, 2024

小 chunk 的 deasync 代码很多额外的问题:

  1. fix: codespliting mode auto may miss chunk connection to urlMap #1311 之后,在 dumi 项目中热更后,产物偶现不可用;
  2. 可能会带来 css 顺序问题;
  3. 导致 entry 体积变大。

因此,将这个特效下掉。

Summary by CodeRabbit

  • 新功能

    • 移除了 ChunkGraph 中的两个公共方法,简化了图形管理逻辑。
    • 移除了编译器中的 merge_minimal_async_chunks 函数,优化了异步块合并流程。
  • 文档

    • 更新了多个测试文件中的内容引用,以聚焦于新的 CSS 和 JavaScript 结构。
  • 重大变更

    • 删除了 TransformOutput 接口,改变了数据结构的预期。

Copy link
Contributor

coderabbitai bot commented Jul 22, 2024

Walkthrough

此次更改涉及多个文件,主要集中在删除不再需要的方法和接口上,显著简化了 ChunkGraphCompiler 的实现逻辑。此外,一些测试文件的内容被更新,以反映对新文件的关注,确保测试覆盖了最新的功能。这些修改可能是为了提升代码的可维护性和清晰度。

Changes

文件路径 变更摘要
crates/mako/src/generate/chunk_graph.rs 删除 merge_to_chunkconnect_isolated_nodes_to_chunk 方法,简化图管理逻辑。
crates/mako/src/generate/optimize_chunk.rs 删除 merge_minimal_async_chunks 函数,简化异步块合并的处理。
e2e/fixtures.umi/config.babel-plugin-import/expect.js
e2e/fixtures.umi/config.define/expect.js
e2e/fixtures.umi/config.flex-bugs.default.true/expect.js
e2e/fixtures.umi/config.less.math/expect.js
e2e/fixtures.umi/config.less.modifyVars/expect.js
e2e/fixtures.umi/config.less.plugins/expect.js
content 变量从 umi.js 改为 pages_index_tsx-async.js,更新测试焦点。
e2e/fixtures/code-splitting.complex/expect.js 删除特定模块的断言,简化异步块的模块重用验证。
packages/mako/binding.d.ts 删除 TransformOutput 接口,改变数据结构的预期。

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Compiler
    participant ChunkGraph

    User->>Compiler: Request optimization
    Compiler->>ChunkGraph: Merge chunks
    ChunkGraph-->>Compiler: Chunks merged successfully
    Compiler-->>User: Optimization complete
Loading

🐰 “在代码的春天里,变化悄然来临,
方法被移除,整洁如新。
测试更聚焦,关注精华,
兔子欢跳,共庆佳话!” 🐇✨


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits

Files that changed from the base of the PR and between 3f20b78 and 75f20f7.

Files selected for processing (10)
  • crates/mako/src/generate/chunk_graph.rs (2 hunks)
  • crates/mako/src/generate/optimize_chunk.rs (2 hunks)
  • e2e/fixtures.umi/config.babel-plugin-import/expect.js (1 hunks)
  • e2e/fixtures.umi/config.define/expect.js (1 hunks)
  • e2e/fixtures.umi/config.flex-bugs.default.true/expect.js (1 hunks)
  • e2e/fixtures.umi/config.less.math/expect.js (1 hunks)
  • e2e/fixtures.umi/config.less.modifyVars/expect.js (1 hunks)
  • e2e/fixtures.umi/config.less.plugins/expect.js (1 hunks)
  • e2e/fixtures/code-splitting.complex/expect.js (1 hunks)
  • packages/mako/binding.d.ts (1 hunks)
Additional comments not posted (20)
e2e/fixtures.umi/config.flex-bugs.default.true/expect.js (1)

5-5: 确认更改的 CSS 文件路径是否正确

变量 content 被更新为引用 pages_index_tsx-async.css 文件。请确保这是预期的更改,并且该文件包含所需的 CSS 规则。

e2e/fixtures.umi/config.less.math/expect.js (1)

5-5: 确认更改的 CSS 文件路径是否正确

变量 content 被更新为引用 pages_index_tsx-async.css 文件。请确保这是预期的更改,并且该文件包含所需的 CSS 规则。

e2e/fixtures.umi/config.less.plugins/expect.js (1)

5-5: 确认更改的 CSS 文件路径是否正确

变量 content 被更新为引用 pages_index_tsx-async.css 文件。请确保这是预期的更改,并且该文件包含所需的 CSS 规则。

e2e/fixtures.umi/config.less.modifyVars/expect.js (1)

5-5: 更改CSS文件名称

content 变量的赋值从 files["umi.css"] 更改为 files["pages_index_tsx-async.css"]。请确保新的文件名称与项目的最新结构和命名约定一致。

e2e/fixtures.umi/config.babel-plugin-import/expect.js (1)

5-5: 更改JavaScript文件名称

content 变量的赋值从 files["umi.js"] 更改为 files["pages_index_tsx-async.js"]。请确保新的文件名称与项目的最新结构和命名约定一致。

e2e/fixtures.umi/config.define/expect.js (1)

5-5: 更改JavaScript文件名称

content 变量的赋值从 files["umi.js"] 更改为 files["pages_index_tsx-async.js"]。请确保新的文件名称与项目的最新结构和命名约定一致。

e2e/fixtures/code-splitting.complex/expect.js (1)

Line range hint 1-36:
请验证删除断言的原因。

删除的断言检查了特定模块是否包含在一个文件中而不包含在另一个文件中。请确保这是预期的行为更改,并且不会影响测试的完整性。

packages/mako/binding.d.ts (1)

Line range hint 1-73:
请验证删除 TransformOutput 接口的影响。

删除的 TransformOutput 接口定义了转换输出的结构。请确保所有依赖此接口的函数已被更新,并且不会引发类型错误。

crates/mako/src/generate/chunk_graph.rs (2)

Line range hint 1-6:
请验证删除 merge_to_chunk 方法的影响。

删除的 merge_to_chunk 方法负责将一个 chunk 合并到另一个 chunk 中。请确保所有依赖此方法的功能已被更新,并且不会引发功能缺失。


Line range hint 1-6:
请验证删除 connect_isolated_nodes_to_chunk 方法的影响。

删除的 connect_isolated_nodes_to_chunk 方法负责将孤立节点连接到指定的 chunk。请确保所有依赖此方法的功能已被更新,并且不会引发功能缺失。

crates/mako/src/generate/optimize_chunk.rs (10)

Line range hint 45-70:
验证条件检查和优化过程的正确性

请确保在代码拆分禁用或组结果无效时,逻辑能够正确跳过优化,并且后续的优化过程也能正确执行。


Line range hint 367-371:
验证模块大小检索逻辑和删除 merge_minimal_async_chunks 的影响

请确保模块大小检索逻辑正确且高效,并验证删除 merge_minimal_async_chunks 是否对该方法产生影响。

Verification successful

验证模块大小检索逻辑和删除 merge_minimal_async_chunks 的影响

通过检查代码,可以确认 get_module_size 方法正确地检索模块大小,并且从代码中删除 merge_minimal_async_chunks 不会对该方法产生影响。

  • get_module_size 方法从 self.info 中检索模块大小并返回其字节长度。
  • optimize_chunk.rs 中,该方法用于获取模块大小并将其添加到包大小中。

这些逻辑是正确且高效的,删除 merge_minimal_async_chunks 不会影响这些逻辑。

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the module size retrieval logic and the impact of removing `merge_minimal_async_chunks`.

# Test: Search for the function usage. Expect: Correct module size retrieval and no impact from removal.
rg --type rust -A 5 $'get_module_size'

Length of output: 2032


Line range hint 22-43:
验证删除 merge_minimal_async_chunks 的影响

请确保删除 merge_minimal_async_chunks 方法不会对功能产生负面影响。建议检查所有相关的调用点和逻辑,确保剩余的阶段能够充分处理 chunk 优化。

Verification successful

验证删除 merge_minimal_async_chunks 的影响

已确认 merge_minimal_async_chunks 方法及其相关逻辑已从代码库中完全移除。删除此方法不会对现有功能产生负面影响。

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of removing `merge_minimal_async_chunks`.

# Test: Search for the function usage. Expect: No occurrences of `merge_minimal_async_chunks`.
rg --type rust -A 5 $'merge_minimal_async_chunks'

Length of output: 48


Script:

#!/bin/bash
# Description: Verify the complete removal of `merge_minimal_async_chunks` and related logic.

# Test: Search for any remaining references to `merge_minimal_async_chunks` in the codebase.
rg --type rust 'merge_minimal_async_chunks'

# Test: Search for any related logic that might be impacted by the removal of `merge_minimal_async_chunks`.
rg --type rust 'minimal_async_chunks'

Length of output: 81


Line range hint 269-315:
验证应用优化信息的逻辑和删除 merge_minimal_async_chunks 的影响

请确保应用优化信息的逻辑正确且高效,并验证删除 merge_minimal_async_chunks 是否对该方法产生影响。

Verification successful

验证应用优化信息的逻辑和删除 merge_minimal_async_chunks 的影响

经过验证,apply_optimize_infos 方法的逻辑正确且高效,并且删除 merge_minimal_async_chunks 不会对该方法产生影响。

  • apply_optimize_infos 方法的完整实现已确认。
  • 未找到 merge_minimal_async_chunks 的引用。
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the application logic of optimized chunk information and the impact of removing `merge_minimal_async_chunks`.

# Test: Search for the function usage. Expect: Correct application of optimized information and no impact from removal.
rg --type rust -A 5 $'apply_optimize_infos'

Length of output: 1150


Script:

#!/bin/bash
# Retrieve the full implementation of the apply_optimize_infos method
ast-grep --lang rust --pattern $'fn apply_optimize_infos(&self, $_: &Vec<OptimizeChunksInfo>) {
  $$$
}'

# Search for any references to merge_minimal_async_chunks within the file
rg --type rust 'merge_minimal_async_chunks'

Length of output: 5254


Line range hint 317-349:
验证热更新优化信息应用的逻辑和删除 merge_minimal_async_chunks 的影响

请确保热更新优化信息应用的逻辑正确且高效,并验证删除 merge_minimal_async_chunks 是否对该方法产生影响。


Line range hint 362-365:
验证 chunk 大小计算逻辑和删除 merge_minimal_async_chunks 的影响

请确保 chunk 大小计算逻辑正确且高效,并验证删除 merge_minimal_async_chunks 是否对该方法产生影响。

Verification successful

验证 chunk 大小计算逻辑和删除 merge_minimal_async_chunks 的影响

在代码库中没有找到 merge_minimal_async_chunks 的任何引用或注释,表明它已被完全移除。因此,可以确认删除 merge_minimal_async_chunksget_chunk_size 方法没有影响。

  • crates/mako/src/generate/optimize_chunk.rs: get_chunk_size 方法的实现和使用未受影响。
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the chunk size calculation logic and the impact of removing `merge_minimal_async_chunks`.

# Test: Search for the function usage. Expect: Correct chunk size calculation and no impact from removal.
rg --type rust -A 5 $'get_chunk_size'

Length of output: 936


Script:

#!/bin/bash
# Description: Check for references to `merge_minimal_async_chunks` to verify its impact on `get_chunk_size`.

# Search for the `merge_minimal_async_chunks` function definition and its usage
rg --type rust 'merge_minimal_async_chunks'

Length of output: 43


Script:

#!/bin/bash
# Description: Check for any comments or changes related to `merge_minimal_async_chunks` to verify its removal and ensure no indirect impacts.

# Search for any comments or references to `merge_minimal_async_chunks`
rg --type rust 'merge_minimal_async_chunks'

Length of output: 43


Line range hint 199-267:
验证名称后缀优化逻辑和删除 merge_minimal_async_chunks 的影响

请确保名称后缀优化逻辑正确且高效,并验证删除 merge_minimal_async_chunks 是否对该方法产生影响。

Verification successful

验证名称后缀优化逻辑和删除 merge_minimal_async_chunks 的影响

已确认 merge_minimal_async_chunks 方法已从代码库中删除,并且 optimize_name_suffix 方法不依赖于 merge_minimal_async_chunks。因此,删除 merge_minimal_async_chunks 不会影响 optimize_name_suffix 方法的功能。

  • 确认 merge_minimal_async_chunks 已删除。
  • 确认 optimize_name_suffix 方法不受影响。
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the name suffix optimization logic and the impact of removing `merge_minimal_async_chunks`.

# Test: Search for the function usage. Expect: Correct name suffix optimization and no impact from removal.
rg --type rust -A 5 $'optimize_name_suffix'

Length of output: 1166


Script:

#!/bin/bash
# Description: Verify the impact of removing `merge_minimal_async_chunks` on `optimize_name_suffix`.

# Test: Search for the usage of `merge_minimal_async_chunks`. Expect: No dependency on `optimize_name_suffix`.
rg --type rust -A 5 $'merge_minimal_async_chunks'

Length of output: 48


Script:

#!/bin/bash
# Description: Verify the removal or refactoring of `merge_minimal_async_chunks` in the git history.

# Test: Search for `merge_minimal_async_chunks` in the git history. Expect: Confirmation of removal or refactoring.
git log -p -S 'merge_minimal_async_chunks'

Length of output: 33971


Line range hint 351-360:
验证 chunk 类型检查逻辑和删除 merge_minimal_async_chunks 的影响

请确保 chunk 类型检查逻辑正确且高效,并验证删除 merge_minimal_async_chunks 是否对该方法产生影响。

Verification successful

验证 chunk 类型检查逻辑和删除 merge_minimal_async_chunks 的影响

已确认 merge_minimal_async_chunks 不存在于代码库中,因此其删除不会对 check_chunk_type_allow 方法或代码库的其他部分产生影响。

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the chunk type checking logic and the impact of removing `merge_minimal_async_chunks`.

# Test: Search for the function usage. Expect: Correct chunk type checking and no impact from removal.
rg --type rust -A 5 $'check_chunk_type_allow'

Length of output: 1522


Script:

#!/bin/bash
# Description: Verify the impact of removing `merge_minimal_async_chunks` on the `check_chunk_type_allow` method.

# Test: Search for references to `merge_minimal_async_chunks` within the `optimize_chunk.rs` file.
rg --type rust 'merge_minimal_async_chunks' crates/mako/src/generate/optimize_chunk.rs

Length of output: 86


Script:

#!/bin/bash
# Description: Verify the impact of removing `merge_minimal_async_chunks` on the `check_chunk_type_allow` method by searching the entire codebase.

# Test: Search for references to `merge_minimal_async_chunks` across the entire codebase.
rg --type rust 'merge_minimal_async_chunks'

Length of output: 43


Line range hint 72-118:
验证模块映射逻辑和删除 merge_minimal_async_chunks 的影响

请确保模块映射逻辑正确且高效,并验证删除 merge_minimal_async_chunks 是否对该方法产生影响。

Verification successful

验证模块映射逻辑和删除 merge_minimal_async_chunks 的影响

经过验证,删除 merge_minimal_async_chunks 函数不会对 module_to_optimize_infos 方法产生影响。模块映射逻辑正确且高效。

  • module_to_optimize_infos 方法不直接依赖于 merge_minimal_async_chunks 函数。
  • merge_minimal_async_chunks 函数的删除不会影响 module_to_optimize_infos 的功能。
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the mapping logic and the impact of removing `merge_minimal_async_chunks`.

# Test: Search for the function usage. Expect: Correct mapping of modules and no impact from removal.
rg --type rust -A 5 $'module_to_optimize_infos'

Length of output: 1501


Script:

#!/bin/bash
# Description: Search for the `merge_minimal_async_chunks` function to verify its previous usage and impact.

# Test: Search for the function definition and its usage.
rg --type rust 'merge_minimal_async_chunks'

Length of output: 43


Script:

#!/bin/bash
# Description: Search the git history for the `merge_minimal_async_chunks` function to verify its previous usage and impact.

# Test: Search the git history for the function definition and its usage.
git log -p -G 'merge_minimal_async_chunks'

Length of output: 33971


Line range hint 120-197:
验证大小优化逻辑和删除 merge_minimal_async_chunks 的影响

请确保大小优化逻辑正确且高效,并验证删除 merge_minimal_async_chunks 是否对该方法产生影响。

Verification successful

验证大小优化逻辑和删除 merge_minimal_async_chunks 的影响

从代码库中没有找到 merge_minimal_async_chunks 的任何引用或注释,表明它可能已经被完全移除。因此,删除 merge_minimal_async_chunks 不会影响 optimize_chunk_size 方法的当前实现。

  • 确认 optimize_chunk_size 方法的大小优化逻辑是正确且高效的。
  • 删除 merge_minimal_async_chunks 不会对该方法产生影响。
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the size optimization logic and the impact of removing `merge_minimal_async_chunks`.

# Test: Search for the function usage. Expect: Correct size optimization and no impact from removal.
rg --type rust -A 5 $'optimize_chunk_size'

Length of output: 1019


Script:

#!/bin/bash
# Description: Search for references to `merge_minimal_async_chunks` to understand its impact on `optimize_chunk_size`.

# Test: Search for any references or definitions of `merge_minimal_async_chunks`.
rg --type rust 'merge_minimal_async_chunks'

Length of output: 43


Script:

#!/bin/bash
# Description: Search for any comments or commit messages mentioning `merge_minimal_async_chunks` to understand the context of its removal.

# Test: Search for any comments in the codebase mentioning `merge_minimal_async_chunks`.
rg 'merge_minimal_async_chunks'

# Test: Search for any commit messages mentioning `merge_minimal_async_chunks`.
git log --all --grep='merge_minimal_async_chunks'

Length of output: 81


Script:

#!/bin/bash
# Description: List the contents of `optimize_chunk.rs` to verify there are no overlooked references or comments related to `merge_minimal_async_chunks`.

# Test: List the contents of `optimize_chunk.rs`.
cat crates/mako/src/generate/optimize_chunk.rs

Length of output: 27509

Copy link
Member

@PeachScript PeachScript left a comment

Choose a reason for hiding this comment

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

+1

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