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
  • Loading branch information
xingxiuyi committed Jun 30, 2021
1 parent da2a41d commit d9bbb6c
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.indexOf(`const ${preloadMethod} =`) < 0
) {
str().prepend(`import { ${preloadMethod} } from "${preloadHelperId}";`)
}

Expand Down

0 comments on commit d9bbb6c

Please sign in to comment.