Skip to content

Commit

Permalink
fix: regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
poyoho committed Apr 23, 2022
1 parent 5f4ab17 commit d85e6e9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/vite/src/node/cleanString.ts
Expand Up @@ -2,9 +2,9 @@ import type { RollupError } from 'rollup'
// bank on the non-overlapping nature of regex matches and combine all filters into one giant regex
// /`([^`\$\{\}]|\$\{(`|\g<1>)*\})*`/g can match nested string template
// but js not support match expression(\g<0>). so clean string template(`...`) in other ways.
const stringsRE = /"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'/
const commentsRE = /\/\*(.|[\r\n])*?\*\/|\/\/.*/
const regexpRE = /\/([^\/\r\n]|(?<=\\)\/)*\//
const stringsRE = /"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'/.source
const commentsRE = /\/\*(.|[\r\n])*?\*\/|\/\/.*/.source
const regexpRE = /\/([^\/\r\n]|(?<=\\)\/)*\//.source
const cleanerRE = new RegExp(`${stringsRE}|${commentsRE}|${regexpRE}`, 'g')

const blankReplacer = (s: string) => ' '.repeat(s.length)
Expand Down

0 comments on commit d85e6e9

Please sign in to comment.