Skip to content

Commit ee0e4f6

Browse files
authored
fix(turbopack): support parse ~ prefix for less & sass (#73)
1 parent be61779 commit ee0e4f6

File tree

1 file changed

+14
-0
lines changed
  • turbopack/crates/turbopack-core/src/resolve

1 file changed

+14
-0
lines changed

turbopack/crates/turbopack-core/src/resolve/parse.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,20 @@ impl Request {
162162
return Request::Empty;
163163
}
164164

165+
// Handle webpack-style tilde prefix (~) for node_modules resolution
166+
// This is commonly used in CSS preprocessors like less-loader and sass-loader
167+
// Only strip ~ if it's followed by a module path (not a relative path like ~/home)
168+
// for utoopack issue: https://github.com/utooland/utoo/issues/2309
169+
let r = if let Some(remainder) = r
170+
.strip_prefix('~')
171+
.filter(|s| !s.is_empty() && !s.starts_with('/') && !s.starts_with('\\'))
172+
.filter(|s| MODULE_PATH.is_match(s))
173+
{
174+
remainder.into()
175+
} else {
176+
r
177+
};
178+
165179
if let Some(remainder) = r.strip_prefix("//") {
166180
return Request::Uri {
167181
protocol: rcstr!("//"),

0 commit comments

Comments
 (0)