Skip to content

Commit

Permalink
fix: add position to import analysis resolve exception (#18344)
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa authored Oct 14, 2024
1 parent 0ddfb9f commit 0fe95d4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/vite/src/node/plugins/importAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { parseAst } from 'rollup/parseAst'
import type { StaticImport } from 'mlly'
import { ESM_STATIC_IMPORT_RE, parseStaticImport } from 'mlly'
import { makeLegalIdentifier } from '@rollup/pluginutils'
import type { PartialResolvedId } from 'rollup'
import type { PartialResolvedId, RollupError } from 'rollup'
import type { Identifier, Literal } from 'estree'
import {
CLIENT_DIR,
Expand Down Expand Up @@ -348,7 +348,12 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
}
}

const resolved = await this.resolve(url, importerFile)
const resolved = await this.resolve(url, importerFile).catch((e) => {
if (e instanceof Error) {
;(e as RollupError).pos ??= pos
}
throw e
})

if (!resolved || resolved.meta?.['vite:alias']?.noResolved) {
// in ssr, we should let node handle the missing modules
Expand Down

0 comments on commit 0fe95d4

Please sign in to comment.