-
Notifications
You must be signed in to change notification settings - Fork 73
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: support dynamic import with template string #1405
Conversation
Walkthrough此次更改通过增加一个新的访问者 Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Transform
participant ImportTemplateToStringLiteral
Developer->>Transform: Add ImportTemplateToStringLiteral visitor
Transform->>ImportTemplateToStringLiteral: Invoke visit_mut_call_expr
ImportTemplateToStringLiteral->>AST: Modify CallExpr nodes
AST->>ImportTemplateToStringLiteral: Return modified nodes
ImportTemplateToStringLiteral->>Transform: Return to Transform with updated nodes
Transform->>Developer: Return transformed AST
Assessment against linked issues
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 Configration 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 (7)
- crates/mako/src/build/transform.rs (2 hunks)
- crates/mako/src/visitors/import_template_to_string_literal.rs (1 hunks)
- crates/mako/src/visitors/mod.rs (1 hunks)
- e2e/fixtures/javascript.dynamic-import.template-string/expect.js (1 hunks)
- e2e/fixtures/javascript.dynamic-import.template-string/foo.js (1 hunks)
- e2e/fixtures/javascript.dynamic-import.template-string/index.js (1 hunks)
- e2e/fixtures/javascript.dynamic-import.template-string/mako.config.json (1 hunks)
Files skipped from review due to trivial changes (5)
- crates/mako/src/visitors/mod.rs
- e2e/fixtures/javascript.dynamic-import.template-string/expect.js
- e2e/fixtures/javascript.dynamic-import.template-string/foo.js
- e2e/fixtures/javascript.dynamic-import.template-string/index.js
- e2e/fixtures/javascript.dynamic-import.template-string/mako.config.json
Additional comments not posted (7)
crates/mako/src/visitors/import_template_to_string_literal.rs (4)
1-2
: 导入语句看起来很好。这些导入语句是合理的,没有发现问题。
4-4
: 导入模板到字符串字面量结构体定义。结构体
ImportTemplateToStringLiteral
定义是空的,但这在实现VisitMut
trait 时是有效的。
6-16
: 实现VisitMut
trait 的visit_mut_call_expr
方法。这个方法检查
import
函数调用并将模板字符串转换为字符串字面量。代码逻辑清晰且合理。
19-39
: 测试模块和run
函数。测试模块定义了一个简单但有效的测试用例来验证
ImportTemplateToStringLiteral
的功能。run
函数生成 AST 并执行转换,代码实现良好。crates/mako/src/build/transform.rs (3)
Line range hint
1-35
: 导入语句看起来很好。这些导入语句是合理的,没有发现问题。
36-36
: 导入ImportTemplateToStringLiteral
模块。导入
ImportTemplateToStringLiteral
模块是正确的,确保了该模块在Transform
实现中可用。
145-145
: 在Transform
实现中添加ImportTemplateToStringLiteral
访问器。将
ImportTemplateToStringLiteral
添加到访问器列表中是实现动态导入模板字符串支持的关键步骤。代码逻辑合理。
Close #1225
Summary by CodeRabbit
新功能
ImportTemplateToStringLiteral
,用于将特定的导入模板表达式转换为字符串字面量。测试
配置
mako.config.json
,用于指定JavaScript项目的入口点、优化选项、平台目标和动态导入相关的全局变量。