Skip to content

Conversation

@fireairforce
Copy link

让 resolve 去把 ~${moduleName}/xx.css 先直接处理成 ${moduleName}/xx.css

for issue: utooland/utoo#2309

@gemini-code-assist
Copy link

Summary of Changes

Hello @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 中使用的 ~ 前缀路径时遇到的问题。通过引入新的解析逻辑,它现在能够识别并处理这种 Webpack 风格的模块路径,从而确保 CSS 预处理器能够正确地引用 node_modules 中的资源,解决了相关构建问题。

Highlights

  • 支持 Less/Sass 的 ~ 前缀解析: 增加了对 Webpack 风格的 ~ 前缀路径解析支持,这在 Less 和 Sass 等 CSS 预处理器中常用于解析 node_modules 中的模块。当 ~ 后跟模块路径时,会将其剥离以正确解析。
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

通常来说,最好将问题跟踪器的链接放在提交信息或 PR 描述中,而不是代码注释里。这样能保持代码整洁,并避免在问题跟踪器 URL 更改或问题关闭时注释变得过时。Git 历史是记录这类元数据的更合适的地方。

Comment on lines +169 to +177
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
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

这个 if let ... else 语句块可以重构为一个更简洁、更符合 Rust 语言习惯的函数式风格链式调用。使用 mapunwrap_or 可以将转换逻辑表达为单个表达式,从而提高可读性。

Suggested change
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);

@fireairforce fireairforce merged commit ee0e4f6 into utoo Nov 11, 2025
13 of 26 checks passed
@xusd320 xusd320 deleted the fix-2309 branch November 25, 2025 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants