Skip to content

Commit

Permalink
fix: handle files with multiple comments (#7202)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Mar 7, 2022
1 parent 3070ecb commit 3f5b645
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/vite/src/node/__tests__/scan.spec.ts
Expand Up @@ -30,7 +30,8 @@ describe('optimizer-scan:script-test', () => {
scriptRE.lastIndex = 0
const ret = scriptRE.exec(
`<template>
<!-- <script >var test = null</script> -->
<!-- <script >var test1 = null</script> -->
<!-- <script >var test2 = null</script> -->
</template>`.replace(commentRE, '')
)
expect(ret).toEqual(null)
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/optimizer/scan.ts
Expand Up @@ -143,7 +143,7 @@ function globEntries(pattern: string | string[], config: ResolvedConfig) {
const scriptModuleRE =
/(<script\b[^>]*type\s*=\s*(?:"module"|'module')[^>]*>)(.*?)<\/script>/gims
export const scriptRE = /(<script\b(?:\s[^>]*>|>))(.*?)<\/script>/gims
export const commentRE = /<!--(.|[\r\n])*?-->/
export const commentRE = /<!--.*?-->/gs
const srcRE = /\bsrc\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im
const typeRE = /\btype\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im
const langRE = /\blang\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s'">]+))/im
Expand Down

0 comments on commit 3f5b645

Please sign in to comment.