Skip to content

Commit

Permalink
fix: avoid scan failues in .svelte files
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Oct 4, 2021
1 parent b582581 commit cc2e5f7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/vite/src/node/optimizer/scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,12 @@ function esbuildScanPlugin(
}
}

if (!code.includes(`export default`)) {
js += `\nexport default {}`
// This will trigger incorrectly if `export default` is contained
// anywhere in a string/template. Svelte files can't have
// 'export default` as code so we know if it's encountered it's a
// false positive
if (!code.includes('export default') || path.endsWith('.svelte')) {
js += '\nexport default {}'
}

if (code.includes('import.meta.glob')) {
Expand Down

0 comments on commit cc2e5f7

Please sign in to comment.