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/upgrade swc #1444

Merged
merged 96 commits into from
Oct 12, 2024
Merged

feat/upgrade swc #1444

merged 96 commits into from
Oct 12, 2024

Conversation

stormslowly
Copy link
Member

@stormslowly stormslowly commented Jul 24, 2024

  • enable bind build in ci
  • enable code cov in ci

svgr-rs 先复制到本地, 等 PR 合并再移除


考虑到 https://swc.rs/docs/plugin/selecting-swc-core#v098x- 有对 plugin 的 breaking change 还是一步到位


close #1432

  • add back or rewrtite emotion plugin
  • add back source-map merge

Summary by CodeRabbit

总结

  • 新特性

    • 新增 clapregex 依赖,增强命令行参数解析和正则表达式功能。
    • 更新 swc_core 依赖至新版本,提升项目功能和稳定性。
    • 精简 mako crate 的依赖特性,确保更高的兼容性和稳定性。
    • 更新多个 @umijs/mako 相关包至新版本,包含新的功能和改进。
  • Bug 修复

    • 改进了错误处理机制,确保错误信息格式一致,提升了错误报告的清晰度。

Copy link
Contributor

coderabbitai bot commented Jul 24, 2024

## Walkthrough

本次更改集中在更新 `Cargo.toml` 文件中的依赖项,新增了 `clap``regex` 依赖,并更新了 `swc_core` 的版本。此外,`mako` 子项目的依赖项也进行了精简和版本固定,确保了依赖管理的稳定性和一致性。整体上,这些更改反映了对项目功能的增强和依赖管理的优化。

## Changes

