File tree 1 file changed +8
-0
lines changed
1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ const fileSystem = fs as FileSystem
102
102
const JS_EXT_PATTERN = / \. (?: [ c m ] j s | j s x ? ) $ /
103
103
const RELATIVE_PATH_PATTERN = / ^ \. { 1 , 2 } (?: \/ .* ) ? $ /
104
104
105
+ let packageJsonPaths : string [ ] = [ ]
105
106
let previousOptionsHash : string
106
107
let optionsHash : string
107
108
let cachedOptions : InternalResolverOptions | undefined
@@ -169,6 +170,7 @@ export function resolve(
169
170
}
170
171
}
171
172
173
+ packageJsonPaths = fastGlob . sync ( [ "**/package.json" , "!**/node_modules/**" ] ) ;
172
174
initMappers ( cachedOptions )
173
175
174
176
const mappedPath = getMappedPath ( source , file , cachedOptions . extensions , true )
@@ -271,6 +273,11 @@ function getMappedPath(
271
273
paths = [ resolved ]
272
274
}
273
275
} else {
276
+ const packageJsonPath = packageJsonPaths . find ( ( p ) => {
277
+ const { dir } = path . parse ( p )
278
+ return ! ! dir && file . includes ( dir )
279
+ } )
280
+
274
281
paths = mappers !
275
282
. map ( mapper =>
276
283
mapper ?.( source ) . map ( item => [
@@ -299,6 +306,7 @@ function getMappedPath(
299
306
300
307
return false
301
308
} )
309
+ . filter ( ( item ) => item . includes ( packageJsonPath ) )
302
310
}
303
311
304
312
if ( retry && paths . length === 0 ) {
You can’t perform that action at this time.
0 commit comments