-
Notifications
You must be signed in to change notification settings - Fork 0
fix(turbopack): support parse ~ prefix for less & sass
#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
Conversation
Summary of ChangesHello @fireairforce, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求解决了 Turbopack 在解析 Less 和 Sass 中使用的 Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
你好,感谢你的贡献。这个 PR 增加了对 less 和 sass 中 ~ 前缀的支持,这是一个很有用的功能。代码的逻辑是正确的,我只是提出了一些关于代码风格和可维护性的建议,可以让代码更简洁和地道。请查看我的具体评论。
| // Handle webpack-style tilde prefix (~) for node_modules resolution | ||
| // This is commonly used in CSS preprocessors like less-loader and sass-loader | ||
| // Only strip ~ if it's followed by a module path (not a relative path like ~/home) | ||
| // for utoopack issue: https://github.com/utooland/utoo/issues/2309 |
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.
| let r = if let Some(remainder) = r | ||
| .strip_prefix('~') | ||
| .filter(|s| !s.is_empty() && !s.starts_with('/') && !s.starts_with('\\')) | ||
| .filter(|s| MODULE_PATH.is_match(s)) | ||
| { | ||
| remainder.into() | ||
| } else { | ||
| r | ||
| }; |
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.
这个 if let ... else 语句块可以重构为一个更简洁、更符合 Rust 语言习惯的函数式风格链式调用。使用 map 和 unwrap_or 可以将转换逻辑表达为单个表达式,从而提高可读性。
| let r = if let Some(remainder) = r | |
| .strip_prefix('~') | |
| .filter(|s| !s.is_empty() && !s.starts_with('/') && !s.starts_with('\\')) | |
| .filter(|s| MODULE_PATH.is_match(s)) | |
| { | |
| remainder.into() | |
| } else { | |
| r | |
| }; | |
| let r = r | |
| .strip_prefix('~') | |
| .filter(|s| { | |
| !s.is_empty() | |
| && !s.starts_with('/') | |
| && !s.starts_with('\') | |
| && MODULE_PATH.is_match(s) | |
| }) | |
| .map(RcStr::from) | |
| .unwrap_or(r); |
让 resolve 去把
~${moduleName}/xx.css先直接处理成${moduleName}/xx.css。for issue: utooland/utoo#2309