Skip to content

Commit

Permalink
fix: Avoid importing in source that __vitePreload has declared (close v…
Browse files Browse the repository at this point in the history
…itejs#4016) (vitejs#4041)

Co-authored-by: patak <matias.capeletto@gmail.com>
  • Loading branch information
2 people authored and aleclarson committed Nov 8, 2021
1 parent 34227a9 commit cdf9d4f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/vite/src/node/plugins/importAnalysisBuild.ts
Expand Up @@ -161,7 +161,11 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
}
}

if (needPreloadHelper && !ssr) {
if (
needPreloadHelper &&
!ssr &&
!source.includes(`const ${preloadMethod} =`)
) {
str().prepend(`import { ${preloadMethod} } from "${preloadHelperId}";`)
}

Expand Down

0 comments on commit cdf9d4f

Please sign in to comment.