| 文件                                         | 更改摘要                                           |
|----------------------------------------------|--------------------------------------------------|
| Cargo.toml                                  | 新增 `clap``regex` 依赖,更新 `swc_core` 版本。 |
| crates/mako/Cargo.toml                       | 精简 `swc_core` 特性集,固定多个依赖项的版本。   |
| packages/bundler-mako/package.json           | 更新 `@umijs/mako` 依赖版本。                   |
| packages/mako/package.json                   | 更新 `@umijs/mako` 及其可选依赖版本。           |
| packages/mako/npm/*                         | 更新多个平台的 `@umijs/mako` 版本。             |

## Assessment against linked issues

| Objective                                     | Addressed | Explanation                          |
|-----------------------------------------------|-----------|--------------------------------------|
| 移除 mako 代码中的 swc workaround (#[1432]) || 本次更改未涉及 `swc` 的相关代码更新。 |
| 使用稳定的 Rust 版本 (#[1432])                 || 本次更改未包含 Rust 版本的更新。   |
| 解决一些具体问题 (#[1432])                     || 本次更改未直接解决提到的问题,需进一步确认。 |

- **#1186**: 该 PR 修改了 `Cargo.toml` 文件,添加了新依赖,与主 PR 中的更改相关。
- **#1460**: 该 PR 更新了 `Cargo.toml` 文件,添加了新依赖,直接与主 PR 的修改有关。
- **#1466**: 该 PR 引入了新依赖,建立了与主 PR 的关系。
- **#1575**: 该 PR 更新了 `package.json` 文件,涉及依赖管理的更改,相关性强。
- **#1595**: 该 PR 涉及 `Cargo.toml` 文件的格式化,与主 PR 中的依赖管理相关。

> 🐇 在代码的草地上跳跃,  
> 每次更新都欢快的拍跺!  
> 新特性闪闪如星光,  
> 性能提升跃向理想!  
> 让我们欢庆这变化,  
> 代码更清晰,未来更笑哈哈!  
> 🐰✨

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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

Outside diff range, codebase verification and nitpick comments (1)
crates/mako/src/plugins/mod.rs (1)

6-6: 确认注释掉的 emotion 模块的影响

注释掉 emotion 模块会影响任何依赖此模块的代码。尽管 crates/mako/src/compiler.rs 中的 EmotionPlugin 引用已被注释掉,但 crates/mako/src/plugins/emotion.rscrates/mako/src/config/config.rs 中的引用仍然是活跃的。请确保所有相关代码都已更新以反映此更改,以防止潜在的运行时错误。

  • crates/mako/src/plugins/emotion.rs
  • crates/mako/src/config/config.rs
Analysis chain

确认注释掉的 emotion 模块的影响

注释掉 emotion 模块会影响任何依赖此模块的代码。请确保所有相关代码都已更新以反映此更改。

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of commenting out the `emotion` module.

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

Length of output: 3761


Script:

#!/bin/bash
# Description: Verify if the references to the `emotion` module in the identified files are commented out or active.

# Check if the references in crates/mako/src/compiler.rs are commented out
rg --type rust -A 5 'emotion' crates/mako/src/compiler.rs

# Check if the references in crates/mako/src/plugins/emotion.rs are commented out
rg --type rust -A 5 'emotion' crates/mako/src/plugins/emotion.rs

# Check if the references in crates/mako/src/config/config.rs are commented out
rg --type rust -A 5 'emotion' crates/mako/src/config/config.rs

Length of output: 1880

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d866363 and 6cd9a0e.

Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (26)
  • Cargo.toml (1 hunks)
  • crates/mako/Cargo.toml (3 hunks)
  • crates/mako/src/ast/css_ast.rs (1 hunks)
  • crates/mako/src/ast/sourcemap.rs (2 hunks)
  • crates/mako/src/build/load.rs (1 hunks)
  • crates/mako/src/compiler.rs (3 hunks)
  • crates/mako/src/features/node.rs (1 hunks)
  • crates/mako/src/generate/chunk_pot/ast_impl.rs (2 hunks)
  • crates/mako/src/generate/chunk_pot/str_impl.rs (1 hunks)
  • crates/mako/src/generate/chunk_pot/util.rs (3 hunks)
  • crates/mako/src/generate/transform.rs (1 hunks)
  • crates/mako/src/plugins/context_module.rs (1 hunks)
  • crates/mako/src/plugins/invalid_webpack_syntax.rs (1 hunks)
  • crates/mako/src/plugins/minifish/inject.rs (1 hunks)
  • crates/mako/src/plugins/mod.rs (1 hunks)
  • crates/mako/src/plugins/tree_shaking/shake/module_concatenate/module_ref_rewriter.rs (2 hunks)
  • crates/mako/src/plugins/tree_shaking/shake/module_concatenate/ref_link.rs (1 hunks)
  • crates/mako/src/stats.rs (1 hunks)
  • crates/mako/src/visitors/async_module.rs (6 hunks)
  • crates/mako/src/visitors/css_px2rem.rs (2 hunks)
  • crates/mako/src/visitors/env_replacer.rs (2 hunks)
  • crates/mako/src/visitors/meta_url_replacer.rs (1 hunks)
  • crates/mako/src/visitors/new_url_assets.rs (2 hunks)
  • crates/mako/src/visitors/optimize_define_utils.rs (8 hunks)
  • crates/mako/src/visitors/public_path_assignment.rs (2 hunks)
  • rust-toolchain.toml (1 hunks)
Files skipped from review due to trivial changes (10)
  • crates/mako/src/ast/sourcemap.rs
  • crates/mako/src/features/node.rs
  • crates/mako/src/generate/chunk_pot/str_impl.rs
  • crates/mako/src/generate/chunk_pot/util.rs
  • crates/mako/src/generate/transform.rs
  • crates/mako/src/plugins/context_module.rs
  • crates/mako/src/plugins/invalid_webpack_syntax.rs
  • crates/mako/src/plugins/tree_shaking/shake/module_concatenate/module_ref_rewriter.rs
  • crates/mako/src/visitors/css_px2rem.rs
  • rust-toolchain.toml
Additional comments not posted (30)
Cargo.toml (1)

10-10: 依赖项升级已批准

swc_core 依赖项版本已从 0.83.22 升级到 0.96.0,这可能包括性能改进、新特性或错误修复。

crates/mako/src/visitors/meta_url_replacer.rs (1)

16-18: 类型处理更改已批准

CondExpr 结构体的 testconsalt 字段中添加 .into() 方法调用,确保类型兼容性和安全性。

crates/mako/src/visitors/public_path_assignment.rs (2)

12-16: 简化了赋值表达式的检查逻辑

使用 as_ident() 方法直接检查赋值表达式的左侧是否为标识符,简化了代码并提高了可读性。确保新逻辑的正确性。


17-20: 改进了赋值表达式的构造

使用 member_expr! 宏直接构造新的赋值表达式,提高了代码的清晰度并减少了构造新赋值时出错的可能性。

crates/mako/Cargo.toml (4)

33-36: 确认新增的 swc_core 功能

新增的功能增强了 swc_core crate 的能力或功能。请确保这些功能是必要的并且已正确实现。


72-72: 固定 swc_error_reporters 版本

swc_error_reporters 的版本固定为 0.18.1,确保兼容性和稳定性。


73-73: 固定 swc_node_comments 版本

swc_node_comments 的版本固定为 0.21.0,确保兼容性和稳定性。


90-90: 更新 mdxjs 版本

mdxjs 的版本更新为 0.2.5,这可能表明库中有显著的变化或改进。

crates/mako/src/visitors/new_url_assets.rs (2)

54-55: 改进了表达式处理

使用 into() 方法包装 document.baseURIself.location.href 表达式,可能提高了类型安全性或与代码库其他部分的兼容性。确保新逻辑的正确性。


94-95: 标准化表达式处理

在涉及 __mako_require__.publicPath 的二元加法操作中使用 into() 方法包装左操作数,表明在不同表达式中统一处理表达式的更广泛努力。确保新逻辑的正确性。

crates/mako/src/visitors/optimize_define_utils.rs (4)

38-38: 更改已批准!

.into() 替换为 .as_callee() 提高了类型安全性和代码清晰度。


59-60: 更改已批准!

.into() 替换为 .as_callee() 提高了类型安全性和代码清晰度。


70-70: 更改已批准!

直接比较 callee_ident.sym 和字符串字面量 "_export" 减少了不必要的开销并提高了可读性。


79-80: 更改已批准!

.into() 替换为 .as_callee() 提高了类型安全性和代码清晰度。

crates/mako/src/ast/css_ast.rs (2)

49-51: 更改已批准!

添加了对 comments 的克隆操作,使 Lexer 能够处理注释,提高了解析的能力。


52-52: 更改已批准!

更新了 Lexer 的初始化,包含了 comments,这可能会改变解析过程中对 CSS 注释的处理方式。

crates/mako/src/build/load.rs (1)

136-136: 更改已批准!

reason 转换为字符串 reason.to_string() 提高了错误消息的清晰度。

crates/mako/src/generate/chunk_pot/ast_impl.rs (1)

100-102: 确认临时更改并计划后续处理。

merge_source_map 函数调用被注释掉,改为从 source_map_chain 弹出最后一个元素。这是一个临时措施,TODO 注释表明未来会有进一步的开发。

请确认这是一个临时更改,并计划在未来版本中处理合并 source map 的逻辑。

crates/mako/src/visitors/env_replacer.rs (3)

86-89: 优化条件检查以替代直接模式匹配。

将直接模式匹配替换为条件检查,增强了代码的可读性和维护性。

这些更改保持了逻辑的完整性,同时提高了代码的可读性。


95-95: 优化条件检查以替代直接模式匹配。

将直接模式匹配替换为条件检查,增强了代码的可读性和维护性。

这些更改保持了逻辑的完整性,同时提高了代码的可读性。


143-146: 优化条件检查以替代直接模式匹配。

将直接模式匹配替换为条件检查,增强了代码的可读性和维护性。

这些更改保持了逻辑的完整性,同时提高了代码的可读性。

crates/mako/src/plugins/tree_shaking/shake/module_concatenate/ref_link.rs (1)

76-76: 验证键的类型转换。

将键插入 defined_idents 前进行类型转换,可能会影响后续操作的行为。

请确保这种类型转换是必要的,并验证它不会引入新的问题。

crates/mako/src/compiler.rs (3)

187-187: 新增字段 comments

CssMeta 结构体中新增了 comments 字段,类型为 SwcComments


195-195: 初始化 comments 字段。

CssMetanew 方法已更新,正确初始化了 comments 字段。


241-241: 确认注释掉 EmotionPlugin 的原因。

EmotionPlugin 的相关代码被注释掉了,建议确认注释的原因是否已记录或理解。

crates/mako/src/visitors/async_module.rs (3)

7-8: 新增导入 ArrayPat

导入了 ArrayPat 和相关结构,确保它们在代码中被正确使用。


127-137: 使用 ArrayPat 优化解构赋值。

解构赋值的逻辑已更新为使用 ArrayPat,提高了代码的可读性和性能。


139-139: 优化条件表达式和 await 处理。

条件表达式和 await 处理的逻辑已更新,提高了代码的可读性和性能。

crates/mako/src/plugins/minifish/inject.rs (1)

199-199: 新增字段 phase

ImportDecl 结构体中新增了 phase 字段,使用 Default::default() 进行初始化。

crates/mako/src/stats.rs (1)

324-324: 简化错误处理

使用 unwrap_or_default() 简化了错误处理逻辑,提升了代码的可读性和简洁性。

@stormslowly stormslowly self-assigned this Jul 24, 2024
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 6cd9a0e and 7234ad3.

Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (8)
  • crates/mako/Cargo.toml (3 hunks)
  • crates/mako/src/ast/js_ast.rs (3 hunks)
  • crates/mako/src/compiler.rs (3 hunks)
  • crates/mako/src/lib.rs (1 hunks)
  • crates/mako/src/stats.rs (1 hunks)
  • crates/mako/src/visitors/common_js.rs (1 hunks)
  • crates/mako/src/visitors/dynamic_import.rs (1 hunks)
  • crates/mako/src/visitors/dynamic_import_to_require.rs (1 hunks)
Files skipped from review due to trivial changes (3)
  • crates/mako/src/lib.rs
  • crates/mako/src/stats.rs
  • crates/mako/src/visitors/dynamic_import.rs
Files skipped from review as they are similar to previous changes (2)
  • crates/mako/Cargo.toml
  • crates/mako/src/compiler.rs
Additional comments not posted (4)
crates/mako/src/visitors/common_js.rs (1)

22-29: 简化了use_strict的逻辑

重构后的代码使用了更简洁和可读的方法来确定use_strict的值。逻辑看起来是正确的,并且应保持相同的功能。

crates/mako/src/visitors/dynamic_import_to_require.rs (1)

34-34: 简化了模块项位置的逻辑

重构后的代码使用了更简洁和可读的方法来确定模块项的位置。逻辑看起来是正确的,并且应保持相同的功能。

crates/mako/src/ast/js_ast.rs (2)

54-57: 重命名TsConfigTsSyntax

重命名在确定TypeScript文件的语法时正确应用,没有引入任何问题。


Line range hint 63-67:
重命名EsConfigEsSyntax

重命名在确定JavaScript文件的语法时正确应用,没有引入任何问题。

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

Outside diff range, codebase verification and nitpick comments (2)
crates/mako/src/generate/chunk_pot/mod.rs (1)

15-15: 移除 chunk_type 字段影响了其他部分的代码

ChunkPot 结构中移除 chunk_type 字段后,代码库的其他部分仍在引用此字段,这可能会导致运行时错误或逻辑错误。请检查并更新以下文件中的相关代码:

  • crates/mako/src/stats.rs
  • crates/mako/src/plugins/ssu.rs
  • crates/mako/src/generate/optimize_chunk.rs
  • crates/mako/src/generate/generate_chunks.rs
  • crates/mako/src/generate/chunk_graph.rs
  • crates/mako/src/generate/chunk_pot/ast_impl.rs
  • crates/mako/src/generate/chunk.rs
  • crates/mako/src/generate/group_chunk.rs

请确保所有引用 chunk_type 字段的代码都已更新,以反映此字段的移除。

Analysis chain

移除 chunk_type 字段以简化结构

移除 ChunkPot 结构中的 chunk_type 字段简化了结构,可能减少复杂性并提高可维护性。

请确保验证此更改对依赖此属性的相关功能的影响。

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of removing `chunk_type` field on related functionality.

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

Length of output: 17713

crates/mako/src/visitors/dep_replacer.rs (1)

请确保结构体实例化匹配新定义。

DepReplacer 结构体的定义已更改,但在以下文件中仍然存在旧定义的实例化,请更新这些实例化以匹配新定义:

  • crates/mako/src/visitors/dep_replacer.rs
  • crates/mako/src/generate/transform.rs
  • crates/mako/src/plugins/bundless_compiler.rs
Analysis chain

Line range hint 15-18:
请确保结构体实例化匹配新定义。

DepReplacer 结构体的定义已更改,请验证代码库中所有对此结构体的实例化是否匹配新定义。

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all struct instantiations of `DepReplacer` match the new definition.

# Test: Search for the struct usage. Expect: Only occurrences of the new definition.
rg --type rust -A 5 $'DepReplacer'

Length of output: 4689


Script:

#!/bin/bash
# Description: Verify all struct instantiations of `DepReplacer` match the new definition.

# Test: Search for the struct instantiation. Expect: Only occurrences of the new definition.
rg --type rust 'DepReplacer \{' -A 5

Length of output: 1645

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 7234ad3 and 1138d0d.

Files selected for processing (15)
  • crates/binding/src/tsfn.rs (1 hunks)
  • crates/mako/src/generate/chunk_pot/mod.rs (3 hunks)
  • crates/mako/src/generate/mod.rs (1 hunks)
  • crates/mako/src/generate/swc_helpers.rs (1 hunks)
  • crates/mako/src/generate/transform.rs (2 hunks)
  • crates/mako/src/main.rs (1 hunks)
  • crates/mako/src/plugins/bundless_compiler.rs (1 hunks)
  • crates/mako/src/plugins/invalid_webpack_syntax.rs (3 hunks)
  • crates/mako/src/plugins/require_context/visitor.rs (1 hunks)
  • crates/mako/src/plugins/tree_shaking/module.rs (2 hunks)
  • crates/mako/src/plugins/tree_shaking/shake/module_concatenate.rs (1 hunks)
  • crates/mako/src/plugins/tree_shaking/shake/module_concatenate/external_transformer.rs (1 hunks)
  • crates/mako/src/plugins/tree_shaking/shake/skip_module.rs (1 hunks)
  • crates/mako/src/plugins/tree_shaking/statement_graph.rs (2 hunks)
  • crates/mako/src/visitors/dep_replacer.rs (2 hunks)
Files skipped from review due to trivial changes (3)
  • crates/binding/src/tsfn.rs
  • crates/mako/src/generate/swc_helpers.rs
  • crates/mako/src/main.rs
Files skipped from review as they are similar to previous changes (2)
  • crates/mako/src/generate/transform.rs
  • crates/mako/src/plugins/invalid_webpack_syntax.rs
Additional comments not posted (12)
crates/mako/src/plugins/tree_shaking/shake/module_concatenate/external_transformer.rs (1)

29-29: 更改参数类型以提高灵活性和性能

将参数类型从 &Vec<ExprOrSpread> 更改为 &[ExprOrSpread] 提高了函数的灵活性,并可能提高性能。

crates/mako/src/plugins/require_context/visitor.rs (1)

50-50: 更改参数类型以提高灵活性和性能

将参数类型从 &Vec<ExprOrSpread> 更改为 &[ExprOrSpread] 提高了函数的灵活性,并可能提高性能。

crates/mako/src/plugins/bundless_compiler.rs (2)

Line range hint 15-18:
请确保函数调用匹配新签名。

函数 transform_js_generate 的签名已更改,请验证代码库中所有对此函数的调用是否匹配新签名。


Line range hint 15-18:
确保内部逻辑正确。

请确保函数 transform_js_generate 内部逻辑在移除 top_level_mark 参数后仍然正确。

crates/mako/src/visitors/dep_replacer.rs (1)
#!/bin/bash
# Description: Verify internal logic correctness after field removal.

# Test: Check for any references to `DepReplacer` within the entire codebase.
rg --type rust 'DepReplacer'
crates/mako/src/plugins/tree_shaking/statement_graph.rs (2)

34-34: 确保新字段正确集成。

ImportInfo 结构体添加了新字段 stmt_id,请确保该字段正确集成且不会引入任何问题。

#!/bin/bash
# Description: Verify the integration of the new field `stmt_id` in `ImportInfo`.

# Test: Check for any usage of the new field within the file.
rg --type rust $'stmt_id' crates/mako/src/plugins/tree_shaking/statement_graph.rs

248-250: 确保新字段正确集成。

Statement 结构体添加了新字段 has_side_effectsspan,请确保这些字段正确集成且不会引入任何问题。

#!/bin/bash
# Description: Verify the integration of the new fields `has_side_effects` and `span` in `Statement`.

# Test: Check for any usage of the new fields within the file.
rg --type rust $'has_side_effects|span' crates/mako/src/plugins/tree_shaking/statement_graph.rs
crates/mako/src/plugins/tree_shaking/shake/module_concatenate.rs (1)

1-1: 请验证删除的模块影响

删除 mod exports_transform; 可能会影响依赖此模块的代码。请确保删除不会破坏现有功能。

Verification successful

删除的模块未影响代码

在代码库中未找到对 exports_transform 模块的引用。可以确认删除此模块不会破坏现有功能。

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of the removed `exports_transform` module.

# Test: Search for references to `exports_transform`. Expect: No occurrences.
rg --type rust -A 5 $'exports_transform'

Length of output: 39


Script:

#!/bin/bash
# Description: Verify the impact of the removed `exports_transform` module.

# Search for any references to `exports_transform` in the codebase, including imports and usage.
rg 'exports_transform' -A 10

Length of output: 28

crates/mako/src/plugins/tree_shaking/module.rs (1)

25-33: 更改已批准

UsedIdent 枚举的 trait 实现从 ToString 更改为 Display,改进了与 Rust 格式化 trait 的集成。实现是正确的。

crates/mako/src/generate/mod.rs (1)

Line range hint 1-1:
请验证删除的结构体影响

删除 EmitFile 结构体可能会影响依赖此结构体的代码。请确保删除不会破坏现有功能,并且新的机制已正确实现。

Verification successful

删除 EmitFile 结构体的影响已验证

EmitFile 结构体已从代码库中删除,并且相关代码已被重构以使用新的文件处理机制。没有发现对 EmitFile 的引用,新的机制已正确实现。

  • 删除确认: EmitFile 结构体已从代码库中移除。
  • 代码重构: 相关代码已更新以使用新的文件处理机制。
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of the removed `EmitFile` struct.

# Test: Search for references to `EmitFile`. Expect: No occurrences.
rg --type rust -A 5 $'EmitFile'

Length of output: 30


Script:

#!/bin/bash
# Description: Verify the removal and impact of the `EmitFile` struct.

# Step 1: Search for the definition of `EmitFile` to confirm it has been removed.
rg --type rust 'struct EmitFile'

# Step 2: Check the commit history to confirm the removal of `EmitFile`.
git log -p -S 'struct EmitFile'

Length of output: 7987

crates/mako/src/plugins/tree_shaking/shake/skip_module.rs (2)

165-165: 参数类型更改已批准

将参数类型从 &Vec<ModuleId> 更改为 &[ModuleId] 提高了函数的灵活性和性能,符合 Rust 的最佳实践。


165-165: 请验证函数调用

确保所有对 skip_module_optimize 的调用都使用了新的参数类型。

Verification successful

请验证函数调用

确保所有对 skip_module_optimize 的调用都使用了新的参数类型。根据搜索结果,shake.rs 中的函数调用使用了 &tree_shake_modules_ids,这与新的参数类型匹配。

  • crates/mako/src/plugins/tree_shaking/shake.rs: skip_module_optimize 函数调用使用了新的参数类型。
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `skip_module_optimize` match the new parameter type.

# Test: Search for the function usage. Expect: Only occurrences of the new parameter type.
rg --type rust -A 5 $'skip_module_optimize'

Length of output: 1696

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 1138d0d and 3ffa4f7.

Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (1)
  • crates/mako/Cargo.toml (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • crates/mako/Cargo.toml

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 3ffa4f7 and 7c90a2e.

Files selected for processing (2)
  • crates/binding/Cargo.toml (1 hunks)
  • crates/mako/src/compiler.rs (2 hunks)
Files skipped from review due to trivial changes (1)
  • crates/binding/Cargo.toml
Files skipped from review as they are similar to previous changes (1)
  • crates/mako/src/compiler.rs

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 7c90a2e and b019acc.

Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (2)
  • crates/mako/Cargo.toml (3 hunks)
  • crates/mako/src/ast/sourcemap.rs (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • crates/mako/Cargo.toml
  • crates/mako/src/ast/sourcemap.rs

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 b019acc and 4999c74.

Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
Files selected for processing (1)
  • scripts/test-hmr.mjs (1 hunks)
Additional comments not posted (1)
scripts/test-hmr.mjs (1)

1644-1644: 请验证 'content-type' 头信息的更改是否符合新标准。

将 'content-type' 从 'application/javascript; charset=utf-8' 更改为 'text/javascript; charset=utf-8' 可能会影响客户端对 JavaScript 内容的解释和处理。请确保此更改符合最新的服务器配置或标准。

@stormslowly stormslowly changed the title wip: feat/upgrade swc feat/upgrade swc Jul 30, 2024
crates/binding/Cargo.toml Outdated Show resolved Hide resolved
@stormslowly stormslowly changed the title feat/upgrade swc ‘’feat/upgrade swc Aug 1, 2024
@stormslowly stormslowly changed the title ‘’feat/upgrade swc wip feat/upgrade swc Aug 1, 2024
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 e428feb and 022702b.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (1)
  • crates/mako/src/generate/chunk_pot/util.rs (7 hunks)
Files skipped from review due to trivial changes (1)
  • crates/mako/src/generate/chunk_pot/util.rs

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 022702b and 90fab94.

Files selected for processing (8)
  • packages/bundler-mako/package.json (1 hunks)
  • packages/mako/npm/darwin-arm64/package.json (1 hunks)
  • packages/mako/npm/darwin-x64/package.json (1 hunks)
  • packages/mako/npm/linux-arm64-gnu/package.json (2 hunks)
  • packages/mako/npm/linux-arm64-musl/package.json (1 hunks)
  • packages/mako/npm/linux-x64-gnu/package.json (1 hunks)
  • packages/mako/npm/linux-x64-musl/package.json (1 hunks)
  • packages/mako/package.json (2 hunks)
Files skipped from review due to trivial changes (2)
  • packages/mako/npm/darwin-x64/package.json
  • packages/mako/package.json
Files skipped from review as they are similar to previous changes (4)
  • packages/mako/npm/darwin-arm64/package.json
  • packages/mako/npm/linux-arm64-musl/package.json
  • packages/mako/npm/linux-x64-gnu/package.json
  • packages/mako/npm/linux-x64-musl/package.json
Additional comments not posted (2)
packages/mako/npm/linux-arm64-gnu/package.json (1)

3-3: 版本更新已批准。

此次更改将版本号从 0.0.0 更新至 0.8.9-canary.20240909.1,符合语义化版本控制的规范。请确保所有相关文档和配置也已更新以反映这一变更。

packages/bundler-mako/package.json (1)

6-6: 依赖版本更新已批准。

此次更改将 @umijs/mako 的版本号从 0.8.8 更新至 0.8.9-canary.20240909.1,符合语义化版本控制的规范。请确保所有相关文档和配置也已更新以反映这一变更。

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 90fab94 and 450c3ae.

Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing (1)
  • packages/bundler-mako/package.json (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/bundler-mako/package.json

@sorrycc sorrycc mentioned this pull request Sep 12, 2024
5 tasks
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

🧹 Outside diff range and nitpick comments (2)
crates/mako/src/generate/chunk_pot/util.rs (2)

74-74: 函数结构更新正确,建议考虑提取常量

FunctionBlockStmt 结构中添加 ctxt: Default::default() 是正确的,这符合更新后的 SWC API 要求。这些更改与处理 SWC 升级中的破坏性变更的 PR 目标一致。

建议:考虑将 Default::default() 提取为一个常量,以提高代码的可读性和可维护性。例如:

const DEFAULT_CONTEXT: swc_core::ecma::ast::Ctxt = Default::default();

然后在需要的地方使用 ctxt: DEFAULT_CONTEXT

Also applies to: 82-82


303-303: 模块函数表达式转换更新正确,建议统一优化

to_module_fn_expr 函数中,FunctionBlockStmt 结构添加了 ctxt: Default::default(),这与之前在 empty_module_fn_expr 中的修改一致。这些更改正确地反映了 SWC API 的更新要求。

建议:

  1. 如之前建议的那样,考虑将 Default::default() 提取为一个常量,以提高代码的一致性和可维护性。
  2. 确保这个更改在整个代码库中统一应用,以保持一致性。

Also applies to: 312-312

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5da9cda and 9d219f5.

📒 Files selected for processing (2)
  • crates/mako/src/generate/chunk_pot/util.rs (7 hunks)
  • crates/mako/src/lib.rs (0 hunks)
💤 Files with no reviewable changes (1)
  • crates/mako/src/lib.rs
🧰 Additional context used
🔇 Additional comments (4)
crates/mako/src/generate/chunk_pot/util.rs (4)

13-15: 导入语句更新正确

导入语句中添加了 Function,这与后续代码中的使用相符。这个更改与升级 SWC 和处理破坏性变更的 PR 目标一致。


Line range hint 137-145: 哈希函数优化得当

hash_hashmap 函数的实现已经得到了简化和优化。新的实现直接收集并排序哈希表条目,避免了创建中间的键值对向量。这种方法更加简洁高效,同时保持了排序和哈希逻辑的一致性,有可能提高了性能。这个改进增强了代码的可读性,是一个很好的优化。


170-172: 模块对象转换函数优化合理

pot_to_module_object 函数的实现已经得到了优化。新的实现直接收集并排序模块映射条目,这与 hash_hashmap 函数的优化类似。这种方法使代码更加简洁,可能提高了效率,同时保持了排序逻辑的一致性。这个改进与 PR 中的整体代码风格改进保持一致,是一个很好的优化。


250-252: 块模块转换函数更新正确,建议验证

pot_to_chunk_module 函数中 chunk_global_obj 的赋值操作已更新,使用了 make_assign_tomake_member 方法。这个更改可能反映了 SWC API 的更新或类型推断的改进。函数的整体逻辑保持不变,这有助于保持行为的一致性。

建议:

  1. 验证这个更改在不同的输入场景下是否能正确工作。
  2. 确保这个更改与最新的 SWC 文档一致。

为了验证这个更改,可以运行以下脚本:

@stormslowly stormslowly merged commit 428cdfa into master Oct 12, 2024
19 of 21 checks passed
@stormslowly stormslowly deleted the feat/upgrade_swc branch October 12, 2024 07:38
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.

UPGRADE SWC to Lastest
3 participants