File tree 1 file changed +21
-14
lines changed
packages/vite/src/node/plugins
1 file changed +21
-14
lines changed Original file line number Diff line number Diff line change @@ -254,19 +254,20 @@ export function resolvePlugin(resolveOptions: InternalResolveOptions): Plugin {
254
254
}
255
255
256
256
if ( ( res = tryFsResolve ( fsPath , options ) ) ) {
257
+ const resPkg = findNearestPackageData (
258
+ path . dirname ( res ) ,
259
+ options . packageCache ,
260
+ )
257
261
res = ensureVersionQuery ( res , id , options , depsOptimizer )
258
262
isDebug &&
259
263
debug ( `[relative] ${ colors . cyan ( id ) } -> ${ colors . dim ( res ) } ` )
260
- const pkg =
261
- importer &&
262
- findNearestPackageData ( path . dirname ( importer ) , options . packageCache )
263
- if ( pkg ) {
264
- return {
265
- id : res ,
266
- moduleSideEffects : pkg . hasSideEffects ( res ) ,
267
- }
268
- }
269
- return res
264
+
265
+ return resPkg
266
+ ? {
267
+ id : res ,
268
+ moduleSideEffects : resPkg . hasSideEffects ( res ) ,
269
+ }
270
+ : res
270
271
}
271
272
}
272
273
@@ -1191,10 +1192,16 @@ function tryResolveBrowserMapping(
1191
1192
) {
1192
1193
isDebug &&
1193
1194
debug ( `[browser mapped] ${ colors . cyan ( id ) } -> ${ colors . dim ( res ) } ` )
1194
- const result = {
1195
- id : res ,
1196
- moduleSideEffects : pkg . hasSideEffects ( res ) ,
1197
- }
1195
+ const resPkg = findNearestPackageData (
1196
+ path . dirname ( res ) ,
1197
+ options . packageCache ,
1198
+ )
1199
+ const result = resPkg
1200
+ ? {
1201
+ id : res ,
1202
+ moduleSideEffects : resPkg . hasSideEffects ( res ) ,
1203
+ }
1204
+ : { id : res }
1198
1205
return externalize ? { ...result , external : true } : result
1199
1206
}
1200
1207
} else if ( browserMappedPath === false ) {
You can’t perform that action at this time.
0 commit comments