This repository was archived by the owner on Jul 6, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -39,12 +39,14 @@ impl ImportMap {
39
39
if v. starts_with ( "./" ) {
40
40
imports. insert (
41
41
k. into ( ) ,
42
- RelativePath :: new ( v)
43
- . normalize ( )
44
- . to_path ( Path :: new ( "/" ) )
45
- . to_slash ( )
46
- . unwrap ( )
47
- . into ( ) ,
42
+ format ! (
43
+ "/{}" ,
44
+ RelativePath :: new( v)
45
+ . normalize( )
46
+ . to_relative_path_buf( )
47
+ . join( "/" )
48
+ . to_string( )
49
+ ) ,
48
50
) ;
49
51
} else {
50
52
imports. insert ( k. into ( ) , v. into ( ) ) ;
@@ -118,6 +120,7 @@ mod tests {
118
120
let mut scope_imports: SpecifierHashMap = HashMap :: new ( ) ;
119
121
imports. insert ( "@/" . into ( ) , "./" . into ( ) ) ;
120
122
imports. insert ( "~/" . into ( ) , "./" . into ( ) ) ;
123
+ imports. insert ( "comps/" . into ( ) , "./components/" . into ( ) ) ;
121
124
imports. insert ( "react" . into ( ) , "https://esm.sh/react" . into ( ) ) ;
122
125
imports. insert ( "react-dom/" . into ( ) , "https://esm.sh/react-dom/" . into ( ) ) ;
123
126
imports. insert (
@@ -135,6 +138,10 @@ mod tests {
135
138
import_map. resolve( "/pages/index.tsx" , "~/components/logo.tsx" ) ,
136
139
"/components/logo.tsx"
137
140
) ;
141
+ assert_eq ! (
142
+ import_map. resolve( "/pages/index.tsx" , "comps/logo.tsx" ) ,
143
+ "/components/logo.tsx"
144
+ ) ;
138
145
assert_eq ! (
139
146
import_map. resolve( "/app.tsx" , "react" ) ,
140
147
"https://esm.sh/react"
You can’t perform that action at this time.
0 commit comments