@@ -7,8 +7,6 @@ import { hasESMSyntax } from 'mlly'
7
7
import type { Plugin } from '../plugin'
8
8
import {
9
9
CLIENT_ENTRY ,
10
- DEFAULT_EXTENSIONS ,
11
- DEFAULT_MAIN_FIELDS ,
12
10
DEP_VERSION_RE ,
13
11
ENV_ENTRY ,
14
12
FS_PREFIX ,
@@ -126,7 +124,6 @@ interface ResolvePluginOptions {
126
124
// if the specifier requests a non-existent `.js/jsx/mjs/cjs` file,
127
125
// should also try import from `.ts/tsx/mts/cts` source file as fallback.
128
126
isFromTsImporter ?: boolean
129
- tryEsmOnly ?: boolean
130
127
// True when resolving during the scan phase to discover dependencies
131
128
scan ?: boolean
132
129
// Appends ?__vite_skip_optimization to the resolved id if shouldn't be optimized
@@ -818,22 +815,7 @@ export function tryNodeResolve(
818
815
const resolveId = deepMatch ? resolveDeepImport : resolvePackageEntry
819
816
const unresolvedId = deepMatch ? '.' + id . slice ( pkgId . length ) : id
820
817
821
- let resolved : string | undefined
822
- try {
823
- resolved = resolveId ( unresolvedId , pkg , options )
824
- } catch ( err ) {
825
- if ( ! options . tryEsmOnly ) {
826
- throw err
827
- }
828
- }
829
- if ( ! resolved && options . tryEsmOnly ) {
830
- resolved = resolveId ( unresolvedId , pkg , {
831
- ...options ,
832
- isRequire : false ,
833
- mainFields : DEFAULT_MAIN_FIELDS ,
834
- extensions : DEFAULT_EXTENSIONS ,
835
- } )
836
- }
818
+ let resolved = resolveId ( unresolvedId , pkg , options )
837
819
if ( ! resolved ) {
838
820
return
839
821
}
0 commit comments