Skip to content

Conversation

@fireairforce
Copy link

@fireairforce fireairforce commented Jan 19, 2026

给 turbopack-resolve 支持解析 windows 下的绝对路径:

import something from "C:\\path\\to\\module.js";

如果绝对路径里面包含了项目的 project_path 支持解析,如果解析到项目路径外了,这种情况不支持解析。

ref issue: utooland/utoo#2479

@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 在 Windows 环境下的兼容性,通过引入对 Windows 绝对路径的解析能力,解决了开发者在导入模块时可能遇到的路径问题。这一改进使得 Turbopack 能够更智能地处理不同操作系统下的文件引用,同时通过限制解析范围在项目根目录内,确保了安全性和一致性。

Highlights

  • 支持 Windows 绝对路径解析: 为 turbopack-resolve 增加了对 Windows 平台下绝对路径(例如 "C:\path\to\module.js")的解析支持。
  • 路径范围限制: 仅当 Windows 绝对路径位于项目根目录内时才会被解析;超出项目根目录的路径将不被支持。
  • 错误信息优化: 当无法解析 Windows 绝对路径时,提供了更清晰的错误信息,指明路径必须在项目根目录内,并建议使用相对路径。
  • 代码格式调整: 对 turbopack/crates/turbo-tasks-fs/src/watcher.rs 和 turbopack/crates/turbopack-node/src/worker_pool/mod.rs 文件进行了细微的代码格式调整。
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.

@fireairforce fireairforce merged commit 1910e3b into utoo Jan 19, 2026
11 of 24 checks passed
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

This pull request adds support for resolving absolute Windows paths within the project root in Turbopack. The overall approach is sound and correctly handles the new case while providing a more informative error message for paths outside the project root. However, the implementation introduces a significant amount of code duplication for path resolution. I've suggested a refactoring to use an existing helper function, which will improve code maintainability. Other changes are minor stylistic improvements.

Comment on lines +2039 to +2077
// Successfully converted - resolve as a raw path
let mut results = Vec::new();
let unix_path = &fs_path.path;
let pattern = Pattern::Constant(unix_path.clone());
let matches = read_matches(
root_path.clone(),
rcstr!(""),
false,
Pattern::new(pattern).resolve().await?,
)
.await?;

for m in matches.iter() {
match m {
PatternMatch::File(matched_pattern, path) => {
results.push(
resolved(
RequestKey::new(matched_pattern.clone()),
path.clone(),
lookup_path.clone(),
request,
options_value,
options,
query.clone(),
fragment.clone(),
)
.await?,
);
}
PatternMatch::Directory(matched_pattern, path) => {
results.push(
resolve_into_folder(path.clone(), options)
.with_request(matched_pattern.clone()),
);
}
}
}

return Ok(merge_results(results));

Choose a reason for hiding this comment

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

medium

This block of code for resolving the path appears to duplicate logic that is already present in resolve_raw_request_into_results. To improve maintainability and reduce code duplication, consider refactoring this to call resolve_raw_request_into_results instead.

// Successfully converted - resolve as a raw path
let raw_path_vc = Vc::cell(RequestContent::new(Value::new(fs_path.path.into())));
let results = resolve_raw_request_into_results(
    lookup_path,
    raw_path_vc,
    query,
    fragment,
    options,
    options_value,
    request,
)
.await?;
return Ok(merge_results(results));

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.

2 participants