-
Notifications
You must be signed in to change notification settings - Fork 85
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
refactor: Unify the static server in bundler-mako and devServer #1468
Conversation
…fix the issue where HMR with "publicPath" results in 404 errors
Walkthrough此次更改在 Changes
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/dev/mod.rs (1 hunks)
- packages/bundler-mako/index.js (1 hunks)
Additional comments not posted (2)
crates/mako/src/dev/mod.rs (1)
200-203
: 改进了静态文件的处理方式新的代码段使用
hyper
库构建 HTTP 请求,并通过staticfile.serve
进行处理。这种改进可能提高了静态文件处理的性能和一致性。请确保在其他地方调用该函数时没有问题。
Verification successful
改进了静态文件的处理方式
新的代码段使用
hyper
库构建 HTTP 请求,并通过staticfile.serve
进行处理。这种改进可能提高了静态文件处理的性能和一致性。
- crates/mako/src/dev/mod.rs:200-203
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of `staticfile.serve` to ensure it aligns with the new request construction. # Test: Search for the function usage. Expect: Only occurrences of the new signature. rg --type rust -A 5 $'staticfile.serve'Length of output: 698
packages/bundler-mako/index.js (1)
111-121
: 简化了请求处理逻辑新的代码段通过直接检查请求方法和内容类型简化了请求处理逻辑。这种改进可能提高了性能和可维护性。
请确保在其他地方调用该函数时没有问题。
Verification successful
简化了请求处理逻辑
新的代码段通过直接检查请求方法和内容类型简化了请求处理逻辑。这种改进可能提高了性能和可维护性。
packages/bundler-mako/index.js
中的逻辑一致,且没有发现其他不一致的调用。Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the modified request handling logic to ensure it aligns with the new implementation. # Test: Search for the function usage. Expect: Only occurrences of the new logic. rg --type js -A 5 $'req.method !== \'GET\' && req.method !== \'HEAD\''Length of output: 796
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 (1)
- packages/bundler-mako/index.js (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/bundler-mako/index.js
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 (1)
- crates/mako/src/dev/mod.rs (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- crates/mako/src/dev/mod.rs
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/dev.rs (2 hunks)
- packages/bundler-mako/index.js (1 hunks)
Additional comments not posted (4)
crates/mako/src/dev.rs (2)
174-183
: 确保静态内容的正确处理在处理静态内容时,增加了对
context.config.write_to_disk
的检查。这段代码逻辑合理,但需要确保context.get_static_content
方法在所有可能的路径都能正确返回内容。请确保
context.get_static_content
方法在所有可能的路径都能正确返回内容。
202-205
: 改进请求构建使用
hyper::Request::builder()
构建请求对象是一个不错的选择,但需要确保path
变量的值始终是一个有效的 URI。请确保
path
变量的值始终是一个有效的 URI。packages/bundler-mako/index.js (2)
114-116
: 改进请求方法检查在检查请求方法时,确保只处理
GET
和HEAD
请求是一个好主意。这可以防止不必要的请求被处理。这段代码更改是合理的。
118-124
: 改进内容类型检查检查请求是否接受 HTML 内容是一个好主意,但需要确保
req.accepts()
方法始终返回一个有效的数组。请确保
req.accepts()
方法始终返回一个有效的数组。
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1468 +/- ##
==========================================
- Coverage 60.94% 60.91% -0.03%
==========================================
Files 126 126
Lines 15121 15135 +14
==========================================
+ Hits 9215 9219 +4
- Misses 5906 5916 +10 ☔ View full report in Codecov by Sentry. |
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 ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (1)
- crates/mako/src/dev.rs (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- crates/mako/src/dev.rs
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 ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
Files selected for processing (1)
- packages/bundler-mako/index.js (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- packages/bundler-mako/index.js
Unify the static server in bundler-mako and devServer, and fix the bug where devServer cannot correctly match static resources.
Summary by CodeRabbit
新功能
性能改进