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: codespliting mode auto may miss chunk connection to urlMap #1311

Merged
merged 7 commits into from
Jun 27, 2024

Conversation

Jinbao1001
Copy link
Member

@Jinbao1001 Jinbao1001 commented Jun 26, 2024

bug 触发条件:

  1. opnazition auto
  2. entry import a
    a dynamic import b
    b dynamic import c

将之前添加孤立节点的调用移除, 添加新的判断方式, 在 remove chunk 的时候检查所有的 outgoing 节点是否 包含 outgoing 边

Summary by CodeRabbit

  • 新功能

    • 为应用程序引入了代码拆分机制,优化了模块合并和连接块的功能。
  • 界面变更

    • index.ts文件中,添加了两个模块should-be-merged-outgotingshould-not-be-merged的导入语句。
    • 引入了一个新的React组件,该组件通过React.lazy动态导入另一个组件。
    • 引入了一个包含红色样式的CSS类.a的新文件a.less
  • 性能优化

    • 优化了循环迭代逻辑,以更高效地删除和连接块。

@Jinbao1001 Jinbao1001 requested a review from xusd320 June 26, 2024 06:33
Copy link
Contributor

coderabbitai bot commented Jun 26, 2024

摘要

概述

这次更新涉及多个文件的更改,主要集中在优化模块合并和连接块功能上,以及增强了代码拆分机制的验证过程。

更改

文件目录 简要概述
crates/mako/src/generate/chunk_graph.rs 新增 ChunkGraph 结构的 merge_to_chunk 方法,用于将一个块合并到另一个块中,并连接出站节点。
crates/mako/src/generate/optimize_chunk.rs 优化了 Compiler 中的循环迭代逻辑,以更高效地移除和连接块。
e2e/fixtures/code-splitting.complex/expect.js expect.js 文件中添加了断言,以确保特定文件包含在 index.js 文件中,并增强了代码拆分机制中的验证过程。
e2e/fixtures/code-splitting.complex/src/index.ts index.ts 文件中添加了两个模块的导入语句,分别为 should-be-merged-outgotingshould-not-be-merged
e2e/fixtures/code-splitting.complex/src/a.less 引入了包含红色样式 .a 的 CSS 类的新文件 a.less
e2e/fixtures/code-splitting.complex/src/should-not-be-merged.ts 新增文件 should-not-be-merged.ts,包含与 React 组件、延迟加载和导出默认值有关的代码。
e2e/fixtures/code-splitting.complex/src/no-incoming.tsx 引入一个动态导入另一个组件的 React 组件,使用 React.lazy 渲染简单 UI。
e2e/fixtures/code-splitting.complex/src/should-be-merged-outgoting.ts 新增文件 should-be-merged-outgoting.ts,引入了 React 组件导入、使用 React.lazy 进行延迟加载和导出默认值的功能。
e2e/fixtures/code-splitting.complex/src/no-incoming-outgoing.tsx 引入一个渲染包含文本“no-incoming-outgoing”的 <div> 的 React 组件。
packages/bundler-mako/index.js 更新了 getMakoConfig 函数中 plugins 属性的赋值,现在将 makoPlugins 赋给 plugins 而不是 opts.plugins。并且从 opts.config 解构出一个新的属性 makoPlugins

诗歌

入块出块,连接心灵,

CSS 风华,红色妆容。

React 添翼,懒加载成风,

Mako 插件,灵动功成。


Note

Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://coderabbit.ai

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 Configration 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.

@stormslowly
Copy link
Member

stormslowly commented Jun 26, 2024

        for (index, (chunk_id, entry_chunk_id, chunk_modules)) in async_to_entry.iter().enumerate()

这个一整个循环 + 后面的移除的 modules 是不提取成一个 chunk graph 上的 方法,

chunk_graph.mergeToEntry(...)

在语义上会跟明显点

PS

enumerate 是没有必要的

@@ -197,6 +197,25 @@ impl ChunkGraph {
self.graph.remove_node(idx);
}

pub fn remove_and_connect_outgoing_to_chunk(&mut self, chunk_id: &ChunkId, from: &ChunkId) {
let idx = self.id_index_map.remove(chunk_id).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

不要 unwrap

Copy link
Member

@stormslowly stormslowly left a comment

Choose a reason for hiding this comment

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

以后不同的功能提不同的 PR

@stormslowly stormslowly merged commit ae122ce into master Jun 27, 2024
8 checks passed
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