@@ -121,6 +121,35 @@ export const resolve: resolve = async (
121
121
return nextResolve ( specifier , context ) ;
122
122
}
123
123
124
+ const isPath = (
125
+ specifier . startsWith ( fileProtocol )
126
+ || isRelativePathPattern . test ( specifier )
127
+ ) ;
128
+
129
+ // bare specifier
130
+ if ( ! isPath ) {
131
+ // TS path alias
132
+ if (
133
+ tsconfigPathsMatcher
134
+ && ! context . parentURL ?. includes ( '/node_modules/' )
135
+ ) {
136
+ const possiblePaths = tsconfigPathsMatcher ( specifier ) ;
137
+ for ( const possiblePath of possiblePaths ) {
138
+ try {
139
+ return await resolve (
140
+ pathToFileURL ( possiblePath ) . toString ( ) ,
141
+ context ,
142
+ nextResolve ,
143
+ ) ;
144
+ } catch { }
145
+ }
146
+ }
147
+
148
+ // npm package -- use default resolution
149
+ return nextResolve ( specifier , context ) ;
150
+ }
151
+
152
+ // Inherit namespace from parent
124
153
let requestNamespace = getNamespace ( specifier ) ;
125
154
if ( context . parentURL ) {
126
155
const parentNamespace = getNamespace ( context . parentURL ) ;
@@ -139,28 +168,6 @@ export const resolve: resolve = async (
139
168
return await tryDirectory ( specifier , context , nextResolve ) ;
140
169
}
141
170
142
- const isPath = (
143
- specifier . startsWith ( fileProtocol )
144
- || isRelativePathPattern . test ( specifier )
145
- ) ;
146
-
147
- if (
148
- tsconfigPathsMatcher
149
- && ! isPath // bare specifier
150
- && ! context . parentURL ?. includes ( '/node_modules/' )
151
- ) {
152
- const possiblePaths = tsconfigPathsMatcher ( specifier ) ;
153
- for ( const possiblePath of possiblePaths ) {
154
- try {
155
- return await resolve (
156
- pathToFileURL ( possiblePath ) . toString ( ) ,
157
- context ,
158
- nextResolve ,
159
- ) ;
160
- } catch { }
161
- }
162
- }
163
-
164
171
// Typescript gives .ts, .cts, or .mts priority over actual .js, .cjs, or .mjs extensions
165
172
//
166
173
// If `allowJs` is set in `tsconfig.json`, then we'll apply the same resolution logic
0 commit comments