Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions packages/vite/src/node/plugins/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import { hasESMSyntax } from 'mlly'
import type { Plugin } from '../plugin'
import {
CLIENT_ENTRY,
DEFAULT_EXTENSIONS,
DEFAULT_MAIN_FIELDS,
DEP_VERSION_RE,
ENV_ENTRY,
FS_PREFIX,
Expand Down Expand Up @@ -126,7 +124,6 @@ interface ResolvePluginOptions {
// if the specifier requests a non-existent `.js/jsx/mjs/cjs` file,
// should also try import from `.ts/tsx/mts/cts` source file as fallback.
isFromTsImporter?: boolean
tryEsmOnly?: boolean
// True when resolving during the scan phase to discover dependencies
scan?: boolean
// Appends ?__vite_skip_optimization to the resolved id if shouldn't be optimized
Expand Down Expand Up @@ -818,22 +815,7 @@ export function tryNodeResolve(
const resolveId = deepMatch ? resolveDeepImport : resolvePackageEntry
const unresolvedId = deepMatch ? '.' + id.slice(pkgId.length) : id

let resolved: string | undefined
try {
resolved = resolveId(unresolvedId, pkg, options)
} catch (err) {
if (!options.tryEsmOnly) {
throw err
}
}
if (!resolved && options.tryEsmOnly) {
resolved = resolveId(unresolvedId, pkg, {
...options,
isRequire: false,
mainFields: DEFAULT_MAIN_FIELDS,
extensions: DEFAULT_EXTENSIONS,
})
}
let resolved = resolveId(unresolvedId, pkg, options)
if (!resolved) {
return
}
Expand Down
1 change: 0 additions & 1 deletion packages/vite/src/node/ssr/fetchModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ export async function fetchModule(
isProduction,
root,
packageCache: environment.config.packageCache,
tryEsmOnly: true,
webCompatible: environment.config.webCompatible,
},
undefined,
Expand Down