-
Notifications
You must be signed in to change notification settings - Fork 74
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
Revert "refactor: define env (#1499)" #1504
Conversation
This reverts commit 845ce1e.
Walkthrough此次更改主要集中在环境变量的处理上,通过简化环境变量引用和改进内存管理,提升了代码的性能与可维护性。 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Transform
participant EnvReplacer
User->>Transform: 请求环境变量
Transform->>EnvReplacer: 获取环境映射
EnvReplacer->>EnvReplacer: 解析环境变量
EnvReplacer-->>Transform: 返回环境变量
Transform-->>User: 返回请求结果
Poem
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 (2)
- crates/mako/src/build/transform.rs (2 hunks)
- crates/mako/src/visitors/env_replacer.rs (5 hunks)
Additional comments not posted (7)
crates/mako/src/visitors/env_replacer.rs (6)
27-32
: 结构体 EnvReplacer 的更改看起来不错。使用
Lrc<AHashMap<JsWord, Expr>>
提高了内存效率并支持共享引用。
36-54
: 构造函数 new 的更改看起来不错。初始化
meta_envs
并将NODE_ENV
转换为MODE
的逻辑是合理的。
58-62
: 方法 get_env 的更改看起来不错。通过使用枚举来区分 Node 和 Browser 环境,增强了代码的可维护性。
66-171
: 方法 visit_mut_expr 的更改看起来不错。这些更改简化了环境变量的解析过程,并有效处理了
process.env
和import.meta.env
的情况。
181-186
: 函数 build_env_map 的更改看起来不错。返回类型的更改与
EnvReplacer
结构体中AHashMap
的使用保持一致,增强了一致性。
362-383
: 测试用例的更改看起来不错。更新和新增的测试用例确保了对更改的充分测试,并涵盖了边缘情况。
crates/mako/src/build/transform.rs (1)
122-128
: 方法 transform 的更改看起来不错。使用
Lrc::new(env_map)
改进了内存管理和共享所有权,有助于提升性能。
This reverts commit 845ce1e.
Summary by CodeRabbit
新功能
修复