Skip to content

Commit

Permalink
fix(build): declare preload-helper has no side effects (#18057)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzheng14 authored Sep 10, 2024
1 parent 7d699aa commit 587ad7b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/vite/src/node/plugins/importAnalysisBuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
const scriptRel =
modulePreload && modulePreload.polyfill
? `'modulepreload'`
: `(${detectScriptRel.toString()})()`
: `/* @__PURE__ */ (${detectScriptRel.toString()})()`

// There are two different cases for the preload list format in __vitePreload
//
Expand All @@ -207,7 +207,7 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
// is appended inside __vitePreload too.
`function(dep) { return ${JSON.stringify(config.base)}+dep }`
const preloadCode = `const scriptRel = ${scriptRel};const assetsURL = ${assetsURL};const seen = {};export const ${preloadMethod} = ${preload.toString()}`
return preloadCode
return { code: preloadCode, moduleSideEffects: false }
}
},

Expand Down

0 comments on commit 587ad7b

Please sign in to comment.