feat: support __webpack_public_path and __mako_public_path assignment#1441
feat: support __webpack_public_path and __mako_public_path assignment#1441
Conversation
|
Caution Review failedThe pull request is closed. Walkthrough此次更改在 Changes
Sequence Diagram(s)sequenceDiagram
participant A as JS Code
participant B as AST Generator
participant C as Visitor
participant D as Transform Logic
A->>B: 生成 AST
B->>C: 提交 AST
C->>D: 执行转换
D->>C: 返回修改后的 AST
C->>A: 转换为代码
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 Configuration File (
|
There was a problem hiding this comment.
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/plugins/invalid_webpack_syntax.rs (1 hunks)
- crates/mako/src/visitors/mod.rs (1 hunks)
- crates/mako/src/visitors/public_path_assignment.rs (1 hunks)
- e2e/fixtures/config.public_path.with-assignment/expect.js (1 hunks)
- e2e/fixtures/config.public_path.with-assignment/mako.config.json (1 hunks)
- e2e/fixtures/config.public_path.with-assignment/src/index.tsx (1 hunks)
Files skipped from review due to trivial changes (3)
- crates/mako/src/visitors/mod.rs
- e2e/fixtures/config.public_path.with-assignment/mako.config.json
- e2e/fixtures/config.public_path.with-assignment/src/index.tsx
Additional comments not posted (9)
e2e/fixtures/config.public_path.with-assignment/expect.js (2)
7-7: 验证__webpack_public_path__的断言该断言检查内容是否包含将
__mako_require__.publicPath赋值为/foo/,这是正确的。
8-8: 验证__mako_public_path__的断言该断言检查内容是否包含将
__mako_require__.publicPath赋值为/bar/,这是正确的。crates/mako/src/visitors/public_path_assignment.rs (4)
1-7: 导入和结构定义导入和结构定义是正确且必要的。
8-23: 实现VisitMut以修改赋值表达式该实现正确地识别并修改了
__webpack_public_path__和__mako_public_path__的相关赋值表达式。
25-43: 测试模块测试模块正确地测试了
PublicPathAssignment访客的功能。
45-53: 实现run函数以测试访客
run函数正确地实现了生成 AST、应用访客并将 AST 转换回代码的过程。crates/mako/src/plugins/invalid_webpack_syntax.rs (1)
65-67: 在visit_ident方法中添加条件以排除__webpack_public_path__这些更改正确地将
__webpack_public_path__排除在 Webpack 前缀检查之外。crates/mako/src/build/transform.rs (2)
39-39: 导入新模块PublicPathAssignment。新模块导入看起来是必要的,并且在文件中正确引用。
135-135: 添加PublicPathAssignment访客。新访客
PublicPathAssignment被正确添加到访客列表中。请验证其功能是否符合预期。Verification successful
确认
PublicPathAssignment访客的集成和功能。
PublicPathAssignment已正确添加到访客列表中,并且在crates/mako/src/visitors/public_path_assignment.rs文件中有相应的测试用例验证其功能。
crates/mako/src/visitors/public_path_assignment.rs: 包含PublicPathAssignment的定义和实现,以及测试用例。crates/mako/src/build/transform.rs:PublicPathAssignment被添加到访客列表中。Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the functionality of the new `PublicPathAssignment` visitor. # Test: Search for the visitor's usage in the codebase. Expect: Proper integration and functionality. rg --type rust 'PublicPathAssignment'Length of output: 616
Script:
#!/bin/bash # Description: Search for test cases or usage examples of `PublicPathAssignment` in the codebase. # Test: Look for references to `PublicPathAssignment` in test files or usage examples. rg --type rust 'PublicPathAssignment' --glob '*test*' -A 5Length of output: 58
Script:
#!/bin/bash # Description: Search for any references to `PublicPathAssignment` in the entire codebase. # Test: Look for references to `PublicPathAssignment` in all files to ensure it is being used and tested. rg --type rust 'PublicPathAssignment' -A 5Length of output: 2768
|
what will happen, if user write should we restrict that in code ?? |
|
and these two cases let __mako_public_path__ = "foo";
let __webpack_public_path__ = "foo"; |
Close #1328
Summary by CodeRabbit
新功能
__webpack_public_path__和__mako_public_path__的处理逻辑,以支持动态公共路径配置。测试
文档
publicPath。