Skip to content

Commit 0fe95d4

Browse files
authored
fix: add position to import analysis resolve exception (#18344)
1 parent 0ddfb9f commit 0fe95d4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/vite/src/node/plugins/importAnalysis.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { parseAst } from 'rollup/parseAst'
1212
import type { StaticImport } from 'mlly'
1313
import { ESM_STATIC_IMPORT_RE, parseStaticImport } from 'mlly'
1414
import { makeLegalIdentifier } from '@rollup/pluginutils'
15-
import type { PartialResolvedId } from 'rollup'
15+
import type { PartialResolvedId, RollupError } from 'rollup'
1616
import type { Identifier, Literal } from 'estree'
1717
import {
1818
CLIENT_DIR,
@@ -348,7 +348,12 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
348348
}
349349
}
350350

351-
const resolved = await this.resolve(url, importerFile)
351+
const resolved = await this.resolve(url, importerFile).catch((e) => {
352+
if (e instanceof Error) {
353+
;(e as RollupError).pos ??= pos
354+
}
355+
throw e
356+
})
352357

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

0 commit comments

Comments
 (0)