Skip to content

Commit

Permalink
fix: comments that are on the same line as a regexp:
Browse files Browse the repository at this point in the history
  • Loading branch information
poyoho committed Apr 23, 2022
1 parent 33db886 commit 2ec1ff1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/vite/src/node/__tests__/cleanString.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ test('regexp', () => {
"'''1'''"
/"''''1''''"/
"''''1''''"
/'1'/ // '1'
/'1'/ /* '1' */
`)
expect(clean).not.toMatch('1')
})
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/cleanString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { RollupError } from 'rollup'
// /`([^`\$\{\}]|\$\{(`|\g<1>)*\})*`/g can match nested string template
// but js not support match expression(\g<0>). so clean string template(`...`) in other ways.
const cleanerRE =
/"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'|\/\*(.|[\r\n])*?\*\/|\/\/.*|\/.*\//g
/"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'|\/\*(.|[\r\n])*?\*\/|\/\/.*|\/([^\/]|(?<=\/)\/)*\//g

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

0 comments on commit 2ec1ff1

Please sign in to comment.