Skip to content

Commit bd34203

Browse files
xingxiuyipatak-cat
andauthored
fix: Avoid importing in source that __vitePreload has declared (close #4016) (#4041)
Co-authored-by: patak <matias.capeletto@gmail.com>
1 parent eb2e41b commit bd34203

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,11 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
161161
}
162162
}
163163

164-
if (needPreloadHelper && !ssr) {
164+
if (
165+
needPreloadHelper &&
166+
!ssr &&
167+
!source.includes(`const ${preloadMethod} =`)
168+
) {
165169
str().prepend(`import { ${preloadMethod} } from "${preloadHelperId}";`)
166170
}
167171

0 commit comments

Comments
 (0)